Opened 8 years ago

Closed 8 years ago

#52822 closed enhancement (fixed)

gstreamer1 - add replacement for sysconf(_SC_NPROCESSORS_ONLN) on Tiger

Reported by: ken-cunningham-webuse Owned by: dbevans (David B. Evans)
Priority: Normal Milestone:
Component: ports Version: 2.3.4
Keywords: Cc: jeremyhu (Jeremy Huddleston Sequoia), mkae (Marko Käning)
Port: gstreamer1

Description

I've made this function change three times so far, so I thought I'd finally submit it for consideration.

sysconf(_SC_NPROCESSORS_ONLN) is 10.5+ only.

this patch adds a suitable BSD replacement for Tiger.

Attachments (3)

patch-gstreamer1-portfile-darwin8.diff (377 bytes) - added by ken-cunningham-webuse 8 years ago.
patch-gstreamer1-darwin-numcpufix-sysctl.diff (1.0 KB) - added by ken-cunningham-webuse 8 years ago.
patch-gstreamer1-revised.diff (2.6 KB) - added by dbevans (David B. Evans) 8 years ago.
Revised patch that can be applied unconditionally

Download all attachments as: .zip

Change History (13)

Changed 8 years ago by ken-cunningham-webuse

Changed 8 years ago by ken-cunningham-webuse

comment:1 Changed 8 years ago by mkae (Marko Käning)

Cc: mkae added

comment:2 Changed 8 years ago by ken-cunningham-webuse

and evidence

tigerg5:~ cunningh$ port -v installed gstreamer1
The following ports are currently installed:
  gstreamer1 @1.8.2_0 platform='darwin 8' archs='ppc'
  gstreamer1 @1.10.0_0 (active) platform='darwin 8' archs='ppc'

comment:3 Changed 8 years ago by dbevans (David B. Evans)

Owner: changed from macports-tickets@… to dbevans
Status: newaccepted

comment:4 Changed 8 years ago by dbevans (David B. Evans)

Will look at this later today.

comment:5 Changed 8 years ago by ken-cunningham-webuse

to make life easier:

$ cat testnumproc.c

#include <unistd.h>
#include <stdio.h>
#include <sys/resource.h>
#include <sys/types.h>
#include <sys/sysctl.h>


int main() {
        int nm[2];
        size_t len = 4;
        uint32_t count;
        uint32_t num_cpus;
          
        nm[0] = CTL_HW; nm[1] = HW_AVAILCPU;
        sysctl(nm, 2, &count, &len, NULL, 0);
          
        if (count < 1) {
                nm[1] = HW_NCPU;
                sysctl(nm, 2, &count, &len, NULL, 0);
                if (count < 1) { count = 1; }
         }
         
         num_cpus = count;
         
         printf("number of cpus %d \n\n", count);
 } 


$ which gcc
/opt/local/bin/gcc

$ gcc --version
powerpc-apple-darwin8-gcc-apple-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3) (MacPorts apple-gcc42 5666.3_15)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ gcc -o testnumpro testnumproc.c

$ ./testnumproc
number of cpus 2 

Version 0, edited 8 years ago by ken-cunningham-webuse (next)

Changed 8 years ago by dbevans (David B. Evans)

Revised patch that can be applied unconditionally

comment:6 Changed 8 years ago by dbevans (David B. Evans)

I've just attached a revised version of your patch that can be applied unconditionally. This is more like something that the upstream developers might accept as a modification and that's where it really should be addressed.

I've successfully tested this on El Capitan and Tiger. Let me know if it works for you and, if so, I will commit.

comment:7 Changed 8 years ago by ken-cunningham-webuse

beautiful. I see how you rounded it out to a more complete fix. I'll check it on a few more systems and get back to you, but I can't see what problems it might raise with the guards you've put on it. thanks, K

comment:8 Changed 8 years ago by ken-cunningham-webuse

Looks good, Dave. Clean builds also on Leopard PPC, Snow Leopard with LibcxxOnOlderSystems, and Sierra.

Thanks for your attentions. I'll leave it to you to decide if this goes upstream, if that's OK. You have more cred up there than I do :>

K

comment:9 Changed 8 years ago by dbevans (David B. Evans)

It needs more work to go upstream. The patch as it is works fine on Macs but the case where

__APPLE__

is not true is not handled correctly -- should go back to the original code again. I'll fix that and then commit the patch. Thanks for your contribution.

comment:10 Changed 8 years ago by dbevans (David B. Evans)

Resolution: fixed
Status: acceptedclosed

In 4678a5ef/macports-ports:

gstreamer1: patch to fix build on 10.5 and earlier.

Fixes #52822

Note: See TracTickets for help on using tickets.