2 #ifndef INCLUDE_WINCE_COMPAT_H
3 #define INCLUDE_WINCE_COMPAT_H
9 /*** ANSI C library ***/
11 /* Missing ANSI C definitions */
15 #define ENOMEM ERROR_NOT_ENOUGH_MEMORY
16 #define EBADF ERROR_INVALID_HANDLE
17 #define EINVAL ERROR_INVALID_PARAMETER
18 #define ENOENT ERROR_FILE_NOT_FOUND
19 #define ERANGE ERROR_INSUFFICIENT_BUFFER
20 #define EINTR WSAEINTR
23 * Because we need a per-thread errno, we define a function
24 * pointer that we can call to return a pointer to the errno
25 * for the current thread. Then we define a macro for errno
26 * that dereferences this function's result.
28 * This makes it syntactically just like the "real" errno.
30 * Using a function pointer allows us to use a very fast
31 * function when there are no threads running and a slower
32 * function when there are multiple threads running.
34 void __WinCE_Errno_New_Thread(int *Errno_Pointer);
35 void __WinCE_Errno_Thread_Exit(void);
36 extern int *(*__WinCE_Errno_Pointer_Function)(void);
38 #define errno (*(*__WinCE_Errno_Pointer_Function)())
40 char *strerror(int errnum);
43 int tm_sec; /* seconds after the minute - [0,59] */
44 int tm_min; /* minutes after the hour - [0,59] */
45 int tm_hour; /* hours since midnight - [0,23] */
46 int tm_mday; /* day of the month - [1,31] */
47 int tm_mon; /* months since January - [0,11] */
48 int tm_year; /* years since 1900 */
49 int tm_wday; /* days since Sunday - [0,6] */
50 int tm_yday; /* days since January 1 - [0,365] */
51 int tm_isdst; /* daylight savings time flag */
54 struct tm *gmtime(const time_t *TimeP); /* for future use */
55 struct tm *localtime(const time_t *TimeP);
56 time_t mktime(struct tm *tm);
57 time_t time(time_t *TimeP);
59 size_t strftime(char *s, size_t maxsize, const char *format, const struct tm *tim_p);
61 int _wrename(const wchar_t *oldname, const wchar_t *newname);
62 int _wremove(const wchar_t *filename);
64 /* Environment variables are not supported */
65 #define getenv(x) (NULL)
67 /* Redefine fileno so that it returns an integer */
69 #define fileno(f) (int)_fileno(f)
71 /* Signals are not supported */
72 #define signal(num, handler) (0)
79 /* Missing POSIX definitions */
81 #define FILENAME_MAX MAX_PATH
84 unsigned long st_size;
87 unsigned long st_atime;
88 unsigned long st_mtime;
89 unsigned long st_ctime;
90 unsigned short st_dev;
91 unsigned short st_nlink;
92 unsigned short st_uid;
93 unsigned short st_gid;
96 #define S_IFMT 0170000
97 #define S_IFDIR 0040000
98 #define S_IFREG 0100000
99 #define S_IEXEC 0000100
100 #define S_IWRITE 0000200
101 #define S_IREAD 0000400
103 #define _S_IFDIR S_IFDIR /* MSVCRT compatibilit */
105 int _fstat(int handle, struct _stat *buffer);
106 int _wstat(const wchar_t *path, struct _stat *buffer);
108 #define stat _stat /* NOTE: applies to _stat() and also struct _stat */
111 #define O_RDWR (1<<0)
112 #define O_RDONLY (2<<0)
113 #define O_WRONLY (3<<0)
114 #define O_MODE_MASK (3<<0)
115 #define O_TRUNC (1<<2)
116 #define O_EXCL (1<<3)
117 #define O_CREAT (1<<4)
120 int _wopen(const wchar_t *filename, int oflag, ...);
121 int _close(int handle);
122 int _write(int handle, const void *buffer, unsigned int count);
123 int _read(int handle, void *buffer, unsigned int count);
124 long _lseek(int handle, long offset, int origin);
131 /* WinCE has only a Unicode version of this function */
132 FILE *fdopen(int handle, const char *mode);
134 int _wmkdir(const wchar_t *dirname);
136 /* WinCE has no concept of current directory so we return a constant path */
137 wchar_t *_wgetcwd(wchar_t *buffer, int maxlen);
139 #define freopen(path, mode, stream) assert(0)
145 #endif /* INCLUDE_WINCE_COMPAT_H */