-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathfix_unistd.h
125 lines (107 loc) · 1.71 KB
/
fix_unistd.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#pragma once
#if defined(POSIX)
#include <unistd.h>
#else
//<unistd.h> for Windows
#ifndef _UNISTD_H_
#define _UNISTD_H_
#ifdef _WIN32
#pragma once
#include <io.h>
/*
access
chmod
chsize
close
creat
dup
dup2
eof
filelength
isatty
locking
lseek
mktemp
open
read
setmode
sopen
tell
umask
unlink
write
*/
#include <direct.h>
/*
chdir
getcwd
mkdir
rmdir
*/
#include <process.h>
/*
cwait
execl
execle
execlp
execlpe
execv
execve
execvp
execvpe
spawnl
spawnle
spawnlp
spawnlpe
spawnv
spawnve
spawnvp
spawnvpe
*/
#pragma comment( lib, "ws2_32" )
#include <winsock2.h>
/*
gethostname
*/
#include <process.h>
/*
_getpid
*/
#include <time.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef int pid_t; /* process id type */
#ifndef _SSIZE_T_DEFINED
typedef int ssize_t;
#define _SSIZE_T_DEFINED
#endif
#ifndef getpid
#define getpid() _getpid()
#ifdef _ACRTIMP
_ACRTIMP
#endif
extern pid_t __cdecl _getpid(void);
#endif
#define nice(incr) (SetPriorityClass(GetCurrentProcess(),incr))//TODO
#define sleep(seconds) (Sleep(seconds*1000))
#define usleep(useconds) (Sleep(useconds))
#define stime(tp) UNISTD_stime(tp)
__forceinline int UNISTD_stime(const time_t *tp ){
FILETIME ft;
SYSTEMTIME st;
LONGLONG ll = Int32x32To64(*tp, 10000000) + 116444736000000000;
ft.dwLowDateTime = (DWORD) ll;
ft.dwHighDateTime = (unsigned __int64)ll >>32;
FileTimeToSystemTime(&ft,&st);
return SetSystemTime(&st);
}
//<sys/stat.h>
#define fstat64(fildes, stat) (_fstati64(fildes, stat))
#define stat64(path, buffer) (_stati64(path,buffer))
#ifdef __cplusplus
}
#endif
#endif /* _WIN32 */
#endif /* _UNISTD_H_ */
#endif