5 * Cross-platform compatibility functions and types for I/O.
6 * Currently used by jim-aio.c and jim-exec.c
12 #include "jimautoconf.h"
14 #include <jim-win32compat.h>
17 * Set an error result based on errno and the given message.
19 void Jim_SetResultErrno(Jim_Interp
*interp
, const char *msg
);
22 * Opens the file for writing (and appending if append is true).
23 * Returns the file descriptor, or -1 on failure.
25 int Jim_OpenForWrite(const char *filename
, int append
);
28 * Opens the file for reading.
29 * Returns the file descriptor, or -1 on failure.
31 int Jim_OpenForRead(const char *filename
);
33 #if defined(__MINGW32__)
37 #define WIN32_LEAN_AND_MEAN
43 typedef HANDLE pidtype
;
44 #define JIM_BAD_PID INVALID_HANDLE_VALUE
45 /* Note that this isn't a separate value on Windows since we don't have os.fork */
46 #define JIM_NO_PID INVALID_HANDLE_VALUE
48 /* These seem to accord with the conventions used by msys/mingw32 */
49 #define WIFEXITED(STATUS) (((STATUS) & 0xff00) == 0)
50 #define WEXITSTATUS(STATUS) ((STATUS) & 0x00ff)
51 #define WIFSIGNALED(STATUS) (((STATUS) & 0xff00) != 0)
52 #define WTERMSIG(STATUS) (((STATUS) >> 8) & 0xff)
56 * Unix-compatible errno
59 pidtype
waitpid(pidtype pid
, int *status
, int nohang
);
62 #define pipe(P) _pipe((P), 0, O_NOINHERIT)
64 #elif defined(HAVE_UNISTD_H)
71 #define Jim_Errno() errno
72 #define JIM_BAD_PID -1
76 #define execvpe(ARG0, ARGV, ENV) execvp(ARG0, ARGV)