forked from ghaerr/microwindows
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuni_std.h
More file actions
76 lines (63 loc) · 1.75 KB
/
Copy pathuni_std.h
File metadata and controls
76 lines (63 loc) · 1.75 KB
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
/*
* Microwindows unistd.h
*
* Required header for ALLOCA, MSC functions, strdup/strn string functions
*
* Usage: replace #include <unistd.h> with "uni_std.h"
*
* https://stackoverflow.com/a/826027/1202830
*/
#if !defined(_MSC_VER)
#include <unistd.h>
#if __MINGW32__
#include <malloc.h> /* for alloca */
#endif
#if RTEMS | PSP | __ECOS | __MINGW32__
#define srandom srand
#define random rand
#endif
#else /* defined(_MSC_VER)*/
#include <io.h>
#include <direct.h> /* for _getcwd() and _chdir()*/
//#include <getopt.h> /* getopt at: https://gist.github.com/ashelly/7776712*/
//#include <process.h> /* for getpid() and exec() family*/
#define alloca _alloca
#define access _access
#define dup2 _dup2
#define execve _execve
#define ftruncate _chsize
#define unlink _unlink
#define fileno _fileno
#define getcwd _getcwd
#define chdir _chdir
#define isatty _isatty
#define lseek _lseek
/* read, write, and close are defined here, but they may not work for sockets, e.g. closesocket()*/
#define open _open
#define read _read
#define write _write
#define close _close
#ifdef _WIN64
#define ssize_t __int64
#else
#define ssize_t long
#endif
#define STDIN_FILENO 0
#define STDOUT_FILENO 1
#define STDERR_FILENO 2
/* Values for the second argument to access*/
#define R_OK 4 /* Read permission*/
#define W_OK 2 /* Write permission*/
#define X_OK 1 /* Execute permission - unsupported in windows*/
#define F_OK 0 /* File exists*/
/* math routines*/
#define srandom srand
#define random rand
/* string routines*/
#define strcasecmp _stricmp
#define strncasecmp _strnicmp
#define strnicmp _strnicmp
#define strdup _strdup
#define snprintf _snprintf
#define vsnprintf _vsnprintf
#endif /* defined(_MSC_VER)*/