Updated to fedora-glibc-20050808T2126
[glibc.git] / posix / bits / unistd.h
blobb72b7c758ab49221d82426a3fc720f4c486cf782
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
18 02111-1307 USA. */
20 #ifndef _UNISTD_H
21 # error "Never include <bits/unistd.h> directly; use <unistd.h> instead."
22 #endif
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);
38 #ifdef __USE_UNIX98
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);
59 # else
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);
68 # endif
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);
79 # endif
80 #endif
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,
85 size_t __buflen)
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,
94 size_t __len))
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);
101 #endif
103 extern char *__getcwd_chk (char *__buf, size_t __size, size_t __buflen)
104 __THROW __wur;
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);
130 #endif
132 extern size_t __confstr_chk (int __name, char *__buf, size_t __len,
133 size_t __buflen) __THROW;
134 extern size_t __REDIRECT_NTH (__confstr_alias, (int __name, char *__buf,
135 size_t __len), confstr);
137 extern __always_inline size_t
138 __NTH (confstr (int __name, char *__buf, size_t __len))
140 if (__bos (__buf) != (size_t) -1
141 && (!__builtin_constant_p (__len) || __bos (__buf) < __len))
142 return __confstr_chk (__name, __buf, __len, __bos (__buf));
143 return __confstr_alias (__name, __buf, __len);
147 extern int __getgroups_chk (int __size, __gid_t __list[], size_t listlen)
148 __THROW __wur;
149 extern int __REDIRECT_NTH (__getgroups_alias, (int __size, __gid_t __list[]),
150 getgroups) __wur;
152 extern __always_inline int
153 __NTH (getgroups (int __size, __gid_t __list[]))
155 if (__bos (__list) != (size_t) -1
156 && (!__builtin_constant_p (__size)
157 || __size * sizeof (__gid_t) > __bos (__list)))
158 return __getgroups_chk (__size, __list, __bos (__list));
159 return __getgroups_alias (__size, __list);
163 extern int __ttyname_r_chk (int __fd, char *__buf, size_t __buflen,
164 size_t __nreal) __THROW __nonnull ((2));
165 extern int __REDIRECT_NTH (__ttyname_r_alias, (int __fd, char *__buf,
166 size_t __buflen), ttyname_r)
167 __nonnull ((2));
169 extern __always_inline int
170 __NTH (ttyname_r (int __fd, char *__buf, size_t __buflen))
172 if (__bos (__buf) != (size_t) -1
173 && (!__builtin_constant_p (__buflen) || __buflen > __bos (__buf)))
174 return __ttyname_r_chk (__fd, __buf, __buflen, __bos (__buf));
175 return __ttyname_r_alias (__fd, __buf, __buflen);
179 #if defined __USE_REENTRANT || defined __USE_UNIX98
180 extern int __getlogin_r_chk (char *__buf, size_t __buflen, size_t __nreal)
181 __nonnull ((1));
182 extern int __REDIRECT (__getlogin_r_alias, (char *__buf, size_t __buflen),
183 getlogin_r) __nonnull ((1));
185 extern __always_inline int
186 getlogin_r (char *__buf, size_t __buflen)
188 if (__bos (__buf) != (size_t) -1
189 && (!__builtin_constant_p (__buflen) || __buflen > __bos (__buf)))
190 return __getlogin_r_chk (__buf, __buflen, __bos (__buf));
191 return __getlogin_r_alias (__buf, __buflen);
193 #endif
196 #if defined __USE_BSD || defined __USE_UNIX98
197 extern int __gethostname_chk (char *__buf, size_t __buflen, size_t __nreal)
198 __THROW __nonnull ((1));
199 extern int __REDIRECT_NTH (__gethostname_alias, (char *__buf, size_t __buflen),
200 gethostname) __nonnull ((1));
202 extern __always_inline int
203 __NTH (gethostname (char *__buf, size_t __buflen))
205 if (__bos (__buf) != (size_t) -1
206 && (!__builtin_constant_p (__buflen) || __buflen > __bos (__buf)))
207 return __gethostname_chk (__buf, __buflen, __bos (__buf));
208 return __gethostname_alias (__buf, __buflen);
210 #endif
213 #if defined __USE_BSD || (defined __USE_XOPEN && !defined __USE_UNIX98)
214 extern int __getdomainname_chk (char *__buf, size_t __buflen, size_t __nreal)
215 __THROW __nonnull ((1)) __wur;
216 extern int __REDIRECT_NTH (__getdomainname_alias, (char *__buf,
217 size_t __buflen),
218 getdomainname) __nonnull ((1)) __wur;
220 extern __always_inline int
221 __NTH (getdomainname (char *__buf, size_t __buflen))
223 if (__bos (__buf) != (size_t) -1
224 && (!__builtin_constant_p (__buflen) || __buflen > __bos (__buf)))
225 return __getdomainname_chk (__buf, __buflen, __bos (__buf));
226 return __getdomainname_alias (__buf, __buflen);
228 #endif