Conflicts between <sys/procfs.h>, <sys/ucontext.h> and <sys/elf.h>

Andreas Jaeger aj@arthur.rhein-neckar.de
Mon Apr 19 23:51:00 GMT 1999


This small program:
#include <sys/procfs.h>
#include <sys/ucontext.h>

int main (void) {}

gives a number of warnings and errors:
$ gcc header.c  -Wall
In file included from header.c:2:
/usr/include/sys/ucontext.h:34: warning: `NGREG' redefined
/usr/include/sys/procfs.h:46: warning: this is the location of the previous definition
In file included from header.c:2:
/usr/include/sys/ucontext.h:31: conflicting types for `greg_t'
/usr/include/sys/procfs.h:43: previous declaration of `greg_t'
/usr/include/sys/ucontext.h:37: conflicting types for `gregset_t'
/usr/include/sys/procfs.h:44: previous declaration of `gregset_t'
/usr/include/sys/ucontext.h:83: conflicting types for `fpregset_t'
/usr/include/sys/procfs.h:45: previous declaration of `fpregset_t'
header.c: In function `main':
header.c:6: warning: control reaches end of non-void function

The problem seems to be <sys/procfs.h> since its typedefs and defines
conflict with those in <sys/ucontext.h> (<sys/procfs.h> includes <sys/elf.h>):

$ grep NGREG /usr/include/sys/*
/usr/include/sys/elf.h:#define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof(elf_greg_t))
/usr/include/sys/elf.h:typedef elf_greg_t elf_gregset_t[ELF_NGREG];
/usr/include/sys/procfs.h:#define NGREG ELF_NGREG
/usr/include/sys/ucontext.h:#define NGREG       19

$ grep greg_t /usr/include/sys/*
/usr/include/sys/ucontext.h:typedef greg_t gregset_t[NGREG];
/usr/include/sys/elf.h:typedef unsigned long elf_greg_t;
/usr/include/sys/procfs.h:typedef elf_greg_t greg_t;
/usr/include/sys/ucontext.h:typedef int greg_t;
/usr/include/sys/ucontext.h:typedef greg_t gregset_t[NGREG];

This is on ix86/Linux but other platforms should have the same
problems.  Which definition is correct and how should we fix this?

Andreas
-- 
 Andreas Jaeger   aj@arthur.rhein-neckar.de    jaeger@informatik.uni-kl.de
  for pgp-key finger ajaeger@aixd1.rhrk.uni-kl.de



More information about the Libc-hacker mailing list