VirtualBox

source: kBuild/trunk/src/kmk/kmkbuiltin/mscfakes.h@ 2759

Last change on this file since 2759 was 2759, checked in by bird, 10 years ago

More generic ENOSPC workaround for windows.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.1 KB
Line 
1/* $Id: mscfakes.h 2759 2015-01-28 16:14: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 the config file (kmk's) so we don't need to duplicate stuff from it here. */
31#include "config.h"
32
33#include <io.h>
34#include <direct.h>
35#include <time.h>
36#include <stdarg.h>
37#include <malloc.h>
38#include "getopt.h"
39#ifndef MSCFAKES_NO_WINDOWS_H
40# include <Windows.h>
41#endif
42
43#include <sys/stat.h>
44#include <io.h>
45#include <direct.h>
46#include "nt/ntstat.h"
47#include "nt/ntunlink.h"
48#if defined(MSC_DO_64_BIT_IO) && _MSC_VER >= 1400 /* We want 64-bit file lengths here when possible. */
49# define off_t __int64
50# define lseek _lseeki64
51#endif
52
53#undef PATH_MAX
54#define PATH_MAX _MAX_PATH
55#undef MAXPATHLEN
56#define MAXPATHLEN _MAX_PATH
57
58#define EX_OK 0
59#define EX_OSERR 1
60#define EX_NOUSER 1
61#define EX_USAGE 1
62
63#define STDIN_FILENO 0
64#define STDOUT_FILENO 1
65#define STDERR_FILENO 2
66
67#define F_OK 0
68#define X_OK 1
69#define W_OK 2
70#define R_OK 4
71
72#define EFTYPE EINVAL
73
74#define _PATH_DEVNULL "/dev/null"
75
76#ifndef MAX
77# define MAX(a,b) ((a) >= (b) ? (a) : (b))
78#endif
79
80typedef int mode_t;
81typedef unsigned short nlink_t;
82#if 0 /* found in config.h */
83typedef unsigned short uid_t;
84typedef unsigned short gid_t;
85#endif
86#if defined(_M_AMD64) || defined(_M_X64) || defined(_M_IA64) || defined(_WIN64)
87typedef __int64 ssize_t;
88#else
89typedef long ssize_t;
90#endif
91typedef unsigned long u_long;
92typedef unsigned int u_int;
93typedef unsigned short u_short;
94
95#if !defined(timerisset) && defined(MSCFAKES_NO_WINDOWS_H)
96struct timeval
97{
98 long tv_sec;
99 long tv_usec;
100};
101#endif
102
103struct iovec
104{
105 char *iov_base;
106 size_t iov_len;
107};
108
109typedef __int64 intmax_t;
110#if 0 /* found in config.h */
111typedef unsigned __int64 uintmax_t;
112#endif
113
114#define chown(path, uid, gid) 0 /** @todo implement fchmod! */
115char *dirname(char *path);
116#define fsync(fd) 0
117#define fchown(fd,uid,gid) 0
118#define fchmod(fd, mode) 0 /** @todo implement fchmod! */
119#define geteuid() 0
120#define getegid() 0
121int lchmod(const char *path, mode_t mode);
122int msc_chmod(const char *path, mode_t mode);
123#define chmod msc_chmod
124#define lchown(path, uid, gid) chown(path, uid, gid)
125#define lutimes(path, tvs) utimes(path, tvs)
126int link(const char *pszDst, const char *pszLink);
127int mkdir_msc(const char *path, mode_t mode);
128#define mkdir(path, mode) mkdir_msc(path, mode)
129#define mkfifo(path, mode) -1
130#define mknod(path, mode, devno) -1
131int mkstemp(char *temp);
132#define readlink(link, buf, size) -1
133#define reallocf(old, size) realloc(old, size)
134int rmdir_msc(const char *path);
135#define rmdir(path) rmdir_msc(path)
136intmax_t strtoimax(const char *nptr, char **endptr, int base);
137uintmax_t strtoumax(const char *nptr, char **endptr, int base);
138#define strtoll(a,b,c) strtoimax(a,b,c)
139#define strtoull(a,b,c) strtoumax(a,b,c)
140int asprintf(char **strp, const char *fmt, ...);
141int vasprintf(char **strp, const char *fmt, va_list ap);
142#if _MSC_VER < 1400
143int snprintf(char *buf, size_t size, const char *fmt, ...);
144#else
145#define snprintf _snprintf
146#endif
147int symlink(const char *pszDst, const char *pszLink);
148int utimes(const char *pszPath, const struct timeval *paTimes);
149ssize_t writev(int fd, const struct iovec *vector, int count);
150
151/* bird write ENOSPC hacks. */
152#undef write
153#define write msc_write
154ssize_t msc_write(int fd, const void *pvSrc, size_t cbSrc);
155
156/*
157 * MSC fake internals / helpers.
158 */
159int birdSetErrno(unsigned dwErr);
160
161#endif /* _MSC_VER */
162#endif
163
Note: See TracBrowser for help on using the repository browser.

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