getopt32: factor out code to treat all args as options
[oweals/busybox.git] / include / platform.h
1 /* vi: set sw=4 ts=4: */
2 /*
3  * Copyright 2006, Bernhard Reutner-Fischer
4  *
5  * Licensed under GPLv2 or later, see file LICENSE in this source tree.
6  */
7 #ifndef BB_PLATFORM_H
8 #define BB_PLATFORM_H 1
9
10
11 /* Convenience macros to test the version of gcc. */
12 #undef __GNUC_PREREQ
13 #if defined __GNUC__ && defined __GNUC_MINOR__
14 # define __GNUC_PREREQ(maj, min) \
15                 ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
16 #else
17 # define __GNUC_PREREQ(maj, min) 0
18 #endif
19
20 /* __restrict is known in EGCS 1.2 and above. */
21 #if !__GNUC_PREREQ(2,92)
22 # ifndef __restrict
23 #  define __restrict
24 # endif
25 #endif
26
27 #if !__GNUC_PREREQ(2,7)
28 # ifndef __attribute__
29 #  define __attribute__(x)
30 # endif
31 #endif
32
33 #undef inline
34 #if defined(__STDC_VERSION__) && __STDC_VERSION__ > 199901L
35 /* it's a keyword */
36 #elif __GNUC_PREREQ(2,7)
37 # define inline __inline__
38 #else
39 # define inline
40 #endif
41
42 #ifndef __const
43 # define __const const
44 #endif
45
46 #define UNUSED_PARAM __attribute__ ((__unused__))
47 #define NORETURN __attribute__ ((__noreturn__))
48
49 #if __GNUC_PREREQ(4,5)
50 # define bb_unreachable(altcode) __builtin_unreachable()
51 #else
52 # define bb_unreachable(altcode) altcode
53 #endif
54
55 /* "The malloc attribute is used to tell the compiler that a function
56  * may be treated as if any non-NULL pointer it returns cannot alias
57  * any other pointer valid when the function returns. This will often
58  * improve optimization. Standard functions with this property include
59  * malloc and calloc. realloc-like functions have this property as long
60  * as the old pointer is never referred to (including comparing it
61  * to the new pointer) after the function returns a non-NULL value."
62  */
63 #define RETURNS_MALLOC __attribute__ ((malloc))
64 #define PACKED __attribute__ ((__packed__))
65 #define ALIGNED(m) __attribute__ ((__aligned__(m)))
66
67 /* __NO_INLINE__: some gcc's do not honor inlining! :( */
68 #if __GNUC_PREREQ(3,0) && !defined(__NO_INLINE__)
69 # define ALWAYS_INLINE __attribute__ ((always_inline)) inline
70 /* I've seen a toolchain where I needed __noinline__ instead of noinline */
71 # define NOINLINE      __attribute__((__noinline__))
72 # if !ENABLE_WERROR
73 #  define DEPRECATED __attribute__ ((__deprecated__))
74 #  define UNUSED_PARAM_RESULT __attribute__ ((warn_unused_result))
75 # else
76 #  define DEPRECATED
77 #  define UNUSED_PARAM_RESULT
78 # endif
79 #else
80 # define ALWAYS_INLINE inline
81 # define NOINLINE
82 # define DEPRECATED
83 # define UNUSED_PARAM_RESULT
84 #endif
85
86 /* used by unit test machinery to run registration functions before calling main() */
87 #define INIT_FUNC __attribute__ ((constructor))
88
89 /* -fwhole-program makes all symbols local. The attribute externally_visible
90  * forces a symbol global.  */
91 #if __GNUC_PREREQ(4,1)
92 # define EXTERNALLY_VISIBLE __attribute__(( visibility("default") ))
93 //__attribute__ ((__externally_visible__))
94 #else
95 # define EXTERNALLY_VISIBLE
96 #endif
97
98 /* At 4.4 gcc become much more anal about this, need to use "aliased" types */
99 #if __GNUC_PREREQ(4,4)
100 # define FIX_ALIASING __attribute__((__may_alias__))
101 #else
102 # define FIX_ALIASING
103 #endif
104
105 /* We use __extension__ in some places to suppress -pedantic warnings
106  * about GCC extensions.  This feature didn't work properly before
107  * gcc 2.8.  */
108 #if !__GNUC_PREREQ(2,8)
109 # ifndef __extension__
110 #  define __extension__
111 # endif
112 #endif
113
114 /* FAST_FUNC is a qualifier which (possibly) makes function call faster
115  * and/or smaller by using modified ABI. It is usually only needed
116  * on non-static, busybox internal functions. Recent versions of gcc
117  * optimize statics automatically. FAST_FUNC on static is required
118  * only if you need to match a function pointer's type.
119  * FAST_FUNC may not work well with -flto so allow user to disable this.
120  * (-DFAST_FUNC= )
121  */
122 #ifndef FAST_FUNC
123 # if __GNUC_PREREQ(3,0) && defined(i386)
124 /* stdcall makes callee to pop arguments from stack, not caller */
125 #  define FAST_FUNC __attribute__((regparm(3),stdcall))
126 /* #elif ... - add your favorite arch today! */
127 # else
128 #  define FAST_FUNC
129 # endif
130 #endif
131
132 /* Make all declarations hidden (-fvisibility flag only affects definitions) */
133 /* (don't include system headers after this until corresponding pop!) */
134 #if __GNUC_PREREQ(4,1) && !defined(__CYGWIN__)
135 # define PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN _Pragma("GCC visibility push(hidden)")
136 # define POP_SAVED_FUNCTION_VISIBILITY              _Pragma("GCC visibility pop")
137 #else
138 # define PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN
139 # define POP_SAVED_FUNCTION_VISIBILITY
140 #endif
141
142 /* gcc-2.95 had no va_copy but only __va_copy. */
143 #if !__GNUC_PREREQ(3,0)
144 # include <stdarg.h>
145 # if !defined va_copy && defined __va_copy
146 #  define va_copy(d,s) __va_copy((d),(s))
147 # endif
148 #endif
149
150
151 /* ---- Endian Detection ------------------------------------ */
152
153 #include <limits.h>
154 #if defined(__digital__) && defined(__unix__)
155 # include <sex.h>
156 #elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) \
157    || defined(__APPLE__)
158 # include <sys/resource.h>  /* rlimit */
159 # include <machine/endian.h>
160 # define bswap_64 __bswap64
161 # define bswap_32 __bswap32
162 # define bswap_16 __bswap16
163 #else
164 # include <byteswap.h>
165 # include <endian.h>
166 #endif
167
168 #if defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN
169 # define BB_BIG_ENDIAN 1
170 # define BB_LITTLE_ENDIAN 0
171 #elif defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN
172 # define BB_BIG_ENDIAN 0
173 # define BB_LITTLE_ENDIAN 1
174 #elif defined(_BYTE_ORDER) && _BYTE_ORDER == _BIG_ENDIAN
175 # define BB_BIG_ENDIAN 1
176 # define BB_LITTLE_ENDIAN 0
177 #elif defined(_BYTE_ORDER) && _BYTE_ORDER == _LITTLE_ENDIAN
178 # define BB_BIG_ENDIAN 0
179 # define BB_LITTLE_ENDIAN 1
180 #elif defined(BYTE_ORDER) && BYTE_ORDER == BIG_ENDIAN
181 # define BB_BIG_ENDIAN 1
182 # define BB_LITTLE_ENDIAN 0
183 #elif defined(BYTE_ORDER) && BYTE_ORDER == LITTLE_ENDIAN
184 # define BB_BIG_ENDIAN 0
185 # define BB_LITTLE_ENDIAN 1
186 #elif defined(__386__)
187 # define BB_BIG_ENDIAN 0
188 # define BB_LITTLE_ENDIAN 1
189 #else
190 # error "Can't determine endianness"
191 #endif
192
193 #if ULONG_MAX > 0xffffffff
194 # define bb_bswap_64(x) bswap_64(x)
195 #endif
196
197 /* SWAP_LEnn means "convert CPU<->little_endian by swapping bytes" */
198 #if BB_BIG_ENDIAN
199 # define SWAP_BE16(x) (x)
200 # define SWAP_BE32(x) (x)
201 # define SWAP_BE64(x) (x)
202 # define SWAP_LE16(x) bswap_16(x)
203 # define SWAP_LE32(x) bswap_32(x)
204 # define SWAP_LE64(x) bb_bswap_64(x)
205 # define IF_BIG_ENDIAN(...) __VA_ARGS__
206 # define IF_LITTLE_ENDIAN(...)
207 #else
208 # define SWAP_BE16(x) bswap_16(x)
209 # define SWAP_BE32(x) bswap_32(x)
210 # define SWAP_BE64(x) bb_bswap_64(x)
211 # define SWAP_LE16(x) (x)
212 # define SWAP_LE32(x) (x)
213 # define SWAP_LE64(x) (x)
214 # define IF_BIG_ENDIAN(...)
215 # define IF_LITTLE_ENDIAN(...) __VA_ARGS__
216 #endif
217
218
219 /* ---- Unaligned access ------------------------------------ */
220
221 #include <stdint.h>
222 typedef int      bb__aliased_int      FIX_ALIASING;
223 typedef long     bb__aliased_long     FIX_ALIASING;
224 typedef uint16_t bb__aliased_uint16_t FIX_ALIASING;
225 typedef uint32_t bb__aliased_uint32_t FIX_ALIASING;
226 typedef uint64_t bb__aliased_uint64_t FIX_ALIASING;
227
228 /* NB: unaligned parameter should be a pointer, aligned one -
229  * a lvalue. This makes it more likely to not swap them by mistake
230  */
231 #if defined(i386) || defined(__x86_64__) || defined(__powerpc__)
232 # define BB_UNALIGNED_MEMACCESS_OK 1
233 # define move_from_unaligned_int(v, intp)  ((v) = *(bb__aliased_int*)(intp))
234 # define move_from_unaligned_long(v, longp) ((v) = *(bb__aliased_long*)(longp))
235 # define move_from_unaligned16(v, u16p) ((v) = *(bb__aliased_uint16_t*)(u16p))
236 # define move_from_unaligned32(v, u32p) ((v) = *(bb__aliased_uint32_t*)(u32p))
237 # define move_to_unaligned16(u16p, v)   (*(bb__aliased_uint16_t*)(u16p) = (v))
238 # define move_to_unaligned32(u32p, v)   (*(bb__aliased_uint32_t*)(u32p) = (v))
239 /* #elif ... - add your favorite arch today! */
240 #else
241 # define BB_UNALIGNED_MEMACCESS_OK 0
242 /* performs reasonably well (gcc usually inlines memcpy here) */
243 # define move_from_unaligned_int(v, intp) (memcpy(&(v), (intp), sizeof(int)))
244 # define move_from_unaligned_long(v, longp) (memcpy(&(v), (longp), sizeof(long)))
245 # define move_from_unaligned16(v, u16p) (memcpy(&(v), (u16p), 2))
246 # define move_from_unaligned32(v, u32p) (memcpy(&(v), (u32p), 4))
247 # define move_to_unaligned16(u16p, v) do { \
248         uint16_t __t = (v); \
249         memcpy((u16p), &__t, 2); \
250 } while (0)
251 # define move_to_unaligned32(u32p, v) do { \
252         uint32_t __t = (v); \
253         memcpy((u32p), &__t, 4); \
254 } while (0)
255 #endif
256
257 /* Unaligned, fixed-endian accessors */
258 #define get_unaligned_le32(buf) ({ uint32_t v; move_from_unaligned32(v, buf); SWAP_LE32(v); })
259 #define get_unaligned_be32(buf) ({ uint32_t v; move_from_unaligned32(v, buf); SWAP_BE32(v); })
260 #define put_unaligned_le32(val, buf) move_to_unaligned32(buf, SWAP_LE32(val))
261 #define put_unaligned_be32(val, buf) move_to_unaligned32(buf, SWAP_BE32(val))
262
263
264 /* ---- Size-saving "small" ints (arch-dependent) ----------- */
265
266 #if defined(i386) || defined(__x86_64__) || defined(__mips__) || defined(__cris__)
267 /* add other arches which benefit from this... */
268 typedef signed char smallint;
269 typedef unsigned char smalluint;
270 #else
271 /* for arches where byte accesses generate larger code: */
272 typedef int smallint;
273 typedef unsigned smalluint;
274 #endif
275
276 /* ISO C Standard:  7.16  Boolean type and values  <stdbool.h> */
277 #if (defined __digital__ && defined __unix__)
278 /* old system without (proper) C99 support */
279 # define bool smalluint
280 #else
281 /* modern system, so use it */
282 # include <stdbool.h>
283 #endif
284
285
286 /*----- Kernel versioning ------------------------------------*/
287
288 #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
289
290 #ifdef __UCLIBC__
291 # define UCLIBC_VERSION KERNEL_VERSION(__UCLIBC_MAJOR__, __UCLIBC_MINOR__, __UCLIBC_SUBLEVEL__)
292 #else
293 # define UCLIBC_VERSION 0
294 #endif
295
296
297 /* ---- Miscellaneous --------------------------------------- */
298
299 #if defined __GLIBC__ \
300  || defined __UCLIBC__ \
301  || defined __dietlibc__ \
302  || defined __BIONIC__ \
303  || defined _NEWLIB_VERSION
304 # include <features.h>
305 #endif
306
307 /* Define bb_setpgrp */
308 #if defined(__digital__) && defined(__unix__)
309 /* use legacy setpgrp(pid_t, pid_t) for now.  move to platform.c */
310 # define bb_setpgrp() do { pid_t __me = getpid(); setpgrp(__me, __me); } while (0)
311 #else
312 # define bb_setpgrp() setpgrp()
313 #endif
314
315 /* fdprintf is more readable, we used it before dprintf was standardized */
316 #include <unistd.h>
317 #define fdprintf dprintf
318
319 /* Useful for defeating gcc's alignment of "char message[]"-like data */
320 #if !defined(__s390__)
321     /* on s390[x], non-word-aligned data accesses require larger code */
322 # define ALIGN1 __attribute__((aligned(1)))
323 # define ALIGN2 __attribute__((aligned(2)))
324 # define ALIGN4 __attribute__((aligned(4)))
325 #else
326 /* Arches which MUST have 2 or 4 byte alignment for everything are here */
327 # define ALIGN1
328 # define ALIGN2
329 # define ALIGN4
330 #endif
331
332 /*
333  * For 0.9.29 and svn, __ARCH_USE_MMU__ indicates no-mmu reliably.
334  * For earlier versions there is no reliable way to check if we are building
335  * for a mmu-less system.
336  */
337 #if ENABLE_NOMMU || \
338     (defined __UCLIBC__ && \
339      UCLIBC_VERSION > KERNEL_VERSION(0, 9, 28) && \
340      !defined __ARCH_USE_MMU__)
341 # define BB_MMU 0
342 # define USE_FOR_NOMMU(...) __VA_ARGS__
343 # define USE_FOR_MMU(...)
344 #else
345 # define BB_MMU 1
346 # define USE_FOR_NOMMU(...)
347 # define USE_FOR_MMU(...) __VA_ARGS__
348 #endif
349
350 #if defined(__digital__) && defined(__unix__)
351 # include <standards.h>
352 # include <inttypes.h>
353 # define PRIu32 "u"
354 # if !defined ADJ_OFFSET_SINGLESHOT && defined MOD_CLKA && defined MOD_OFFSET
355 #  define ADJ_OFFSET_SINGLESHOT (MOD_CLKA | MOD_OFFSET)
356 # endif
357 # if !defined ADJ_FREQUENCY && defined MOD_FREQUENCY
358 #  define ADJ_FREQUENCY MOD_FREQUENCY
359 # endif
360 # if !defined ADJ_TIMECONST && defined MOD_TIMECONST
361 #  define ADJ_TIMECONST MOD_TIMECONST
362 # endif
363 # if !defined ADJ_TICK && defined MOD_CLKB
364 #  define ADJ_TICK MOD_CLKB
365 # endif
366 #endif
367
368 #if defined(__CYGWIN__)
369 # define MAXSYMLINKS SYMLOOP_MAX
370 #endif
371
372 #if defined(ANDROID) || defined(__ANDROID__)
373 # define BB_ADDITIONAL_PATH ":/system/sbin:/system/bin:/system/xbin"
374 # define SYS_ioprio_set __NR_ioprio_set
375 # define SYS_ioprio_get __NR_ioprio_get
376 #endif
377
378
379 /* ---- Who misses what? ------------------------------------ */
380
381 /* Assume all these functions and header files exist by default.
382  * Platforms where it is not true will #undef them below.
383  */
384 #define HAVE_CLEARENV 1
385 #define HAVE_FDATASYNC 1
386 #define HAVE_DPRINTF 1
387 #define HAVE_MEMRCHR 1
388 #define HAVE_MKDTEMP 1
389 #define HAVE_TTYNAME_R 1
390 #define HAVE_PTSNAME_R 1
391 #define HAVE_SETBIT 1
392 #define HAVE_SIGHANDLER_T 1
393 #define HAVE_STPCPY 1
394 #define HAVE_MEMPCPY 1
395 #define HAVE_STRCASESTR 1
396 #define HAVE_STRCHRNUL 1
397 #define HAVE_STRSEP 1
398 #define HAVE_STRSIGNAL 1
399 #define HAVE_STRVERSCMP 1
400 #define HAVE_VASPRINTF 1
401 #define HAVE_USLEEP 1
402 #define HAVE_UNLOCKED_STDIO 1
403 #define HAVE_UNLOCKED_LINE_OPS 1
404 #define HAVE_GETLINE 1
405 #define HAVE_XTABS 1
406 #define HAVE_MNTENT_H 1
407 #define HAVE_NET_ETHERNET_H 1
408 #define HAVE_SYS_STATFS_H 1
409 #define HAVE_PRINTF_PERCENTM 1
410
411 #if defined(__UCLIBC__)
412 # if UCLIBC_VERSION < KERNEL_VERSION(0, 9, 32)
413 #  undef HAVE_STRVERSCMP
414 # endif
415 # if UCLIBC_VERSION >= KERNEL_VERSION(0, 9, 30)
416 #  ifndef __UCLIBC_SUSV3_LEGACY__
417 #   undef HAVE_USLEEP
418 #  endif
419 # endif
420 #endif
421
422 #if defined(__WATCOMC__)
423 # undef HAVE_DPRINTF
424 # undef HAVE_GETLINE
425 # undef HAVE_MEMRCHR
426 # undef HAVE_MKDTEMP
427 # undef HAVE_SETBIT
428 # undef HAVE_STPCPY
429 # undef HAVE_STRCASESTR
430 # undef HAVE_STRCHRNUL
431 # undef HAVE_STRSEP
432 # undef HAVE_STRSIGNAL
433 # undef HAVE_STRVERSCMP
434 # undef HAVE_VASPRINTF
435 # undef HAVE_UNLOCKED_STDIO
436 # undef HAVE_UNLOCKED_LINE_OPS
437 # undef HAVE_NET_ETHERNET_H
438 #endif
439
440 #if defined(__CYGWIN__)
441 # undef HAVE_CLEARENV
442 # undef HAVE_FDPRINTF
443 # undef HAVE_MEMRCHR
444 # undef HAVE_PTSNAME_R
445 # undef HAVE_STRVERSCMP
446 # undef HAVE_UNLOCKED_LINE_OPS
447 #endif
448
449 /* These BSD-derived OSes share many similarities */
450 #if (defined __digital__ && defined __unix__) \
451  || defined __APPLE__ \
452  || defined __OpenBSD__ || defined __NetBSD__
453 # undef HAVE_CLEARENV
454 # undef HAVE_FDATASYNC
455 # undef HAVE_GETLINE
456 # undef HAVE_MNTENT_H
457 # undef HAVE_PTSNAME_R
458 # undef HAVE_SYS_STATFS_H
459 # undef HAVE_SIGHANDLER_T
460 # undef HAVE_STRVERSCMP
461 # undef HAVE_XTABS
462 # undef HAVE_DPRINTF
463 # undef HAVE_UNLOCKED_STDIO
464 # undef HAVE_UNLOCKED_LINE_OPS
465 # undef HAVE_PRINTF_PERCENTM
466 #endif
467
468 #if defined(__dietlibc__)
469 # undef HAVE_STRCHRNUL
470 #endif
471
472 #if defined(__APPLE__)
473 # undef HAVE_STRCHRNUL
474 #endif
475
476 #if defined(__FreeBSD__)
477 /* users say mempcpy is not present in FreeBSD 9.x */
478 # undef HAVE_MEMPCPY
479 # undef HAVE_CLEARENV
480 # undef HAVE_FDATASYNC
481 # undef HAVE_MNTENT_H
482 # undef HAVE_PTSNAME_R
483 # undef HAVE_SYS_STATFS_H
484 # undef HAVE_SIGHANDLER_T
485 # undef HAVE_STRVERSCMP
486 # undef HAVE_XTABS
487 # undef HAVE_UNLOCKED_LINE_OPS
488 # undef HAVE_PRINTF_PERCENTM
489 # include <osreldate.h>
490 # if __FreeBSD_version < 1000029
491 #  undef HAVE_STRCHRNUL /* FreeBSD added strchrnul() between 1000028 and 1000029 */
492 # endif
493 #endif
494
495 #if defined(__NetBSD__)
496 # define HAVE_GETLINE 1  /* Recent NetBSD versions have getline() */
497 #endif
498
499 #if defined(__digital__) && defined(__unix__)
500 # undef HAVE_STPCPY
501 #endif
502
503 #if defined(ANDROID) || defined(__ANDROID__)
504 # if __ANDROID_API__ < 8
505    /* ANDROID < 8 has no [f]dprintf at all */
506 #  undef HAVE_DPRINTF
507 # elif __ANDROID_API__ < 21
508    /* ANDROID < 21 has fdprintf */
509 #  define dprintf fdprintf
510 # else
511    /* ANDROID >= 21 has standard dprintf */
512 # endif
513 # if __ANDROID_API__ < 21
514 #  undef HAVE_TTYNAME_R
515 #  undef HAVE_GETLINE
516 #  undef HAVE_STPCPY
517 # endif
518 # undef HAVE_MEMPCPY
519 # undef HAVE_STRCHRNUL
520 # undef HAVE_STRVERSCMP
521 # undef HAVE_UNLOCKED_LINE_OPS
522 # undef HAVE_NET_ETHERNET_H
523 # undef HAVE_PRINTF_PERCENTM
524 #endif
525
526 /*
527  * Now, define prototypes for all the functions defined in platform.c
528  * These must come after all the HAVE_* macros are defined (or not)
529  */
530
531 #ifndef HAVE_DPRINTF
532 extern int dprintf(int fd, const char *format, ...);
533 #endif
534
535 #ifndef HAVE_MEMRCHR
536 extern void *memrchr(const void *s, int c, size_t n) FAST_FUNC;
537 #endif
538
539 #ifndef HAVE_MKDTEMP
540 extern char *mkdtemp(char *template) FAST_FUNC;
541 #endif
542
543 #ifndef HAVE_TTYNAME_R
544 #define ttyname_r bb_ttyname_r
545 extern int ttyname_r(int fd, char *buf, size_t buflen);
546 #endif
547
548 #ifndef HAVE_SETBIT
549 # define setbit(a, b)  ((a)[(b) >> 3] |= 1 << ((b) & 7))
550 # define clrbit(a, b)  ((a)[(b) >> 3] &= ~(1 << ((b) & 7)))
551 #endif
552
553 #ifndef HAVE_SIGHANDLER_T
554 typedef void (*sighandler_t)(int);
555 #endif
556
557 #ifndef HAVE_STPCPY
558 extern char *stpcpy(char *p, const char *to_add) FAST_FUNC;
559 #endif
560
561 #ifndef HAVE_MEMPCPY
562 #include <string.h>
563 /* In case we are wrong about !HAVE_MEMPCPY, and toolchain _does_ have
564  * mempcpy(), avoid colliding with it:
565  */
566 #define mempcpy bb__mempcpy
567 static ALWAYS_INLINE void *mempcpy(void *dest, const void *src, size_t len)
568 {
569         return memcpy(dest, src, len) + len;
570 }
571 #endif
572
573 #ifndef HAVE_STRCASESTR
574 extern char *strcasestr(const char *s, const char *pattern) FAST_FUNC;
575 #endif
576
577 #ifndef HAVE_STRCHRNUL
578 extern char *strchrnul(const char *s, int c) FAST_FUNC;
579 #endif
580
581 #ifndef HAVE_STRSEP
582 extern char *strsep(char **stringp, const char *delim) FAST_FUNC;
583 #endif
584
585 #ifndef HAVE_STRSIGNAL
586 /* Not exactly the same: instead of "Stopped" it shows "STOP" etc */
587 # define strsignal(sig) get_signame(sig)
588 #endif
589
590 #ifndef HAVE_USLEEP
591 extern int usleep(unsigned) FAST_FUNC;
592 #endif
593
594 #ifndef HAVE_VASPRINTF
595 extern int vasprintf(char **string_ptr, const char *format, va_list p) FAST_FUNC;
596 #endif
597
598 #ifndef HAVE_GETLINE
599 # include <stdio.h> /* for FILE */
600 # include <sys/types.h> /* size_t */
601 extern ssize_t getline(char **lineptr, size_t *n, FILE *stream) FAST_FUNC;
602 #endif
603
604 #endif