This is the mail archive of the libc-hacker@cygnus.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

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



Hi Geoff,

I'm CC'ing libc-hacker again.
>>>>> Geoff Keating writes:

>> From: Andreas Jaeger <aj@arthur.rhein-neckar.de>
>> Date: 20 Apr 1999 08:50:39 +0200
>> 
>> This small program:
>> #include <sys/procfs.h>
>> #include <sys/ucontext.h>
>> 
>> int main (void) {}
>> 
>> gives a number of warnings and errors:

Geoff> Works fine for me:

Geoff> [geoffk@geoffk /tmp]$ gcc z.c -Wall
Geoff> z.c: In function `main':
Geoff> z.c:3: warning: control reaches end of non-void function


>> $ 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

Geoff> On my machine running 2.1, these types are only defined in 'procfs.h'.

Ok, Powerpc does it right.  Just compare:
./sysdeps/unix/sysv/linux/alpha/sys/ucontext.h
./sysdeps/unix/sysv/linux/i386/sys/ucontext.h
./sysdeps/unix/sysv/linux/mips/sys/ucontext.h
./sysdeps/unix/sysv/linux/powerpc/sys/ucontext.h
./sysdeps/unix/sysv/linux/sparc/sparc32/sys/ucontext.h
./sysdeps/unix/sysv/linux/sparc/sparc64/sys/ucontext.h
./sysdeps/m68k/sys/ucontext.h

The i386, mips, m68k and sparc32 seem to be the only broken ones
(alpha, powerpc and sparc64 look ok).

On ix86 it's even worse than the duplicate definition, it results in
different values:

#ifdef PROCFS
#include <sys/procfs.h>
#else
#include <sys/ucontext.h>
#endif

#include <stdio.h>

int main (void) 
{
  printf ("NGREG is %d\n", NGREG);
  printf ("sizeof(greg_t): %d, sizeof(gregset_t): %d, sizeof(fpregset_t): %d\n",
	  sizeof(greg_t), sizeof(gregset_t), sizeof(fpregset_t));
  return 0;
}

$ gcc -DPROCFS -Wall header.c -o header;./header
NGREG is 17
sizeof(greg_t): 4, sizeof(gregset_t): 68, sizeof(fpregset_t): 108

$ gcc  -Wall header.c -o header;./header
NGREG is 19
sizeof(greg_t): 4, sizeof(gregset_t): 76, sizeof(fpregset_t): 4


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]