diff options
author | Steve Bennett <steveb@workware.net.au> | 2024-10-24 22:24:43 +0000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2024-10-27 11:19:15 +1000 |
commit | 74b223e60cb06c1f0211e019a8dc37a3a274b6eb (patch) | |
tree | 864426a9223cbb0dda96b06de4b56f83cdf7b20d | |
parent | 0b6c814cdd67b20a2104a9540b6514a37f92a76a (diff) | |
download | jimtcl-74b223e60cb06c1f0211e019a8dc37a3a274b6eb.zip jimtcl-74b223e60cb06c1f0211e019a8dc37a3a274b6eb.tar.gz jimtcl-74b223e60cb06c1f0211e019a8dc37a3a274b6eb.tar.bz2 |
Allow bootstrap jimsh to build with msvc on windows
Signed-off-by: Steve Bennett <steveb@workware.net.au>
-rw-r--r-- | jim-aio.c | 39 | ||||
-rw-r--r-- | jim-win32compat.h | 11 | ||||
-rw-r--r-- | jimiocompat.c | 2 | ||||
-rw-r--r-- | jimiocompat.h | 10 | ||||
-rwxr-xr-x | make-bootstrap-jim | 4 |
5 files changed, 35 insertions, 31 deletions
@@ -723,7 +723,26 @@ static void aio_consume(Jim_Obj *objPtr, int n) } /* forward declaration */ -static int aio_autoflush(Jim_Interp *interp, void *clientData, int mask); +static int aio_flush(Jim_Interp *interp, AioFile *af); + +#ifdef jim_ext_eventloop +/** + * Called when the channel is writable. + * Write what we can and return -1 when the write buffer is empty to remove the handler. + */ +static int aio_autoflush(Jim_Interp *interp, void *clientData, int mask) +{ + AioFile *af = clientData; + + aio_flush(interp, af); + if (Jim_Length(af->writebuf) == 0) { + /* Done, so remove the handler */ + return -1; + } + return 0; +} +#endif + /** * Flushes af->writebuf to the channel and removes that data @@ -772,22 +791,6 @@ static int aio_flush(Jim_Interp *interp, AioFile *af) } /** - * Called when the channel is writable. - * Write what we can and return -1 when the write buffer is empty to remove the handler. - */ -static int aio_autoflush(Jim_Interp *interp, void *clientData, int mask) -{ - AioFile *af = clientData; - - aio_flush(interp, af); - if (Jim_Length(af->writebuf) == 0) { - /* Done, so remove the handler */ - return -1; - } - return 0; -} - -/** * Read until 'len' bytes are available in readbuf. * * If flags contains AIO_NONBLOCK, indicates a nonblocking read. @@ -1682,6 +1685,7 @@ static int aio_cmd_readsize(Jim_Interp *interp, int argc, Jim_Obj *const *argv) return JIM_OK; } +#ifdef jim_ext_eventloop static int aio_cmd_timeout(Jim_Interp *interp, int argc, Jim_Obj *const *argv) { #ifdef HAVE_SELECT @@ -1699,7 +1703,6 @@ static int aio_cmd_timeout(Jim_Interp *interp, int argc, Jim_Obj *const *argv) #endif } -#ifdef jim_ext_eventloop static int aio_eventinfo(Jim_Interp *interp, AioFile * af, unsigned mask, int argc, Jim_Obj * const *argv) { diff --git a/jim-win32compat.h b/jim-win32compat.h index 16133b5..acb47c8 100644 --- a/jim-win32compat.h +++ b/jim-win32compat.h @@ -30,6 +30,9 @@ char *dlerror(void); #include <limits.h> #define jim_wide _int64 +#ifndef HAVE_LONG_LONG +#define HAVE_LONG_LONG +#endif #ifndef LLONG_MAX #define LLONG_MAX 9223372036854775807I64 #endif @@ -43,12 +46,8 @@ char *dlerror(void); #define strtoull _strtoui64 #include <io.h> - -struct timeval { - long tv_sec; - long tv_usec; -}; - +/* For struct timeval */ +#include <winsock.h> int gettimeofday(struct timeval *tv, void *unused); #define HAVE_OPENDIR diff --git a/jimiocompat.c b/jimiocompat.c index 0f789f4..44a1387 100644 --- a/jimiocompat.c +++ b/jimiocompat.c @@ -6,7 +6,7 @@ void Jim_SetResultErrno(Jim_Interp *interp, const char *msg) Jim_SetResultFormatted(interp, "%s: %s", msg, strerror(Jim_Errno())); } -#if defined(__MINGW32__) +#if defined(_WIN32) || defined(WIN32) #include <sys/stat.h> int Jim_Errno(void) diff --git a/jimiocompat.h b/jimiocompat.h index 0837b73..64dc4c1 100644 --- a/jimiocompat.h +++ b/jimiocompat.h @@ -31,7 +31,7 @@ int Jim_OpenForWrite(const char *filename, int append); */ int Jim_OpenForRead(const char *filename); -#if defined(__MINGW32__) +#if defined(__MINGW32__) || defined(_WIN32) #ifndef STRICT #define STRICT #endif @@ -69,6 +69,7 @@ int Jim_OpenForRead(const char *filename); #define Jim_Stat _stat64 #define Jim_FileStat _fstat64 #define Jim_Lseek _lseeki64 + #define O_TEXT _O_TEXT #else #if defined(HAVE_STAT64) @@ -111,10 +112,11 @@ int Jim_OpenForRead(const char *filename); #define execvpe(ARG0, ARGV, ENV) execvp(ARG0, ARGV) #endif #endif -#endif -#ifndef O_TEXT -#define O_TEXT 0 + #ifndef O_TEXT + #define O_TEXT 0 + #endif + #endif /* jim-file.c */ diff --git a/make-bootstrap-jim b/make-bootstrap-jim index c053ac8..662384f 100755 --- a/make-bootstrap-jim +++ b/make-bootstrap-jim @@ -40,11 +40,11 @@ EOF echo "}" } -cexts="aio readdir regexp file exec clock array posix" +cexts="aio readdir regexp file exec clock array" tclexts="bootstrap initjimsh glob stdlib tclcompat" # Note ordering -allexts="bootstrap aio readdir regexp file glob exec posix clock array stdlib tclcompat" +allexts="bootstrap aio readdir regexp file glob exec clock array stdlib tclcompat" echo "/* This is single source file, bootstrap version of Jim Tcl. See http://jim.tcl.tk/ */" |