1 /* Checking macros for unistd functions.
2 Copyright (C) 2005 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21 # error "Never include <bits/unistd.h> directly; use <unistd.h> instead."
24 extern ssize_t
__read_chk (int __fd
, void *__buf
, size_t __nbytes
,
25 size_t __buflen
) __wur
;
26 extern ssize_t
__REDIRECT (__read_alias
, (int __fd
, void *__buf
,
27 size_t __nbytes
), read
) __wur
;
29 extern __always_inline __wur ssize_t
30 read (int __fd
, void *__buf
, size_t __nbytes
)
32 if (__bos0 (__buf
) != (size_t) -1
33 && (!__builtin_constant_p (__nbytes
) || __nbytes
> __bos0 (__buf
)))
34 return __read_chk (__fd
, __buf
, __nbytes
, __bos0 (__buf
));
35 return __read_alias (__fd
, __buf
, __nbytes
);
39 extern ssize_t
__pread_chk (int __fd
, void *__buf
, size_t __nbytes
,
40 __off_t __offset
, size_t __bufsize
) __wur
;
41 extern ssize_t
__pread64_chk (int __fd
, void *__buf
, size_t __nbytes
,
42 __off64_t __offset
, size_t __bufsize
) __wur
;
43 extern ssize_t
__REDIRECT (__pread_alias
,
44 (int __fd
, void *__buf
, size_t __nbytes
,
45 __off_t __offset
), pread
) __wur
;
46 extern ssize_t
__REDIRECT (__pread64_alias
,
47 (int __fd
, void *__buf
, size_t __nbytes
,
48 __off64_t __offset
), pread64
) __wur
;
50 # ifndef __USE_FILE_OFFSET64
51 extern __always_inline __wur ssize_t
52 pread (int __fd
, void *__buf
, size_t __nbytes
, __off_t __offset
)
54 if (__bos0 (__buf
) != (size_t) -1
55 && (!__builtin_constant_p (__nbytes
) || __nbytes
> __bos0 (__buf
)))
56 return __pread_chk (__fd
, __buf
, __nbytes
, __offset
, __bos0 (__buf
));
57 return __pread_alias (__fd
, __buf
, __nbytes
, __offset
);
60 extern __always_inline __wur ssize_t
61 pread (int __fd
, void *__buf
, size_t __nbytes
, __off64_t __offset
)
63 if (__bos0 (__buf
) != (size_t) -1
64 && (!__builtin_constant_p (__nbytes
) || __nbytes
> __bos0 (__buf
)))
65 return __pread64_chk (__fd
, __buf
, __nbytes
, __offset
, __bos0 (__buf
));
66 return __pread64_alias (__fd
, __buf
, __nbytes
, __offset
);
70 # ifdef __USE_LARGEFILE64
71 extern __always_inline __wur ssize_t
72 pread64 (int __fd
, void *__buf
, size_t __nbytes
, __off64_t __offset
)
74 if (__bos0 (__buf
) != (size_t) -1
75 && (!__builtin_constant_p (__nbytes
) || __nbytes
> __bos0 (__buf
)))
76 return __pread64_chk (__fd
, __buf
, __nbytes
, __offset
, __bos0 (__buf
));
77 return __pread64_alias (__fd
, __buf
, __nbytes
, __offset
);
82 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K
83 extern int __readlink_chk (__const
char *__restrict __path
,
84 char *__restrict __buf
, size_t __len
,
86 __THROW
__nonnull ((1, 2)) __wur
;
87 extern int __REDIRECT_NTH (__readlink_alias
,
88 (__const
char *__restrict __path
,
89 char *__restrict __buf
, size_t __len
), readlink
)
90 __nonnull ((1, 2)) __wur
;
92 extern __always_inline
__nonnull ((1, 2)) __wur
int
93 __NTH (readlink (__const
char *__restrict __path
, char *__restrict __buf
,
96 if (__bos (__buf
) != (size_t) -1
97 && (!__builtin_constant_p (__len
) || __len
> __bos (__buf
)))
98 return __readlink_chk (__path
, __buf
, __len
, __bos (__buf
));
99 return __readlink_alias (__path
, __buf
, __len
);
103 extern char *__getcwd_chk (char *__buf
, size_t __size
, size_t __buflen
)
105 extern char *__REDIRECT_NTH (__getcwd_alias
,
106 (char *__buf
, size_t __size
), getcwd
) __wur
;
108 extern __always_inline __wur
char *
109 __NTH (getcwd (char *__buf
, size_t __size
))
111 if (__bos (__buf
) != (size_t) -1
112 && (!__builtin_constant_p (__size
) || __size
> __bos (__buf
)))
113 return __getcwd_chk (__buf
, __size
, __bos (__buf
));
114 return __getcwd_alias (__buf
, __size
);
117 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
118 extern char *__getwd_chk (char *__buf
, size_t buflen
)
119 __THROW
__nonnull ((1)) __wur
;
120 extern char *__REDIRECT_NTH (__getwd_alias
, (char *__buf
), getwd
)
121 __nonnull ((1)) __wur
;
123 extern __always_inline
__nonnull ((1)) __attribute_deprecated__ __wur
char *
124 __NTH (getwd (char *__buf
))
126 if (__bos (__buf
) != (size_t) -1)
127 return __getwd_chk (__buf
, __bos (__buf
));
128 return __getwd_alias (__buf
);