-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdefinitions.h
76 lines (57 loc) · 1.22 KB
/
definitions.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
#ifndef __DEFINITIONS_H__
#define __DEFINITIONS_H__
#define textIP(a) (uint32_t)a[0] << "." << (uint32_t)a[1] << "." << (uint32_t)a[2] << "." << (uint32_t)a[3]
#if defined __WINDOWS__ || defined WIN32
#else
#include "stdint.h"
#endif
//#define NETWORKMESSAGE_MAXSIZE 16768
#define NETWORKMESSAGE_MAXSIZE 15360
#if defined WIN32 || defined __WINDOWS__
#include "windows.h"
#define EWOULDBLOCK WSAEWOULDBLOCK
#ifndef __GNUC__
#pragma comment( lib, "Ws2_32.lib" )
typedef unsigned long uint32_t;
typedef signed long int32_t;
typedef unsigned short uint16_t;
typedef unsigned char uint8_t;
#endif
#define OTSYS_SLEEP(t) Sleep(t)
/*
#define OTSYS_SLEEP(uint32_t t){
Sleep(t);
}
*/
#else
#include <time.h>
#include <sys/timeb.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <stdint.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#ifndef SOCKET
#define SOCKET int
#endif
#ifndef closesocket
#define closesocket close
#endif
#ifndef SOCKADDR
#define SOCKADDR sockaddr
#endif
#ifndef SOCKET_ERROR
#define SOCKET_ERROR -1
#endif
inline void OTSYS_SLEEP(int t)
{
timespec tv;
tv.tv_sec = t / 1000;
tv.tv_nsec = (t % 1000)*1000000;
nanosleep(&tv, NULL);
}
#endif
#endif