VirtualBox

source: kBuild/trunk/src/ash/win/mscfakes.h@ 1433

Last change on this file since 1433 was 785, checked in by bird, 18 years ago

copyright and email updates.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.0 KB
Line 
1/* $Id: mscfakes.h 785 2007-01-24 22:21:56Z bird $ */
2/** @file
3 *
4 * Unix fakes for MSC.
5 *
6 * Copyright (c) 2005-2007 knut st. osmundsen <[email protected]>
7 *
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with This program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 *
23 */
24
25#ifndef __mscfakes_h__
26#define __mscfakes_h__
27#ifdef _MSC_VER
28
29#define setmode setmode_msc
30#include <sys/cdefs.h>
31#include <io.h>
32#include <direct.h>
33#include <time.h>
34#include <fcntl.h>
35#include <limits.h>
36#include <stdlib.h>
37#include <process.h>
38#undef setmode
39//#include "getopt.h"
40
41#if !defined(__GNUC__) && !defined(__attribute__)
42#define __attribute__(a)
43#endif
44
45#define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
46#define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
47#define S_ISLNK(m) 0
48#define S_IRWXU (_S_IREAD | _S_IWRITE | _S_IEXEC)
49#define S_IXUSR _S_IEXEC
50#define S_IWUSR _S_IWRITE
51#define S_IRUSR _S_IREAD
52#define S_IRWXG 0000070
53#define S_IRGRP 0000040
54#define S_IWGRP 0000020
55#define S_IXGRP 0000010
56#define S_IRWXO 0000007
57#define S_IROTH 0000004
58#define S_IWOTH 0000002
59#define S_IXOTH 0000001
60#define S_ISUID 0004000
61#define S_ISGID 0002000
62#define ALLPERMS 0000777
63
64#define PATH_MAX _MAX_PATH
65#define MAXPATHLEN _MAX_PATH
66
67#define EX_OK 0
68#define EX_OSERR 1
69#define EX_NOUSER 1
70#define EX_USAGE 1
71
72#define STDIN_FILENO 0
73#define STDOUT_FILENO 1
74#define STDERR_FILENO 2
75
76#define F_OK 0
77#define X_OK 1
78#define W_OK 2
79#define R_OK 4
80
81#define EFTYPE EINVAL
82
83#define _PATH_DEVNULL "/dev/null"
84
85#define MAX(a,b) ((a) >= (b) ? (a) : (b))
86
87typedef int mode_t;
88typedef unsigned short nlink_t;
89typedef long ssize_t;
90typedef unsigned long u_long;
91typedef unsigned int u_int;
92typedef unsigned short u_short;
93
94#ifndef timerisset
95struct timeval
96{
97 long tv_sec;
98 long tv_usec;
99};
100#endif
101
102struct iovec
103{
104 char *iov_base;
105 size_t iov_len;
106};
107
108
109#define chown(path, uid, gid) 0 /** @todo implement fchmod! */
110char *dirname(char *path);
111#define fsync(fd) 0
112#define fchown(fd,uid,gid) 0
113#define fchmod(fd, mode) 0 /** @todo implement fchmod! */
114#define geteuid() 0
115#define lstat(path, s) stat(path, s)
116#define lchmod(path, mod) chmod(path, mod)
117#define lchown(path, uid, gid) chown(path, uid, gid)
118#define lutimes(path, tvs) utimes(path, tvs)
119int link(const char *pszDst, const char *pszLink);
120int mkdir_msc(const char *path, mode_t mode);
121#define mkdir(path, mode) mkdir_msc(path, mode)
122#define mkfifo(path, mode) -1
123#define mknod(path, mode, devno) -1
124#define pipe(v) _pipe(v,0,0)
125int mkstemp(char *temp);
126#define readlink(link, buf, size) -1
127#define reallocf(old, size) realloc(old, size)
128#define strcasecmp stricmp
129#define strncasecmp strnicmp
130#if _MSC_VER < 1400
131int snprintf(char *buf, size_t size, const char *fmt, ...);
132#else
133#define snprintf _snprintf
134#endif
135size_t strlcpy(char *, const char *, size_t);
136int symlink(const char *pszDst, const char *pszLink);
137int utimes(const char *pszPath, const struct timeval *paTimes);
138int writev(int fd, const struct iovec *vector, int count);
139#define F_DUPFD 0
140#define F_GETFD 1
141#define F_SETFD 2
142#define F_GETFL 3
143#define F_SETFL 4
144#define FD_CLOEXEC 1
145#define O_NONBLOCK 0 /// @todo
146#define EWOULDBLOCK 512
147int fcntl(int, int, ...);
148int ioctl(int, unsigned long, ...);
149pid_t tcgetpgrp(int fd);
150
151
152/* signal hacks */
153#include <signal.h>
154typedef struct sigset
155{
156 unsigned long __bitmap[1];
157} sigset_t;
158typedef void __sighandler_t(int);
159typedef void __siginfohandler_t(int, struct __siginfo *, void *);
160typedef __sighandler_t *sig_t; /** BSD 4.4 type. */
161struct sigaction
162{
163 union
164 {
165 __siginfohandler_t *__sa_sigaction;
166 __sighandler_t *__sa_handler;
167 } __sigaction_u;
168 sigset_t sa_mask;
169 int sa_flags;
170};
171#define sa_handler __sigaction_u.__sa_handler
172#define sa_sigaction __sigaction_u.__sa_sigaction
173
174int sigprocmask(int, const sigset_t *, sigset_t *);
175#define SIG_BLOCK 1
176#define SIG_UNBLOCK 2
177#define SIG_SETMASK 3
178
179#define SIGTTIN 19
180#define SIGTSTP 18
181#define SIGTTOU 17
182#define SIGCONT 20
183#define SIGPIPE 12
184#define SIGQUIT 9
185#define SIGHUP 5
186
187extern const char *const sys_siglist[NSIG]; /* NSIG == 23 */
188
189int kill(pid_t, int);
190int sigaction(int, const struct sigaction *, struct sigaction *);
191//int sigaddset(sigset_t *, int);
192//int sigdelset(sigset_t *, int);
193int sigemptyset(sigset_t *);
194//int sigfillset(sigset_t *);
195//int sigismember(const sigset_t *, int);
196//int sigpending(sigset_t *);
197//int sigsuspend(const sigset_t *);
198//int sigwait(const sigset_t *, int *);
199int siginterrupt(int, int);
200
201#endif /* _MSC_VER */
202#endif
203
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette