5 * Cross-platform compatibility functions and types for I/O.
6 * Currently used by jim-aio.c and jim-exec.c
13 #include "jimautoconf.h"
15 #include <jim-win32compat.h>
18 * Set an error result based on errno and the given message.
20 void Jim_SetResultErrno(Jim_Interp
*interp
, const char *msg
);
23 * Opens the file for writing (and appending if append is true).
24 * Returns the file descriptor, or -1 on failure.
26 int Jim_OpenForWrite(const char *filename
, int append
);
29 * Opens the file for reading.
30 * Returns the file descriptor, or -1 on failure.
32 int Jim_OpenForRead(const char *filename
);
34 #if defined(__MINGW32__)
38 #define WIN32_LEAN_AND_MEAN
44 typedef HANDLE pidtype
;
45 #define JIM_BAD_PID INVALID_HANDLE_VALUE
46 /* Note that this isn't a separate value on Windows since we don't have os.fork */
47 #define JIM_NO_PID INVALID_HANDLE_VALUE
49 /* These seem to accord with the conventions used by msys/mingw32 */
50 #define WIFEXITED(STATUS) (((STATUS) & 0xff00) == 0)
51 #define WEXITSTATUS(STATUS) ((STATUS) & 0x00ff)
52 #define WIFSIGNALED(STATUS) (((STATUS) & 0xff00) != 0)
53 #define WTERMSIG(STATUS) (((STATUS) >> 8) & 0xff)
57 * Unix-compatible errno
60 pidtype
waitpid(pidtype pid
, int *status
, int nohang
);
63 #define pipe(P) _pipe((P), 0, O_NOINHERIT)
65 typedef struct _stat64 jim_stat_t
;
66 #define Jim_Stat _stat64
69 typedef struct stat jim_stat_t
;
72 #if defined(HAVE_UNISTD_H)
78 #define Jim_Errno() errno
79 #define JIM_BAD_PID -1
83 #define execvpe(ARG0, ARGV, ENV) execvp(ARG0, ARGV)