VirtualBox

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

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

MSC seems to have stdint.h in more recent editions. kewl.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.4 KB
Line 
1/* $Id: mscfakes.h 2766 2015-01-30 03:32:38Z 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 _MSC_VER >= 1600
96# include <stdint.h>
97#else
98typedef unsigned char uint8_t;
99typedef unsigned short uint16_t;
100typedef unsigned int uint32_t;
101typedef signed char int8_t;
102typedef signed short int16_t;
103typedef signed int int32_t;
104#endif
105
106#if !defined(timerisset) && defined(MSCFAKES_NO_WINDOWS_H)
107struct timeval
108{
109 long tv_sec;
110 long tv_usec;
111};
112#endif
113
114struct iovec
115{
116 char *iov_base;
117 size_t iov_len;
118};
119
120typedef __int64 intmax_t;
121#if 0 /* found in config.h */
122typedef unsigned __int64 uintmax_t;
123#endif
124
125#define chown(path, uid, gid) 0 /** @todo implement fchmod! */
126char *dirname(char *path);
127#define fsync(fd) 0
128#define fchown(fd,uid,gid) 0
129#define fchmod(fd, mode) 0 /** @todo implement fchmod! */
130#define geteuid() 0
131#define getegid() 0
132int lchmod(const char *path, mode_t mode);
133int msc_chmod(const char *path, mode_t mode);
134#define chmod msc_chmod
135#define lchown(path, uid, gid) chown(path, uid, gid)
136#define lutimes(path, tvs) utimes(path, tvs)
137int link(const char *pszDst, const char *pszLink);
138int mkdir_msc(const char *path, mode_t mode);
139#define mkdir(path, mode) mkdir_msc(path, mode)
140#define mkfifo(path, mode) -1
141#define mknod(path, mode, devno) -1
142int mkstemp(char *temp);
143#define readlink(link, buf, size) -1
144#define reallocf(old, size) realloc(old, size)
145int rmdir_msc(const char *path);
146#define rmdir(path) rmdir_msc(path)
147intmax_t strtoimax(const char *nptr, char **endptr, int base);
148uintmax_t strtoumax(const char *nptr, char **endptr, int base);
149#define strtoll(a,b,c) strtoimax(a,b,c)
150#define strtoull(a,b,c) strtoumax(a,b,c)
151int asprintf(char **strp, const char *fmt, ...);
152int vasprintf(char **strp, const char *fmt, va_list ap);
153#if _MSC_VER < 1400
154int snprintf(char *buf, size_t size, const char *fmt, ...);
155#else
156#define snprintf _snprintf
157#endif
158int symlink(const char *pszDst, const char *pszLink);
159int utimes(const char *pszPath, const struct timeval *paTimes);
160ssize_t writev(int fd, const struct iovec *vector, int count);
161
162/* bird write ENOSPC hacks. */
163#undef write
164#define write msc_write
165ssize_t msc_write(int fd, const void *pvSrc, size_t cbSrc);
166
167/*
168 * MSC fake internals / helpers.
169 */
170int birdSetErrno(unsigned dwErr);
171
172#endif /* _MSC_VER */
173#endif
174
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