This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
FreeBSD port (46): linuxthreads version of open
- From: Bruno Haible <bruno at clisp dot org>
- To: Roland McGrath <roland at frob dot com>
- Cc: libc-alpha at sources dot redhat dot com
- Date: Thu, 5 Sep 2002 14:16:12 +0200 (CEST)
- Subject: 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)