diff options
Diffstat (limited to 'include/libbb.h')
-rw-r--r-- | include/libbb.h | 75 |
1 files changed, 73 insertions, 2 deletions
diff --git a/include/libbb.h b/include/libbb.h index 135d9111d..c4734e86d 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -143,6 +143,12 @@ | |||
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 | # ifndef WINVER | ||
148 | # define WINVER 0x0501 | ||
149 | # endif | ||
150 | # include <winsock2.h> | ||
151 | # include <ws2tcpip.h> | ||
146 | #else | 152 | #else |
147 | # include <arpa/inet.h> | 153 | # include <arpa/inet.h> |
148 | //This breaks on bionic: | 154 | //This breaks on bionic: |
@@ -182,7 +188,9 @@ | |||
182 | 188 | ||
183 | /* Some libc's forget to declare these, do it ourself */ | 189 | /* Some libc's forget to declare these, do it ourself */ |
184 | 190 | ||
191 | #if !ENABLE_PLATFORM_MINGW32 | ||
185 | extern char **environ; | 192 | extern char **environ; |
193 | #endif | ||
186 | /* klogctl is in libc's klog.h, but we cheat and not #include that */ | 194 | /* klogctl is in libc's klog.h, but we cheat and not #include that */ |
187 | int klogctl(int type, char *b, int len); | 195 | int klogctl(int type, char *b, int len); |
188 | #ifndef PATH_MAX | 196 | #ifndef PATH_MAX |
@@ -192,6 +200,12 @@ int klogctl(int type, char *b, int len); | |||
192 | # define BUFSIZ 4096 | 200 | # define BUFSIZ 4096 |
193 | #endif | 201 | #endif |
194 | 202 | ||
203 | #if ENABLE_PLATFORM_MINGW32 | ||
204 | # include "mingw.h" | ||
205 | # define MINGW_SPECIAL(a) mingw_ ## a | ||
206 | #else | ||
207 | # define MINGW_SPECIAL(a) a | ||
208 | #endif | ||
195 | 209 | ||
196 | /* Busybox does not use threads, we can speed up stdio. */ | 210 | /* Busybox does not use threads, we can speed up stdio. */ |
197 | #ifdef HAVE_UNLOCKED_STDIO | 211 | #ifdef HAVE_UNLOCKED_STDIO |
@@ -254,6 +268,13 @@ PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN | |||
254 | : ((T)1 << (sizeof(T)*8-1)) \ | 268 | : ((T)1 << (sizeof(T)*8-1)) \ |
255 | ) | 269 | ) |
256 | 270 | ||
271 | #if ENABLE_PLATFORM_MINGW32 && \ | ||
272 | (!defined(__USE_MINGW_ANSI_STDIO) || !__USE_MINGW_ANSI_STDIO) | ||
273 | #define LL_FMT "I64" | ||
274 | #else | ||
275 | #define LL_FMT "ll" | ||
276 | #endif | ||
277 | |||
257 | /* Large file support */ | 278 | /* Large file support */ |
258 | /* Note that CONFIG_LFS=y forces bbox to be built with all common ops | 279 | /* Note that CONFIG_LFS=y forces bbox to be built with all common ops |
259 | * (stat, lseek etc) mapped to "largefile" variants by libc. | 280 | * (stat, lseek etc) mapped to "largefile" variants by libc. |
@@ -279,7 +300,7 @@ typedef unsigned long long uoff_t; | |||
279 | # define XATOOFF(a) xatoull_range((a), 0, LLONG_MAX) | 300 | # define XATOOFF(a) xatoull_range((a), 0, LLONG_MAX) |
280 | # define BB_STRTOOFF bb_strtoull | 301 | # define BB_STRTOOFF bb_strtoull |
281 | # define STRTOOFF strtoull | 302 | # define STRTOOFF strtoull |
282 | # define OFF_FMT "ll" | 303 | # define OFF_FMT LL_FMT |
283 | # endif | 304 | # endif |
284 | #else | 305 | #else |
285 | /* CONFIG_LFS is off */ | 306 | /* CONFIG_LFS is off */ |
@@ -553,20 +574,37 @@ enum { | |||
553 | * Dance around with long long to guard against that... | 574 | * Dance around with long long to guard against that... |
554 | */ | 575 | */ |
555 | BB_FATAL_SIGS = (int)(0 | 576 | BB_FATAL_SIGS = (int)(0 |
577 | #ifdef SIGHUP | ||
556 | + (1LL << SIGHUP) | 578 | + (1LL << SIGHUP) |
579 | #endif | ||
557 | + (1LL << SIGINT) | 580 | + (1LL << SIGINT) |
558 | + (1LL << SIGTERM) | 581 | + (1LL << SIGTERM) |
559 | + (1LL << SIGPIPE) // Write to pipe with no readers | 582 | + (1LL << SIGPIPE) // Write to pipe with no readers |
583 | #ifdef SIGQUIT | ||
560 | + (1LL << SIGQUIT) // Quit from keyboard | 584 | + (1LL << SIGQUIT) // Quit from keyboard |
585 | #endif | ||
561 | + (1LL << SIGABRT) // Abort signal from abort(3) | 586 | + (1LL << SIGABRT) // Abort signal from abort(3) |
587 | #ifdef SIGALRM | ||
562 | + (1LL << SIGALRM) // Timer signal from alarm(2) | 588 | + (1LL << SIGALRM) // Timer signal from alarm(2) |
589 | #endif | ||
590 | #ifdef SIGVTALRM | ||
563 | + (1LL << SIGVTALRM) // Virtual alarm clock | 591 | + (1LL << SIGVTALRM) // Virtual alarm clock |
592 | #endif | ||
593 | #ifdef SIGXCPU | ||
564 | + (1LL << SIGXCPU) // CPU time limit exceeded | 594 | + (1LL << SIGXCPU) // CPU time limit exceeded |
595 | #endif | ||
596 | #ifdef SIGXFSZ | ||
565 | + (1LL << SIGXFSZ) // File size limit exceeded | 597 | + (1LL << SIGXFSZ) // File size limit exceeded |
598 | #endif | ||
599 | #ifdef SIGUSR1 | ||
566 | + (1LL << SIGUSR1) // Yes kids, these are also fatal! | 600 | + (1LL << SIGUSR1) // Yes kids, these are also fatal! |
601 | #endif | ||
602 | #ifdef SIGUSR1 | ||
567 | + (1LL << SIGUSR2) | 603 | + (1LL << SIGUSR2) |
604 | #endif | ||
568 | + 0), | 605 | + 0), |
569 | }; | 606 | }; |
607 | #if !ENABLE_PLATFORM_MINGW32 | ||
570 | void bb_signals(int sigs, void (*f)(int)) FAST_FUNC; | 608 | void bb_signals(int sigs, void (*f)(int)) FAST_FUNC; |
571 | /* Unlike signal() and bb_signals, sets handler with sigaction() | 609 | /* Unlike signal() and bb_signals, sets handler with sigaction() |
572 | * and in a way that while signal handler is run, no other signals | 610 | * and in a way that while signal handler is run, no other signals |
@@ -586,6 +624,10 @@ int sigaction_set(int sig, const struct sigaction *act) FAST_FUNC; | |||
586 | int sigprocmask_allsigs(int how) FAST_FUNC; | 624 | int sigprocmask_allsigs(int how) FAST_FUNC; |
587 | /* Return old set in the same set: */ | 625 | /* Return old set in the same set: */ |
588 | int sigprocmask2(int how, sigset_t *set) FAST_FUNC; | 626 | int sigprocmask2(int how, sigset_t *set) FAST_FUNC; |
627 | #else | ||
628 | #define bb_signals(s, f) | ||
629 | #define kill_myself_with_sig(s) | ||
630 | #endif | ||
589 | /* Standard handler which just records signo */ | 631 | /* Standard handler which just records signo */ |
590 | extern smallint bb_got_signal; | 632 | extern smallint bb_got_signal; |
591 | void record_signo(int signo); /* not FAST_FUNC! */ | 633 | void record_signo(int signo); /* not FAST_FUNC! */ |
@@ -668,7 +710,7 @@ void xsettimeofday(const struct timeval *tv) FAST_FUNC; | |||
668 | int xsocket(int domain, int type, int protocol) FAST_FUNC; | 710 | int xsocket(int domain, int type, int protocol) FAST_FUNC; |
669 | void xbind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen) FAST_FUNC; | 711 | void xbind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen) FAST_FUNC; |
670 | void xlisten(int s, int backlog) FAST_FUNC; | 712 | void xlisten(int s, int backlog) FAST_FUNC; |
671 | void xconnect(int s, const struct sockaddr *s_addr, socklen_t addrlen) FAST_FUNC; | 713 | void xconnect(int s, const struct sockaddr *saddr, socklen_t addrlen) FAST_FUNC; |
672 | ssize_t xsendto(int s, const void *buf, size_t len, const struct sockaddr *to, | 714 | ssize_t xsendto(int s, const void *buf, size_t len, const struct sockaddr *to, |
673 | socklen_t tolen) FAST_FUNC; | 715 | socklen_t tolen) FAST_FUNC; |
674 | 716 | ||
@@ -1177,6 +1219,7 @@ void BB_EXECVP_or_die(char **argv) NORETURN FAST_FUNC; | |||
1177 | 1219 | ||
1178 | /* xvfork() can't be a _function_, return after vfork in child mangles stack | 1220 | /* xvfork() can't be a _function_, return after vfork in child mangles stack |
1179 | * in the parent. It must be a macro. */ | 1221 | * in the parent. It must be a macro. */ |
1222 | #if !ENABLE_PLATFORM_MINGW32 | ||
1180 | #define xvfork() \ | 1223 | #define xvfork() \ |
1181 | ({ \ | 1224 | ({ \ |
1182 | pid_t bb__xvfork_pid = vfork(); \ | 1225 | pid_t bb__xvfork_pid = vfork(); \ |
@@ -1184,6 +1227,9 @@ void BB_EXECVP_or_die(char **argv) NORETURN FAST_FUNC; | |||
1184 | bb_simple_perror_msg_and_die("vfork"); \ | 1227 | bb_simple_perror_msg_and_die("vfork"); \ |
1185 | bb__xvfork_pid; \ | 1228 | bb__xvfork_pid; \ |
1186 | }) | 1229 | }) |
1230 | #else | ||
1231 | #define xvfork() vfork() | ||
1232 | #endif | ||
1187 | #if BB_MMU | 1233 | #if BB_MMU |
1188 | pid_t xfork(void) FAST_FUNC; | 1234 | pid_t xfork(void) FAST_FUNC; |
1189 | #endif | 1235 | #endif |
@@ -1778,9 +1824,15 @@ int bb_xioctl(int fd, unsigned request, void *argp) FAST_FUNC; | |||
1778 | #define xioctl(fd,request,argp) bb_xioctl(fd,request,argp) | 1824 | #define xioctl(fd,request,argp) bb_xioctl(fd,request,argp) |
1779 | #endif | 1825 | #endif |
1780 | 1826 | ||
1827 | #if !ENABLE_PLATFORM_MINGW32 || ENABLE_FEATURE_EXTRA_FILE_DATA | ||
1781 | char *is_in_ino_dev_hashtable(const struct stat *statbuf) FAST_FUNC; | 1828 | char *is_in_ino_dev_hashtable(const struct stat *statbuf) FAST_FUNC; |
1782 | void add_to_ino_dev_hashtable(const struct stat *statbuf, const char *name) FAST_FUNC; | 1829 | void add_to_ino_dev_hashtable(const struct stat *statbuf, const char *name) FAST_FUNC; |
1783 | void reset_ino_dev_hashtable(void) FAST_FUNC; | 1830 | void reset_ino_dev_hashtable(void) FAST_FUNC; |
1831 | #else | ||
1832 | #define add_to_ino_dev_hashtable(s, n) (void)0 | ||
1833 | #define is_in_ino_dev_hashtable(s) NULL | ||
1834 | #define reset_ino_dev_hashtable() | ||
1835 | #endif | ||
1784 | #ifdef __GLIBC__ | 1836 | #ifdef __GLIBC__ |
1785 | /* At least glibc has horrendously large inline for this, so wrap it */ | 1837 | /* At least glibc has horrendously large inline for this, so wrap it */ |
1786 | unsigned long long bb_makedev(unsigned major, unsigned minor) FAST_FUNC; | 1838 | unsigned long long bb_makedev(unsigned major, unsigned minor) FAST_FUNC; |
@@ -1978,7 +2030,11 @@ int FAST_FUNC procps_read_smaps(pid_t pid, struct smaprec *total, | |||
1978 | void (*cb)(struct smaprec *, void *), void *data); | 2030 | void (*cb)(struct smaprec *, void *), void *data); |
1979 | 2031 | ||
1980 | typedef struct procps_status_t { | 2032 | typedef struct procps_status_t { |
2033 | #if !ENABLE_PLATFORM_MINGW32 | ||
1981 | DIR *dir; | 2034 | DIR *dir; |
2035 | #else | ||
2036 | HANDLE snapshot; | ||
2037 | #endif | ||
1982 | IF_FEATURE_SHOW_THREADS(DIR *task_dir;) | 2038 | IF_FEATURE_SHOW_THREADS(DIR *task_dir;) |
1983 | uint8_t shift_pages_to_bytes; | 2039 | uint8_t shift_pages_to_bytes; |
1984 | uint8_t shift_pages_to_kb; | 2040 | uint8_t shift_pages_to_kb; |
@@ -2212,12 +2268,27 @@ extern const char bb_path_wtmp_file[] ALIGN1; | |||
2212 | #define bb_path_motd_file "/etc/motd" | 2268 | #define bb_path_motd_file "/etc/motd" |
2213 | 2269 | ||
2214 | #define bb_dev_null "/dev/null" | 2270 | #define bb_dev_null "/dev/null" |
2271 | #if ENABLE_PLATFORM_MINGW32 | ||
2272 | #define bb_busybox_exec_path get_busybox_exec_path() | ||
2273 | extern char bb_comm[]; | ||
2274 | extern char bb_command_line[]; | ||
2275 | #else | ||
2215 | extern const char bb_busybox_exec_path[] ALIGN1; | 2276 | extern const char bb_busybox_exec_path[] ALIGN1; |
2277 | #endif | ||
2216 | /* allow default system PATH to be extended via CFLAGS */ | 2278 | /* allow default system PATH to be extended via CFLAGS */ |
2217 | #ifndef BB_ADDITIONAL_PATH | 2279 | #ifndef BB_ADDITIONAL_PATH |
2218 | #define BB_ADDITIONAL_PATH "" | 2280 | #define BB_ADDITIONAL_PATH "" |
2219 | #endif | 2281 | #endif |
2282 | #if !ENABLE_PLATFORM_MINGW32 | ||
2220 | #define BB_PATH_ROOT_PATH "PATH=/sbin:/usr/sbin:/bin:/usr/bin" BB_ADDITIONAL_PATH | 2283 | #define BB_PATH_ROOT_PATH "PATH=/sbin:/usr/sbin:/bin:/usr/bin" BB_ADDITIONAL_PATH |
2284 | #define PATH_SEP ':' | ||
2285 | #define PATH_SEP_STR ":" | ||
2286 | #else | ||
2287 | #define BB_PATH_ROOT_PATH "PATH=/sbin;/usr/sbin;/bin;/usr/bin" BB_ADDITIONAL_PATH | ||
2288 | #define PATH_SEP ';' | ||
2289 | #define PATH_SEP_STR ";" | ||
2290 | extern const char bb_skip_ansi_emulation[] ALIGN1; | ||
2291 | #endif | ||
2221 | extern const char bb_PATH_root_path[] ALIGN1; /* BB_PATH_ROOT_PATH */ | 2292 | extern const char bb_PATH_root_path[] ALIGN1; /* BB_PATH_ROOT_PATH */ |
2222 | #define bb_default_root_path (bb_PATH_root_path + sizeof("PATH")) | 2293 | #define bb_default_root_path (bb_PATH_root_path + sizeof("PATH")) |
2223 | /* util-linux manpage says /sbin:/bin:/usr/sbin:/usr/bin, | 2294 | /* util-linux manpage says /sbin:/bin:/usr/sbin:/usr/bin, |