aboutsummaryrefslogtreecommitdiff
path: root/include/libbb.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/libbb.h')
-rw-r--r--include/libbb.h73
1 files changed, 71 insertions, 2 deletions
diff --git a/include/libbb.h b/include/libbb.h
index dfcaa05ec..3a958b555 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -143,6 +143,9 @@
143# include <arpa/inet.h> 143# include <arpa/inet.h>
144#elif defined __APPLE__ 144#elif defined __APPLE__
145# include <netinet/in.h> 145# include <netinet/in.h>
146#elif ENABLE_PLATFORM_MINGW32
147# include <winsock2.h>
148# include <ws2tcpip.h>
146#else 149#else
147# include <arpa/inet.h> 150# include <arpa/inet.h>
148//This breaks on bionic: 151//This breaks on bionic:
@@ -182,7 +185,9 @@
182 185
183/* Some libc's forget to declare these, do it ourself */ 186/* Some libc's forget to declare these, do it ourself */
184 187
188#if !ENABLE_PLATFORM_MINGW32
185extern char **environ; 189extern char **environ;
190#endif
186/* klogctl is in libc's klog.h, but we cheat and not #include that */ 191/* klogctl is in libc's klog.h, but we cheat and not #include that */
187int klogctl(int type, char *b, int len); 192int klogctl(int type, char *b, int len);
188#ifndef PATH_MAX 193#ifndef PATH_MAX
@@ -192,6 +197,13 @@ int klogctl(int type, char *b, int len);
192# define BUFSIZ 4096 197# define BUFSIZ 4096
193#endif 198#endif
194 199
200#if ENABLE_PLATFORM_MINGW32
201# include "mingw.h"
202# define MINGW_SPECIAL(a) mingw_ ## a
203#else
204# define MINGW_SPECIAL(a) a
205#endif
206
195#if __GNUC_PREREQ(5,0) 207#if __GNUC_PREREQ(5,0)
196/* Since musl is apparently unable to get it right and would use 208/* Since musl is apparently unable to get it right and would use
197 * a function call to a single-instruction function of "bswap %eax", 209 * a function call to a single-instruction function of "bswap %eax",
@@ -276,6 +288,13 @@ PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN
276 : ((T)1 << (sizeof(T)*8-1)) \ 288 : ((T)1 << (sizeof(T)*8-1)) \
277 ) 289 )
278 290
291#if ENABLE_PLATFORM_MINGW32 && \
292 (!defined(__USE_MINGW_ANSI_STDIO) || !__USE_MINGW_ANSI_STDIO)
293#define LL_FMT "I64"
294#else
295#define LL_FMT "ll"
296#endif
297
279/* Large file support */ 298/* Large file support */
280/* Note that CONFIG_LFS=y forces bbox to be built with all common ops 299/* Note that CONFIG_LFS=y forces bbox to be built with all common ops
281 * (stat, lseek etc) mapped to "largefile" variants by libc. 300 * (stat, lseek etc) mapped to "largefile" variants by libc.
@@ -301,7 +320,7 @@ typedef unsigned long long uoff_t;
301# define XATOOFF(a) xatoull_range((a), 0, LLONG_MAX) 320# define XATOOFF(a) xatoull_range((a), 0, LLONG_MAX)
302# define BB_STRTOOFF bb_strtoull 321# define BB_STRTOOFF bb_strtoull
303# define STRTOOFF strtoull 322# define STRTOOFF strtoull
304# define OFF_FMT "ll" 323# define OFF_FMT LL_FMT
305# endif 324# endif
306#else 325#else
307/* CONFIG_LFS is off */ 326/* CONFIG_LFS is off */
@@ -585,20 +604,37 @@ enum {
585 * Dance around with long long to guard against that... 604 * Dance around with long long to guard against that...
586 */ 605 */
587 BB_FATAL_SIGS = (int)(0 606 BB_FATAL_SIGS = (int)(0
607#ifdef SIGHUP
588 + (1LL << SIGHUP) 608 + (1LL << SIGHUP)
609#endif
589 + (1LL << SIGINT) 610 + (1LL << SIGINT)
590 + (1LL << SIGTERM) 611 + (1LL << SIGTERM)
591 + (1LL << SIGPIPE) // Write to pipe with no readers 612 + (1LL << SIGPIPE) // Write to pipe with no readers
613#ifdef SIGQUIT
592 + (1LL << SIGQUIT) // Quit from keyboard 614 + (1LL << SIGQUIT) // Quit from keyboard
615#endif
593 + (1LL << SIGABRT) // Abort signal from abort(3) 616 + (1LL << SIGABRT) // Abort signal from abort(3)
617#ifdef SIGALRM
594 + (1LL << SIGALRM) // Timer signal from alarm(2) 618 + (1LL << SIGALRM) // Timer signal from alarm(2)
619#endif
620#ifdef SIGVTALRM
595 + (1LL << SIGVTALRM) // Virtual alarm clock 621 + (1LL << SIGVTALRM) // Virtual alarm clock
622#endif
623#ifdef SIGXCPU
596 + (1LL << SIGXCPU) // CPU time limit exceeded 624 + (1LL << SIGXCPU) // CPU time limit exceeded
625#endif
626#ifdef SIGXFSZ
597 + (1LL << SIGXFSZ) // File size limit exceeded 627 + (1LL << SIGXFSZ) // File size limit exceeded
628#endif
629#ifdef SIGUSR1
598 + (1LL << SIGUSR1) // Yes kids, these are also fatal! 630 + (1LL << SIGUSR1) // Yes kids, these are also fatal!
631#endif
632#ifdef SIGUSR1
599 + (1LL << SIGUSR2) 633 + (1LL << SIGUSR2)
634#endif
600 + 0), 635 + 0),
601}; 636};
637#if !ENABLE_PLATFORM_MINGW32
602void bb_signals(int sigs, void (*f)(int)) FAST_FUNC; 638void bb_signals(int sigs, void (*f)(int)) FAST_FUNC;
603/* Unlike signal() and bb_signals, sets handler with sigaction() 639/* Unlike signal() and bb_signals, sets handler with sigaction()
604 * and in a way that while signal handler is run, no other signals 640 * and in a way that while signal handler is run, no other signals
@@ -618,6 +654,10 @@ int sigaction_set(int sig, const struct sigaction *act) FAST_FUNC;
618int sigprocmask_allsigs(int how) FAST_FUNC; 654int sigprocmask_allsigs(int how) FAST_FUNC;
619/* Return old set in the same set: */ 655/* Return old set in the same set: */
620int sigprocmask2(int how, sigset_t *set) FAST_FUNC; 656int sigprocmask2(int how, sigset_t *set) FAST_FUNC;
657#else
658#define bb_signals(s, f)
659#define kill_myself_with_sig(s)
660#endif
621/* Standard handler which just records signo */ 661/* Standard handler which just records signo */
622extern smallint bb_got_signal; 662extern smallint bb_got_signal;
623void record_signo(int signo); /* not FAST_FUNC! */ 663void record_signo(int signo); /* not FAST_FUNC! */
@@ -700,7 +740,7 @@ void xsettimeofday(const struct timeval *tv) FAST_FUNC;
700int xsocket(int domain, int type, int protocol) FAST_FUNC; 740int xsocket(int domain, int type, int protocol) FAST_FUNC;
701void xbind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen) FAST_FUNC; 741void xbind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen) FAST_FUNC;
702void xlisten(int s, int backlog) FAST_FUNC; 742void xlisten(int s, int backlog) FAST_FUNC;
703void xconnect(int s, const struct sockaddr *s_addr, socklen_t addrlen) FAST_FUNC; 743void xconnect(int s, const struct sockaddr *saddr, socklen_t addrlen) FAST_FUNC;
704ssize_t xsendto(int s, const void *buf, size_t len, const struct sockaddr *to, 744ssize_t xsendto(int s, const void *buf, size_t len, const struct sockaddr *to,
705 socklen_t tolen) FAST_FUNC; 745 socklen_t tolen) FAST_FUNC;
706 746
@@ -1209,6 +1249,7 @@ void BB_EXECVP_or_die(char **argv) NORETURN FAST_FUNC;
1209 1249
1210/* xvfork() can't be a _function_, return after vfork in child mangles stack 1250/* xvfork() can't be a _function_, return after vfork in child mangles stack
1211 * in the parent. It must be a macro. */ 1251 * in the parent. It must be a macro. */
1252#if !ENABLE_PLATFORM_MINGW32
1212#define xvfork() \ 1253#define xvfork() \
1213({ \ 1254({ \
1214 pid_t bb__xvfork_pid = vfork(); \ 1255 pid_t bb__xvfork_pid = vfork(); \
@@ -1216,6 +1257,9 @@ void BB_EXECVP_or_die(char **argv) NORETURN FAST_FUNC;
1216 bb_simple_perror_msg_and_die("vfork"); \ 1257 bb_simple_perror_msg_and_die("vfork"); \
1217 bb__xvfork_pid; \ 1258 bb__xvfork_pid; \
1218}) 1259})
1260#else
1261#define xvfork() vfork()
1262#endif
1219#if BB_MMU 1263#if BB_MMU
1220pid_t xfork(void) FAST_FUNC; 1264pid_t xfork(void) FAST_FUNC;
1221#endif 1265#endif
@@ -1812,9 +1856,15 @@ int bb_xioctl(int fd, unsigned request, void *argp) FAST_FUNC;
1812#define xioctl(fd,request,argp) bb_xioctl(fd,request,argp) 1856#define xioctl(fd,request,argp) bb_xioctl(fd,request,argp)
1813#endif 1857#endif
1814 1858
1859#if !ENABLE_PLATFORM_MINGW32 || ENABLE_FEATURE_EXTRA_FILE_DATA
1815char *is_in_ino_dev_hashtable(const struct stat *statbuf) FAST_FUNC; 1860char *is_in_ino_dev_hashtable(const struct stat *statbuf) FAST_FUNC;
1816void add_to_ino_dev_hashtable(const struct stat *statbuf, const char *name) FAST_FUNC; 1861void add_to_ino_dev_hashtable(const struct stat *statbuf, const char *name) FAST_FUNC;
1817void reset_ino_dev_hashtable(void) FAST_FUNC; 1862void reset_ino_dev_hashtable(void) FAST_FUNC;
1863#else
1864#define add_to_ino_dev_hashtable(s, n) (void)0
1865#define is_in_ino_dev_hashtable(s) NULL
1866#define reset_ino_dev_hashtable()
1867#endif
1818#ifdef __GLIBC__ 1868#ifdef __GLIBC__
1819/* At least glibc has horrendously large inline for this, so wrap it */ 1869/* At least glibc has horrendously large inline for this, so wrap it */
1820unsigned long long bb_makedev(unsigned major, unsigned minor) FAST_FUNC; 1870unsigned long long bb_makedev(unsigned major, unsigned minor) FAST_FUNC;
@@ -2012,7 +2062,11 @@ int FAST_FUNC procps_read_smaps(pid_t pid, struct smaprec *total,
2012 void (*cb)(struct smaprec *, void *), void *data); 2062 void (*cb)(struct smaprec *, void *), void *data);
2013 2063
2014typedef struct procps_status_t { 2064typedef struct procps_status_t {
2065#if !ENABLE_PLATFORM_MINGW32
2015 DIR *dir; 2066 DIR *dir;
2067#else
2068 HANDLE snapshot;
2069#endif
2016 IF_FEATURE_SHOW_THREADS(DIR *task_dir;) 2070 IF_FEATURE_SHOW_THREADS(DIR *task_dir;)
2017 uint8_t shift_pages_to_bytes; 2071 uint8_t shift_pages_to_bytes;
2018 uint8_t shift_pages_to_kb; 2072 uint8_t shift_pages_to_kb;
@@ -2246,12 +2300,27 @@ extern const char bb_path_wtmp_file[] ALIGN1;
2246#define bb_path_motd_file "/etc/motd" 2300#define bb_path_motd_file "/etc/motd"
2247 2301
2248#define bb_dev_null "/dev/null" 2302#define bb_dev_null "/dev/null"
2303#if ENABLE_PLATFORM_MINGW32
2304#define bb_busybox_exec_path get_busybox_exec_path()
2305extern char bb_comm[];
2306extern char bb_command_line[];
2307#else
2249extern const char bb_busybox_exec_path[] ALIGN1; 2308extern const char bb_busybox_exec_path[] ALIGN1;
2309#endif
2250/* allow default system PATH to be extended via CFLAGS */ 2310/* allow default system PATH to be extended via CFLAGS */
2251#ifndef BB_ADDITIONAL_PATH 2311#ifndef BB_ADDITIONAL_PATH
2252#define BB_ADDITIONAL_PATH "" 2312#define BB_ADDITIONAL_PATH ""
2253#endif 2313#endif
2314#if !ENABLE_PLATFORM_MINGW32
2254#define BB_PATH_ROOT_PATH "PATH=/sbin:/usr/sbin:/bin:/usr/bin" BB_ADDITIONAL_PATH 2315#define BB_PATH_ROOT_PATH "PATH=/sbin:/usr/sbin:/bin:/usr/bin" BB_ADDITIONAL_PATH
2316#define PATH_SEP ':'
2317#define PATH_SEP_STR ":"
2318#else
2319#define BB_PATH_ROOT_PATH "PATH=/sbin;/usr/sbin;/bin;/usr/bin" BB_ADDITIONAL_PATH
2320#define PATH_SEP ';'
2321#define PATH_SEP_STR ";"
2322extern const char bb_skip_ansi_emulation[] ALIGN1;
2323#endif
2255extern const char bb_PATH_root_path[] ALIGN1; /* BB_PATH_ROOT_PATH */ 2324extern const char bb_PATH_root_path[] ALIGN1; /* BB_PATH_ROOT_PATH */
2256#define bb_default_root_path (bb_PATH_root_path + sizeof("PATH")) 2325#define bb_default_root_path (bb_PATH_root_path + sizeof("PATH"))
2257/* util-linux manpage says /sbin:/bin:/usr/sbin:/usr/bin, 2326/* util-linux manpage says /sbin:/bin:/usr/sbin:/usr/bin,