1
/* $Id: system.h 4067 2008-04-09 22:23:08Z rra $
3
* Declarations of routines and variables in the C library. Including this
4
* file is the equivalent of including all of the following headers, portably:
6
* #include <sys/types.h>
16
* Missing functions are provided via #define or prototyped if available.
17
* Also provides some standard #defines.
19
* Written by Russ Allbery <rra@stanford.edu>
20
* This work is hereby placed in the public domain by its author.
23
#ifndef PORTABLE_SYSTEM_H
24
#define PORTABLE_SYSTEM_H 1
26
/* Make sure we have our configuration information. */
29
/* BEGIN_DECL and __attribute__. */
30
#include <portable/macros.h>
32
/* A set of standard ANSI C headers. We don't care about pre-ANSI systems. */
37
#include <sys/types.h>
40
# include <inttypes.h>
49
/* SCO OpenServer gets int32_t from here. */
50
#if HAVE_SYS_BITYPES_H
51
# include <sys/bitypes.h>
54
/* Get the bool type. */
55
#include <portable/stdbool.h>
60
* Provide prototypes for functions not declared in system headers. Use the
61
* HAVE_DECL macros for those functions that may be prototyped but
62
* implemented incorrectly or implemented without a prototype.
65
extern int asprintf(char **, const char *, ...);
66
extern int vasprintf(char **, const char *, va_list);
69
extern int daemon(int, int);
72
extern int mkstemp(char *);
74
#if !HAVE_DECL_SNPRINTF
75
extern int snprintf(char *, size_t, const char *, ...)
76
__attribute__((__format__(printf, 3, 4)));
78
#if !HAVE_DECL_VSNPRINTF
79
extern int vsnprintf(char *, size_t, const char *, va_list);
84
/* Windows provides snprintf under a different name. */
86
# define snprintf _snprintf
90
* POSIX requires that these be defined in <unistd.h>. If one of them has
91
* been defined, all the rest almost certainly have.
94
# define STDIN_FILENO 0
95
# define STDOUT_FILENO 1
96
# define STDERR_FILENO 2
100
* C99 requires va_copy. Older versions of GCC provide __va_copy. Per the
101
* Autoconf manual, memcpy is a generally portable fallback.
105
# define va_copy(d, s) __va_copy((d), (s))
107
# define va_copy(d, s) memcpy(&(d), &(s), sizeof(va_list))
111
#endif /* !PORTABLE_SYSTEM_H */