~ubuntu-branches/ubuntu/trusty/kstart/trusty-proposed

« back to all changes in this revision

Viewing changes to portable/system.h

  • Committer: Package Import Robot
  • Author(s): Russ Allbery
  • Date: 2012-02-04 18:05:16 UTC
  • mfrom: (1.1.11) (2.1.9 sid)
  • Revision ID: package-import@ubuntu.com-20120204180516-hjeqs2sl3hpvc46p
Tags: 4.1-2
* Update to debhelper compatibility level V9.
  - Enable compiler hardening flags, including bindnow and PIE.
* Move single-debian-patch to local-options and patch-header to
  local-patch-header so that they only apply to the packages I build and
  NMUs get regular version-numbered patches.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
 *     #include <stddef.h>
14
14
 *     #include <stdint.h>
15
15
 *     #include <string.h>
 
16
 *     #include <strings.h>
16
17
 *     #include <unistd.h>
17
18
 *
18
19
 * Missing functions are provided via #define or prototyped if available from
19
 
 * the util helper library.  Also provides some standard #defines.
 
20
 * the portable helper library.  Also provides some standard #defines.
 
21
 *
 
22
 * The canonical version of this file is maintained in the rra-c-util package,
 
23
 * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
20
24
 *
21
25
 * Written by Russ Allbery <rra@stanford.edu>
22
 
 * This work is hereby placed in the public domain by its author.
 
26
 *
 
27
 * The authors hereby relinquish any claim to any copyright that they may have
 
28
 * in this work, whether granted under contract or by operation of law or
 
29
 * international treaty, and hereby commit to the public, at large, that they
 
30
 * shall not, at any time in the future, seek to enforce any copyright in this
 
31
 * work against any person or entity, or prevent any person or entity from
 
32
 * copying, publishing, distributing or creating derivative works of this
 
33
 * work.
23
34
 */
24
35
 
25
36
#ifndef PORTABLE_SYSTEM_H
38
49
#include <stdlib.h>
39
50
#include <sys/types.h>
40
51
#include <string.h>
 
52
#if HAVE_STRINGS_H
 
53
# include <strings.h>
 
54
#endif
41
55
#if HAVE_INTTYPES_H
42
56
# include <inttypes.h>
43
57
#endif
56
70
/* Get the bool type. */
57
71
#include <portable/stdbool.h>
58
72
 
 
73
/* Windows provides snprintf under a different name. */
 
74
#ifdef _WIN32
 
75
# define snprintf _snprintf
 
76
#endif
 
77
 
 
78
/* Define sig_atomic_t if it's not available in signal.h. */
 
79
#ifndef HAVE_SIG_ATOMIC_T
 
80
typedef int sig_atomic_t;
 
81
#endif
 
82
 
 
83
/* Windows does not define ssize_t. */
 
84
#ifndef HAVE_SSIZE_T
 
85
typedef ptrdiff_t ssize_t;
 
86
#endif
 
87
 
 
88
/*
 
89
 * POSIX requires that these be defined in <unistd.h>.  If one of them has
 
90
 * been defined, all the rest almost certainly have.
 
91
 */
 
92
#ifndef STDIN_FILENO
 
93
# define STDIN_FILENO  0
 
94
# define STDOUT_FILENO 1
 
95
# define STDERR_FILENO 2
 
96
#endif
 
97
 
 
98
/*
 
99
 * C99 requires va_copy.  Older versions of GCC provide __va_copy.  Per the
 
100
 * Autoconf manual, memcpy is a generally portable fallback.
 
101
 */
 
102
#ifndef va_copy
 
103
# ifdef __va_copy
 
104
#  define va_copy(d, s) __va_copy((d), (s))
 
105
# else
 
106
#  define va_copy(d, s) memcpy(&(d), &(s), sizeof(va_list))
 
107
# endif
 
108
#endif
 
109
 
59
110
BEGIN_DECLS
60
111
 
61
112
/* Default to a hidden visibility for all portability functions. */
93
144
#if !HAVE_STRLCPY
94
145
extern size_t strlcpy(char *, const char *, size_t);
95
146
#endif
 
147
#if !HAVE_STRNDUP
 
148
extern char *strndup(const char *, size_t);
 
149
#endif
96
150
 
97
151
/* Undo default visibility change. */
98
152
#pragma GCC visibility pop
99
153
 
100
154
END_DECLS
101
155
 
102
 
/* Windows provides snprintf under a different name. */
103
 
#ifdef _WIN32
104
 
# define snprintf _snprintf
105
 
#endif
106
 
 
107
 
/*
108
 
 * POSIX requires that these be defined in <unistd.h>.  If one of them has
109
 
 * been defined, all the rest almost certainly have.
110
 
 */
111
 
#ifndef STDIN_FILENO
112
 
# define STDIN_FILENO  0
113
 
# define STDOUT_FILENO 1
114
 
# define STDERR_FILENO 2
115
 
#endif
116
 
 
117
 
/*
118
 
 * C99 requires va_copy.  Older versions of GCC provide __va_copy.  Per the
119
 
 * Autoconf manual, memcpy is a generally portable fallback.
120
 
 */
121
 
#ifndef va_copy
122
 
# ifdef __va_copy
123
 
#  define va_copy(d, s) __va_copy((d), (s))
124
 
# else
125
 
#  define va_copy(d, s) memcpy(&(d), &(s), sizeof(va_list))
126
 
# endif
127
 
#endif
128
 
 
129
156
#endif /* !PORTABLE_SYSTEM_H */