Ticket #54104: patch-libcilkrts-runtime-sysdep-tigerfix.diff

File patch-libcilkrts-runtime-sysdep-tigerfix.diff, 1.6 KB (added by kencu (Ken), 7 years ago)

patchfile for sysdep-unix.c for Tiger i386

  • ./libcilkrts/runtime/sysdep-unix.c

    old new  
    9999//#   include <scheduler.h>  // Angle brackets include Apple's scheduler.h, not ours.
    100100#endif
    101101
     102#ifdef __APPLE__
     103#ifndef __MAC_OS_X_VERSION_MIN_REQUIRED
     104#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050
     105#include <Availability.h>
     106#else
     107#include <AvailabilityMacros.h>
     108#endif
     109#endif //#ifndef __MAC_OS_X_VERSION_MIN_REQUIRED
     110
     111
     112#if __MAC_OS_X_VERSION_MIN_REQUIRED < 1050
     113#include <sys/types.h>
     114#include <sys/sysctl.h>
     115#define _SC_NPROCESSORS_ONLN 58
     116
     117long tigersysconf(int name){
     118
     119    if (name == _SC_NPROCESSORS_ONLN) {
     120                int nm[2];
     121                size_t len = 4;
     122                uint32_t count;
     123               
     124                nm[0] = CTL_HW; nm[1] = HW_AVAILCPU;
     125                sysctl(nm, 2, &count, &len, NULL, 0);
     126               
     127                if (count < 1) {
     128                        nm[1] = HW_NCPU;
     129                        sysctl(nm, 2, &count, &len, NULL, 0);
     130                        if (count < 1) { count = 1; }
     131                        }
     132                       
     133                return (long)count;
     134    }
     135    return -1;
     136}
     137#endif //#if __MAC_OS_X_VERSION_MIN_REQUIRED < 1050
     138#endif //#ifdef __APPLE__
     139
     140
     141
    102142#ifdef __linux__
    103143#   include <sys/resource.h>
    104144#   include <sys/sysinfo.h>
     
    733773#ifdef __VXWORKS__     
    734774    fprintf(fp, "System cores: %d\n", (int)__builtin_popcount(vxCpuEnabledGet()));
    735775#else   
     776
     777#if __MAC_OS_X_VERSION_MIN_REQUIRED < 1050
     778    fprintf(fp, "System cores: %d\n", (int)tigersysconf(_SC_NPROCESSORS_ONLN));
     779#else
    736780    fprintf(fp, "System cores: %d\n", (int)sysconf(_SC_NPROCESSORS_ONLN));
     781#endif
     782
    737783#endif   
    738784    fprintf(fp, "Cilk workers requested: %d\n", n);
    739785#if (PARALLEL_THREAD_CREATE)