diff options
Diffstat (limited to 'include/libbb.h')
-rw-r--r-- | include/libbb.h | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/include/libbb.h b/include/libbb.h index abdc8c2b8..0b9cfb585 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -138,6 +138,12 @@ | |||
138 | # include <arpa/inet.h> | 138 | # include <arpa/inet.h> |
139 | #elif defined __APPLE__ | 139 | #elif defined __APPLE__ |
140 | # include <netinet/in.h> | 140 | # include <netinet/in.h> |
141 | #elif ENABLE_PLATFORM_MINGW32 | ||
142 | # ifndef WINVER | ||
143 | # define WINVER 0x0501 | ||
144 | # endif | ||
145 | # include <winsock2.h> | ||
146 | # include <ws2tcpip.h> | ||
141 | #else | 147 | #else |
142 | # include <arpa/inet.h> | 148 | # include <arpa/inet.h> |
143 | //This breaks on bionic: | 149 | //This breaks on bionic: |
@@ -166,7 +172,9 @@ | |||
166 | 172 | ||
167 | /* Some libc's forget to declare these, do it ourself */ | 173 | /* Some libc's forget to declare these, do it ourself */ |
168 | 174 | ||
175 | #if !ENABLE_PLATFORM_MINGW32 | ||
169 | extern char **environ; | 176 | extern char **environ; |
177 | #endif | ||
170 | #if defined(__GLIBC__) && __GLIBC__ < 2 | 178 | #if defined(__GLIBC__) && __GLIBC__ < 2 |
171 | int vdprintf(int d, const char *format, va_list ap); | 179 | int vdprintf(int d, const char *format, va_list ap); |
172 | #endif | 180 | #endif |
@@ -179,6 +187,9 @@ int klogctl(int type, char *b, int len); | |||
179 | # define BUFSIZ 4096 | 187 | # define BUFSIZ 4096 |
180 | #endif | 188 | #endif |
181 | 189 | ||
190 | #if ENABLE_PLATFORM_MINGW32 | ||
191 | # include "mingw.h" | ||
192 | #endif | ||
182 | 193 | ||
183 | /* Busybox does not use threads, we can speed up stdio. */ | 194 | /* Busybox does not use threads, we can speed up stdio. */ |
184 | #ifdef HAVE_UNLOCKED_STDIO | 195 | #ifdef HAVE_UNLOCKED_STDIO |
@@ -490,6 +501,7 @@ enum { | |||
490 | + (1LL << SIGUSR2) | 501 | + (1LL << SIGUSR2) |
491 | + 0), | 502 | + 0), |
492 | }; | 503 | }; |
504 | #if !ENABLE_PLATFORM_MINGW32 | ||
493 | void bb_signals(int sigs, void (*f)(int)) FAST_FUNC; | 505 | void bb_signals(int sigs, void (*f)(int)) FAST_FUNC; |
494 | /* Unlike signal() and bb_signals, sets handler with sigaction() | 506 | /* Unlike signal() and bb_signals, sets handler with sigaction() |
495 | * and in a way that while signal handler is run, no other signals | 507 | * and in a way that while signal handler is run, no other signals |
@@ -507,6 +519,10 @@ void sig_unblock(int sig) FAST_FUNC; | |||
507 | int sigaction_set(int sig, const struct sigaction *act) FAST_FUNC; | 519 | int sigaction_set(int sig, const struct sigaction *act) FAST_FUNC; |
508 | /* SIG_BLOCK/SIG_UNBLOCK all signals: */ | 520 | /* SIG_BLOCK/SIG_UNBLOCK all signals: */ |
509 | int sigprocmask_allsigs(int how) FAST_FUNC; | 521 | int sigprocmask_allsigs(int how) FAST_FUNC; |
522 | #else | ||
523 | #define bb_signals(s, f) | ||
524 | #define kill_myself_with_sig(s) | ||
525 | #endif | ||
510 | /* Standard handler which just records signo */ | 526 | /* Standard handler which just records signo */ |
511 | extern smallint bb_got_signal; | 527 | extern smallint bb_got_signal; |
512 | void record_signo(int signo); /* not FAST_FUNC! */ | 528 | void record_signo(int signo); /* not FAST_FUNC! */ |
@@ -586,7 +602,7 @@ char *strftime_YYYYMMDDHHMMSS(char *buf, unsigned len, time_t *tp) FAST_FUNC; | |||
586 | int xsocket(int domain, int type, int protocol) FAST_FUNC; | 602 | int xsocket(int domain, int type, int protocol) FAST_FUNC; |
587 | void xbind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen) FAST_FUNC; | 603 | void xbind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen) FAST_FUNC; |
588 | void xlisten(int s, int backlog) FAST_FUNC; | 604 | void xlisten(int s, int backlog) FAST_FUNC; |
589 | void xconnect(int s, const struct sockaddr *s_addr, socklen_t addrlen) FAST_FUNC; | 605 | void xconnect(int s, const struct sockaddr *saddr, socklen_t addrlen) FAST_FUNC; |
590 | ssize_t xsendto(int s, const void *buf, size_t len, const struct sockaddr *to, | 606 | ssize_t xsendto(int s, const void *buf, size_t len, const struct sockaddr *to, |
591 | socklen_t tolen) FAST_FUNC; | 607 | socklen_t tolen) FAST_FUNC; |
592 | 608 | ||
@@ -890,6 +906,9 @@ char *safe_gethostname(void) FAST_FUNC; | |||
890 | char* str_tolower(char *str) FAST_FUNC; | 906 | char* str_tolower(char *str) FAST_FUNC; |
891 | 907 | ||
892 | char *utoa(unsigned n) FAST_FUNC; | 908 | char *utoa(unsigned n) FAST_FUNC; |
909 | #if ENABLE_PLATFORM_MINGW32 | ||
910 | # define itoa bb_itoa | ||
911 | #endif | ||
893 | char *itoa(int n) FAST_FUNC; | 912 | char *itoa(int n) FAST_FUNC; |
894 | /* Returns a pointer past the formatted number, does NOT null-terminate */ | 913 | /* Returns a pointer past the formatted number, does NOT null-terminate */ |
895 | char *utoa_to_buf(unsigned n, char *buf, unsigned buflen) FAST_FUNC; | 914 | char *utoa_to_buf(unsigned n, char *buf, unsigned buflen) FAST_FUNC; |
@@ -1664,6 +1683,9 @@ typedef struct procps_status_t { | |||
1664 | #if ENABLE_FEATURE_TOP_SMP_PROCESS | 1683 | #if ENABLE_FEATURE_TOP_SMP_PROCESS |
1665 | int last_seen_on_cpu; | 1684 | int last_seen_on_cpu; |
1666 | #endif | 1685 | #endif |
1686 | #if ENABLE_PLATFORM_MINGW32 | ||
1687 | HANDLE snapshot; | ||
1688 | #endif | ||
1667 | } procps_status_t; | 1689 | } procps_status_t; |
1668 | /* flag bits for procps_scan(xx, flags) calls */ | 1690 | /* flag bits for procps_scan(xx, flags) calls */ |
1669 | enum { | 1691 | enum { |
@@ -1702,7 +1724,11 @@ void free_procps_scan(procps_status_t* sp) FAST_FUNC; | |||
1702 | procps_status_t* procps_scan(procps_status_t* sp, int flags) FAST_FUNC; | 1724 | procps_status_t* procps_scan(procps_status_t* sp, int flags) FAST_FUNC; |
1703 | /* Format cmdline (up to col chars) into char buf[size] */ | 1725 | /* Format cmdline (up to col chars) into char buf[size] */ |
1704 | /* Puts [comm] if cmdline is empty (-> process is a kernel thread) */ | 1726 | /* Puts [comm] if cmdline is empty (-> process is a kernel thread) */ |
1727 | #if !ENABLE_PLATFORM_MINGW32 | ||
1705 | void read_cmdline(char *buf, int size, unsigned pid, const char *comm) FAST_FUNC; | 1728 | void read_cmdline(char *buf, int size, unsigned pid, const char *comm) FAST_FUNC; |
1729 | #else | ||
1730 | #define read_cmdline(buf, size, pid, comm) snprintf(buf, size, "[%s]", comm) | ||
1731 | #endif | ||
1706 | pid_t *find_pid_by_name(const char* procName) FAST_FUNC; | 1732 | pid_t *find_pid_by_name(const char* procName) FAST_FUNC; |
1707 | pid_t *pidlist_reverse(pid_t *pidList) FAST_FUNC; | 1733 | pid_t *pidlist_reverse(pid_t *pidList) FAST_FUNC; |
1708 | int starts_with_cpu(const char *str) FAST_FUNC; | 1734 | int starts_with_cpu(const char *str) FAST_FUNC; |
@@ -1842,7 +1868,11 @@ extern const char bb_path_wtmp_file[] ALIGN1; | |||
1842 | #define bb_path_motd_file "/etc/motd" | 1868 | #define bb_path_motd_file "/etc/motd" |
1843 | 1869 | ||
1844 | #define bb_dev_null "/dev/null" | 1870 | #define bb_dev_null "/dev/null" |
1871 | #if ENABLE_PLATFORM_MINGW32 | ||
1872 | #define bb_busybox_exec_path get_busybox_exec_path() | ||
1873 | #else | ||
1845 | extern const char bb_busybox_exec_path[] ALIGN1; | 1874 | extern const char bb_busybox_exec_path[] ALIGN1; |
1875 | #endif | ||
1846 | /* util-linux manpage says /sbin:/bin:/usr/sbin:/usr/bin, | 1876 | /* util-linux manpage says /sbin:/bin:/usr/sbin:/usr/bin, |
1847 | * but I want to save a few bytes here */ | 1877 | * but I want to save a few bytes here */ |
1848 | extern const char bb_PATH_root_path[] ALIGN1; /* "PATH=/sbin:/usr/sbin:/bin:/usr/bin" */ | 1878 | extern const char bb_PATH_root_path[] ALIGN1; /* "PATH=/sbin:/usr/sbin:/bin:/usr/bin" */ |