Print this page
5187 missing functions in stdlib.h : mkostemp, mkostemps & mkdtemp
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/head/stdlib.h
+++ new/usr/src/head/stdlib.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
24 24 * Copyright (c) 2013 Gary Mills
25 25 *
26 26 * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
27 27 */
28 28
29 29 /* Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved. */
30 30
31 31 /* Copyright (c) 1988 AT&T */
32 32 /* All Rights Reserved */
33 33
34 34 #ifndef _STDLIB_H
35 35 #define _STDLIB_H
36 36
37 37 #include <iso/stdlib_iso.h>
38 38 #include <iso/stdlib_c99.h>
39 39
40 40 #if defined(__EXTENSIONS__) || defined(_XPG4)
41 41 #include <sys/wait.h>
42 42 #endif
43 43
44 44 /*
45 45 * Allow global visibility for symbols defined in
46 46 * C++ "std" namespace in <iso/stdlib_iso.h>.
47 47 */
48 48 #if __cplusplus >= 199711L
49 49 using std::div_t;
50 50 using std::ldiv_t;
51 51 using std::size_t;
52 52 using std::abort;
53 53 using std::abs;
54 54 using std::atexit;
55 55 using std::atof;
56 56 using std::atoi;
57 57 using std::atol;
58 58 using std::bsearch;
59 59 using std::calloc;
60 60 using std::div;
61 61 using std::exit;
62 62 using std::free;
63 63 using std::getenv;
64 64 using std::labs;
65 65 using std::ldiv;
66 66 using std::malloc;
67 67 using std::mblen;
68 68 using std::mbstowcs;
69 69 using std::mbtowc;
70 70 using std::qsort;
71 71 using std::rand;
72 72 using std::realloc;
73 73 using std::srand;
74 74 using std::strtod;
75 75 using std::strtol;
76 76 using std::strtoul;
77 77 using std::system;
78 78 using std::wcstombs;
79 79 using std::wctomb;
80 80 #endif
81 81
82 82 #ifdef __cplusplus
83 83 extern "C" {
84 84 #endif
85 85
86 86 #ifndef _UID_T
↓ open down ↓ |
86 lines elided |
↑ open up ↑ |
87 87 #define _UID_T
88 88 typedef unsigned int uid_t; /* UID type */
89 89 #endif /* !_UID_T */
90 90
91 91 /* large file compilation environment setup */
92 92 #if !defined(_LP64) && _FILE_OFFSET_BITS == 64
93 93
94 94 #ifdef __PRAGMA_REDEFINE_EXTNAME
95 95 #pragma redefine_extname mkstemp mkstemp64
96 96 #pragma redefine_extname mkstemps mkstemps64
97 +#pragma redefine_extname mkostemp mkostemp64
98 +#pragma redefine_extname mkostemps mkostemps64
97 99 #else /* __PRAGMA_REDEFINE_EXTNAME */
98 100 #define mkstemp mkstemp64
99 101 #define mkstemps mkstemps64
102 +#define mkostemp mkostemp64
103 +#define mkostemps mkostemps64
100 104 #endif /* __PRAGMA_REDEFINE_EXTNAME */
101 105
102 106 #endif /* _FILE_OFFSET_BITS == 64 */
103 107
104 108 /* In the LP64 compilation environment, all APIs are already large file */
105 109 #if defined(_LP64) && defined(_LARGEFILE64_SOURCE)
106 110
107 111 #ifdef __PRAGMA_REDEFINE_EXTNAME
108 112 #pragma redefine_extname mkstemp64 mkstemp
109 113 #pragma redefine_extname mkstemps64 mkstemps
114 +#pragma redefine_extname mkostemp64 mkostemp
115 +#pragma redefine_extname mkostemps64 mkostemps
110 116 #else /* __PRAGMA_REDEFINE_EXTNAME */
111 117 #define mkstemp64 mkstemp
112 118 #define mkstemps64 mkstemps
119 +#define mkostemp64 mkostemp
120 +#define mkostemps64 mkostemps
113 121 #endif /* __PRAGMA_REDEFINE_EXTNAME */
114 122
115 123 #endif /* _LP64 && _LARGEFILE64_SOURCE */
116 124
117 125 #if defined(__EXTENSIONS__) || \
118 126 (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
119 127 (_POSIX_C_SOURCE - 0 >= 199506L) || defined(_REENTRANT)
120 128 extern int rand_r(unsigned int *);
121 129 #endif
122 130
123 131 extern void _exithandle(void);
124 132
125 133 #if defined(__EXTENSIONS__) || \
126 134 (!defined(_STRICT_STDC) && !defined(_POSIX_C_SOURCE)) || \
127 135 defined(_XPG4)
128 136 extern double drand48(void);
129 137 extern double erand48(unsigned short *);
130 138 extern long jrand48(unsigned short *);
131 139 extern void lcong48(unsigned short *);
132 140 extern long lrand48(void);
133 141 extern long mrand48(void);
134 142 extern long nrand48(unsigned short *);
135 143 extern unsigned short *seed48(unsigned short *);
136 144 extern void srand48(long);
137 145 extern int putenv(char *);
138 146 extern void setkey(const char *);
139 147 #endif /* defined(__EXTENSIONS__) || !defined(_STRICT_STDC) ... */
140 148
141 149 /*
142 150 * swab() has historically been in <stdlib.h> as delivered from AT&T
143 151 * and continues to be visible in the default compilation environment.
144 152 * As of Issue 4 of the X/Open Portability Guides, swab() was declared
145 153 * in <unistd.h>. As a result, with respect to X/Open namespace the
146 154 * swab() declaration in this header is only visible for the XPG3
147 155 * environment.
148 156 */
149 157 #if (defined(__EXTENSIONS__) || \
150 158 (!defined(_STRICT_STDC__) && !defined(_POSIX_C_SOURCE))) && \
151 159 (!defined(_XOPEN_SOURCE) || (defined(_XPG3) && !defined(_XPG4)))
152 160 #ifndef _SSIZE_T
153 161 #define _SSIZE_T
154 162 #if defined(_LP64) || defined(_I32LPx)
155 163 typedef long ssize_t; /* size of something in bytes or -1 */
156 164 #else
157 165 typedef int ssize_t; /* (historical version) */
158 166 #endif
159 167 #endif /* !_SSIZE_T */
160 168
161 169 extern void swab(const char *, char *, ssize_t);
162 170 #endif /* defined(__EXTENSIONS__) || !defined(_STRICT_STDC) ... */
163 171
164 172 #if defined(__EXTENSIONS__) || \
165 173 !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || \
166 174 (defined(_LARGEFILE_SOURCE) && _FILE_OFFSET_BITS == 64)
167 175 extern int mkstemp(char *);
168 176 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
169 177 extern int mkstemps(char *, int);
↓ open down ↓ |
47 lines elided |
↑ open up ↑ |
170 178 #endif
171 179 #endif /* defined(__EXTENSIONS__) ... */
172 180
173 181 #if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
174 182 !defined(__PRAGMA_REDEFINE_EXTNAME))
175 183 extern int mkstemp64(char *);
176 184 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
177 185 extern int mkstemps64(char *, int);
178 186 #endif
179 187 #endif /* _LARGEFILE64_SOURCE... */
188 +
189 +#if !defined(_STRICT_SYMBOLS) || defined(_XPG7)
190 +extern char *mkdtemp(char *);
191 +#endif /* !defined(_STRICT_SYMBOLS) || defined(_XPG7) */
192 +
193 +#if !defined(_STRICT_SYMBOLS)
194 +extern int mkostemp(char *, int);
195 +extern int mkostemps(char *, int, int);
196 +#if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
197 + !defined(__PRAGMA_REDEFINE_EXTNAME))
198 +extern int mkostemp64(char *, int);
199 +extern int mkostemps64(char *, int, int);
200 +#endif /* defined(_LARGEFILE64_SOURCE) || !((_FILE_OFFSET_BITS == 64) ... */
201 +#endif /* !defined(_STRICT_SYMBOLS) */
180 202
181 203 #if defined(__EXTENSIONS__) || \
182 204 (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
183 205 defined(_XPG4_2)
184 206 extern long a64l(const char *);
185 207 extern char *ecvt(double, int, int *_RESTRICT_KYWD, int *_RESTRICT_KYWD);
186 208 extern char *fcvt(double, int, int *_RESTRICT_KYWD, int *_RESTRICT_KYWD);
187 209 extern char *gcvt(double, int, char *);
188 210 extern int getsubopt(char **, char *const *, char **);
189 211 extern int grantpt(int);
190 212 extern char *initstate(unsigned, char *, size_t);
191 213 extern char *l64a(long);
192 214 extern char *mktemp(char *);
193 215 extern char *ptsname(int);
194 216 extern long random(void);
195 217 extern char *realpath(const char *_RESTRICT_KYWD, char *_RESTRICT_KYWD);
196 218 extern char *setstate(const char *);
197 219 extern void srandom(unsigned);
198 220 extern int unlockpt(int);
199 221 /* Marked LEGACY in SUSv2 and removed in SUSv3 */
200 222 #if !defined(_XPG6) || defined(__EXTENSIONS__)
201 223 extern int ttyslot(void);
202 224 extern void *valloc(size_t);
203 225 #endif /* !defined(_XPG6) || defined(__EXTENSIONS__) */
204 226 #endif /* defined(__EXTENSIONS__) || ... || defined(_XPG4_2) */
205 227
206 228 #if defined(__EXTENSIONS__) || \
207 229 (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
208 230 defined(_XPG6)
209 231 extern int posix_memalign(void **, size_t, size_t);
210 232 extern int posix_openpt(int);
211 233 extern int setenv(const char *, const char *, int);
212 234 extern int unsetenv(const char *);
213 235 #endif
214 236
215 237 #if defined(__EXTENSIONS__) || \
216 238 (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX))
217 239 extern char *canonicalize_file_name(const char *);
218 240 extern int clearenv(void);
219 241 extern void closefrom(int);
220 242 extern int daemon(int, int);
221 243 extern int dup2(int, int);
222 244 extern int dup3(int, int, int);
223 245 extern int fdwalk(int (*)(void *, int), void *);
224 246 extern char *qecvt(long double, int, int *, int *);
225 247 extern char *qfcvt(long double, int, int *, int *);
226 248 extern char *qgcvt(long double, int, char *);
227 249 extern char *getcwd(char *, size_t);
228 250 extern const char *getexecname(void);
229 251
230 252 #ifndef __GETLOGIN_DEFINED /* Avoid duplicate in unistd.h */
231 253 #define __GETLOGIN_DEFINED
232 254 #ifndef __USE_LEGACY_LOGNAME__
233 255 #ifdef __PRAGMA_REDEFINE_EXTNAME
234 256 #pragma redefine_extname getlogin getloginx
235 257 #else /* __PRAGMA_REDEFINE_EXTNAME */
236 258 extern char *getloginx(void);
237 259 #define getlogin getloginx
238 260 #endif /* __PRAGMA_REDEFINE_EXTNAME */
239 261 #endif /* __USE_LEGACY_LOGNAME__ */
240 262 extern char *getlogin(void);
241 263 #endif /* __GETLOGIN_DEFINED */
242 264
243 265 extern int getopt(int, char *const *, const char *);
244 266 extern char *optarg;
245 267 extern int optind, opterr, optopt;
246 268 extern char *getpass(const char *);
247 269 extern char *getpassphrase(const char *);
248 270 extern int getpw(uid_t, char *);
249 271 extern int isatty(int);
250 272 extern void *memalign(size_t, size_t);
251 273 extern char *ttyname(int);
252 274 extern char *mkdtemp(char *);
253 275 extern const char *getprogname(void);
254 276 extern void setprogname(const char *);
255 277
256 278 #if !defined(_STRICT_STDC) && defined(_LONGLONG_TYPE)
257 279 extern char *lltostr(long long, char *);
258 280 extern char *ulltostr(unsigned long long, char *);
259 281 #endif /* !defined(_STRICT_STDC) && defined(_LONGLONG_TYPE) */
260 282
261 283 #endif /* defined(__EXTENSIONS__) || !defined(_STRICT_STDC) ... */
262 284
263 285 /* OpenBSD compatibility functions */
264 286 #if !defined(_STRICT_SYMBOLS)
265 287
266 288 #include <inttypes.h>
267 289 extern uint32_t arc4random(void);
268 290 extern void arc4random_buf(void *, size_t);
269 291 extern uint32_t arc4random_uniform(uint32_t);
270 292
271 293 #endif /* !_STRICT_SYBMOLS */
272 294
273 295
274 296 #ifdef __cplusplus
275 297 }
276 298 #endif
277 299
278 300 #endif /* _STDLIB_H */
↓ open down ↓ |
89 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX