summary refs log tree commit diff
path: root/posix/bits/unistd.h
blob: 6cf95acc0b88941158be84002c6811890b5bea8d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/* Checking macros for unistd functions.
   Copyright (C) 2005 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.  */

#ifndef _UNISTD_H
# error "Never include <bits/unistd.h> directly; use <unistd.h> instead."
#endif

extern ssize_t __read_chk (int __fd, void *__buf, size_t __nbytes,
			   size_t __buflen) __wur;
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
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
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
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

#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K
extern int __readlink_chk (__const char *__restrict __path,
			   char *__restrict __buf, size_t __len,
			   size_t __buflen)
     __THROW __nonnull ((1, 2)) __wur;
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;
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)) __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