1 | /* $Id: mscfakes.h 2713 2013-11-21 21:11:00Z bird $ */
|
---|
2 | /** @file
|
---|
3 | * Unix fakes for MSC.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (c) 2005-2010 knut st. osmundsen <[email protected]>
|
---|
8 | *
|
---|
9 | * This file is part of kBuild.
|
---|
10 | *
|
---|
11 | * kBuild is free software; you can redistribute it and/or modify
|
---|
12 | * it under the terms of the GNU General Public License as published by
|
---|
13 | * the Free Software Foundation; either version 3 of the License, or
|
---|
14 | * (at your option) any later version.
|
---|
15 | *
|
---|
16 | * kBuild is distributed in the hope that it will be useful,
|
---|
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
19 | * GNU General Public License for more details.
|
---|
20 | *
|
---|
21 | * You should have received a copy of the GNU General Public License
|
---|
22 | * along with kBuild. If not, see <http://www.gnu.org/licenses/>
|
---|
23 | *
|
---|
24 | */
|
---|
25 |
|
---|
26 | #ifndef ___mscfakes_h
|
---|
27 | #define ___mscfakes_h
|
---|
28 | #ifdef _MSC_VER
|
---|
29 |
|
---|
30 | #include <io.h>
|
---|
31 | #include <direct.h>
|
---|
32 | #include <time.h>
|
---|
33 | #include <stdarg.h>
|
---|
34 | #include <malloc.h>
|
---|
35 | #include "getopt.h"
|
---|
36 |
|
---|
37 | /* Note: Duplicated it config.h.win */
|
---|
38 | #include <sys/stat.h>
|
---|
39 | #include <io.h>
|
---|
40 | #include <direct.h>
|
---|
41 | #include "nt/ntstat.h"
|
---|
42 | #include "nt/ntunlink.h"
|
---|
43 | #if defined(MSC_DO_64_BIT_IO) && _MSC_VER >= 1400 /* We want 64-bit file lengths here when possible. */
|
---|
44 | # define off_t __int64
|
---|
45 | # define lseek _lseeki64
|
---|
46 | #endif
|
---|
47 |
|
---|
48 | #undef PATH_MAX
|
---|
49 | #define PATH_MAX _MAX_PATH
|
---|
50 | #undef MAXPATHLEN
|
---|
51 | #define MAXPATHLEN _MAX_PATH
|
---|
52 |
|
---|
53 | #define EX_OK 0
|
---|
54 | #define EX_OSERR 1
|
---|
55 | #define EX_NOUSER 1
|
---|
56 | #define EX_USAGE 1
|
---|
57 |
|
---|
58 | #define STDIN_FILENO 0
|
---|
59 | #define STDOUT_FILENO 1
|
---|
60 | #define STDERR_FILENO 2
|
---|
61 |
|
---|
62 | #define F_OK 0
|
---|
63 | #define X_OK 1
|
---|
64 | #define W_OK 2
|
---|
65 | #define R_OK 4
|
---|
66 |
|
---|
67 | #define EFTYPE EINVAL
|
---|
68 |
|
---|
69 | #define _PATH_DEVNULL "/dev/null"
|
---|
70 |
|
---|
71 | #ifndef MAX
|
---|
72 | # define MAX(a,b) ((a) >= (b) ? (a) : (b))
|
---|
73 | #endif
|
---|
74 |
|
---|
75 | typedef int mode_t;
|
---|
76 | typedef unsigned short nlink_t;
|
---|
77 | #if 0 /* found in config.h */
|
---|
78 | typedef unsigned short uid_t;
|
---|
79 | typedef unsigned short gid_t;
|
---|
80 | #endif
|
---|
81 | typedef long ssize_t;
|
---|
82 | typedef unsigned long u_long;
|
---|
83 | typedef unsigned int u_int;
|
---|
84 | typedef unsigned short u_short;
|
---|
85 |
|
---|
86 | #ifndef timerisset
|
---|
87 | struct timeval
|
---|
88 | {
|
---|
89 | long tv_sec;
|
---|
90 | long tv_usec;
|
---|
91 | };
|
---|
92 | #endif
|
---|
93 |
|
---|
94 | struct iovec
|
---|
95 | {
|
---|
96 | char *iov_base;
|
---|
97 | size_t iov_len;
|
---|
98 | };
|
---|
99 |
|
---|
100 | typedef __int64 intmax_t;
|
---|
101 | #if 0 /* found in config.h */
|
---|
102 | typedef unsigned __int64 uintmax_t;
|
---|
103 | #endif
|
---|
104 |
|
---|
105 | #define chown(path, uid, gid) 0 /** @todo implement fchmod! */
|
---|
106 | char *dirname(char *path);
|
---|
107 | #define fsync(fd) 0
|
---|
108 | #define fchown(fd,uid,gid) 0
|
---|
109 | #define fchmod(fd, mode) 0 /** @todo implement fchmod! */
|
---|
110 | #define geteuid() 0
|
---|
111 | #define getegid() 0
|
---|
112 | int lchmod(const char *path, mode_t mode);
|
---|
113 | int msc_chmod(const char *path, mode_t mode);
|
---|
114 | #define chmod msc_chmod
|
---|
115 | #define lchown(path, uid, gid) chown(path, uid, gid)
|
---|
116 | #define lutimes(path, tvs) utimes(path, tvs)
|
---|
117 | int link(const char *pszDst, const char *pszLink);
|
---|
118 | int mkdir_msc(const char *path, mode_t mode);
|
---|
119 | #define mkdir(path, mode) mkdir_msc(path, mode)
|
---|
120 | #define mkfifo(path, mode) -1
|
---|
121 | #define mknod(path, mode, devno) -1
|
---|
122 | int mkstemp(char *temp);
|
---|
123 | #define readlink(link, buf, size) -1
|
---|
124 | #define reallocf(old, size) realloc(old, size)
|
---|
125 | int rmdir_msc(const char *path);
|
---|
126 | #define rmdir(path) rmdir_msc(path)
|
---|
127 | intmax_t strtoimax(const char *nptr, char **endptr, int base);
|
---|
128 | uintmax_t strtoumax(const char *nptr, char **endptr, int base);
|
---|
129 | #define strtoll(a,b,c) strtoimax(a,b,c)
|
---|
130 | #define strtoull(a,b,c) strtoumax(a,b,c)
|
---|
131 | int asprintf(char **strp, const char *fmt, ...);
|
---|
132 | int vasprintf(char **strp, const char *fmt, va_list ap);
|
---|
133 | #if _MSC_VER < 1400
|
---|
134 | int snprintf(char *buf, size_t size, const char *fmt, ...);
|
---|
135 | #else
|
---|
136 | #define snprintf _snprintf
|
---|
137 | #endif
|
---|
138 | int symlink(const char *pszDst, const char *pszLink);
|
---|
139 | int utimes(const char *pszPath, const struct timeval *paTimes);
|
---|
140 | int writev(int fd, const struct iovec *vector, int count);
|
---|
141 |
|
---|
142 |
|
---|
143 |
|
---|
144 | /*
|
---|
145 | * MSC fake internals / helpers.
|
---|
146 | */
|
---|
147 | int birdSetErrno(unsigned dwErr);
|
---|
148 |
|
---|
149 | #endif /* _MSC_VER */
|
---|
150 | #endif
|
---|
151 |
|
---|