Commits

Jed Brown  committed 0d7e0a8 Merge

Merge branch 'balay/threadcomm-fixes'

* 'balay/threadcomm-fixes'
threadcomm: fix potential "set, but not used variable" warning
threadcomm: fix build on bgl/c++ threadcommred.c
threadcomm: CHKERRQ() shouldn't be used on sysctlbyname(). #155945 Fixes on bsd:

  • Participants
  • Parent commits 5c3e6ab, caa81c7

Comments (0)

Files changed (2)

File config/PETSc/Configure.py

                  'gettimeofday', 'getwd', 'memalign', 'memmove', 'mkstemp', 'popen', 'PXFGETARG', 'rand', 'getpagesize',
                  'readlink', 'realpath',  'sigaction', 'signal', 'sigset', 'usleep', 'sleep', '_sleep', 'socket',
                  'times', 'gethostbyname', 'uname','snprintf','_snprintf','_fullpath','lseek','_lseek','time','fork','stricmp',
-                 'strcasecmp', 'bzero', 'dlopen', 'dlsym', 'dlclose', 'dlerror',
+                 'strcasecmp', 'bzero', 'dlopen', 'dlsym', 'dlclose', 'dlerror','get_nprocs','sysctlbyname',
                  '_intel_fast_memcpy','_intel_fast_memset']
     libraries1 = [(['socket', 'nsl'], 'socket'), (['fpe'], 'handle_sigfpes')]
     self.headers.headers.extend(headersC)

File src/sys/threadcomm/interface/threadcomm.c

   if (N_CORES == -1) {
     N_CORES = 1; /* Default value if number of cores cannot be found out */
 
-#if defined(PETSC_HAVE_SCHED_CPU_SET_T) /* Linux */
+#if defined(PETSC_HAVE_SYS_SYSINFO_H) && (PETSC_HAVE_GET_NPROCS) /* Linux */
     N_CORES = get_nprocs();
-#elif defined(PETSC_HAVE_SYS_SYSCTL_H) /* MacOS, BSD */
+#elif defined(PETSC_HAVE_SYS_SYSCTL_H) && (PETSC_HAVE_SYSCTLBYNAME) /* MacOS, BSD */
     {
       PetscErrorCode ierr;
       size_t         len = sizeof(N_CORES);
-      ierr = sysctlbyname("hw.activecpu",&N_CORES,&len,NULL,0);CHKERRQ(ierr); /* osx preferes activecpu over ncpu */
+      ierr = sysctlbyname("hw.activecpu",&N_CORES,&len,NULL,0); /* osx preferes activecpu over ncpu */
       if (ierr) { /* freebsd check ncpu */
-        ierr = sysctlbyname("hw.ncpu",&N_CORES,&len,NULL,0);CHKERRQ(ierr);
+        sysctlbyname("hw.ncpu",&N_CORES,&len,NULL,0);
+        /* continue even if there is an error */
       }
     }
 #elif defined(PETSC_HAVE_WINDOWS_H)   /* Windows */