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

Last change on this file since 2702 was 2702, checked in by bird, 12 years ago

kmk/WindowsNT: Avoiding unnecessary stat() calls. Reimplemented stat(), lstat(), fstat(), opendir(), readdir(), and closedir() using native NT APIs.

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