* sysdeps/x86_64/cacheinfo.c (init_cacheinfo): Pass correct value
[glibc.git] / posix / bits / unistd.h
blob331e8ea3b99e482e1bd257c9a6b8027580879287
1 /* Checking macros for unistd functions.
2 Copyright (C) 2005, 2006, 2007 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 ssize_t __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 ssize_t __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 ssize_t
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 #ifdef __USE_ATFILE
104 extern ssize_t __readlinkat_chk (int __fd, __const char *__restrict __path,
105 char *__restrict __buf, size_t __len,
106 size_t __buflen)
107 __THROW __nonnull ((2, 3)) __wur;
108 extern ssize_t __REDIRECT_NTH (__readlinkat_alias,
109 (int __fd, __const char *__restrict __path,
110 char *__restrict __buf, size_t __len),
111 readlinkat)
112 __nonnull ((2, 3)) __wur;
114 __extern_always_inline __nonnull ((2, 3)) __wur ssize_t
115 __NTH (readlinkat (int __fd, __const char *__restrict __path,
116 char *__restrict __buf, size_t __len))
118 if (__bos (__buf) != (size_t) -1
119 && (!__builtin_constant_p (__len) || __len > __bos (__buf)))
120 return __readlinkat_chk (__fd, __path, __buf, __len, __bos (__buf));
121 return __readlinkat_alias (__fd, __path, __buf, __len);
123 #endif
125 extern char *__getcwd_chk (char *__buf, size_t __size, size_t __buflen)
126 __THROW __wur;
127 extern char *__REDIRECT_NTH (__getcwd_alias,
128 (char *__buf, size_t __size), getcwd) __wur;
130 __extern_always_inline __wur char *
131 __NTH (getcwd (char *__buf, size_t __size))
133 if (__bos (__buf) != (size_t) -1
134 && (!__builtin_constant_p (__size) || __size > __bos (__buf)))
135 return __getcwd_chk (__buf, __size, __bos (__buf));
136 return __getcwd_alias (__buf, __size);
139 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
140 extern char *__getwd_chk (char *__buf, size_t buflen)
141 __THROW __nonnull ((1)) __wur;
142 extern char *__REDIRECT_NTH (__getwd_alias, (char *__buf), getwd)
143 __nonnull ((1)) __wur;
145 __extern_always_inline __nonnull ((1)) __attribute_deprecated__ __wur char *
146 __NTH (getwd (char *__buf))
148 if (__bos (__buf) != (size_t) -1)
149 return __getwd_chk (__buf, __bos (__buf));
150 return __getwd_alias (__buf);
152 #endif
154 extern size_t __confstr_chk (int __name, char *__buf, size_t __len,
155 size_t __buflen) __THROW;
156 extern size_t __REDIRECT_NTH (__confstr_alias, (int __name, char *__buf,
157 size_t __len), confstr);
159 __extern_always_inline size_t
160 __NTH (confstr (int __name, char *__buf, size_t __len))
162 if (__bos (__buf) != (size_t) -1
163 && (!__builtin_constant_p (__len) || __bos (__buf) < __len))
164 return __confstr_chk (__name, __buf, __len, __bos (__buf));
165 return __confstr_alias (__name, __buf, __len);
169 extern int __getgroups_chk (int __size, __gid_t __list[], size_t listlen)
170 __THROW __wur;
171 extern int __REDIRECT_NTH (__getgroups_alias, (int __size, __gid_t __list[]),
172 getgroups) __wur;
174 __extern_always_inline int
175 __NTH (getgroups (int __size, __gid_t __list[]))
177 if (__bos (__list) != (size_t) -1
178 && (!__builtin_constant_p (__size)
179 || __size * sizeof (__gid_t) > __bos (__list)))
180 return __getgroups_chk (__size, __list, __bos (__list));
181 return __getgroups_alias (__size, __list);
185 extern int __ttyname_r_chk (int __fd, char *__buf, size_t __buflen,
186 size_t __nreal) __THROW __nonnull ((2));
187 extern int __REDIRECT_NTH (__ttyname_r_alias, (int __fd, char *__buf,
188 size_t __buflen), ttyname_r)
189 __nonnull ((2));
191 __extern_always_inline int
192 __NTH (ttyname_r (int __fd, char *__buf, size_t __buflen))
194 if (__bos (__buf) != (size_t) -1
195 && (!__builtin_constant_p (__buflen) || __buflen > __bos (__buf)))
196 return __ttyname_r_chk (__fd, __buf, __buflen, __bos (__buf));
197 return __ttyname_r_alias (__fd, __buf, __buflen);
201 #if defined __USE_REENTRANT || defined __USE_POSIX199506
202 extern int __getlogin_r_chk (char *__buf, size_t __buflen, size_t __nreal)
203 __nonnull ((1));
204 extern int __REDIRECT (__getlogin_r_alias, (char *__buf, size_t __buflen),
205 getlogin_r) __nonnull ((1));
207 __extern_always_inline int
208 getlogin_r (char *__buf, size_t __buflen)
210 if (__bos (__buf) != (size_t) -1
211 && (!__builtin_constant_p (__buflen) || __buflen > __bos (__buf)))
212 return __getlogin_r_chk (__buf, __buflen, __bos (__buf));
213 return __getlogin_r_alias (__buf, __buflen);
215 #endif
218 #if defined __USE_BSD || defined __USE_UNIX98
219 extern int __gethostname_chk (char *__buf, size_t __buflen, size_t __nreal)
220 __THROW __nonnull ((1));
221 extern int __REDIRECT_NTH (__gethostname_alias, (char *__buf, size_t __buflen),
222 gethostname) __nonnull ((1));
224 __extern_always_inline int
225 __NTH (gethostname (char *__buf, size_t __buflen))
227 if (__bos (__buf) != (size_t) -1
228 && (!__builtin_constant_p (__buflen) || __buflen > __bos (__buf)))
229 return __gethostname_chk (__buf, __buflen, __bos (__buf));
230 return __gethostname_alias (__buf, __buflen);
232 #endif
235 #if defined __USE_BSD || (defined __USE_XOPEN && !defined __USE_UNIX98)
236 extern int __getdomainname_chk (char *__buf, size_t __buflen, size_t __nreal)
237 __THROW __nonnull ((1)) __wur;
238 extern int __REDIRECT_NTH (__getdomainname_alias, (char *__buf,
239 size_t __buflen),
240 getdomainname) __nonnull ((1)) __wur;
242 __extern_always_inline int
243 __NTH (getdomainname (char *__buf, size_t __buflen))
245 if (__bos (__buf) != (size_t) -1
246 && (!__builtin_constant_p (__buflen) || __buflen > __bos (__buf)))
247 return __getdomainname_chk (__buf, __buflen, __bos (__buf));
248 return __getdomainname_alias (__buf, __buflen);
250 #endif