VirtualBox

source: kBuild/trunk/src/ash-messup/win/mscfakes.h@ 881

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

hacking...

  • 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 881 2007-04-21 08:47:37Z 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 lstat(path, s) stat(path, s)
115#define lchmod(path, mod) chmod(path, mod)
116#define lchown(path, uid, gid) chown(path, uid, gid)
117#define lutimes(path, tvs) utimes(path, tvs)
118int link(const char *pszDst, const char *pszLink);
119int mkdir_msc(const char *path, mode_t mode);
120#define mkdir(path, mode) mkdir_msc(path, mode)
121#define mkfifo(path, mode) -1
122#define mknod(path, mode, devno) -1
123#define pipe(v) _pipe(v,0,0)
124int mkstemp(char *temp);
125#define readlink(link, buf, size) -1
126#define reallocf(old, size) realloc(old, size)
127#define strcasecmp stricmp
128#define strncasecmp strnicmp
129#if _MSC_VER < 1400
130int snprintf(char *buf, size_t size, const char *fmt, ...);
131#else
132#define snprintf _snprintf
133#endif
134size_t strlcpy(char *, const char *, size_t);
135int symlink(const char *pszDst, const char *pszLink);
136int utimes(const char *pszPath, const struct timeval *paTimes);
137int writev(int fd, const struct iovec *vector, int count);
138#define F_DUPFD 0
139#define F_GETFD 1
140#define F_SETFD 2
141#define F_GETFL 3
142#define F_SETFL 4
143#define FD_CLOEXEC 1
144#define O_NONBLOCK 0 /// @todo
145#define EWOULDBLOCK 512
146int fcntl(int, int, ...);
147int ioctl(int, unsigned long, ...);
148pid_t tcgetpgrp(int fd);
149
150
151/* signal hacks */
152#include <signal.h>
153typedef struct sigset
154{
155 unsigned long __bitmap[1];
156} sigset_t;
157typedef void __sighandler_t(int);
158typedef void __siginfohandler_t(int, struct __siginfo *, void *);
159typedef __sighandler_t *sig_t; /** BSD 4.4 type. */
160struct sigaction
161{
162 union
163 {
164 __siginfohandler_t *__sa_sigaction;
165 __sighandler_t *__sa_handler;
166 } __sigaction_u;
167 sigset_t sa_mask;
168 int sa_flags;
169};
170#define sa_handler __sigaction_u.__sa_handler
171#define sa_sigaction __sigaction_u.__sa_sigaction
172
173int sigprocmask(int, const sigset_t *, sigset_t *);
174#define SIG_BLOCK 1
175#define SIG_UNBLOCK 2
176#define SIG_SETMASK 3
177
178#define SIGTTIN 19
179#define SIGTSTP 18
180#define SIGTTOU 17
181#define SIGCONT 20
182#define SIGPIPE 12
183#define SIGQUIT 9
184#define SIGHUP 5
185
186extern const char *const sys_siglist[NSIG]; /* NSIG == 23 */
187
188int kill(pid_t, int);
189int sigaction(int, const struct sigaction *, struct sigaction *);
190//int sigaddset(sigset_t *, int);
191//int sigdelset(sigset_t *, int);
192int sigemptyset(sigset_t *);
193//int sigfillset(sigset_t *);
194//int sigismember(const sigset_t *, int);
195//int sigpending(sigset_t *);
196//int sigsuspend(const sigset_t *);
197//int sigwait(const sigset_t *, int *);
198int siginterrupt(int, int);
199
200#endif /* _MSC_VER */
201#endif
202
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