This commit is contained in:
manojampalam 2016-03-06 14:14:29 -08:00
parent d6f5485283
commit b6f7898659
5 changed files with 64 additions and 37 deletions

View File

@ -3,6 +3,8 @@
*
* POSIX header and needed function definitions
*/
#ifndef COMPAT_SIGNAL_H
#define COMPAT_SIGNAL_H 1
#include "w32posix.h"
@ -23,7 +25,6 @@
#define SIGPIPE 27
#define SIGQUIT 3
// Signal action codes
#define SIG_DFL (0) // default signal action
#define SIG_IGN (1) // ignore signal
@ -31,4 +32,4 @@
#define SIG_SGE (3) // signal gets error
#define SIG_ACK (4) // acknowledge
#define signal w32_signal
#endif

View File

@ -3,8 +3,8 @@
*
* POSIX header and needed function definitions
*/
#pragma once
#include "..\w32posix.h"
#define fd_set w32_fd_set
#define select w32_select

View File

@ -3,19 +3,20 @@
*
* POSIX header and needed function definitions
*/
#pragma once
#include "..\w32posix.h"
#define socket w32_socket
#define accept w32_accept
#define setsockopt w32_setsockopt
#define getsockopt w32_getsockopt
#define getsockname w32_getsockname
#define getpeername w32_getpeername
#define listen w32_listen
#define bind w32_bind
#define connect w32_connect
#define recv w32_recv
#define send w32_send
#define shutdown w32_shutdown
#define socketpair w32_socketpair
#define socket(a,b,c) w32_socket((a), (b), (c))
#define accept(a,b,c) w32_accept((a), (b), (c))
#define setsockopt(a,b,c,d,e) w32_setsockopt((a), (b), (c), (d), (e))
#define getsockopt(a,b,c,d,e) w32_getsockopt((a), (b), (c), (d), (e))
#define getsockname(a,b,c) w32_getsockname((a), (b), (c))
#define getpeername(a,b,c) w32_getpeername((a), (b), (c))
#define listen(a,b) w32_listen((a), (b))
#define bind(a,b,c) w32_bind((a), (b), (c))
#define connect(a,b,c) w32_connect((a), (b), (c))
#define recv(a,b,c,d) w32_recv((a), (b), (c), (d))
#define send(a,b,c,d) w32_send(((a), (b), (c), (d))
#define shutdown(a,b) w32_shutdown((a), (b))
#define socketpair(a,b,c) w32_socketpair((a), (b), (c))

View File

@ -3,17 +3,38 @@
*
* POSIX header and needed function definitions
*/
#ifndef COMPAT_UNISTD_H
#define COMPAT_UNISTD_H 1
#include "w32posix.h"
#define pipe w32_pipe
#define open w32_open
#define read w32_read
#define write w32_write
#define isatty w32_isatty
#define close w32_close
#define dup w32_dup
#define dup2 w32_dup2
#define pipe(a) w32_pipe((a))
#define open(a,b,...) w32_open((a), (b), __VA_ARGS__)
#define read(a,b,c) w32_read((a), (b), (c))
#define write(a,b,c) w32_write((a), (b), (c))
#define isatty(a) w32_isatty((a))
#define close(a) w32_close((a))
#define dup(a) w32_dup((a))
#define dup2(a,b) w32_dup2((a), (b))
#define sleep(sec) Sleep(1000 * sec)
#define alarm w32_alarm
#define sleep(sec) Sleep(1000 * sec)
#define alarm(a) w32_alarm((a))
/* Compatibility header to avoid lots of #ifdefs in includes.h on Win32 */
#include <conio.h>
#include <direct.h>
/* We can't put these in string.h since we can't easily override that header, so here they are */
#if !defined(HAVE_STRCASECMP) && !defined(__MINGW32__)
size_t strcasecmp(const char *left, const char *right);
#endif
#if !defined(HAVE_STRNCASECMP) && !defined(__MINGW32__)
size_t strncasecmp(const char *left, const char *right, size_t n);
#endif
int gettimeofday(struct timeval *tv, void *tz);
/* End of prototypes in the wrong file */
#endif

View File

@ -17,6 +17,8 @@ typedef struct w32_fd_set_ {
unsigned char bitmap[MAX_FDS >> 3];
}w32_fd_set;
#define fd_set w32_fd_set
void w32posix_initialize();
void w32posix_done();
@ -36,8 +38,8 @@ int w32_shutdown(int fd, int how);
int w32_socketpair(int domain, int type, int sv[2]);
/*non-network (file) i/o*/
#define fdopen w32_fdopen
#define fstat w32_fstat
#define fdopen(a,b) w32_fdopen((a), (b))
#define fstat(a,b) w32_fstat((a), (b))
int w32_pipe(int *pfds);
int w32_open(const char *pathname, int flags, ...);
@ -48,7 +50,8 @@ int w32_isatty(int fd);
FILE* w32_fdopen(int fd, const char *mode);
/*common i/o*/
#define fcntl w32_fcntl
#define fcntl(a,b,...) w32_fcntl((a), (b), __VA_ARGS__)
#define select(a,b,c,d,e) w32_select((a), (b), (c), (d), (e))
int w32_close(int fd);
int w32_select(int fds, w32_fd_set* readfds, w32_fd_set* writefds, w32_fd_set* exceptfds,
const struct timeval *timeout);
@ -56,11 +59,12 @@ int w32_fcntl(int fd, int cmd, ... /* arg */);
int w32_dup(int oldfd);
int w32_dup2(int oldfd, int newfd);
/* misc */
unsigned int w32_alarm(unsigned int seconds);
typedef void(*sighandler_t)(int);
#define signal w32_signal
#define mysignal w32_signal
#define signal(a,b) w32_signal((a), (b))
#define mysignal(a,b) w32_signal((a), (b))
/* Shutdown constants */
@ -102,9 +106,9 @@ HANDLE w32_fd_to_handle(int fd);
int w32_allocate_fd_for_handle(HANDLE h);
/* temporary definitions to aid in transition */
#define WSHELPDelChildToWatch w32_temp_DelChildToWatch
#define WSHELPAddChildToWatch w32_temp_AddChildToWatch
#define sfd_to_handle w32_fd_to_handle
#define allocate_sfd w32_allocate_fd_for_handle
#define WSHELPwopen w32_open
#define WSHELPDelChildToWatch(a) w32_temp_DelChildToWatch((a))
#define WSHELPAddChildToWatch(a) w32_temp_AddChildToWatch((a))
#define sfd_to_handle(a) w32_fd_to_handle((a))
#define allocate_sfd(a) w32_allocate_fd_for_handle((a))
#define WSHELPwopen(a) w32_open((a))