summaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
Diffstat (limited to 'unix')
-rw-r--r--unix/Makefile.in4
-rwxr-xr-xunix/configure2
-rw-r--r--unix/tcl.m42
-rw-r--r--unix/tclUnixCompat.c37
-rw-r--r--unix/tclUnixFile.c34
-rw-r--r--unix/tclUnixPort.h7
-rw-r--r--unix/tclUnixSock.c23
7 files changed, 105 insertions, 4 deletions
diff --git a/unix/Makefile.in b/unix/Makefile.in
index 1a0beb2..4a3c3aa 100644
--- a/unix/Makefile.in
+++ b/unix/Makefile.in
@@ -1544,6 +1544,10 @@ tclMacOSXFCmd.o: $(MAC_OSX_DIR)/tclMacOSXFCmd.c
tclMacOSXNotify.o: $(MAC_OSX_DIR)/tclMacOSXNotify.c
$(CC) -c $(CC_SWITCHES) $(MAC_OSX_DIR)/tclMacOSXNotify.c
+# The following is a CYGWIN only source:
+tclWinError.o: $(TOP_DIR)/win/tclWinError.c
+ $(CC) -c $(CC_SWITCHES) $(TOP_DIR)/win/tclWinError.c
+
# DTrace support
$(TCL_OBJS) $(STUB_LIB_OBJS) $(TCLSH_OBJS) $(TCLTEST_OBJS) $(XTTEST_OBJS): @DTRACE_HDR@
diff --git a/unix/configure b/unix/configure
index 9c4a7ae..5e59570 100755
--- a/unix/configure
+++ b/unix/configure
@@ -7429,7 +7429,7 @@ fi
SHLIB_CFLAGS=""
SHLIB_LD='${CC} -shared'
SHLIB_SUFFIX=".dll"
- DL_OBJS="tclLoadDl.o"
+ DL_OBJS="tclLoadDl.o tclWinError.o"
DL_LIBS="-ldl"
CC_SEARCH_FLAGS=""
LD_SEARCH_FLAGS=""
diff --git a/unix/tcl.m4 b/unix/tcl.m4
index 39f8ca1..f6e002e 100644
--- a/unix/tcl.m4
+++ b/unix/tcl.m4
@@ -1224,7 +1224,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
SHLIB_CFLAGS=""
SHLIB_LD='${CC} -shared'
SHLIB_SUFFIX=".dll"
- DL_OBJS="tclLoadDl.o"
+ DL_OBJS="tclLoadDl.o tclWinError.o"
DL_LIBS="-ldl"
CC_SEARCH_FLAGS=""
LD_SEARCH_FLAGS=""
diff --git a/unix/tclUnixCompat.c b/unix/tclUnixCompat.c
index 456a552..48ba4d3 100644
--- a/unix/tclUnixCompat.c
+++ b/unix/tclUnixCompat.c
@@ -964,3 +964,40 @@ CopyString(
* fill-column: 78
* End:
*/
+
+/*
+ *------------------------------------------------------------------------
+ *
+ * TclWinCPUID --
+ *
+ * Get CPU ID information on an Intel box under UNIX (either Linux or Cygwin)
+ *
+ * Results:
+ * Returns TCL_OK if successful, TCL_ERROR if CPUID is not supported or
+ * fails.
+ *
+ * Side effects:
+ * If successful, stores EAX, EBX, ECX and EDX registers after the CPUID
+ * instruction in the four integers designated by 'regsPtr'
+ *
+ *----------------------------------------------------------------------
+ */
+
+int
+TclWinCPUID(
+ unsigned int index, /* Which CPUID value to retrieve. */
+ unsigned int *regsPtr) /* Registers after the CPUID. */
+{
+ int status = TCL_ERROR;
+
+ /* There is no reason this couldn't be implemented on UNIX as well */
+ return status;
+}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */
diff --git a/unix/tclUnixFile.c b/unix/tclUnixFile.c
index c8afeb2..fe3c608 100644
--- a/unix/tclUnixFile.c
+++ b/unix/tclUnixFile.c
@@ -1178,6 +1178,40 @@ TclpUtime(
{
return utime(Tcl_FSGetNativePath(pathPtr), tval);
}
+#ifdef __CYGWIN__
+int TclOSstat(const char *name, Tcl_StatBuf *statBuf) {
+ struct stat buf;
+ int result = stat(name, &buf);
+ statBuf->st_mode = buf.st_mode;
+ statBuf->st_ino = buf.st_ino;
+ statBuf->st_dev = buf.st_dev;
+ statBuf->st_rdev = buf.st_rdev;
+ statBuf->st_nlink = buf.st_nlink;
+ statBuf->st_uid = buf.st_uid;
+ statBuf->st_gid = buf.st_gid;
+ statBuf->st_size = buf.st_size;
+ statBuf->st_atime = buf.st_atime;
+ statBuf->st_mtime = buf.st_mtime;
+ statBuf->st_ctime = buf.st_ctime;
+ return result;
+}
+int TclOSlstat(const char *name, Tcl_StatBuf *statBuf) {
+ struct stat buf;
+ int result = lstat(name, &buf);
+ statBuf->st_mode = buf.st_mode;
+ statBuf->st_ino = buf.st_ino;
+ statBuf->st_dev = buf.st_dev;
+ statBuf->st_rdev = buf.st_rdev;
+ statBuf->st_nlink = buf.st_nlink;
+ statBuf->st_uid = buf.st_uid;
+ statBuf->st_gid = buf.st_gid;
+ statBuf->st_size = buf.st_size;
+ statBuf->st_atime = buf.st_atime;
+ statBuf->st_mtime = buf.st_mtime;
+ statBuf->st_ctime = buf.st_ctime;
+ return result;
+}
+#endif
/*
* Local Variables:
diff --git a/unix/tclUnixPort.h b/unix/tclUnixPort.h
index 2666fb5..48aef9c 100644
--- a/unix/tclUnixPort.h
+++ b/unix/tclUnixPort.h
@@ -78,7 +78,12 @@ typedef off_t Tcl_SeekOffset;
# define TclOSopen open
#endif
-#ifdef HAVE_STRUCT_STAT64
+#ifdef __CYGWIN__
+MODULE_SCOPE int TclOSstat(const char *name, Tcl_StatBuf *statBuf);
+MODULE_SCOPE int TclOSlstat(const char *name, Tcl_StatBuf *statBuf);
+#undef HAVE_STRUCT_STAT_ST_BLOCKS
+#undef HAVE_STRUCT_STAT_ST_BLKSIZE
+#elif defined(HAVE_STRUCT_STAT64)
# define TclOSstat stat64
# define TclOSlstat lstat64
#else
diff --git a/unix/tclUnixSock.c b/unix/tclUnixSock.c
index 7b5c9e0..8c94e7f 100644
--- a/unix/tclUnixSock.c
+++ b/unix/tclUnixSock.c
@@ -1252,13 +1252,25 @@ Tcl_OpenTcpServer(
const char *errorMsg = NULL;
TcpFdList *fds = NULL, *newfds;
+ /*
+ * Try to record and return the most meaningful error message, i.e. the
+ * one from the first socket that went the farthest before it failed.
+ */
+ enum { START, SOCKET, BIND, LISTEN } howfar = START;
+ int my_errno = 0;
+
if (!TclCreateSocketAddress(interp, &addrlist, myHost, port, 1, &errorMsg)) {
goto error;
}
for (addrPtr = addrlist; addrPtr != NULL; addrPtr = addrPtr->ai_next) {
- sock = socket(addrPtr->ai_family, SOCK_STREAM, 0);
+ sock = socket(addrPtr->ai_family, addrPtr->ai_socktype,
+ addrPtr->ai_protocol);
if (sock == -1) {
+ if (howfar < SOCKET) {
+ howfar = SOCKET;
+ my_errno = errno;
+ }
continue;
}
@@ -1308,6 +1320,10 @@ Tcl_OpenTcpServer(
status = bind(sock, addrPtr->ai_addr, addrPtr->ai_addrlen);
if (status == -1) {
+ if (howfar < BIND) {
+ howfar = BIND;
+ my_errno = errno;
+ }
close(sock);
continue;
}
@@ -1326,6 +1342,10 @@ Tcl_OpenTcpServer(
}
status = listen(sock, SOMAXCONN);
if (status < 0) {
+ if (howfar < LISTEN) {
+ howfar = LISTEN;
+ my_errno = errno;
+ }
close(sock);
continue;
}
@@ -1367,6 +1387,7 @@ Tcl_OpenTcpServer(
return statePtr->channel;
}
if (interp != NULL) {
+ errno = my_errno;
Tcl_AppendResult(interp, "couldn't open socket: ",
Tcl_PosixError(interp), NULL);
if (errorMsg != NULL) {