aboutsummaryrefslogtreecommitdiff
path: root/posix
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2005-03-19 00:06:22 +0000
committerUlrich Drepper <drepper@redhat.com>2005-03-19 00:06:22 +0000
commit60bd9f7c4114b405579263b160e53ed606db7291 (patch)
treedc3834b2d5b2d18a7ce516884509ee94a2d5a4c0 /posix
parent959184846bd9ce2bd4527fe1e0f50d633094e80f (diff)
downloadglibc-60bd9f7c4114b405579263b160e53ed606db7291.tar
glibc-60bd9f7c4114b405579263b160e53ed606db7291.tar.gz
glibc-60bd9f7c4114b405579263b160e53ed606db7291.tar.bz2
glibc-60bd9f7c4114b405579263b160e53ed606db7291.zip
(read, pread, pread64, readlink, getcwd, getwd): Change macros into extern inline functions. (__read_alias, __pread_alias, __pread64_alias, __readlink_alias, __getcwd_alias, __getwd_alias): New prototypes.
Diffstat (limited to 'posix')
-rw-r--r--posix/bits/unistd.h106
1 files changed, 74 insertions, 32 deletions
diff --git a/posix/bits/unistd.h b/posix/bits/unistd.h
index 26cb6641e9..6cf95acc0b 100644
--- a/posix/bits/unistd.h
+++ b/posix/bits/unistd.h
@@ -23,37 +23,58 @@
extern ssize_t __read_chk (int __fd, void *__buf, size_t __nbytes,
size_t __buflen) __wur;
-#define read(fd, buf, nbytes) \
- (__bos0 (buf) != (size_t) -1 \
- && (!__builtin_constant_p (nbytes) || (nbytes) > __bos0 (buf)) \
- ? __read_chk (fd, buf, nbytes, __bos0 (buf)) \
- : read (fd, buf, nbytes))
+extern ssize_t __REDIRECT (__read_alias, (int __fd, void *__buf,
+ size_t __nbytes), read) __wur;
+
+extern __inline __wur ssize_t
+read (int __fd, void *__buf, size_t __nbytes)
+{
+ if (__bos0 (__buf) != (size_t) -1
+ && (!__builtin_constant_p (__nbytes) || __nbytes > __bos0 (__buf)))
+ return __read_chk (__fd, __buf, __nbytes, __bos0 (__buf));
+ return __read_alias (__fd, __buf, __nbytes);
+}
#ifdef __USE_UNIX98
extern ssize_t __pread_chk (int __fd, void *__buf, size_t __nbytes,
__off_t __offset, size_t __bufsize) __wur;
extern ssize_t __pread64_chk (int __fd, void *__buf, size_t __nbytes,
__off64_t __offset, size_t __bufsize) __wur;
+extern ssize_t __REDIRECT (__pread_alias,
+ (int __fd, void *__buf, size_t __nbytes,
+ __off_t __offset), pread) __wur;
+extern ssize_t __REDIRECT (__pread64_alias,
+ (int __fd, void *__buf, size_t __nbytes,
+ __off64_t __offset), pread64) __wur;
# ifndef __USE_FILE_OFFSET64
-# define pread(fd, buf, nbytes, offset) \
- (__bos0 (buf) != (size_t) -1 \
- && (!__builtin_constant_p (nbytes) || (nbytes) > __bos0 (buf)) \
- ? __pread64_chk (fd, buf, nbytes, offset, __bos0 (buf)) \
- : pread64 (fd, buf, nbytes, offset))
+extern __inline __wur ssize_t
+pread (int __fd, void *__buf, size_t __nbytes, __off_t __offset)
+{
+ if (__bos0 (__buf) != (size_t) -1
+ && (!__builtin_constant_p (__nbytes) || __nbytes > __bos0 (__buf)))
+ return __pread_chk (__fd, __buf, __nbytes, __offset, __bos0 (__buf));
+ return __pread_alias (__fd, __buf, __nbytes, __offset);
+}
# else
-# define pread(fd, buf, nbytes, offset) \
- (__bos0 (buf) != (size_t) -1 \
- && (!__builtin_constant_p (nbytes) || (nbytes) > __bos0 (buf)) \
- ? __pread_chk (fd, buf, nbytes, offset, __bos0 (buf)) \
- : pread (fd, buf, nbytes, offset))
+extern __inline __wur ssize_t
+pread (int __fd, void *__buf, size_t __nbytes, __off_t __offset)
+{
+ if (__bos0 (__buf) != (size_t) -1
+ && (!__builtin_constant_p (__nbytes) || __nbytes > __bos0 (__buf)))
+ return __pread64_chk (__fd, __buf, __nbytes, __offset, __bos0 (__buf));
+ return __pread64_alias (__fd, __buf, __nbytes, __offset);
+}
# endif
# ifdef __USE_LARGEFILE64
-# define pread64(fd, buf, nbytes, offset) \
- (__bos0 (buf) != (size_t) -1 \
- && (!__builtin_constant_p (nbytes) || (nbytes) > __bos0 (buf)) \
- ? __pread64_chk (fd, buf, nbytes, offset, __bos0 (buf)) \
- : pread64 (fd, buf, nbytes, offset))
+extern __inline __wur ssize_t
+pread64 (int __fd, void *__buf, size_t __nbytes, __off64_t __offset)
+{
+ if (__bos0 (__buf) != (size_t) -1
+ && (!__builtin_constant_p (__nbytes) || __nbytes > __bos0 (__buf)))
+ return __pread64_chk (__fd, __buf, __nbytes, __offset, __bos0 (__buf));
+ return __pread64_alias (__fd, __buf, __nbytes, __offset);
+}
# endif
#endif
@@ -62,23 +83,44 @@ extern int __readlink_chk (__const char *__restrict __path,
char *__restrict __buf, size_t __len,
size_t __buflen)
__THROW __nonnull ((1, 2)) __wur;
-# define readlink(path, buf, len) \
- (__bos (buf) != (size_t) -1 \
- && (!__builtin_constant_p (len) || (len) > __bos (buf)) \
- ? __readlink_chk (path, buf, len, __bos (buf)) \
- : readlink (path, buf, len))
+extern int __REDIRECT_NTH (__readlink_alias,
+ (__const char *__restrict __path,
+ char *__restrict __buf, size_t __len), readlink)
+ __nonnull ((1, 2)) __wur;
+extern __inline __nonnull ((1, 2)) __wur int
+__NTH (readlink (__const char *__restrict __path, char *__restrict __buf,
+ size_t __len))
+{
+ if (__bos (__buf) != (size_t) -1
+ && (!__builtin_constant_p (__len) || __len > __bos (__buf)))
+ return __readlink_chk (__path, __buf, __len, __bos (__buf));
+ return __readlink_alias (__path, __buf, __len);
+}
#endif
extern char *__getcwd_chk (char *__buf, size_t __size, size_t __buflen)
__THROW __wur;
-#define getcwd(buf, size) \
- (__bos (buf) != (size_t) -1 \
- && (!__builtin_constant_p (size) || (size) > __bos (buf)) \
- ? __getcwd_chk (buf, size, buflen) : getcwd (buf, size))
+extern char *__REDIRECT_NTH (__getcwd_alias,
+ (char *__buf, size_t __size), getcwd) __wur;
+extern __inline __wur char *
+__NTH (getcwd (char *__buf, size_t __size))
+{
+ if (__bos (__buf) != (size_t) -1
+ && (!__builtin_constant_p (__size) || __size > __bos (__buf)))
+ return __getcwd_chk (__buf, __size, __bos (__buf));
+ return __getcwd_alias (__buf, __size);
+}
#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
extern char *__getwd_chk (char *__buf, size_t buflen)
- __THROW __nonnull ((1)) __attribute_deprecated__ __wur;
-#define getwd(buf) \
- (__bos (buf) != (size_t) -1 ? __getwd_chk (buf, buflen) : getwd (buf))
+ __THROW __nonnull ((1)) __wur;
+extern char *__REDIRECT_NTH (__getwd_alias, (char *__buf), getwd)
+ __nonnull ((1)) __wur;
+extern __inline __nonnull ((1)) __attribute_deprecated__ __wur char *
+__NTH (getwd (char *__buf))
+{
+ if (__bos (__buf) != (size_t) -1)
+ return __getwd_chk (__buf, __bos (__buf));
+ return __getwd_alias (__buf);
+}
#endif