diff options
author | Jakub Jelinek <jakub@redhat.com> | 2007-08-04 20:51:44 +0000 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2007-08-04 20:51:44 +0000 |
commit | 9452e30a05dd79850be35ba9886992f482761b1e (patch) | |
tree | 386776084a3fc4a14b2d560865dde715431d5e88 /io | |
parent | e08057b1ff24258dd7460ad81e84491f7a28b424 (diff) | |
download | glibc-9452e30a05dd79850be35ba9886992f482761b1e.tar.gz |
Updated to fedora-glibc-20070804T2027
Diffstat (limited to 'io')
-rw-r--r-- | io/Makefile | 2 | ||||
-rw-r--r-- | io/bits/fcntl2.h | 240 | ||||
-rw-r--r-- | io/have_o_cloexec.c | 24 |
3 files changed, 150 insertions, 116 deletions
diff --git a/io/Makefile b/io/Makefile index da589b118a..1acda4c8b6 100644 --- a/io/Makefile +++ b/io/Makefile @@ -54,6 +54,8 @@ routines := \ sendfile sendfile64 \ utimensat futimens +aux := have_o_cloexec + # These routines will be omitted from the libc shared object. # Instead the static object files will be included in a special archive # linked against when the shared library will be used. diff --git a/io/bits/fcntl2.h b/io/bits/fcntl2.h index a1b03f6194..5b9fcd5e71 100644 --- a/io/bits/fcntl2.h +++ b/io/bits/fcntl2.h @@ -31,70 +31,74 @@ extern int __REDIRECT (__open_2, (__const char *__file, int __oflag), #endif #define open(fname, flags, ...) \ - ({ int ___r; \ - /* If the compiler complains about an invalid type, excess elements, etc \ - in the initialization this means a parameter of the wrong type has \ - been passed to open. */ \ - int ___arr[] = { __VA_ARGS__ }; \ - if (__builtin_constant_p (flags) && ((flags) & O_CREAT) != 0) \ - { \ - /* If the compiler complains about the size of this array type the \ - mode parameter is missing since O_CREAT has been used. */ \ - typedef int __open_missing_mode[((flags) & O_CREAT) != 0 \ - ? ((long int) sizeof (___arr) \ - - (long int) sizeof (int)) : 1]; \ - } \ - if (sizeof (___arr) == 0) \ - { \ - if (__builtin_constant_p (flags) && ((flags) & O_CREAT) == 0) \ - ___r = open (fname, flags); \ - else \ - ___r = __open_2 (fname, flags); \ - } \ - else \ - { \ - /* If the compiler complains about the size of this array type too \ - many parameters have been passed to open. */ \ - typedef int __open_too_many_args[-(sizeof (___arr) > sizeof (int))]; \ - ___r = open (fname, flags, ___arr[0]); \ - } \ - ___r; \ - }) + (__extension__ \ + ({ int ___r; \ + /* If the compiler complains about an invalid type, excess elements, \ + etc. in the initialization this means a parameter of the wrong type \ + has been passed to open. */ \ + int ___arr[] = { __VA_ARGS__ }; \ + if (__builtin_constant_p (flags) && ((flags) & O_CREAT) != 0) \ + { \ + /* If the compiler complains about the size of this array type the \ + mode parameter is missing since O_CREAT has been used. */ \ + typedef int __open_missing_mode[((flags) & O_CREAT) != 0 \ + ? ((long int) sizeof (___arr) \ + - (long int) sizeof (int)) : 1];\ + } \ + if (sizeof (___arr) == 0) \ + { \ + if (__builtin_constant_p (flags) && ((flags) & O_CREAT) == 0) \ + ___r = open (fname, flags); \ + else \ + ___r = __open_2 (fname, flags); \ + } \ + else \ + { \ + /* If the compiler complains about the size of this array type too \ + many parameters have been passed to open. */ \ + typedef int __open_too_many_args[-(sizeof (___arr) \ + > sizeof (int))]; \ + ___r = open (fname, flags, ___arr[0]); \ + } \ + ___r; \ + })) #ifdef __USE_LARGEFILE64 extern int __open64_2 (__const char *__path, int __oflag) __nonnull ((1)); # define open64(fname, flags, ...) \ - ({ int ___r; \ - /* If the compiler complains about an invalid type, excess elements, etc \ - in the initialization this means a parameter of the wrong type has \ - been passed to open64. */ \ - int ___arr[] = { __VA_ARGS__ }; \ - if (__builtin_constant_p (flags) && ((flags) & O_CREAT) != 0) \ - { \ - /* If the compiler complains about the size of this array type the \ - mode parameter is missing since O_CREAT has been used. */ \ - typedef int __open_missing_mode[((flags) & O_CREAT) != 0 \ - ? ((long int) sizeof (___arr) \ - - (long int) sizeof (int)) : 1]; \ - } \ - if (sizeof (___arr) == 0) \ - { \ - if (__builtin_constant_p (flags) && ((flags) & O_CREAT) == 0) \ - ___r = open64 (fname, flags); \ - else \ - ___r = __open64_2 (fname, flags); \ - } \ - else \ - { \ - /* If the compiler complains about the size of this array type too \ - many parameters have been passed to open64. */ \ - typedef int __open_too_many_args[-(sizeof (___arr) > sizeof (int))]; \ - ___r = open64 (fname, flags, ___arr[0]); \ - } \ - ___r; \ - }) + (__extension__ \ + ({ int ___r; \ + /* If the compiler complains about an invalid type, excess elements, \ + etc. in the initialization this means a parameter of the wrong type \ + has been passed to open64. */ \ + int ___arr[] = { __VA_ARGS__ }; \ + if (__builtin_constant_p (flags) && ((flags) & O_CREAT) != 0) \ + { \ + /* If the compiler complains about the size of this array type the \ + mode parameter is missing since O_CREAT has been used. */ \ + typedef int __open_missing_mode[((flags) & O_CREAT) != 0 \ + ? ((long int) sizeof (___arr) \ + - (long int) sizeof (int)) : 1];\ + } \ + if (sizeof (___arr) == 0) \ + { \ + if (__builtin_constant_p (flags) && ((flags) & O_CREAT) == 0) \ + ___r = open64 (fname, flags); \ + else \ + ___r = __open64_2 (fname, flags); \ + } \ + else \ + { \ + /* If the compiler complains about the size of this array type too \ + many parameters have been passed to open64. */ \ + typedef int __open_too_many_args[-(sizeof (___arr) \ + > sizeof (int))]; \ + ___r = open64 (fname, flags, ___arr[0]); \ + } \ + ___r; \ + })) #endif #ifdef __USE_ATFILE @@ -108,35 +112,37 @@ extern int __REDIRECT (__openat_2, (int __fd, __const char *__file, # endif # define openat(fd, fname, flags, ...) \ - ({ int ___r; \ - /* If the compiler complains about an invalid type, excess elements, etc \ - in the initialization this means a parameter of the wrong type has \ - been passed to openat. */ \ - int ___arr[] = { __VA_ARGS__ }; \ - if (__builtin_constant_p (flags) && ((flags) & O_CREAT) != 0) \ - { \ - /* If the compiler complains about the size of this array type the \ - mode parameter is missing since O_CREAT has been used. */ \ - typedef int __open_missing_mode[((flags) & O_CREAT) != 0 \ - ? ((long int) sizeof (___arr) \ - - (long int) sizeof (int)) : 1]; \ - } \ - if (sizeof (___arr) == 0) \ - { \ - if (__builtin_constant_p (flags) && ((flags) & O_CREAT) == 0) \ - ___r = openat (fd, fname, flags); \ - else \ - ___r = __openat_2 (fd, fname, flags); \ - } \ - else \ - { \ - /* If the compiler complains about the size of this array type too \ - many parameters have been passed to openat. */ \ - typedef int __open_too_many_args[-(sizeof (___arr) > sizeof (int))]; \ - ___r = openat (fd, fname, flags, ___arr[0]); \ - } \ - ___r; \ - }) + (__extension__ \ + ({ int ___r; \ + /* If the compiler complains about an invalid type, excess elements, \ + etc. in the initialization this means a parameter of the wrong type \ + has been passed to openat. */ \ + int ___arr[] = { __VA_ARGS__ }; \ + if (__builtin_constant_p (flags) && ((flags) & O_CREAT) != 0) \ + { \ + /* If the compiler complains about the size of this array type the \ + mode parameter is missing since O_CREAT has been used. */ \ + typedef int __open_missing_mode[((flags) & O_CREAT) != 0 \ + ? ((long int) sizeof (___arr) \ + - (long int) sizeof (int)) : 1];\ + } \ + if (sizeof (___arr) == 0) \ + { \ + if (__builtin_constant_p (flags) && ((flags) & O_CREAT) == 0) \ + ___r = openat (fd, fname, flags); \ + else \ + ___r = __openat_2 (fd, fname, flags); \ + } \ + else \ + { \ + /* If the compiler complains about the size of this array type too \ + many parameters have been passed to openat. */ \ + typedef int __open_too_many_args[-(sizeof (___arr) \ + > sizeof (int))]; \ + ___r = openat (fd, fname, flags, ___arr[0]); \ + } \ + ___r; \ + })) # ifdef __USE_LARGEFILE64 @@ -144,34 +150,36 @@ extern int __openat64_2 (int __fd, __const char *__path, int __oflag) __nonnull ((2)); # define openat64(fd, fname, flags, ...) \ - ({ int ___r; \ - /* If the compiler complains about an invalid type, excess elements, etc \ - in the initialization this means a parameter of the wrong type has \ - been passed to openat64. */ \ - int ___arr[] = { __VA_ARGS__ }; \ - if (__builtin_constant_p (flags) && ((flags) & O_CREAT) != 0) \ - { \ - /* If the compiler complains about the size of this array type the \ - mode parameter is missing since O_CREAT has been used. */ \ - typedef int __open_missing_mode[((flags) & O_CREAT) != 0 \ - ? ((long int) sizeof (___arr) \ - - (long int) sizeof (int)) : 1]; \ - } \ - if (sizeof (___arr) == 0) \ - { \ - if (__builtin_constant_p (flags) && ((flags) & O_CREAT) == 0) \ - ___r = openat64 (fd, fname, flags); \ - else \ - ___r = __openat64_2 (fd, fname, flags); \ - } \ - else \ - { \ - /* If the compiler complains about the size of this array type too \ - many parameters have been passed to openat64. */ \ - typedef int __open_too_many_args[-(sizeof (___arr) > sizeof (int))]; \ - ___r = openat64 (fd, fname, flags, ___arr[0]); \ - } \ - ___r; \ - }) + (__extension__ \ + ({ int ___r; \ + /* If the compiler complains about an invalid type, excess elements, \ + etc. in the initialization this means a parameter of the wrong type \ + has been passed to openat64. */ \ + int ___arr[] = { __VA_ARGS__ }; \ + if (__builtin_constant_p (flags) && ((flags) & O_CREAT) != 0) \ + { \ + /* If the compiler complains about the size of this array type the \ + mode parameter is missing since O_CREAT has been used. */ \ + typedef int __open_missing_mode[((flags) & O_CREAT) != 0 \ + ? ((long int) sizeof (___arr) \ + - (long int) sizeof (int)) : 1];\ + } \ + if (sizeof (___arr) == 0) \ + { \ + if (__builtin_constant_p (flags) && ((flags) & O_CREAT) == 0) \ + ___r = openat64 (fd, fname, flags); \ + else \ + ___r = __openat64_2 (fd, fname, flags); \ + } \ + else \ + { \ + /* If the compiler complains about the size of this array type too \ + many parameters have been passed to openat64. */ \ + typedef int __open_too_many_args[-(sizeof (___arr) \ + > sizeof (int))]; \ + ___r = openat64 (fd, fname, flags, ___arr[0]); \ + } \ + ___r; \ + })) # endif #endif diff --git a/io/have_o_cloexec.c b/io/have_o_cloexec.c new file mode 100644 index 0000000000..a83e8a4487 --- /dev/null +++ b/io/have_o_cloexec.c @@ -0,0 +1,24 @@ +/* Copyright (C) 2007 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. */ + +#include <fcntl.h> +#include <kernel-features.h> + +#if defined O_CLOEXEC && !defined __ASSUME_O_CLOEXEC +int __have_o_cloexec; +#endif |