[petsc-dev] __USE_GNU

Shri abhyshr at mcs.anl.gov
Sat May 12 21:11:49 CDT 2012


> On Sat, May 12, 2012 at 6:40 AM, Shri <abhyshr at mcs.anl.gov> wrote:
> 1. I needed functions in sched.h like CPU_SET and others for setting the core affinities and these are only active if __USE_GNU is set and i wasn't sure whether _GNU_SOURCE or __USE_GNU should be defined directly, so i put in both.
> 
> __USE_GNU should never be defined directly.
> 
> http://gcc.gnu.org/ml/fortran/2005-10/msg00365.html
> http://stackoverflow.com/questions/7296963/gnu-source-and-use-gnu
>  
> 
> <sched.h>
> #ifdef __USE_GNU
> /* Access macros for `cpu_set'.  */
> #define CPU_SETSIZE __CPU_SETSIZE
> #define CPU_SET(cpu, cpusetp)   __CPU_SET (cpu, cpusetp)
> #define CPU_CLR(cpu, cpusetp)   __CPU_CLR (cpu, cpusetp)
> #define CPU_ISSET(cpu, cpusetp) __CPU_ISSET (cpu, cpusetp)
> #define CPU_ZERO(cpusetp)       __CPU_ZERO (cpusetp)
> 
> With your changes i get the following build errors on Karlin.
> 
> I'm pretty sure the correct fix is to get _GNU_SOURCE defined before anything system headers are included. Should probably write the test in Configure.py and put it in with PETSC_DESIRE_FEATURE_TEST_MACROS.

      Done, let me know if i can push it.
>  
> 
> /home/abhyshr/petsc/petsc-dev/src/sys/threadcomm/impls/pthread/pthread.c:45:5: warning: implicit declaration of function ‘CPU_ZERO’ [-Wimplicit-function-declaration]
> /home/abhyshr/petsc/petsc-dev/src/sys/threadcomm/impls/pthread/pthread.c:46:5: warning: implicit declaration of function ‘CPU_SET’ [-Wimplicit-function-declaration]
> /home/abhyshr/petsc/petsc-dev/src/sys/threadcomm/impls/pthread/pthread.c:47:5: warning: implicit declaration of function ‘pthread_setaffinity_np’ [-Wimplicit-function-declaration]
> /home/abhyshr/petsc/petsc-dev/src/sys/threadcomm/impls/pthread/pthread.c: In function ‘PetscThreadCommCreate_PThread’:
> /home/abhyshr/petsc/petsc-dev/src/sys/threadcomm/impls/pthread/pthread.c:177:5: warning: implicit declaration of function ‘sched_setaffinity’ [-Wimplicit-function-declaration]
> [ 29%] Building C object CMakeFiles/petsc.dir/src/vec/pf/interface/ftn-auto/pff.c.o
> /home/abhyshr/petsc/petsc-dev/src/sys/objects/pthread/pthread.c: In function ‘PetscSetMainThreadAffinity’:
> /home/abhyshr/petsc/petsc-dev/src/sys/objects/pthread/pthread.c:53:3: warning: implicit declaration of function ‘CPU_ZERO’ [-Wimplicit-function-declaration]
> /home/abhyshr/petsc/petsc-dev/src/sys/objects/pthread/pthread.c:54:3: warning: implicit declaration of function ‘CPU_SET’ [-Wimplicit-function-declaration]
> /home/abhyshr/petsc/petsc-dev/src/sys/objects/pthread/pthread.c:55:3: warning: implicit declaration of function ‘sched_setaffinity’ [-Wimplicit-function-declaration]
> /home/abhyshr/petsc/petsc-dev/src/sys/objects/pthread/pthread.c: In function ‘PetscThreadsDoCoreAffinity’:
> /home/abhyshr/petsc/petsc-dev/src/sys/objects/pthread/pthread.c:70:5: warning: implicit declaration of function ‘pthread_setaffinity_np’ [-Wimplicit-function-declaration]
> [ 29%] Building C object CMakeFiles/petsc.dir/src/vec/is/impls/general/ftn-auto/generalf.c.o
> 
> 1$ cat a.c
> #define _POSIX_C_SOURCE 200112L
> #include <string.h>
> #define __USE_GNU
> #include <time.h>
> 
> $ gcc -c a.c
> In file included from a.c:4:0:
> /usr/include/time.h:226:5: error: unknown type name ‘__locale_t’
> 
> 
> 1. Shri, why is __USE_GNU being defined directly?
> 
> 2. If we are defining _GNU_SOURCE, it _must_ be defined before any system headers are included, see PETSC_DESIRE_FEATURE_TEST_MACROS (petscsys.h and config/PETSc/Configure.py:configureFeatureTestMacros()).
> 
> 3. I pushed http://petsc.cs.iit.edu/petsc/petsc-dev/rev/81ca8251e64d, but we need a more complete solution (including #2).

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20120512/189b6353/attachment.html>


More information about the petsc-dev mailing list