-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy paththreads.h
79 lines (66 loc) · 2.12 KB
/
threads.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
/*
* threads.h
*/
#ifndef _EMERALD_THREADS_H
#define _EMERALD_THREADS_H
#ifndef _EMERALD_STORAGE_H
#include "storage.h"
#endif
extern int useThreads;
#define EMERALDFIRSTPORT 0x3ee3
#define EMERALDPORTSKIP 0x400
#define EMERALDPORTPROBE(n) ((n) + EMERALDPORTSKIP)
#ifdef MTHREADS
#include "mthreads.h"
#ifdef WIN32
#include <io.h>
#endif /* not WIN32 */
#define filesizeofNodeAddr (sizeof(unsigned int) + 2 * sizeof(unsigned short))
int vmInitThreads(void);
char *NodeAddrString(NodeAddr);
extern NodeAddr myid;
#define SameNodeAddrHost(a,b) ((a).ipaddress == (b).ipaddress && (a).port == (b).port)
#define SameNodeAddr(a,b) ((a).ipaddress == (b).ipaddress && (a).port == (b).port && (a).incarnation == (b).incarnation)
#define vmOpen(a,b,c) open(a,b,c)
#ifdef WIN32
#define reax(fd, buf, nbytes) _read(fd, buf, nbytes)
extern size_t vmRead(int fd, void *buf, size_t nbytes);
#define writx(fd, buf, nbytes) _write(fd, buf, nbytes)
extern size_t vmWrite(int fd, void *buf, size_t nbytes);
#define selecx(fd, r, w, x, t) select(fd, r, w, x, t)
#else /* not WIN32 */
#define vmRead(fd, buf, nbytes) read(fd, buf, nbytes)
#define vmWrite(fd, buf, nbytes) write(fd, buf, nbytes)
#ifndef FAKESELECT
#define selecx(fd, r, w, x, t) select(fd, r, w, x, t)
#endif
#endif /* not WIN32 */
#define vmClose(a) close(a)
#define vmSocket(a,b,c) socket(a,b,c)
#define vmAccept(a,b,c) accept(a,b,c)
#else
typedef int NodeAddr;
#define filesizeofNodeAddr sizeof(unsigned)
typedef int semaphore;
#define vmInitThreads() (-1)
#define vmCreateThread(b,c) (-1)
#define vmThreadSleep(a) sleep(a)
#define vmThreadMSleep(a, b) sleep(a)
#define SameNodeAddrHost(a,b) (0)
#define vmMain(a,b) main(a,b)
#define vmOpen(a,b,c) open(a,b,c)
#define vmRead(a,b,c) read(a,b,c)
#define vmWrite(a,b,c) write(a,b,c)
#define vmClose(a) close(a)
#ifdef WIN32
#define vmSocket(a,b,c) xxxxsocket(a,b,c)
#else /* not WIN32 */
#define vmSocket(a,b,c) socket(a,b,c)
#endif /* not WIN32 */
#define vmAccept(a,b,c) accept(a,b,c)
#define WriteNodeAddr(a, b) abort()
#define ReadNodeAddr(a, b) abort()
#define NodeAddrString(x) "a thread"
#endif /* MTHREADS */
#endif /* _EMERALD_THREADS_H */
/* EOF */