line |
stmt |
bran |
cond |
sub |
time |
code |
1
|
|
|
|
|
|
/* Checking macros for stdlib functions. |
2
|
|
|
|
|
|
Copyright (C) 2005, 2007 Free Software Foundation, Inc. |
3
|
|
|
|
|
|
This file is part of the GNU C Library. |
4
|
|
|
|
|
|
|
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. |
9
|
|
|
|
|
|
|
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. |
14
|
|
|
|
|
|
|
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. */ |
19
|
|
|
|
|
|
|
20
|
|
|
|
|
|
#ifndef _STDLIB_H |
21
|
|
|
|
|
|
# error "Never include directly; use instead." |
22
|
|
|
|
|
|
#endif |
23
|
|
|
|
|
|
|
24
|
|
|
|
|
|
extern char *__realpath_chk (__const char *__restrict __name, |
25
|
|
|
|
|
|
char *__restrict __resolved, |
26
|
|
|
|
|
|
size_t __resolvedlen) __THROW __wur; |
27
|
|
|
|
|
|
extern char *__REDIRECT_NTH (__realpath_alias, |
28
|
|
|
|
|
|
(__const char *__restrict __name, |
29
|
|
|
|
|
|
char *__restrict __resolved), realpath) __wur; |
30
|
|
|
|
|
|
extern char *__REDIRECT_NTH (__realpath_chk_warn, |
31
|
|
|
|
|
|
(__const char *__restrict __name, |
32
|
|
|
|
|
|
char *__restrict __resolved, |
33
|
|
|
|
|
|
size_t __resolvedlen), __realpath_chk) __wur |
34
|
|
|
|
|
|
__warnattr ("second argument of realpath must be either NULL or at " |
35
|
|
|
|
|
|
"least PATH_MAX bytes long buffer"); |
36
|
|
|
|
|
|
|
37
|
|
|
|
|
|
__extern_always_inline __wur char * |
38
|
|
|
|
|
|
__NTH (realpath (__const char *__restrict __name, char *__restrict __resolved)) |
39
|
|
|
|
|
|
{ |
40
|
|
|
|
|
|
if (__bos (__resolved) != (size_t) -1) |
41
|
|
|
|
|
|
{ |
42
|
|
|
|
|
|
#if defined _LIBC_LIMITS_H_ && defined PATH_MAX |
43
|
|
|
|
|
|
if (__bos (__resolved) < PATH_MAX) |
44
|
|
|
|
|
|
return __realpath_chk_warn (__name, __resolved, __bos (__resolved)); |
45
|
|
|
|
|
|
#endif |
46
|
|
|
|
|
|
return __realpath_chk (__name, __resolved, __bos (__resolved)); |
47
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
49
|
|
|
|
|
|
return __realpath_alias (__name, __resolved); |
50
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
53
|
|
|
|
|
|
extern int __ptsname_r_chk (int __fd, char *__buf, size_t __buflen, |
54
|
|
|
|
|
|
size_t __nreal) __THROW __nonnull ((2)); |
55
|
|
|
|
|
|
extern int __REDIRECT_NTH (__ptsname_r_alias, (int __fd, char *__buf, |
56
|
|
|
|
|
|
size_t __buflen), ptsname_r) |
57
|
|
|
|
|
|
__nonnull ((2)); |
58
|
|
|
|
|
|
extern int __REDIRECT_NTH (__ptsname_r_chk_warn, |
59
|
|
|
|
|
|
(int __fd, char *__buf, size_t __buflen, |
60
|
|
|
|
|
|
size_t __nreal), __ptsname_r_chk) |
61
|
|
|
|
|
|
__nonnull ((2)) __warnattr ("ptsname_r called with buflen bigger than " |
62
|
|
|
|
|
|
"size of buf"); |
63
|
|
|
|
|
|
|
64
|
|
|
|
|
|
__extern_always_inline int |
65
|
|
|
|
|
|
__NTH (ptsname_r (int __fd, char *__buf, size_t __buflen)) |
66
|
|
|
|
|
|
{ |
67
|
|
|
|
|
|
if (__bos (__buf) != (size_t) -1) |
68
|
|
|
|
|
|
{ |
69
|
|
|
|
|
|
if (!__builtin_constant_p (__buflen)) |
70
|
|
|
|
|
|
return __ptsname_r_chk (__fd, __buf, __buflen, __bos (__buf)); |
71
|
|
|
|
|
|
if (__buflen > __bos (__buf)) |
72
|
|
|
|
|
|
return __ptsname_r_chk_warn (__fd, __buf, __buflen, __bos (__buf)); |
73
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
return __ptsname_r_alias (__fd, __buf, __buflen); |
75
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
78
|
|
|
|
|
|
extern int __wctomb_chk (char *__s, wchar_t __wchar, size_t __buflen) |
79
|
|
|
|
|
|
__THROW __wur; |
80
|
|
|
|
|
|
extern int __REDIRECT_NTH (__wctomb_alias, (char *__s, wchar_t __wchar), |
81
|
|
|
|
|
|
wctomb) __wur; |
82
|
|
|
|
|
|
|
83
|
|
|
|
|
|
__extern_always_inline __wur int |
84
|
|
|
|
|
|
__NTH (wctomb (char *__s, wchar_t __wchar)) |
85
|
|
|
|
|
|
{ |
86
|
|
|
|
|
|
/* We would have to include to get a definition of MB_LEN_MAX. |
87
|
|
|
|
|
|
But this would only disturb the namespace. So we define our own |
88
|
|
|
|
|
|
version here. */ |
89
|
|
|
|
|
|
#define __STDLIB_MB_LEN_MAX 16 |
90
|
|
|
|
|
|
#if defined MB_LEN_MAX && MB_LEN_MAX != __STDLIB_MB_LEN_MAX |
91
|
|
|
|
|
|
# error "Assumed value of MB_LEN_MAX wrong" |
92
|
|
|
|
|
|
#endif |
93
|
0
|
|
|
|
|
if (__bos (__s) != (size_t) -1 && __STDLIB_MB_LEN_MAX > __bos (__s)) |
94
|
0
|
|
|
|
|
return __wctomb_chk (__s, __wchar, __bos (__s)); |
95
|
0
|
|
|
|
|
return __wctomb_alias (__s, __wchar); |
96
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
99
|
|
|
|
|
|
extern size_t __mbstowcs_chk (wchar_t *__restrict __dst, |
100
|
|
|
|
|
|
__const char *__restrict __src, |
101
|
|
|
|
|
|
size_t __len, size_t __dstlen) __THROW; |
102
|
|
|
|
|
|
extern size_t __REDIRECT_NTH (__mbstowcs_alias, |
103
|
|
|
|
|
|
(wchar_t *__restrict __dst, |
104
|
|
|
|
|
|
__const char *__restrict __src, |
105
|
|
|
|
|
|
size_t __len), mbstowcs); |
106
|
|
|
|
|
|
extern size_t __REDIRECT_NTH (__mbstowcs_chk_warn, |
107
|
|
|
|
|
|
(wchar_t *__restrict __dst, |
108
|
|
|
|
|
|
__const char *__restrict __src, |
109
|
|
|
|
|
|
size_t __len, size_t __dstlen), __mbstowcs_chk) |
110
|
|
|
|
|
|
__warnattr ("mbstowcs called with dst buffer smaller than len " |
111
|
|
|
|
|
|
"* sizeof (wchar_t)"); |
112
|
|
|
|
|
|
|
113
|
|
|
|
|
|
__extern_always_inline size_t |
114
|
|
|
|
|
|
__NTH (mbstowcs (wchar_t *__restrict __dst, __const char *__restrict __src, |
115
|
|
|
|
|
|
size_t __len)) |
116
|
|
|
|
|
|
{ |
117
|
0
|
|
|
|
|
if (__bos (__dst) != (size_t) -1) |
118
|
|
|
|
|
|
{ |
119
|
0
|
|
|
|
|
if (!__builtin_constant_p (__len)) |
120
|
0
|
|
|
|
|
return __mbstowcs_chk (__dst, __src, __len, |
121
|
0
|
|
|
|
|
__bos (__dst) / sizeof (wchar_t)); |
122
|
|
|
|
|
|
|
123
|
0
|
|
|
|
|
if (__len > __bos (__dst) / sizeof (wchar_t)) |
124
|
0
|
|
|
|
|
return __mbstowcs_chk_warn (__dst, __src, __len, |
125
|
0
|
|
|
|
|
__bos (__dst) / sizeof (wchar_t)); |
126
|
|
|
|
|
|
} |
127
|
0
|
|
|
|
|
return __mbstowcs_alias (__dst, __src, __len); |
128
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
131
|
|
|
|
|
|
extern size_t __wcstombs_chk (char *__restrict __dst, |
132
|
|
|
|
|
|
__const wchar_t *__restrict __src, |
133
|
|
|
|
|
|
size_t __len, size_t __dstlen) __THROW; |
134
|
|
|
|
|
|
extern size_t __REDIRECT_NTH (__wcstombs_alias, |
135
|
|
|
|
|
|
(char *__restrict __dst, |
136
|
|
|
|
|
|
__const wchar_t *__restrict __src, |
137
|
|
|
|
|
|
size_t __len), wcstombs); |
138
|
|
|
|
|
|
extern size_t __REDIRECT_NTH (__wcstombs_chk_warn, |
139
|
|
|
|
|
|
(char *__restrict __dst, |
140
|
|
|
|
|
|
__const wchar_t *__restrict __src, |
141
|
|
|
|
|
|
size_t __len, size_t __dstlen), __wcstombs_chk) |
142
|
|
|
|
|
|
__warnattr ("wcstombs called with dst buffer smaller than len"); |
143
|
|
|
|
|
|
|
144
|
|
|
|
|
|
__extern_always_inline size_t |
145
|
|
|
|
|
|
__NTH (wcstombs (char *__restrict __dst, __const wchar_t *__restrict __src, |
146
|
|
|
|
|
|
size_t __len)) |
147
|
|
|
|
|
|
{ |
148
|
0
|
|
|
|
|
if (__bos (__dst) != (size_t) -1) |
149
|
|
|
|
|
|
{ |
150
|
0
|
|
|
|
|
if (!__builtin_constant_p (__len)) |
151
|
0
|
|
|
|
|
return __wcstombs_chk (__dst, __src, __len, __bos (__dst)); |
152
|
0
|
|
|
|
|
if (__len > __bos (__dst)) |
153
|
0
|
|
|
|
|
return __wcstombs_chk_warn (__dst, __src, __len, __bos (__dst)); |
154
|
|
|
|
|
|
} |
155
|
0
|
|
|
|
|
return __wcstombs_alias (__dst, __src, __len); |
156
|
|
|
|
|
|
} |