source: trunk/src/kmk/kmkbuiltin/mscfakes.h@ 3188

Last change on this file since 3188 was 3188, checked in by bird, 7 years ago

kmk,lib,kWorker: Console output on windows cleanups.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.5 KB
Line 
1/* $Id: mscfakes.h 3188 2018-03-24 15:32:26Z bird $ */
2/** @file
3 * Unix fakes for MSC.
4 */
5
6/*
7 * Copyright (c) 2005-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net>
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#define timeval windows_timeval
31
32/* Include the config file (kmk's) so we don't need to duplicate stuff from it here. */
33#include "config.h"
34
35#include <io.h>
36#include <direct.h>
37#include <time.h>
38#include <stdarg.h>
39#include <malloc.h>
40#include "getopt.h"
41#ifndef MSCFAKES_NO_WINDOWS_H
42# include <Windows.h>
43#endif
44
45#include <sys/stat.h>
46#include <io.h>
47#include <direct.h>
48#include "nt/ntstat.h"
49#include "nt/ntunlink.h"
50#ifdef MSC_DO_64_BIT_IO
51# if _MSC_VER >= 1400 /* We want 64-bit file lengths here when possible. */
52# define off_t __int64
53# define lseek _lseeki64
54# endif
55#endif
56
57#undef timeval
58
59#undef PATH_MAX
60#define PATH_MAX _MAX_PATH
61#undef MAXPATHLEN
62#define MAXPATHLEN _MAX_PATH
63
64#define EX_OK 0
65#define EX_OSERR 1
66#define EX_NOUSER 1
67#define EX_USAGE 1
68
69#define STDIN_FILENO 0
70#define STDOUT_FILENO 1
71#define STDERR_FILENO 2
72
73#define F_OK 0
74#define X_OK 1
75#define W_OK 2
76#define R_OK 4
77
78#define EFTYPE EINVAL
79
80#define _PATH_DEVNULL "/dev/null"
81
82#ifndef MAX
83# define MAX(a,b) ((a) >= (b) ? (a) : (b))
84#endif
85
86typedef int mode_t;
87typedef unsigned short nlink_t;
88#if 0 /* found in config.h */
89typedef unsigned short uid_t;
90typedef unsigned short gid_t;
91#endif
92typedef intptr_t ssize_t;
93typedef unsigned long u_long;
94typedef unsigned int u_int;
95typedef unsigned short u_short;
96
97#if _MSC_VER >= 1600
98# include <stdint.h>
99#else
100typedef unsigned char uint8_t;
101typedef unsigned short uint16_t;
102typedef unsigned int uint32_t;
103typedef signed char int8_t;
104typedef signed short int16_t;
105typedef signed int int32_t;
106#endif
107
108struct msc_timeval
109{
110 __time64_t tv_sec;
111 long tv_usec;
112};
113#define timeval msc_timeval
114
115struct iovec
116{
117 char *iov_base;
118 size_t iov_len;
119};
120
121typedef __int64 intmax_t;
122#if 0 /* found in config.h */
123typedef unsigned __int64 uintmax_t;
124#endif
125
126#define chown(path, uid, gid) 0 /** @todo implement fchmod! */
127char *dirname(char *path);
128#define fsync(fd) 0
129#define fchown(fd,uid,gid) 0
130#define fchmod(fd, mode) 0 /** @todo implement fchmod! */
131#define geteuid() 0
132#define getegid() 0
133int lchmod(const char *path, mode_t mode);
134int msc_chmod(const char *path, mode_t mode);
135#define chmod msc_chmod
136#define lchown(path, uid, gid) chown(path, uid, gid)
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 msc_timeval *paTimes);
160int lutimes(const char *pszPath, const struct msc_timeval *paTimes);
161ssize_t writev(int fd, const struct iovec *vector, int count);
162
163int gettimeofday(struct msc_timeval *pNow, void *pvIgnored);
164struct tm *localtime_r(const __time64_t *pNow, struct tm *pResult);
165__time64_t timegm(struct tm *pNow);
166#undef mktime
167#define mktime _mktime64
168
169/* bird write ENOSPC hacks. */
170#undef write
171#define write msc_write
172ssize_t msc_write(int fd, const void *pvSrc, size_t cbSrc);
173
174/*
175 * MSC fake internals / helpers.
176 */
177int birdSetErrno(unsigned dwErr);
178
179#endif /* _MSC_VER */
180#endif
181
Note: See TracBrowser for help on using the repository browser.