summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--auto.def21
-rw-r--r--jim-aio.c4
-rw-r--r--jim-eventloop.c61
-rw-r--r--jim-file.c2
-rw-r--r--jim-win32compat.c6
-rw-r--r--jim-win32compat.h27
-rwxr-xr-xmake-bootstrap-jim6
7 files changed, 67 insertions, 60 deletions
diff --git a/auto.def b/auto.def
index d32e963..1e1c495 100644
--- a/auto.def
+++ b/auto.def
@@ -58,10 +58,11 @@ options {
cc-check-types "long long"
+cc-check-includes sys/socket.h netinet/in.h arpa/inet.h netdb.h
cc-check-includes sys/un.h dlfcn.h unistd.h crt_externs.h
-cc-check-functions ualarm sysinfo lstat fork vfork system
-cc-check-functions backtrace geteuid mkstemp realpath strptime
+cc-check-functions ualarm sysinfo lstat fork vfork system select
+cc-check-functions backtrace geteuid mkstemp realpath strptime gettimeofday
cc-check-functions regcomp waitpid sigaction sys_signame sys_siglist
cc-check-functions syslog opendir readlink sleep usleep pipe inet_ntop getaddrinfo
@@ -86,6 +87,16 @@ if {![cc-check-functions _NSGetEnviron]} {
}
}
+# Windows has a mkdir with no permission arg
+cc-check-includes sys/types.h sys/stat.h
+msg-checking "Checking for mkdir with one arg..."
+if {[cctest -includes {sys/types.h sys/stat.h} -code {mkdir("/dummy");}]} {
+ define HAVE_MKDIR_ONE_ARG
+ msg-result yes
+} else {
+ msg-result no
+}
+
set extra_objs {}
set jimregexp 0
@@ -168,7 +179,7 @@ set dep(binary) pack
set needs(aio) {expr {[cc-check-function-in-lib socket socket] || 1}}
set needs(exec) {expr {([have-feature vfork] && [have-feature waitpid]) || [have-feature system]}}
-set needs(load) {expr {[have-feature dlopen-compat] || [cc-check-function-in-lib dlopen dl]}}
+set needs(load) {expr {[cc-check-function-in-lib dlopen dl] || [have-feature dlopen-compat]}}
set needs(posix) {have-feature waitpid}
set needs(readdir) {have-feature opendir}
set needs(readline) {cc-check-function-in-lib readline readline}
@@ -176,6 +187,7 @@ set needs(signal) {expr {[have-feature sigaction] && [have-feature vfork]}}
set needs(sqlite) {cc-check-function-in-lib sqlite_open sqlite}
set needs(sqlite3) {cc-check-function-in-lib sqlite3_open sqlite3}
set needs(syslog) {have-feature syslog}
+set needs(eventloop) {expr {[have-feature select] || [have-feature usleep]}}
set needs(win32) {have-feature windows}
# First handle dependencies. If an extension is enabled, also enable its dependency
@@ -274,9 +286,6 @@ foreach i [lsort $ext_all] {
}
if {[have-feature windows]} {
- if {"aio" in "$ext $extmod"} {
- define-append LIBS -lwsock32
- }
lappend extra_objs jim-win32compat.o
if {$extmod ne "" && [get-define JIM_LIBTYPE] eq "static"} {
diff --git a/jim-aio.c b/jim-aio.c
index 8f7b12e..e39e60d 100644
--- a/jim-aio.c
+++ b/jim-aio.c
@@ -47,7 +47,7 @@
#include "jim.h"
#include "jimautoconf.h"
-#if !defined(JIM_ANSIC)
+#if defined(HAVE_SYS_SOCKET_H) && defined(HAVE_SELECT) && defined(HAVE_NETINET_IN_H) && defined(HAVE_NETDB_H) && defined(HAVE_ARPA_INET_H)
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
@@ -55,6 +55,8 @@
#ifdef HAVE_SYS_UN_H
#include <sys/un.h>
#endif
+#else
+#define JIM_ANSIC
#endif
#include "jim-eventloop.h"
diff --git a/jim-eventloop.c b/jim-eventloop.c
index ce932a4..fd0336e 100644
--- a/jim-eventloop.c
+++ b/jim-eventloop.c
@@ -344,8 +344,7 @@ jim_wide Jim_DeleteTimeHandler(Jim_Interp *interp, jim_wide id)
int Jim_ProcessEvents(Jim_Interp *interp, int flags)
{
jim_wide sleep_ms = -1;
- int maxfd = -1, numfd = 0, processed = 0;
- fd_set rfds, wfds, efds;
+ int processed = 0;
Jim_EventLoop *eventLoop = Jim_GetAssocData(interp, "eventloop");
Jim_FileEvent *fe = eventLoop->fileEventHead;
Jim_TimeEvent *te;
@@ -359,28 +358,6 @@ int Jim_ProcessEvents(Jim_Interp *interp, int flags)
}
}
- if (flags & JIM_FILE_EVENTS) {
- FD_ZERO(&rfds);
- FD_ZERO(&wfds);
- FD_ZERO(&efds);
-
- /* Check file events */
- while (fe != NULL) {
- int fd = fileno(fe->handle);
-
- if (fe->mask & JIM_EVENT_READABLE)
- FD_SET(fd, &rfds);
- if (fe->mask & JIM_EVENT_WRITABLE)
- FD_SET(fd, &wfds);
- if (fe->mask & JIM_EVENT_EXCEPTION)
- FD_SET(fd, &efds);
- if (maxfd < fd)
- maxfd = fd;
- numfd++;
- fe = fe->next;
- }
- }
-
/* Note that we want call select() even if there are no
* file events to process as long as we want to process time
* events, in order to sleep until the next time event is ready
@@ -410,15 +387,32 @@ int Jim_ProcessEvents(Jim_Interp *interp, int flags)
}
}
- if (numfd == 0) {
- /* Some systems (mingw) can't select() in this case, so convert to a simple sleep */
- if (sleep_ms > 0) {
- msleep(sleep_ms);
- }
- }
- else {
+#ifdef HAVE_SELECT
+ if (flags & JIM_FILE_EVENTS) {
int retval;
struct timeval tv, *tvp = NULL;
+ fd_set rfds, wfds, efds;
+ int maxfd = -1;
+
+ FD_ZERO(&rfds);
+ FD_ZERO(&wfds);
+ FD_ZERO(&efds);
+
+ /* Check file events */
+ while (fe != NULL) {
+ int fd = fileno(fe->handle);
+
+ if (fe->mask & JIM_EVENT_READABLE)
+ FD_SET(fd, &rfds);
+ if (fe->mask & JIM_EVENT_WRITABLE)
+ FD_SET(fd, &wfds);
+ if (fe->mask & JIM_EVENT_EXCEPTION)
+ FD_SET(fd, &efds);
+ if (maxfd < fd)
+ maxfd = fd;
+ fe = fe->next;
+ }
+
if (sleep_ms >= 0) {
tvp = &tv;
tvp->tv_sec = sleep_ms / 1000;
@@ -474,6 +468,11 @@ int Jim_ProcessEvents(Jim_Interp *interp, int flags)
}
}
}
+#else
+ if (sleep_ms > 0) {
+ msleep(sleep_ms);
+ }
+#endif
/* Check time events */
te = eventLoop->timeEventHead;
diff --git a/jim-file.c b/jim-file.c
index 2c70559..4b65aa8 100644
--- a/jim-file.c
+++ b/jim-file.c
@@ -351,7 +351,7 @@ static int file_cmd_delete(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
return JIM_OK;
}
-#ifdef MKDIR_ONE_ARG
+#ifdef HAVE_MKDIR_ONE_ARG
#define MKDIR_DEFAULT(PATHNAME) mkdir(PATHNAME)
#else
#define MKDIR_DEFAULT(PATHNAME) mkdir(PATHNAME, 0755)
diff --git a/jim-win32compat.c b/jim-win32compat.c
index 08e8a54..9eb8e7f 100644
--- a/jim-win32compat.c
+++ b/jim-win32compat.c
@@ -1,7 +1,7 @@
#include "jim.h"
#include "jimautoconf.h"
-#ifdef HAVE_DLOPEN_COMPAT
+#if defined(HAVE_DLOPEN_COMPAT)
void *dlopen(const char *path, int mode)
{
JIM_NOTUSED(mode);
@@ -20,7 +20,7 @@ void *dlsym(void *handle, const char *symbol)
return GetProcAddress((HMODULE)handle, symbol);
}
-const char *dlerror(void)
+char *dlerror(void)
{
static char msg[121];
FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(),
@@ -29,7 +29,7 @@ const char *dlerror(void)
}
#endif
-#if !defined(__MINGW32__) && !defined(__CYGWIN__)
+#ifdef _MSC_VER
/* POSIX gettimeofday() compatibility for WIN32 */
int gettimeofday(struct timeval *tv, void *unused)
{
diff --git a/jim-win32compat.h b/jim-win32compat.h
index 4976579..89e01f5 100644
--- a/jim-win32compat.h
+++ b/jim-win32compat.h
@@ -1,27 +1,24 @@
#ifndef JIM_WIN32COMPAT_H
#define JIM_WIN32COMPAT_H
-#if defined(_WIN32) || defined(WIN32) || defined(__CYGWIN__)
+/* Compatibility for Windows (mingw and msvc, not cygwin */
+
+/* Note that at this point we don't yet have access to jimautoconf.h */
+#if defined(_WIN32) || defined(WIN32)
#ifndef STRICT
#define STRICT
#endif
-
-/* None of these is needed for cygwin */
-#if !defined(__CYGWIN__)
-
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
-#define JIM_ANSIC
-#define MKDIR_ONE_ARG
-
+#define HAVE_DLOPEN
void *dlopen(const char *path, int mode);
int dlclose(void *handle);
void *dlsym(void *handle, const char *symbol);
-const char *dlerror(void);
+char *dlerror(void);
-#if !defined(__MINGW32__)
-/* Most of these are really gcc vs msvc */
+#ifdef _MSC_VER
+/* These are msvc vs gcc */
#if _MSC_VER >= 1000
#pragma warning(disable:4146)
@@ -42,6 +39,7 @@ const char *dlerror(void);
#include <io.h>
+#define HAVE_GETTIMEOFDAY
struct timeval {
long tv_sec;
long tv_usec;
@@ -49,6 +47,7 @@ struct timeval {
int gettimeofday(struct timeval *tv, void *unused);
+#define HAVE_OPENDIR
struct dirent {
char *d_name;
};
@@ -63,10 +62,8 @@ typedef struct DIR {
DIR *opendir(const char *name);
int closedir(DIR *dir);
struct dirent *readdir(DIR *dir);
-#endif /* MSC */
-
-#endif /* __MINGW32__ */
+#endif /* _MSC_VER */
-#endif /* __CYGWIN__ */
+#endif /* WIN32 */
#endif
diff --git a/make-bootstrap-jim b/make-bootstrap-jim
index 11f7a2f..4f492f8 100755
--- a/make-bootstrap-jim
+++ b/make-bootstrap-jim
@@ -48,7 +48,7 @@ allexts="bootstrap aio readdir glob regexp file exec clock array stdlib tclcompa
echo "/* This is single source file, bootstrap version of Jim Tcl. See http://jim.berlios.de/ */"
# define some core features
-for i in _GNU_SOURCE JIM_TCL_COMPAT JIM_REFERENCES JIM_ANSIC HAVE_VFORK JIM_REGEXP HAVE_NO_AUTOCONF _JIMAUTOCONF_H; do
+for i in _GNU_SOURCE JIM_TCL_COMPAT JIM_REFERENCES JIM_ANSIC JIM_REGEXP HAVE_NO_AUTOCONF _JIMAUTOCONF_H; do
echo "#define $i"
done
echo '#define TCL_LIBRARY "."'
@@ -59,8 +59,8 @@ done
# Can we make a bootstrap jimsh work even on mingw32?
cat <<EOF
-#ifdef __MINGW32__
-#define MKDIR_ONE_ARG
+#if defined(__MINGW32__) || defined(__MINGW64__)
+#define HAVE_MKDIR_ONE_ARG
#define HAVE_SYSTEM
#else
#define HAVE_VFORK