aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2012-03-22 15:21:20 +0000
committerRon Yorston <rmy@pobox.com>2012-03-22 15:21:20 +0000
commit0d8b2c4a929ea9d3ac37499319fe0d8e7941a0c2 (patch)
tree6709ddd6071a9c238ba69233540bbcfe560c6a44 /include
parent67758035a4fe040c6ac69b39d61bcd6bddd7b827 (diff)
parent56a3b82e9692a25ef9c9269e88feac0d579ce8e8 (diff)
downloadbusybox-w32-0d8b2c4a929ea9d3ac37499319fe0d8e7941a0c2.tar.gz
busybox-w32-0d8b2c4a929ea9d3ac37499319fe0d8e7941a0c2.tar.bz2
busybox-w32-0d8b2c4a929ea9d3ac37499319fe0d8e7941a0c2.zip
Merge commit '56a3b82e9692a25ef9c9269e88feac0d579ce8e8' into merge
Conflicts: coreutils/ls.c include/platform.h libbb/bb_basename.c
Diffstat (limited to 'include')
-rw-r--r--include/archive.h2
-rw-r--r--include/libbb.h38
-rw-r--r--include/mingw.h2
-rw-r--r--include/platform.h158
4 files changed, 113 insertions, 87 deletions
diff --git a/include/archive.h b/include/archive.h
index b139dc5be..9e176d335 100644
--- a/include/archive.h
+++ b/include/archive.h
@@ -125,7 +125,7 @@ typedef struct archive_handle_t {
125#define TAR_BLOCK_SIZE 512 125#define TAR_BLOCK_SIZE 512
126#define NAME_SIZE 100 126#define NAME_SIZE 100
127#define NAME_SIZE_STR "100" 127#define NAME_SIZE_STR "100"
128typedef struct tar_header_t { /* byte offset */ 128typedef struct tar_header_t { /* byte offset */
129 char name[NAME_SIZE]; /* 0-99 */ 129 char name[NAME_SIZE]; /* 0-99 */
130 char mode[8]; /* 100-107 */ 130 char mode[8]; /* 100-107 */
131 char uid[8]; /* 108-115 */ 131 char uid[8]; /* 108-115 */
diff --git a/include/libbb.h b/include/libbb.h
index 4f46cf8c5..ac5722c89 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -20,6 +20,12 @@
20#include <netdb.h> 20#include <netdb.h>
21#include <setjmp.h> 21#include <setjmp.h>
22#include <signal.h> 22#include <signal.h>
23#if defined __UCLIBC__ /* TODO: and glibc? */
24/* use inlined versions of these: */
25# define sigfillset(s) __sigfillset(s)
26# define sigemptyset(s) __sigemptyset(s)
27# define sigisemptyset(s) __sigisemptyset(s)
28#endif
23#include <stdint.h> 29#include <stdint.h>
24#include <stdio.h> 30#include <stdio.h>
25#include <stdlib.h> 31#include <stdlib.h>
@@ -363,6 +369,7 @@ extern void bb_copyfd_exact_size(int fd1, int fd2, off_t size) FAST_FUNC;
363/* "short" copy can be detected by return value < size */ 369/* "short" copy can be detected by return value < size */
364/* this helper yells "short read!" if param is not -1 */ 370/* this helper yells "short read!" if param is not -1 */
365extern void complain_copyfd_and_die(off_t sz) NORETURN FAST_FUNC; 371extern void complain_copyfd_and_die(off_t sz) NORETURN FAST_FUNC;
372
366extern char bb_process_escape_sequence(const char **ptr) FAST_FUNC; 373extern char bb_process_escape_sequence(const char **ptr) FAST_FUNC;
367char* strcpy_and_process_escape_sequences(char *dst, const char *src) FAST_FUNC; 374char* strcpy_and_process_escape_sequences(char *dst, const char *src) FAST_FUNC;
368/* xxxx_strip version can modify its parameter: 375/* xxxx_strip version can modify its parameter:
@@ -371,9 +378,13 @@ char* strcpy_and_process_escape_sequences(char *dst, const char *src) FAST_FUNC;
371 * "abc/def" -> "def" 378 * "abc/def" -> "def"
372 * "abc/def/" -> "def" !! 379 * "abc/def/" -> "def" !!
373 */ 380 */
374extern char *bb_get_last_path_component_strip(char *path) FAST_FUNC; 381char *bb_get_last_path_component_strip(char *path) FAST_FUNC;
375/* "abc/def/" -> "" and it never modifies 'path' */ 382/* "abc/def/" -> "" and it never modifies 'path' */
376extern char *bb_get_last_path_component_nostrip(const char *path) FAST_FUNC; 383char *bb_get_last_path_component_nostrip(const char *path) FAST_FUNC;
384/* Simpler version: does not special case "/" string */
385const char *bb_basename(const char *name) FAST_FUNC;
386/* NB: can violate const-ness (similarly to strchr) */
387char *last_char_is(const char *s, int c) FAST_FUNC;
377 388
378void ndelay_on(int fd) FAST_FUNC; 389void ndelay_on(int fd) FAST_FUNC;
379void ndelay_off(int fd) FAST_FUNC; 390void ndelay_off(int fd) FAST_FUNC;
@@ -685,7 +696,7 @@ void* xrealloc_vector_helper(void *vector, unsigned sizeof_and_shift, int idx) F
685 696
686 697
687extern ssize_t safe_read(int fd, void *buf, size_t count) FAST_FUNC; 698extern ssize_t safe_read(int fd, void *buf, size_t count) FAST_FUNC;
688extern ssize_t nonblock_safe_read(int fd, void *buf, size_t count) FAST_FUNC; 699extern ssize_t nonblock_immune_read(int fd, void *buf, size_t count, int loop_on_EINTR) FAST_FUNC;
689// NB: will return short read on error, not -1, 700// NB: will return short read on error, not -1,
690// if some data was read before error occurred 701// if some data was read before error occurred
691extern ssize_t full_read(int fd, void *buf, size_t count) FAST_FUNC; 702extern ssize_t full_read(int fd, void *buf, size_t count) FAST_FUNC;
@@ -696,7 +707,7 @@ extern ssize_t open_read_close(const char *filename, void *buf, size_t maxsz) FA
696// Reads one line a-la fgets (but doesn't save terminating '\n'). 707// Reads one line a-la fgets (but doesn't save terminating '\n').
697// Reads byte-by-byte. Useful when it is important to not read ahead. 708// Reads byte-by-byte. Useful when it is important to not read ahead.
698// Bytes are appended to pfx (which must be malloced, or NULL). 709// Bytes are appended to pfx (which must be malloced, or NULL).
699extern char *xmalloc_reads(int fd, char *pfx, size_t *maxsz_p) FAST_FUNC; 710extern char *xmalloc_reads(int fd, size_t *maxsz_p) FAST_FUNC;
700/* Reads block up to *maxsz_p (default: INT_MAX - 4095) */ 711/* Reads block up to *maxsz_p (default: INT_MAX - 4095) */
701extern void *xmalloc_read(int fd, size_t *maxsz_p) FAST_FUNC RETURNS_MALLOC; 712extern void *xmalloc_read(int fd, size_t *maxsz_p) FAST_FUNC RETURNS_MALLOC;
702/* Returns NULL if file can't be opened (default max size: INT_MAX - 4095) */ 713/* Returns NULL if file can't be opened (default max size: INT_MAX - 4095) */
@@ -997,9 +1008,13 @@ extern uint32_t option_mask32;
997extern uint32_t getopt32(char **argv, const char *applet_opts, ...) FAST_FUNC; 1008extern uint32_t getopt32(char **argv, const char *applet_opts, ...) FAST_FUNC;
998 1009
999 1010
1011/* Having next pointer as a first member allows easy creation
1012 * of "llist-compatible" structs, and using llist_FOO functions
1013 * on them.
1014 */
1000typedef struct llist_t { 1015typedef struct llist_t {
1001 char *data;
1002 struct llist_t *link; 1016 struct llist_t *link;
1017 char *data;
1003} llist_t; 1018} llist_t;
1004void llist_add_to(llist_t **old_head, void *data) FAST_FUNC; 1019void llist_add_to(llist_t **old_head, void *data) FAST_FUNC;
1005void llist_add_to_end(llist_t **list_head, void *data) FAST_FUNC; 1020void llist_add_to_end(llist_t **list_head, void *data) FAST_FUNC;
@@ -1198,10 +1213,8 @@ void config_close(parser_t *parser) FAST_FUNC;
1198 * If path is NULL, it is assumed to be "/". 1213 * If path is NULL, it is assumed to be "/".
1199 * filename should not be NULL. */ 1214 * filename should not be NULL. */
1200char *concat_path_file(const char *path, const char *filename) FAST_FUNC; 1215char *concat_path_file(const char *path, const char *filename) FAST_FUNC;
1216/* Returns NULL on . and .. */
1201char *concat_subpath_file(const char *path, const char *filename) FAST_FUNC; 1217char *concat_subpath_file(const char *path, const char *filename) FAST_FUNC;
1202const char *bb_basename(const char *name) FAST_FUNC;
1203/* NB: can violate const-ness (similarly to strchr) */
1204char *last_char_is(const char *s, int c) FAST_FUNC;
1205 1218
1206 1219
1207int bb_make_directory(char *path, long mode, int flags) FAST_FUNC; 1220int bb_make_directory(char *path, long mode, int flags) FAST_FUNC;
@@ -1269,14 +1282,19 @@ extern int correct_password(const struct passwd *pw) FAST_FUNC;
1269#endif 1282#endif
1270extern char *pw_encrypt(const char *clear, const char *salt, int cleanup) FAST_FUNC; 1283extern char *pw_encrypt(const char *clear, const char *salt, int cleanup) FAST_FUNC;
1271extern int obscure(const char *old, const char *newval, const struct passwd *pwdp) FAST_FUNC; 1284extern int obscure(const char *old, const char *newval, const struct passwd *pwdp) FAST_FUNC;
1272/* rnd is additional random input. New one is returned. 1285/*
1286 * rnd is additional random input. New one is returned.
1273 * Useful if you call crypt_make_salt many times in a row: 1287 * Useful if you call crypt_make_salt many times in a row:
1274 * rnd = crypt_make_salt(buf1, 4, 0); 1288 * rnd = crypt_make_salt(buf1, 4, 0);
1275 * rnd = crypt_make_salt(buf2, 4, rnd); 1289 * rnd = crypt_make_salt(buf2, 4, rnd);
1276 * rnd = crypt_make_salt(buf3, 4, rnd); 1290 * rnd = crypt_make_salt(buf3, 4, rnd);
1277 * (otherwise we risk having same salt generated) 1291 * (otherwise we risk having same salt generated)
1278 */ 1292 */
1279extern int crypt_make_salt(char *p, int cnt, int rnd) FAST_FUNC; 1293extern int crypt_make_salt(char *p, int cnt /*, int rnd*/) FAST_FUNC;
1294/* "$N$" + sha_salt_16_bytes + NUL */
1295#define MAX_PW_SALT_LEN (3 + 16 + 1)
1296extern char* crypt_make_pw_salt(char p[MAX_PW_SALT_LEN], const char *algo) FAST_FUNC;
1297
1280 1298
1281/* Returns number of lines changed, or -1 on error */ 1299/* Returns number of lines changed, or -1 on error */
1282#if !(ENABLE_FEATURE_ADDUSER_TO_GROUP || ENABLE_FEATURE_DEL_USER_FROM_GROUP) 1300#if !(ENABLE_FEATURE_ADDUSER_TO_GROUP || ENABLE_FEATURE_DEL_USER_FROM_GROUP)
diff --git a/include/mingw.h b/include/mingw.h
index 49de6cb5e..69bf05574 100644
--- a/include/mingw.h
+++ b/include/mingw.h
@@ -209,6 +209,8 @@ NOIMPL(mingw_bind,SOCKET s UNUSED_PARAM,const struct sockaddr* sa UNUSED_PARAM,i
209/* 209/*
210 * sys/stat.h 210 * sys/stat.h
211 */ 211 */
212typedef int nlink_t;
213
212#define S_ISUID 04000 214#define S_ISUID 04000
213#define S_ISGID 02000 215#define S_ISGID 02000
214#define S_ISVTX 01000 216#define S_ISVTX 01000
diff --git a/include/platform.h b/include/platform.h
index eb9f8032b..48e256aa0 100644
--- a/include/platform.h
+++ b/include/platform.h
@@ -17,24 +17,6 @@
17# endif 17# endif
18#endif 18#endif
19 19
20/* Assume all these functions exist by default. Platforms where it is not
21 * true will #undef them below.
22 */
23#define HAVE_CLEARENV 1
24#define HAVE_FDATASYNC 1
25#define HAVE_DPRINTF 1
26#define HAVE_MEMRCHR 1
27#define HAVE_MKDTEMP 1
28#define HAVE_PTSNAME_R 1
29#define HAVE_SETBIT 1
30#define HAVE_SIGHANDLER_T 1
31#define HAVE_STPCPY 1
32#define HAVE_STRCASESTR 1
33#define HAVE_STRCHRNUL 1
34#define HAVE_STRSEP 1
35#define HAVE_STRSIGNAL 1
36#define HAVE_VASPRINTF 1
37
38/* Convenience macros to test the version of gcc. */ 20/* Convenience macros to test the version of gcc. */
39#undef __GNUC_PREREQ 21#undef __GNUC_PREREQ
40#if defined __GNUC__ && defined __GNUC_MINOR__ 22#if defined __GNUC__ && defined __GNUC_MINOR__
@@ -51,10 +33,6 @@
51# endif 33# endif
52#endif 34#endif
53 35
54/* Define macros for some gcc attributes. This permits us to use the
55 macros freely, and know that they will come into play for the
56 version of gcc in which they are supported. */
57
58#if !__GNUC_PREREQ(2,7) 36#if !__GNUC_PREREQ(2,7)
59# ifndef __attribute__ 37# ifndef __attribute__
60# define __attribute__(x) 38# define __attribute__(x)
@@ -108,7 +86,7 @@
108#endif 86#endif
109 87
110/* -fwhole-program makes all symbols local. The attribute externally_visible 88/* -fwhole-program makes all symbols local. The attribute externally_visible
111 forces a symbol global. */ 89 * forces a symbol global. */
112#if __GNUC_PREREQ(4,1) 90#if __GNUC_PREREQ(4,1)
113# define EXTERNALLY_VISIBLE __attribute__(( visibility("default") )) 91# define EXTERNALLY_VISIBLE __attribute__(( visibility("default") ))
114//__attribute__ ((__externally_visible__)) 92//__attribute__ ((__externally_visible__))
@@ -124,22 +102,14 @@
124#endif 102#endif
125 103
126/* We use __extension__ in some places to suppress -pedantic warnings 104/* We use __extension__ in some places to suppress -pedantic warnings
127 about GCC extensions. This feature didn't work properly before 105 * about GCC extensions. This feature didn't work properly before
128 gcc 2.8. */ 106 * gcc 2.8. */
129#if !__GNUC_PREREQ(2,8) 107#if !__GNUC_PREREQ(2,8)
130# ifndef __extension__ 108# ifndef __extension__
131# define __extension__ 109# define __extension__
132# endif 110# endif
133#endif 111#endif
134 112
135/* gcc-2.95 had no va_copy but only __va_copy. */
136#if !__GNUC_PREREQ(3,0)
137# include <stdarg.h>
138# if !defined va_copy && defined __va_copy
139# define va_copy(d,s) __va_copy((d),(s))
140# endif
141#endif
142
143/* FAST_FUNC is a qualifier which (possibly) makes function call faster 113/* FAST_FUNC is a qualifier which (possibly) makes function call faster
144 * and/or smaller by using modified ABI. It is usually only needed 114 * and/or smaller by using modified ABI. It is usually only needed
145 * on non-static, busybox internal functions. Recent versions of gcc 115 * on non-static, busybox internal functions. Recent versions of gcc
@@ -163,6 +133,15 @@
163# define POP_SAVED_FUNCTION_VISIBILITY 133# define POP_SAVED_FUNCTION_VISIBILITY
164#endif 134#endif
165 135
136/* gcc-2.95 had no va_copy but only __va_copy. */
137#if !__GNUC_PREREQ(3,0)
138# include <stdarg.h>
139# if !defined va_copy && defined __va_copy
140# define va_copy(d,s) __va_copy((d),(s))
141# endif
142#endif
143
144
166/* ---- Endian Detection ------------------------------------ */ 145/* ---- Endian Detection ------------------------------------ */
167 146
168#include <limits.h> 147#include <limits.h>
@@ -238,6 +217,7 @@
238# define IF_LITTLE_ENDIAN(...) __VA_ARGS__ 217# define IF_LITTLE_ENDIAN(...) __VA_ARGS__
239#endif 218#endif
240 219
220
241/* ---- Unaligned access ------------------------------------ */ 221/* ---- Unaligned access ------------------------------------ */
242 222
243#include <stdint.h> 223#include <stdint.h>
@@ -270,37 +250,9 @@ typedef uint32_t bb__aliased_uint32_t FIX_ALIASING;
270} while (0) 250} while (0)
271#endif 251#endif
272 252
273/* ---- Compiler dependent settings ------------------------- */
274 253
275#if (defined __digital__ && defined __unix__) \ 254/* ---- Size-saving "small" ints (arch-dependent) ----------- */
276 || defined __APPLE__ \
277 || defined __FreeBSD__ || defined __OpenBSD__ || defined __NetBSD__
278# undef HAVE_CLEARENV
279# undef HAVE_FDATASYNC
280# undef HAVE_MNTENT_H
281# undef HAVE_PTSNAME_R
282# undef HAVE_SYS_STATFS_H
283# undef HAVE_SIGHANDLER_T
284# undef HAVE_XTABS
285# undef HAVE_DPRINTF
286#else
287# define HAVE_MNTENT_H 1
288# define HAVE_SYS_STATFS_H 1
289# define HAVE_XTABS 1
290#endif
291
292/*----- Kernel versioning ------------------------------------*/
293
294#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
295
296/* ---- Miscellaneous --------------------------------------- */
297 255
298#if defined __GLIBC__ || defined __UCLIBC__ \
299 || defined __dietlibc__ || defined _NEWLIB_VERSION
300# include <features.h>
301#endif
302
303/* Size-saving "small" ints (arch-dependent) */
304#if defined(i386) || defined(__x86_64__) || defined(__mips__) || defined(__cris__) 256#if defined(i386) || defined(__x86_64__) || defined(__mips__) || defined(__cris__)
305/* add other arches which benefit from this... */ 257/* add other arches which benefit from this... */
306typedef signed char smallint; 258typedef signed char smallint;
@@ -320,7 +272,34 @@ typedef unsigned smalluint;
320# include <stdbool.h> 272# include <stdbool.h>
321#endif 273#endif
322 274
323/* Try to defeat gcc's alignment of "char message[]"-like data */ 275
276/*----- Kernel versioning ------------------------------------*/
277
278#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
279
280
281/* ---- Miscellaneous --------------------------------------- */
282
283#if defined __GLIBC__ \
284 || defined __UCLIBC__ \
285 || defined __dietlibc__ \
286 || defined _NEWLIB_VERSION
287# include <features.h>
288#endif
289
290/* Define bb_setpgrp */
291#if defined(__digital__) && defined(__unix__)
292/* use legacy setpgrp(pid_t, pid_t) for now. move to platform.c */
293# define bb_setpgrp() do { pid_t __me = getpid(); setpgrp(__me, __me); } while (0)
294#else
295# define bb_setpgrp() setpgrp()
296#endif
297
298/* fdprintf is more readable, we used it before dprintf was standardized */
299#include <unistd.h>
300#define fdprintf dprintf
301
302/* Useful for defeating gcc's alignment of "char message[]"-like data */
324#if 1 /* if needed: !defined(arch1) && !defined(arch2) */ 303#if 1 /* if needed: !defined(arch1) && !defined(arch2) */
325# define ALIGN1 __attribute__((aligned(1))) 304# define ALIGN1 __attribute__((aligned(1)))
326# define ALIGN2 __attribute__((aligned(2))) 305# define ALIGN2 __attribute__((aligned(2)))
@@ -332,8 +311,7 @@ typedef unsigned smalluint;
332# define ALIGN4 311# define ALIGN4
333#endif 312#endif
334 313
335 314/*
336/* uclibc does not implement daemon() for no-mmu systems.
337 * For 0.9.29 and svn, __ARCH_USE_MMU__ indicates no-mmu reliably. 315 * For 0.9.29 and svn, __ARCH_USE_MMU__ indicates no-mmu reliably.
338 * For earlier versions there is no reliable way to check if we are building 316 * For earlier versions there is no reliable way to check if we are building
339 * for a mmu-less system. 317 * for a mmu-less system.
@@ -351,12 +329,9 @@ typedef unsigned smalluint;
351#endif 329#endif
352 330
353#if defined(__digital__) && defined(__unix__) 331#if defined(__digital__) && defined(__unix__)
354
355# include <standards.h> 332# include <standards.h>
356# include <inttypes.h> 333# include <inttypes.h>
357# define PRIu32 "u" 334# define PRIu32 "u"
358/* use legacy setpgrp(pid_t,pid_t) for now. move to platform.c */
359# define bb_setpgrp() do { pid_t __me = getpid(); setpgrp(__me, __me); } while (0)
360# if !defined ADJ_OFFSET_SINGLESHOT && defined MOD_CLKA && defined MOD_OFFSET 335# if !defined ADJ_OFFSET_SINGLESHOT && defined MOD_CLKA && defined MOD_OFFSET
361# define ADJ_OFFSET_SINGLESHOT (MOD_CLKA | MOD_OFFSET) 336# define ADJ_OFFSET_SINGLESHOT (MOD_CLKA | MOD_OFFSET)
362# endif 337# endif
@@ -369,17 +344,31 @@ typedef unsigned smalluint;
369# if !defined ADJ_TICK && defined MOD_CLKB 344# if !defined ADJ_TICK && defined MOD_CLKB
370# define ADJ_TICK MOD_CLKB 345# define ADJ_TICK MOD_CLKB
371# endif 346# endif
347#endif
372 348
373# undef HAVE_STPCPY
374
375#else
376
377# define bb_setpgrp() setpgrp()
378 349
379#endif 350/* ---- Who misses what? ------------------------------------ */
380 351
381#include <unistd.h> 352/* Assume all these functions exist by default. Platforms where it is not
382#define fdprintf dprintf 353 * true will #undef them below.
354 */
355#define HAVE_CLEARENV 1
356#define HAVE_FDATASYNC 1
357#define HAVE_DPRINTF 1
358#define HAVE_MEMRCHR 1
359#define HAVE_MKDTEMP 1
360#define HAVE_PTSNAME_R 1
361#define HAVE_SETBIT 1
362#define HAVE_SIGHANDLER_T 1
363#define HAVE_STPCPY 1
364#define HAVE_STRCASESTR 1
365#define HAVE_STRCHRNUL 1
366#define HAVE_STRSEP 1
367#define HAVE_STRSIGNAL 1
368#define HAVE_VASPRINTF 1
369#define HAVE_MNTENT_H 1
370#define HAVE_SYS_STATFS_H 1
371#define HAVE_XTABS 1
383 372
384#if defined(__dietlibc__) 373#if defined(__dietlibc__)
385# undef HAVE_STRCHRNUL 374# undef HAVE_STRCHRNUL
@@ -416,6 +405,23 @@ typedef unsigned smalluint;
416# undef HAVE_STRCHRNUL 405# undef HAVE_STRCHRNUL
417#endif 406#endif
418 407
408#if (defined __digital__ && defined __unix__) \
409 || defined __APPLE__ \
410 || defined __FreeBSD__ || defined __OpenBSD__ || defined __NetBSD__
411# undef HAVE_CLEARENV
412# undef HAVE_FDATASYNC
413# undef HAVE_MNTENT_H
414# undef HAVE_PTSNAME_R
415# undef HAVE_SYS_STATFS_H
416# undef HAVE_SIGHANDLER_T
417# undef HAVE_XTABS
418# undef HAVE_DPRINTF
419#endif
420
421#if defined(__digital__) && defined(__unix__)
422# undef HAVE_STPCPY
423#endif
424
419/* 425/*
420 * Now, define prototypes for all the functions defined in platform.c 426 * Now, define prototypes for all the functions defined in platform.c
421 * These must come after all the HAVE_* macros are defined (or not) 427 * These must come after all the HAVE_* macros are defined (or not)