summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--include/libbb.h27
-rw-r--r--include/mingw.h438
-rw-r--r--include/platform.h40
3 files changed, 504 insertions, 1 deletions
diff --git a/include/libbb.h b/include/libbb.h
index 68a7cf002..2850b1d5a 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -112,6 +112,13 @@
112# include <arpa/inet.h> 112# include <arpa/inet.h>
113#elif defined __APPLE__ 113#elif defined __APPLE__
114# include <netinet/in.h> 114# include <netinet/in.h>
115#elif ENABLE_PLATFORM_MINGW32
116# ifndef WINVER
117# define WINVER 0x0501
118# endif
119# include <winsock2.h>
120# include <ws2tcpip.h>
121# undef s_addr
115#else 122#else
116# include <arpa/inet.h> 123# include <arpa/inet.h>
117# if !defined(__socklen_t_defined) && !defined(_SOCKLEN_T_DECLARED) 124# if !defined(__socklen_t_defined) && !defined(_SOCKLEN_T_DECLARED)
@@ -136,7 +143,9 @@
136 143
137/* Some libc's forget to declare these, do it ourself */ 144/* Some libc's forget to declare these, do it ourself */
138 145
146#if !ENABLE_PLATFORM_MINGW32
139extern char **environ; 147extern char **environ;
148#endif
140#if defined(__GLIBC__) && __GLIBC__ < 2 149#if defined(__GLIBC__) && __GLIBC__ < 2
141int vdprintf(int d, const char *format, va_list ap); 150int vdprintf(int d, const char *format, va_list ap);
142#endif 151#endif
@@ -149,6 +158,10 @@ int klogctl(int type, char *b, int len);
149# define BUFSIZ 4096 158# define BUFSIZ 4096
150#endif 159#endif
151 160
161/* Can't use ENABLE_PLATFORM_MINGW32 because it's also called by host compiler */
162#if ENABLE_PLATFORM_MINGW32
163# include "mingw.h"
164#endif
152 165
153/* Busybox does not use threads, we can speed up stdio. */ 166/* Busybox does not use threads, we can speed up stdio. */
154#ifdef HAVE_UNLOCKED_STDIO 167#ifdef HAVE_UNLOCKED_STDIO
@@ -830,6 +843,9 @@ char *safe_gethostname(void) FAST_FUNC;
830char* str_tolower(char *str) FAST_FUNC; 843char* str_tolower(char *str) FAST_FUNC;
831 844
832char *utoa(unsigned n) FAST_FUNC; 845char *utoa(unsigned n) FAST_FUNC;
846#if ENABLE_PLATFORM_MINGW32
847# define itoa bb_itoa
848#endif
833char *itoa(int n) FAST_FUNC; 849char *itoa(int n) FAST_FUNC;
834/* Returns a pointer past the formatted number, does NOT null-terminate */ 850/* Returns a pointer past the formatted number, does NOT null-terminate */
835char *utoa_to_buf(unsigned n, char *buf, unsigned buflen) FAST_FUNC; 851char *utoa_to_buf(unsigned n, char *buf, unsigned buflen) FAST_FUNC;
@@ -1596,6 +1612,9 @@ typedef struct procps_status_t {
1596#if ENABLE_FEATURE_TOP_SMP_PROCESS 1612#if ENABLE_FEATURE_TOP_SMP_PROCESS
1597 int last_seen_on_cpu; 1613 int last_seen_on_cpu;
1598#endif 1614#endif
1615#if ENABLE_PLATFORM_MINGW32
1616 HANDLE snapshot;
1617#endif
1599} procps_status_t; 1618} procps_status_t;
1600/* flag bits for procps_scan(xx, flags) calls */ 1619/* flag bits for procps_scan(xx, flags) calls */
1601enum { 1620enum {
@@ -1634,7 +1653,11 @@ void free_procps_scan(procps_status_t* sp) FAST_FUNC;
1634procps_status_t* procps_scan(procps_status_t* sp, int flags) FAST_FUNC; 1653procps_status_t* procps_scan(procps_status_t* sp, int flags) FAST_FUNC;
1635/* Format cmdline (up to col chars) into char buf[size] */ 1654/* Format cmdline (up to col chars) into char buf[size] */
1636/* Puts [comm] if cmdline is empty (-> process is a kernel thread) */ 1655/* Puts [comm] if cmdline is empty (-> process is a kernel thread) */
1656#if !ENABLE_PLATFORM_MINGW32
1637void read_cmdline(char *buf, int size, unsigned pid, const char *comm) FAST_FUNC; 1657void read_cmdline(char *buf, int size, unsigned pid, const char *comm) FAST_FUNC;
1658#else
1659#define read_cmdline(buf, size, pid, comm) snprintf(buf, size, "[%s]", comm)
1660#endif
1638pid_t *find_pid_by_name(const char* procName) FAST_FUNC; 1661pid_t *find_pid_by_name(const char* procName) FAST_FUNC;
1639pid_t *pidlist_reverse(pid_t *pidList) FAST_FUNC; 1662pid_t *pidlist_reverse(pid_t *pidList) FAST_FUNC;
1640int starts_with_cpu(const char *str) FAST_FUNC; 1663int starts_with_cpu(const char *str) FAST_FUNC;
@@ -1770,7 +1793,11 @@ extern const char bb_path_wtmp_file[] ALIGN1;
1770#define bb_path_motd_file "/etc/motd" 1793#define bb_path_motd_file "/etc/motd"
1771 1794
1772#define bb_dev_null "/dev/null" 1795#define bb_dev_null "/dev/null"
1796#if ENABLE_PLATFORM_MINGW32
1797#define bb_busybox_exec_path get_busybox_exec_path()
1798#else
1773extern const char bb_busybox_exec_path[] ALIGN1; 1799extern const char bb_busybox_exec_path[] ALIGN1;
1800#endif
1774/* util-linux manpage says /sbin:/bin:/usr/sbin:/usr/bin, 1801/* util-linux manpage says /sbin:/bin:/usr/sbin:/usr/bin,
1775 * but I want to save a few bytes here */ 1802 * but I want to save a few bytes here */
1776extern const char bb_PATH_root_path[] ALIGN1; /* "PATH=/sbin:/usr/sbin:/bin:/usr/bin" */ 1803extern const char bb_PATH_root_path[] ALIGN1; /* "PATH=/sbin:/usr/sbin:/bin:/usr/bin" */
diff --git a/include/mingw.h b/include/mingw.h
new file mode 100644
index 000000000..090dd1776
--- /dev/null
+++ b/include/mingw.h
@@ -0,0 +1,438 @@
1
2#define NOIMPL(name,...) static inline int name(__VA_ARGS__) { errno = ENOSYS; return -1; }
3#define IMPL(name,ret,retval,...) static inline ret name(__VA_ARGS__) { return retval; }
4
5/*
6 * sys/types.h
7 */
8typedef int gid_t;
9typedef int uid_t;
10#ifndef _WIN64
11typedef int pid_t;
12#else
13typedef __int64 pid_t;
14#endif
15
16/*
17 * arpa/inet.h
18 */
19static inline unsigned int git_ntohl(unsigned int x) { return (unsigned int)ntohl(x); }
20#define ntohl git_ntohl
21int inet_aton(const char *cp, struct in_addr *inp);
22
23/*
24 * fcntl.h
25 */
26#define F_DUPFD 0
27#define F_GETFD 1
28#define F_SETFD 2
29#define F_GETFL 3
30#define F_SETFL 3
31#define FD_CLOEXEC 0x1
32#define O_NONBLOCK 04000
33
34/*
35 * grp.h
36 */
37
38struct group {
39 char *gr_name;
40 char *gr_passwd;
41 gid_t gr_gid;
42 char **gr_mem;
43};
44IMPL(getgrnam,struct group *,NULL,const char *name UNUSED_PARAM);
45IMPL(getgrgid,struct group *,NULL,gid_t gid UNUSED_PARAM);
46NOIMPL(initgroups,const char *group UNUSED_PARAM,gid_t gid UNUSED_PARAM);
47static inline void endgrent(void) {}
48
49/*
50 * limits.h
51 */
52#define NAME_MAX 255
53#define MAXSYMLINKS 20
54
55/*
56 * netdb.h
57 */
58
59typedef int sa_family_t;
60
61/*
62 * linux/un.h
63 */
64struct sockaddr_un {
65 sa_family_t sun_family;
66 char sun_path[1]; /* to make compiler happy, don't bother */
67};
68
69/*
70 * pwd.h
71 */
72struct passwd {
73 char *pw_name;
74 char *pw_gecos;
75 char *pw_dir;
76 char *pw_shell;
77 uid_t pw_uid;
78 gid_t pw_gid;
79};
80
81IMPL(getpwnam,struct passwd *,NULL,const char *name UNUSED_PARAM);
82struct passwd *getpwuid(int uid);
83static inline void setpwent(void) {}
84static inline void endpwent(void) {}
85IMPL(getpwent_r,int,ENOENT,struct passwd *pwbuf UNUSED_PARAM,char *buf UNUSED_PARAM,size_t buflen UNUSED_PARAM,struct passwd **pwbufp UNUSED_PARAM);
86
87/*
88 * signal.h
89 */
90#define SIGHUP 1
91#define SIGQUIT 3
92#define SIGKILL 9
93#define SIGUSR1 10
94#define SIGUSR2 12
95#define SIGPIPE 13
96#define SIGALRM 14
97#define SIGCHLD 17
98#define SIGCONT 18
99#define SIGSTOP 19
100#define SIGTSTP 20
101#define SIGTTIN 21
102#define SIGTTOU 22
103#define SIGXCPU 24
104#define SIGXFSZ 25
105#define SIGVTALRM 26
106#define SIGWINCH 28
107
108#define SIG_UNBLOCK 1
109
110typedef void (__cdecl *sighandler_t)(int);
111struct sigaction {
112 sighandler_t sa_handler;
113 unsigned sa_flags;
114 int sa_mask;
115};
116#define sigemptyset(x) (void)0
117#define SA_RESTART 0
118
119int sigaction(int sig, struct sigaction *in, struct sigaction *out);
120sighandler_t mingw_signal(int sig, sighandler_t handler);
121NOIMPL(sigfillset,int *mask UNUSED_PARAM);
122NOIMPL(FAST_FUNC sigprocmask_allsigs, int how UNUSED_PARAM);
123NOIMPL(FAST_FUNC sigaction_set,int signo UNUSED_PARAM, const struct sigaction *sa UNUSED_PARAM);
124
125#define signal mingw_signal
126/*
127 * stdio.h
128 */
129#undef fseeko
130#define fseeko(f,o,w) fseek(f,o,w)
131
132int fdprintf(int fd, const char *format, ...);
133FILE* mingw_fopen(const char *filename, const char *mode);
134int mingw_rename(const char*, const char*);
135#define fopen mingw_fopen
136#define rename mingw_rename
137
138FILE *mingw_popen(const char *cmd, const char *mode);
139int mingw_pclose(FILE *fd);
140#undef popen
141#undef pclose
142#define popen mingw_popen
143#define pclose mingw_pclose
144
145#define setlinebuf(fd) setvbuf(fd, (char *) NULL, _IOLBF, 0)
146
147/*
148 * ANSI emulation wrappers
149 */
150
151int winansi_putchar(int c);
152int winansi_puts(const char *s);
153size_t winansi_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream);
154int winansi_fputs(const char *str, FILE *stream);
155int winansi_vfprintf(FILE *stream, const char *format, va_list list);
156int winansi_printf(const char *format, ...) __attribute__((format (printf, 1, 2)));
157int winansi_fprintf(FILE *stream, const char *format, ...) __attribute__((format (printf, 2, 3)));
158int winansi_write(int fd, const void *buf, size_t count);
159int winansi_read(int fd, void *buf, size_t count);
160int winansi_getc(FILE *stream);
161#define putchar winansi_putchar
162#define puts winansi_puts
163#define fwrite winansi_fwrite
164#define fputs winansi_fputs
165#define vprintf(...) winansi_vfprintf(stdout, __VA_ARGS__)
166#define printf(...) winansi_printf(__VA_ARGS__)
167#define fprintf(...) winansi_fprintf(__VA_ARGS__)
168#define write winansi_write
169#define read winansi_read
170#define getc winansi_getc
171
172int winansi_get_terminal_width_height(struct winsize *win);
173
174/*
175 * stdlib.h
176 */
177#define WIFEXITED(x) ((unsigned)(x) < 259) /* STILL_ACTIVE */
178#define WEXITSTATUS(x) ((x) & 0xff)
179#define WIFSIGNALED(x) ((unsigned)(x) > 259)
180#define WTERMSIG(x) ((x) & 0x7f)
181#define WCOREDUMP(x) 0
182
183int mingw_system(const char *cmd);
184#define system mingw_system
185
186int clearenv(void);
187char *mingw_getenv(const char *name);
188char *mingw_mktemp(char *template);
189int mkstemp(char *template);
190char *realpath(const char *path, char *resolved_path);
191int setenv(const char *name, const char *value, int replace);
192void unsetenv(const char *env);
193
194#define getenv mingw_getenv
195#define mktemp mingw_mktemp
196
197/*
198 * string.h
199 */
200void *mempcpy(void *dest, const void *src, size_t n);
201
202/*
203 * sys/ioctl.h
204 */
205
206#define TIOCGWINSZ 0x5413
207
208int ioctl(int fd, int code, ...);
209
210/*
211 * sys/socket.h
212 */
213#define hstrerror strerror
214
215int mingw_socket(int domain, int type, int protocol);
216int mingw_connect(int sockfd, struct sockaddr *sa, size_t sz);
217
218NOIMPL(mingw_sendto,SOCKET s UNUSED_PARAM, const char *buf UNUSED_PARAM, int len UNUSED_PARAM, int flags UNUSED_PARAM, const struct sockaddr *sa UNUSED_PARAM, int salen UNUSED_PARAM);
219NOIMPL(mingw_listen,SOCKET s UNUSED_PARAM,int backlog UNUSED_PARAM);
220NOIMPL(mingw_bind,SOCKET s UNUSED_PARAM,const struct sockaddr* sa UNUSED_PARAM,int salen UNUSED_PARAM);
221
222#define socket mingw_socket
223#define connect mingw_connect
224#define sendto mingw_sendto
225#define listen mingw_listen
226#define bind mingw_bind
227
228/*
229 * sys/stat.h
230 */
231#define S_ISUID 04000
232#define S_ISGID 02000
233#define S_ISVTX 01000
234#ifndef S_IRWXU
235#define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
236#endif
237#define S_IRWXG (S_IRWXU >> 3)
238#define S_IRWXO (S_IRWXG >> 3)
239
240#define S_IFSOCK 0140000
241#define S_IFLNK 0120000 /* Symbolic link */
242#define S_ISLNK(x) (((x) & S_IFMT) == S_IFLNK)
243#define S_ISSOCK(x) 0
244
245#define S_IRGRP (S_IRUSR >> 3)
246#define S_IWGRP (S_IWUSR >> 3)
247#define S_IXGRP (S_IXUSR >> 3)
248#define S_IROTH (S_IRGRP >> 3)
249#define S_IWOTH (S_IWGRP >> 3)
250#define S_IXOTH (S_IXGRP >> 3)
251
252IMPL(fchmod,int,0,int fildes UNUSED_PARAM, mode_t mode UNUSED_PARAM);
253NOIMPL(fchown,int fd UNUSED_PARAM, uid_t uid UNUSED_PARAM, gid_t gid UNUSED_PARAM);
254int mingw_mkdir(const char *path, int mode);
255#define mkdir mingw_mkdir
256
257#if ENABLE_LFS
258# define off_t off64_t
259#endif
260#undef lseek
261#define lseek _lseeki64
262
263typedef int nlink_t;
264typedef int blksize_t;
265typedef off_t blkcnt_t;
266
267struct mingw_stat {
268 dev_t st_dev;
269 ino_t st_ino;
270 mode_t st_mode;
271 nlink_t st_nlink;
272 uid_t st_uid;
273 gid_t st_gid;
274 dev_t st_rdev;
275 off_t st_size;
276 time_t st_atime;
277 time_t st_mtime;
278 time_t st_ctime;
279 blksize_t st_blksize;
280 blkcnt_t st_blocks;
281};
282
283int mingw_lstat(const char *file_name, struct mingw_stat *buf);
284int mingw_stat(const char *file_name, struct mingw_stat *buf);
285int mingw_fstat(int fd, struct mingw_stat *buf);
286#undef lstat
287#undef stat
288#undef fstat
289#define lstat mingw_lstat
290#define stat mingw_stat
291#define fstat mingw_fstat
292
293/*
294 * sys/sysmacros.h
295 */
296#define makedev(a,b) 0*(a)*(b) /* avoid unused warning */
297#define minor(x) 0
298#define major(x) 0
299
300/*
301 * sys/time.h
302 */
303#ifndef _TIMESPEC_DEFINED
304#define _TIMESPEC_DEFINED
305struct timespec {
306 time_t tv_sec;
307 long int tv_nsec;
308};
309#endif
310struct itimerval {
311 struct timeval it_value, it_interval;
312};
313#define ITIMER_REAL 0
314
315int setitimer(int type, struct itimerval *in, struct itimerval *out);
316
317/*
318 * sys/wait.h
319 */
320#define WNOHANG 1
321#define WUNTRACED 2
322int waitpid(pid_t pid, int *status, unsigned options);
323
324/*
325 * time.h
326 */
327struct tm *gmtime_r(const time_t *timep, struct tm *result);
328struct tm *localtime_r(const time_t *timep, struct tm *result);
329char *strptime(const char *s, const char *format, struct tm *tm);
330size_t mingw_strftime(char *buf, size_t max, const char *format, const struct tm *tm);
331int stime(time_t *t);
332
333#define strftime mingw_strftime
334
335/*
336 * times.h
337 */
338#define clock_t long
339
340struct tms {
341 clock_t tms_utime; /* user CPU time */
342 clock_t tms_stime; /* system CPU time */
343 clock_t tms_cutime; /* user CPU time of children */
344 clock_t tms_cstime; /* system CPU time of children */
345};
346
347clock_t times(struct tms *buf);
348
349/*
350 * unistd.h
351 */
352#define PIPE_BUF 8192
353
354#define _SC_CLK_TCK 2
355
356IMPL(alarm,unsigned int,0,unsigned int seconds UNUSED_PARAM);
357IMPL(chown,int,0,const char *path UNUSED_PARAM, uid_t uid UNUSED_PARAM, gid_t gid UNUSED_PARAM);
358NOIMPL(chroot,const char *root UNUSED_PARAM);
359int mingw_dup2 (int fd, int fdto);
360char *mingw_getcwd(char *pointer, int len);
361
362
363IMPL(getgid,int,1,void);
364NOIMPL(getgroups,int n UNUSED_PARAM,gid_t *groups UNUSED_PARAM);
365IMPL(getppid,int,1,void);
366IMPL(getegid,int,1,void);
367IMPL(geteuid,int,1,void);
368NOIMPL(getsid,pid_t pid UNUSED_PARAM);
369IMPL(getuid,int,1,void);
370int fcntl(int fd, int cmd, ...);
371#define fork() -1
372IMPL(fsync,int,0,int fd UNUSED_PARAM);
373int kill(pid_t pid, int sig);
374int link(const char *oldpath, const char *newpath);
375NOIMPL(mknod,const char *name UNUSED_PARAM, mode_t mode UNUSED_PARAM, dev_t device UNUSED_PARAM);
376int mingw_open (const char *filename, int oflags, ...);
377int pipe(int filedes[2]);
378NOIMPL(readlink,const char *path UNUSED_PARAM, char *buf UNUSED_PARAM, size_t bufsiz UNUSED_PARAM);
379NOIMPL(setgid,gid_t gid UNUSED_PARAM);
380NOIMPL(setegid,gid_t gid UNUSED_PARAM);
381NOIMPL(setsid,void);
382NOIMPL(setuid,uid_t gid UNUSED_PARAM);
383NOIMPL(seteuid,uid_t gid UNUSED_PARAM);
384unsigned int sleep(unsigned int seconds);
385NOIMPL(symlink,const char *oldpath UNUSED_PARAM, const char *newpath UNUSED_PARAM);
386static inline void sync(void) {}
387long sysconf(int name);
388NOIMPL(ttyname_r,int fd UNUSED_PARAM, char *buf UNUSED_PARAM, int sz UNUSED_PARAM);
389int mingw_unlink(const char *pathname);
390NOIMPL(vfork,void);
391int mingw_access(const char *name, int mode);
392
393#define dup2 mingw_dup2
394#define getcwd mingw_getcwd
395#define lchown chown
396#define open mingw_open
397#define unlink mingw_unlink
398
399#undef access
400#define access mingw_access
401
402/*
403 * utime.h
404 */
405int utimes(const char *file_name, const struct timeval times[2]);
406
407/*
408 * MinGW specific
409 */
410#define is_dir_sep(c) ((c) == '/' || (c) == '\\')
411#define PRIuMAX "I64u"
412
413pid_t mingw_spawn(char **argv);
414int mingw_execv(const char *cmd, const char *const *argv);
415int mingw_execvp(const char *cmd, const char *const *argv);
416int mingw_execve(const char *cmd, const char *const *argv, const char *const *envp);
417pid_t mingw_spawn_applet(int mode, const char *applet, const char *const *argv, const char *const *envp);
418pid_t mingw_spawn_1(int mode, const char *cmd, const char *const *argv, const char *const *envp);
419#define execvp mingw_execvp
420#define execve mingw_execve
421#define execv mingw_execv
422
423const char * next_path_sep(const char *path);
424#define has_dos_drive_prefix(path) (isalpha(*(path)) && (path)[1] == ':')
425#define is_absolute_path(path) ((path)[0] == '/' || has_dos_drive_prefix(path))
426
427/*
428 * helpers
429 */
430
431char **copy_environ(const char *const *env);
432void free_environ(char **env);
433char **env_setenv(char **env, const char *name);
434
435const char *get_busybox_exec_path(void);
436void init_winsock(void);
437
438char *file_is_win32_executable(const char *p);
diff --git a/include/platform.h b/include/platform.h
index 09c7ccd9c..e2b61592e 100644
--- a/include/platform.h
+++ b/include/platform.h
@@ -7,6 +7,15 @@
7#ifndef BB_PLATFORM_H 7#ifndef BB_PLATFORM_H
8#define BB_PLATFORM_H 1 8#define BB_PLATFORM_H 1
9 9
10#if ENABLE_PLATFORM_MINGW32
11# if !defined(__MINGW32__) /* HOSTCC is called */
12# undef ENABLE_PLATFORM_MINGW32
13# endif
14#else
15# if defined(__MINGW32__)
16# error "You must select target platform MS Windows, or it won't build"
17# endif
18#endif
10 19
11/* Convenience macros to test the version of gcc. */ 20/* Convenience macros to test the version of gcc. */
12#undef __GNUC_PREREQ 21#undef __GNUC_PREREQ
@@ -119,7 +128,7 @@
119 128
120/* Make all declarations hidden (-fvisibility flag only affects definitions) */ 129/* Make all declarations hidden (-fvisibility flag only affects definitions) */
121/* (don't include system headers after this until corresponding pop!) */ 130/* (don't include system headers after this until corresponding pop!) */
122#if __GNUC_PREREQ(4,1) && !defined(__CYGWIN__) 131#if __GNUC_PREREQ(4,1) && !defined(__CYGWIN__) && !ENABLE_PLATFORM_MINGW32
123# define PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN _Pragma("GCC visibility push(hidden)") 132# define PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN _Pragma("GCC visibility push(hidden)")
124# define POP_SAVED_FUNCTION_VISIBILITY _Pragma("GCC visibility pop") 133# define POP_SAVED_FUNCTION_VISIBILITY _Pragma("GCC visibility pop")
125#else 134#else
@@ -148,6 +157,14 @@
148# define bswap_64 __bswap64 157# define bswap_64 __bswap64
149# define bswap_32 __bswap32 158# define bswap_32 __bswap32
150# define bswap_16 __bswap16 159# define bswap_16 __bswap16
160# define __BIG_ENDIAN__ (_BYTE_ORDER == _BIG_ENDIAN)
161#elif ENABLE_PLATFORM_MINGW32
162# define __BIG_ENDIAN 0
163# define __LITTLE_ENDIAN 1
164# define __BYTE_ORDER __LITTLE_ENDIAN
165# define bswap_16(x) ((((x) & 0xFF00) >> 8) | (((x) & 0xFF) << 8))
166# define bswap_32(x) ((bswap_16(((x) & 0xFFFF0000L) >> 16)) | (bswap_16((x) & 0xFFFFL) << 16))
167# define bswap_64(x) ((bswap_32(((x) & 0xFFFFFFFF00000000LL) >> 32)) | (bswap_32((x) & 0xFFFFFFFFLL) << 32))
151#else 168#else
152# include <byteswap.h> 169# include <byteswap.h>
153# include <endian.h> 170# include <endian.h>
@@ -396,6 +413,25 @@ typedef unsigned smalluint;
396# endif 413# endif
397#endif 414#endif
398 415
416#if ENABLE_PLATFORM_MINGW32
417# undef HAVE_DPRINTF
418# undef HAVE_GETLINE
419# undef HAVE_MEMRCHR
420# undef HAVE_MKDTEMP
421# undef HAVE_SETBIT
422# undef HAVE_STPCPY
423# undef HAVE_STRCASESTR
424# undef HAVE_STRCHRNUL
425# undef HAVE_STRSEP
426# undef HAVE_STRSIGNAL
427# undef HAVE_STRVERSCMP
428#if !defined(__MINGW64_VERSION_MAJOR)
429# undef HAVE_VASPRINTF
430#endif
431# undef HAVE_UNLOCKED_STDIO
432# undef HAVE_UNLOCKED_LINE_OPS
433#endif
434
399#if defined(__WATCOMC__) 435#if defined(__WATCOMC__)
400# undef HAVE_DPRINTF 436# undef HAVE_DPRINTF
401# undef HAVE_GETLINE 437# undef HAVE_GETLINE
@@ -493,6 +529,7 @@ extern int dprintf(int fd, const char *format, ...);
493#endif 529#endif
494 530
495#ifndef HAVE_MEMRCHR 531#ifndef HAVE_MEMRCHR
532#include <stddef.h>
496extern void *memrchr(const void *s, int c, size_t n) FAST_FUNC; 533extern void *memrchr(const void *s, int c, size_t n) FAST_FUNC;
497#endif 534#endif
498 535
@@ -535,6 +572,7 @@ extern int usleep(unsigned) FAST_FUNC;
535#endif 572#endif
536 573
537#ifndef HAVE_VASPRINTF 574#ifndef HAVE_VASPRINTF
575# include <stdarg.h>
538extern int vasprintf(char **string_ptr, const char *format, va_list p) FAST_FUNC; 576extern int vasprintf(char **string_ptr, const char *format, va_list p) FAST_FUNC;
539#endif 577#endif
540 578