forked from bergdino/xptminer-linux
-
Notifications
You must be signed in to change notification settings - Fork 2
/
win.h
101 lines (68 loc) · 2.05 KB
/
win.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#ifndef __WIN_H
#define __WIN_H
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include <sys/signal.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/select.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <time.h>
#include <malloc.h>
#include "emmintrin.h"
typedef void *LPVOID;
typedef uint32_t *LPDWORD;
typedef int SOCKET;
typedef struct sockaddr_in SOCKADDR_IN;
typedef struct sockaddr SOCKADDR;
typedef fd_set FD_SET;
typedef void *WSADATA;
#define WSAStartup(a, b)
#define MAKEWORD(a, b) a
#define ADDR_ANY INADDR_ANY
#define SOCKET_ERROR -1
#define strcpy_s(dst, n, src) \
strncpy((dst), (src), (n))
#define RtlZeroMemory(s, size)\
memset((s), 0, (size))
#define RtlCopyMemory(dest, src, size)\
memcpy((dest), (src), (size))
#define max(a, b) \
((a)>(b)?(a):(b))
#define min(a, b) \
((a)<(b)?(a):(b))
#define FIONBIO 0
#define WSAIoctl(socket, ig1, ig2, ig3, ig4, ig5, ig6, ig7, ig8) \
fcntl(socket, F_SETFL, O_NONBLOCK)
#define WSAGetLastError() errno
#define WSAEWOULDBLOCK EWOULDBLOCK
#define closesocket(fd) close(fd)
typedef struct {
pthread_mutex_t mutex;
pthread_mutexattr_t attr;
} CRITICAL_SECTION;
void InitializeCriticalSection(CRITICAL_SECTION *s);
void EnterCriticalSection(CRITICAL_SECTION *s);
void LeaveCriticalSection(CRITICAL_SECTION *s);
typedef void *(*LPTHREAD_START_ROUTINE)(void *);
void CreateThread(LPVOID ig1, size_t ig2, LPTHREAD_START_ROUTINE func, LPVOID arg, uint32_t ig3, LPDWORD tid);
#define __declspec(x) __##x
#define Sleep(x) usleep(x*1000)
#define __debugbreak() raise(SIGTRAP)
#define GetTickCount() (uint32) (time(NULL) - 1383638888) * 1000 // A quick hack for time_t overflow
#define _strdup strdup
typedef struct {
int dwNumberOfProcessors;
} SYSTEM_INFO;
#define GetSystemInfo(ps) \
(ps)->dwNumberOfProcessors = sysconf(_SC_NPROCESSORS_ONLN)
#define GetCurrentProcess() getpid()
#define BELOW_NORMAL_PRIORITY_CLASS 15
#define SetPriorityClass(pid, priority) \
nice(priority)
#endif