Unify preprocessor checks for win32

<https://sourceforge.net/p/predef/wiki/OperatingSystems/> says that _WIN32 is
always defined for both 32-bit and 64-bit versions of Windows.
This commit is contained in:
Lassi Kortela 2019-08-10 00:12:33 +03:00
parent 267cd00146
commit e9d6ca265c
10 changed files with 19 additions and 34 deletions

View File

@ -3,9 +3,8 @@
#include <stdlib.h>
#include <string.h>
#ifdef WIN32
#ifdef _WIN32
#include <malloc.h>
#define alloca _alloca
#endif
#include "dtypes.h"

View File

@ -34,13 +34,13 @@
#include <stdlib.h>
#include <string.h>
#include "dtypes.h"
#include "bitvector.h"
#ifdef WIN32
#ifdef _WIN32
#include <malloc.h>
#endif
#include "dtypes.h"
#include "bitvector.h"
uint32_t *bitvector_resize(uint32_t *b, uint64_t oldsz, uint64_t newsz,
int initzero)
{

View File

@ -345,7 +345,7 @@ static value_t fl_path_cwd(value_t *args, uint32_t nargs)
return FL_T;
}
#ifdef WIN32
#ifdef _WIN32
#define stat _stat
#endif
static value_t fl_path_exists(value_t *args, uint32_t nargs)

View File

@ -13,24 +13,10 @@
We assume the LP64 convention for 64-bit platforms.
*/
#if defined(__gnu_linux__)
#define LINUX
#elif defined(__APPLE__) && defined(__MACH__)
#define MACOSX
#elif defined(__OpenBSD__)
#define OPENBSD
#elif defined(__FreeBSD__)
#define FREEBSD
#elif defined(_WIN32)
#define WIN32
#else
#error "unknown platform"
#endif
#undef BITS32 // TODO
#define BITS64 // TODO
#if defined(WIN32)
#ifdef _WIN32
#define STDCALL __stdcall
#if defined(IMPORT_EXPORTS)
#define DLLEXPORT __declspec(dllimport)

View File

@ -2624,7 +2624,7 @@ static void lisp_init(size_t initial_heapsize)
#ifdef LINUX
set(symbol("*os-name*"), symbol("linux"));
#elif defined(WIN32) || defined(WIN64)
#elif defined(_WIN32)
set(symbol("*os-name*"), symbol("win32"));
#elif defined(MACOSX)
set(symbol("*os-name*"), symbol("macos"));

View File

@ -9,7 +9,7 @@
#include "dtypes.h"
#ifdef WIN32
#ifdef _WIN32
#include <malloc.h>
#include <io.h>
#include <fcntl.h>
@ -43,7 +43,7 @@ static void *our_memrchr(const void *s, int c, size_t n)
// poll for read, unless forwrite!=0
static void _fd_poll(long fd, int forwrite)
{
#ifndef WIN32
#ifndef _WIN32
fd_set set;
FD_ZERO(&set);

View File

@ -107,7 +107,7 @@ int open_any_udp_port(short *portno)
return sockfd;
}
#ifndef WIN32
#ifndef _WIN32
void closesocket(int fd) { close(fd); }
#endif

View File

@ -1,4 +1,4 @@
#ifdef WIN32
#ifdef _WIN32
#include <winsock2.h>
#else
#include <netinet/in.h>
@ -8,6 +8,10 @@
#include <fcntl.h>
#endif
#ifndef _WIN32
void closesocket(int fd);
#endif
int open_tcp_port(short portno);
int open_any_tcp_port(short *portno);
int open_any_udp_port(short *portno);
@ -17,7 +21,3 @@ int sendall(int sockfd, char *buffer, int bufLen, int flags);
int readall(int sockfd, char *buffer, int bufLen, int flags);
int addr_eq(struct sockaddr_in *a, struct sockaddr_in *b);
int socket_ready(int sock);
#ifndef WIN32
void closesocket(int fd);
#endif

View File

@ -23,7 +23,7 @@
#include <wchar.h>
#include <wctype.h>
#ifdef WIN32
#ifdef _WIN32
#include <malloc.h>
#define snprintf _snprintf
#endif
@ -253,7 +253,7 @@ size_t u8_strlen(const char *s)
return count;
}
#if defined(__WIN32__)
#ifdef _WIN32
#include "wcwidth.h"
#endif

View File

@ -1,6 +1,6 @@
extern int locale_is_utf8;
#if defined(__WIN32__)
#ifdef _WIN32
extern int wcwidth(uint32_t);
#endif