diff options
author | joseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d> | 2011-10-25 00:37:10 +0000 |
---|---|---|
committer | joseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d> | 2011-10-25 00:37:10 +0000 |
commit | 4bbe4e2185c5484328182720ff7b3bb4f9593bff (patch) | |
tree | cd67e40a74928c0f58d4f5b79d2e260e4099fee7 /libc/misc | |
parent | 91b4be71461f78cabe1fb5f164cea71b60e9e98a (diff) |
Merge changes between r15223 and r15532 from /fsf/trunk.
git-svn-id: svn://svn.eglibc.org/trunk@15545 7b3dc134-2b1b-0410-93df-9e9f96275f8d
Diffstat (limited to 'libc/misc')
-rw-r--r-- | libc/misc/Makefile | 3 | ||||
-rw-r--r-- | libc/misc/bits/select2.h | 34 | ||||
-rw-r--r-- | libc/misc/err.c | 18 | ||||
-rw-r--r-- | libc/misc/getttyent.c | 6 | ||||
-rw-r--r-- | libc/misc/mntent_r.c | 6 | ||||
-rw-r--r-- | libc/misc/sys/cdefs.h | 15 | ||||
-rw-r--r-- | libc/misc/sys/select.h | 16 |
7 files changed, 67 insertions, 31 deletions
diff --git a/libc/misc/Makefile b/libc/misc/Makefile index f52c9a3c6..dc88e748d 100644 --- a/libc/misc/Makefile +++ b/libc/misc/Makefile @@ -35,7 +35,8 @@ headers := sys/uio.h bits/uio.h sys/ioctl.h bits/ioctls.h bits/ioctl-types.h \ sys/select.h ustat.h sys/ustat.h bits/ustat.h sys/sysinfo.h \ regexp.h bits/select.h bits/mman.h sys/xattr.h \ syslog.h sys/syslog.h \ - bits/syslog.h bits/syslog-ldbl.h bits/syslog-path.h bits/error.h + bits/syslog.h bits/syslog-ldbl.h bits/syslog-path.h bits/error.h \ + bits/select2.h routines := brk sbrk sstk ioctl \ readv writev preadv preadv64 pwritev pwritev64 \ diff --git a/libc/misc/bits/select2.h b/libc/misc/bits/select2.h new file mode 100644 index 000000000..37c4827f1 --- /dev/null +++ b/libc/misc/bits/select2.h @@ -0,0 +1,34 @@ +/* Checking macros for select functions. + Copyright (C) 2011 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SYS_SELECT_H +# error "Never include <bits/select2.h> directly; use <sys/select.h> instead." +#endif + +/* Helper functions to issue warnings and errors when needed. */ +extern unsigned long int __fdelt_chk (unsigned long int __d); +extern unsigned long int __fdelt_warn (unsigned long int __d) + __warnattr ("bit outside of fd_set selected"); +#undef __FD_ELT +#define __FD_ELT(d) \ + ({ unsigned long int __d = d; \ + (__builtin_constant_p (__d) \ + ? (__d >= __FD_SETSIZE \ + ? __fdelt_warn (__d) : (__d / __NFDBITS)) \ + : __fdelt_chk (__d)); }) diff --git a/libc/misc/err.c b/libc/misc/err.c index 6d67c72d2..8dde6edb9 100644 --- a/libc/misc/err.c +++ b/libc/misc/err.c @@ -1,5 +1,5 @@ /* 4.4BSD utility functions for error messages. - Copyright (C) 1995,96,98,2001,02 Free Software Foundation, Inc. + Copyright (C) 1995,1996,1998,2001,2002,2011 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -25,11 +25,9 @@ #include <stdio.h> #include <gnu/option-groups.h> -#ifdef USE_IN_LIBIO -# include <wchar.h> -# define flockfile(s) _IO_flockfile (s) -# define funlockfile(s) _IO_funlockfile (s) -#endif +#include <wchar.h> +#define flockfile(s) _IO_flockfile (s) +#define funlockfile(s) _IO_funlockfile (s) extern char *__progname; @@ -41,12 +39,11 @@ extern char *__progname; va_end (ap); \ } -#ifdef USE_IN_LIBIO #if __OPTION_POSIX_WIDE_CHAR_DEVICE_IO static void convert_and_print (const char *format, __gnuc_va_list ap) { -# define ALLOCA_LIMIT 2000 +#define ALLOCA_LIMIT 2000 size_t len; wchar_t *wformat = NULL; mbstate_t st; @@ -88,13 +85,11 @@ convert_and_print (const char *format, __gnuc_va_list ap) __vfwprintf (stderr, wformat, ap); } #endif -#endif void vwarnx (const char *format, __gnuc_va_list ap) { flockfile (stderr); -#ifdef USE_IN_LIBIO if (_IO_fwide (stderr, 0) > 0) { #if __OPTION_POSIX_WIDE_CHAR_DEVICE_IO @@ -106,7 +101,6 @@ vwarnx (const char *format, __gnuc_va_list ap) #endif } else -#endif { fprintf (stderr, "%s: ", __progname); if (format) @@ -123,7 +117,6 @@ vwarn (const char *format, __gnuc_va_list ap) int error = errno; flockfile (stderr); -#ifdef USE_IN_LIBIO if (_IO_fwide (stderr, 0) > 0) { #if __OPTION_POSIX_WIDE_CHAR_DEVICE_IO @@ -140,7 +133,6 @@ vwarn (const char *format, __gnuc_va_list ap) #endif } else -#endif { fprintf (stderr, "%s: ", __progname); if (format) diff --git a/libc/misc/getttyent.c b/libc/misc/getttyent.c index 756017089..6d789c4e2 100644 --- a/libc/misc/getttyent.c +++ b/libc/misc/getttyent.c @@ -37,10 +37,8 @@ static char sccsid[] = "@(#)getttyent.c 8.1 (Berkeley) 6/4/93"; #include <ctype.h> #include <string.h> -#ifdef USE_IN_LIBIO -# define flockfile(s) _IO_flockfile (s) -# define funlockfile(s) _IO_funlockfile (s) -#endif +#define flockfile(s) _IO_flockfile (s) +#define funlockfile(s) _IO_funlockfile (s) static char zapchar; static FILE *tf; diff --git a/libc/misc/mntent_r.c b/libc/misc/mntent_r.c index 6959f0e21..0e9835c61 100644 --- a/libc/misc/mntent_r.c +++ b/libc/misc/mntent_r.c @@ -25,10 +25,8 @@ #include <string.h> #include <sys/types.h> -#ifdef USE_IN_LIBIO -# define flockfile(s) _IO_flockfile (s) -# define funlockfile(s) _IO_funlockfile (s) -#endif +#define flockfile(s) _IO_flockfile (s) +#define funlockfile(s) _IO_funlockfile (s) #undef __setmntent #undef __endmntent diff --git a/libc/misc/sys/cdefs.h b/libc/misc/sys/cdefs.h index 165a94a64..72073e855 100644 --- a/libc/misc/sys/cdefs.h +++ b/libc/misc/sys/cdefs.h @@ -38,18 +38,27 @@ #ifdef __GNUC__ +/* All functions, except those with callbacks, are leaf functions. */ +# if __GNUC_PREREQ (4, 6) && !defined _LIBC +# define __LEAF , __leaf__ +# define __LEAF_ATTR __attribute__ ((__leaf__)) +# else +# define __LEAF +# define __LEAF_ATTR +# endif + /* GCC can always grok prototypes. For C++ programs we add throw() to help it optimize the function calls. But this works only with gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions as non-throwing using a function attribute since programs can use the -fexceptions options for C code as well. */ # if !defined __cplusplus && __GNUC_PREREQ (3, 3) -# define __THROW __attribute__ ((__nothrow__)) -# define __NTH(fct) __attribute__ ((__nothrow__)) fct +# define __THROW __attribute__ ((__nothrow__ __LEAF)) +# define __NTH(fct) __attribute__ ((__nothrow__ __LEAF)) fct # else # if defined __cplusplus && __GNUC_PREREQ (2,8) # define __THROW throw () -# define __NTH(fct) fct throw () +# define __NTH(fct) __LEAF_ATTR fct throw () # else # define __THROW # define __NTH(fct) fct diff --git a/libc/misc/sys/select.h b/libc/misc/sys/select.h index f4a37be55..97f2b3d65 100644 --- a/libc/misc/sys/select.h +++ b/libc/misc/sys/select.h @@ -1,5 +1,5 @@ /* `fd_set' type and related macros, and `select'/`pselect' declarations. - Copyright (C) 1996-2003, 2009 Free Software Foundation, Inc. + Copyright (C) 1996-2003, 2009, 2011 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -54,14 +54,12 @@ typedef __suseconds_t suseconds_t; /* The fd_set member is required to be an array of longs. */ typedef long int __fd_mask; -/* Some versions of <linux/posix_types.h> define these macros. */ +/* Some versions of <linux/posix_types.h> define this macros. */ #undef __NFDBITS -#undef __FDELT -#undef __FDMASK /* It's easier to assume 8-bit bytes than to get CHAR_BIT. */ #define __NFDBITS (8 * (int) sizeof (__fd_mask)) -#define __FDELT(d) ((d) / __NFDBITS) -#define __FDMASK(d) ((__fd_mask) 1 << ((d) % __NFDBITS)) +#define __FD_ELT(d) ((d) / __NFDBITS) +#define __FD_MASK(d) ((__fd_mask) 1 << ((d) % __NFDBITS)) /* fd_set for select and pselect. */ typedef struct @@ -125,6 +123,12 @@ extern int pselect (int __nfds, fd_set *__restrict __readfds, const __sigset_t *__restrict __sigmask); #endif + +/* Define some inlines helping to catch common problems. */ +#if __USE_FORTIFY_LEVEL > 0 && defined __GNUC__ +# include <bits/select2.h> +#endif + __END_DECLS #endif /* sys/select.h */ |