Skip to content

Commit 3179d23

Browse files
committed
windows: Make unistd.h more posix compatible
- add SEEK_XXX definitions, this fixes missing definition in py/stream.c - move R_OK from realpath.c and add W_OK/F_OK defintions - move STDXXX_FILENO definitions from mpconfigport for consistency
1 parent bdd78c3 commit 3179d23

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

windows/mpconfigport.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,6 @@ void msec_sleep(double msec);
186186
#define restrict
187187
#define inline __inline
188188
#define alignof(t) __alignof(t)
189-
#define STDIN_FILENO 0
190-
#define STDOUT_FILENO 1
191-
#define STDERR_FILENO 2
192189
#define PATH_MAX MICROPY_ALLOC_PATH_MAX
193190
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
194191
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)

windows/msvc/unistd.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,15 @@
2626

2727
// There's no unistd.h, but this is the equivalent
2828
#include <io.h>
29+
30+
#define F_OK 0
31+
#define W_OK 2
32+
#define R_OK 4
33+
34+
#define STDIN_FILENO 0
35+
#define STDOUT_FILENO 1
36+
#define STDERR_FILENO 2
37+
38+
#define SEEK_CUR 1
39+
#define SEEK_END 2
40+
#define SEEK_SET 0

windows/realpath.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,7 @@
2626

2727
#include <stdlib.h>
2828
#include <errno.h>
29-
#include <io.h>
30-
31-
#ifndef R_OK
32-
#define R_OK 4
33-
#endif
29+
#include <unistd.h>
3430

3531
// Make sure a path only has forward slashes.
3632
char *to_unix_path(char *p) {

0 commit comments

Comments
 (0)