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

Last change on this file since 2592 was 2592, checked in by bird, 13 years ago

kmk build fixes for win.amd64.

  • 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 2592 2012-06-17 22:50:38Z 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#if defined(MSC_DO_64_BIT_IO) && _MSC_VER >= 1400 /* We want 64-bit file lengths here when possible. */
42# define off_t __int64
43# undef stat
44# define stat _stat64
45# define fstat _fstat64
46# define lseek _lseeki64
47#else
48# ifndef STAT_REDEFINED_ALREADY
49# define STAT_REDEFINED_ALREADY
50# undef stat
51# define stat(_path, _st) bird_w32_stat(_path, _st)
52extern int bird_w32_stat(const char *, struct stat *);
53# endif
54#endif
55
56#ifndef S_ISDIR
57# define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
58#endif
59#ifndef S_ISREG
60# define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
61#endif
62#define S_ISLNK(m) 0
63#define S_IRWXU (_S_IREAD | _S_IWRITE | _S_IEXEC)
64#define S_IXUSR _S_IEXEC
65#define S_IWUSR _S_IWRITE
66#define S_IRUSR _S_IREAD
67#define S_IRWXG 0000070
68#define S_IRGRP 0000040
69#define S_IWGRP 0000020
70#define S_IXGRP 0000010
71#define S_IRWXO 0000007
72#define S_IROTH 0000004
73#define S_IWOTH 0000002
74#define S_IXOTH 0000001
75#define S_ISUID 0004000
76#define S_ISGID 0002000
77#define ALLPERMS 0000777
78
79#undef PATH_MAX
80#define PATH_MAX _MAX_PATH
81#undef MAXPATHLEN
82#define MAXPATHLEN _MAX_PATH
83
84#define EX_OK 0
85#define EX_OSERR 1
86#define EX_NOUSER 1
87#define EX_USAGE 1
88
89#define STDIN_FILENO 0
90#define STDOUT_FILENO 1
91#define STDERR_FILENO 2
92
93#define F_OK 0
94#define X_OK 1
95#define W_OK 2
96#define R_OK 4
97
98#define EFTYPE EINVAL
99
100#define _PATH_DEVNULL "/dev/null"
101
102#ifndef MAX
103# define MAX(a,b) ((a) >= (b) ? (a) : (b))
104#endif
105
106typedef int mode_t;
107typedef unsigned short nlink_t;
108#if 0 /* found in config.h */
109typedef unsigned short uid_t;
110typedef unsigned short gid_t;
111#endif
112typedef long ssize_t;
113typedef unsigned long u_long;
114typedef unsigned int u_int;
115typedef unsigned short u_short;
116
117#ifndef timerisset
118struct timeval
119{
120 long tv_sec;
121 long tv_usec;
122};
123#endif
124
125struct iovec
126{
127 char *iov_base;
128 size_t iov_len;
129};
130
131typedef __int64 intmax_t;
132#if 0 /* found in config.h */
133typedef unsigned __int64 uintmax_t;
134#endif
135
136#define chown(path, uid, gid) 0 /** @todo implement fchmod! */
137char *dirname(char *path);
138#define fsync(fd) 0
139#define fchown(fd,uid,gid) 0
140#define fchmod(fd, mode) 0 /** @todo implement fchmod! */
141#define geteuid() 0
142#define getegid() 0
143#define lstat(path, s) stat(path, s)
144int lchmod(const char *path, mode_t mode);
145int msc_chmod(const char *path, mode_t mode);
146#define chmod msc_chmod
147#define lchown(path, uid, gid) chown(path, uid, gid)
148#define lutimes(path, tvs) utimes(path, tvs)
149int link(const char *pszDst, const char *pszLink);
150int mkdir_msc(const char *path, mode_t mode);
151#define mkdir(path, mode) mkdir_msc(path, mode)
152#define mkfifo(path, mode) -1
153#define mknod(path, mode, devno) -1
154int mkstemp(char *temp);
155#define readlink(link, buf, size) -1
156#define reallocf(old, size) realloc(old, size)
157int rmdir_msc(const char *path);
158#define rmdir(path) rmdir_msc(path)
159intmax_t strtoimax(const char *nptr, char **endptr, int base);
160uintmax_t strtoumax(const char *nptr, char **endptr, int base);
161#define strtoll(a,b,c) strtoimax(a,b,c)
162#define strtoull(a,b,c) strtoumax(a,b,c)
163int asprintf(char **strp, const char *fmt, ...);
164int vasprintf(char **strp, const char *fmt, va_list ap);
165#if _MSC_VER < 1400
166int snprintf(char *buf, size_t size, const char *fmt, ...);
167#else
168#define snprintf _snprintf
169#endif
170int symlink(const char *pszDst, const char *pszLink);
171int utimes(const char *pszPath, const struct timeval *paTimes);
172int writev(int fd, const struct iovec *vector, int count);
173
174#endif /* _MSC_VER */
175#endif
176
Note: See TracBrowser for help on using the repository browser.