This is the mail archive of the libc-alpha@sources.redhat.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]
Other format: [Raw text]

FreeBSD port (46): linuxthreads version of open


On GNU/FreeBSD, 'mode_t' is 'unsigned short' (choice made for compatibility
of some structs, like 'struct stat', with the FreeBSD kernel).
Now linuxthreads/wrapsyscall.c contains the expression

     va_arg (ap, mode_t)

gcc >= 3.1 compiles this expression into an abort trap (on platforms where
such a kernel trap exists) or into a call to the abort() function (on i386).
The correct fix is to use

     va_arg (ap, int)

instead on platforms where mode_t is smaller than 'int'.


linuxthreads/ChangeLog:
2002-09-04  Bruno Haible  <bruno@clisp.org>

	* wrapsyscall.c (PROMOTE_INTEGRAL_TYPE): New macro.
	(open, open64): Change va_arg argument type to the integral type to
	which mode_t promotes.

diff -r -c3 glibc-20020828.bak/linuxthreads/wrapsyscall.c glibc-20020828/linuxthreads/wrapsyscall.c
*** glibc-20020828.bak/linuxthreads/wrapsyscall.c	Tue Aug 27 13:38:43 2002
--- glibc-20020828/linuxthreads/wrapsyscall.c	Fri Aug 30 11:04:30 2002
***************
*** 1,5 ****
  /* Wrapper arpund system calls to provide cancelation points.
!    Copyright (C) 1996,1997,1998,1999,2000,2001 Free Software Foundation, Inc.
     This file is part of the GNU C Library.
     Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
  
--- 1,5 ----
  /* Wrapper arpund system calls to provide cancelation points.
!    Copyright (C) 1996-1999,2000-2002 Free Software Foundation, Inc.
     This file is part of the GNU C Library.
     Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
  
***************
*** 69,74 ****
--- 69,76 ----
    return result;							      \
  }
  
+ #define PROMOTE_INTEGRAL_TYPE(type) __typeof__ ((type) 0 + 0)
+ 
  
  /* close(2).  */
  CANCELABLE_SYSCALL (int, close, (int fd), (fd))
***************
*** 110,122 ****
  
  /* open(2).  */
  CANCELABLE_SYSCALL_VA (int, open, (const char *pathname, int flags, ...),
! 		       (pathname, flags, va_arg (ap, mode_t)), flags)
  strong_alias (open, __open)
  
  
  /* open64(3).  */
  CANCELABLE_SYSCALL_VA (int, open64, (const char *pathname, int flags, ...),
! 		       (pathname, flags, va_arg (ap, mode_t)), flags)
  strong_alias (open64, __open64)
  
  
--- 112,128 ----
  
  /* open(2).  */
  CANCELABLE_SYSCALL_VA (int, open, (const char *pathname, int flags, ...),
! 		       (pathname, flags,
! 			va_arg (ap, PROMOTE_INTEGRAL_TYPE (mode_t))),
! 		       flags)
  strong_alias (open, __open)
  
  
  /* open64(3).  */
  CANCELABLE_SYSCALL_VA (int, open64, (const char *pathname, int flags, ...),
! 		       (pathname, flags,
! 			va_arg (ap, PROMOTE_INTEGRAL_TYPE (mode_t))),
! 		       flags)
  strong_alias (open64, __open64)
  
  


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