diff options
-rw-r--r-- | generic/tcl.h | 56 | ||||
-rw-r--r-- | generic/tclCmdAH.c | 7 | ||||
-rw-r--r-- | generic/tclIO.c | 4 | ||||
-rw-r--r-- | generic/tclIOCmd.c | 4 | ||||
-rw-r--r-- | unix/tclUnixChan.c | 4 | ||||
-rw-r--r-- | unix/tclUnixFCmd.c | 14 | ||||
-rw-r--r-- | unix/tclUnixFile.c | 6 | ||||
-rw-r--r-- | unix/tclUnixPipe.c | 4 |
8 files changed, 75 insertions, 24 deletions
diff --git a/generic/tcl.h b/generic/tcl.h index ee22f7c..91a5d54 100644 --- a/generic/tcl.h +++ b/generic/tcl.h @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tcl.h,v 1.102.2.5 2001/09/27 15:48:17 dkf Exp $ + * RCS: @(#) $Id: tcl.h,v 1.102.2.6 2001/09/28 14:29:22 dkf Exp $ */ #ifndef _TCL @@ -174,7 +174,8 @@ extern "C" { #ifndef RESOURCE_INCLUDED /* - * Must define _before_ any #include of system headers... + * Must #define _before_ any #include of system headers or all hell + * breaks loose... */ #define _LARGEFILE64_SOURCE 1 /* @@ -344,11 +345,56 @@ typedef long LONG; * Type of 64-bit values on 32-bit systems. FIXME - DKF */ typedef long long Tcl_WideInt; +/* + * Strip the high bits, bearing in mind the sign! + */ +#define Tcl_WideAsLong(val) ((long)(val)) +/* + * Sign-extend the top-bit to the full value! + */ +#define Tcl_LongAsWide(val) ((Tcl_WideInt)(val)) + +/* + * Note on converting between Tcl_WideInt and strings. This + * implementation (in tclObj.c) depends on the functions strtoull() + * and lltostr(); although strtoull is fairly straight-forward, + * lltostr is a most unusual function on Solaris8 (taking its + * operating buffer backwards) so any changes you make will need to be + * done cautiously... + */ + +/* + * If _LARGEFILE64_SOURCE is not defined, then on Solaris at least + * there is no chance that any of the following definitions will work + * in wide mode, so we'll switch to narrow off_t et al. instead. + */ +#ifndef _LARGEFILE64_SOURCE +#define NARROW_OFFSETS +#endif + +#ifdef NARROW_OFFSETS + +typedef struct stat Tcl_StatBuf; +typedef off_t Tcl_SeekOffset; +typedef struct dirent Tcl_DirEntry; +#define Tcl_PlatformStat stat +#define Tcl_PlatformLStat lstat +#define Tcl_PlatformSeek lseek +#define Tcl_PlatformOpen open +#define Tcl_PlatformReaddir readdir + +#else /* NARROW_OFFSETS */ + typedef struct stat64 Tcl_StatBuf; typedef off64_t Tcl_SeekOffset; -#define Tcl_PlatformStat stat64 -#define Tcl_PlatformLStat lstat64 -#define Tcl_PlatformSeek lseek64 +typedef struct dirent64 Tcl_DirEntry; +#define Tcl_PlatformStat stat64 +#define Tcl_PlatformLStat lstat64 +#define Tcl_PlatformSeek lseek64 +#define Tcl_PlatformOpen open64 +#define Tcl_PlatformReaddir readdir64 + +#endif /* NARROW_OFFSETS */ /* * This flag controls whether binary compatability is maintained with diff --git a/generic/tclCmdAH.c b/generic/tclCmdAH.c index fc92ea2..a65c9fb 100644 --- a/generic/tclCmdAH.c +++ b/generic/tclCmdAH.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclCmdAH.c,v 1.16.2.5 2001/09/27 15:08:23 dkf Exp $ + * RCS: @(#) $Id: tclCmdAH.c,v 1.16.2.6 2001/09/28 14:29:23 dkf Exp $ */ #include "tclInt.h" @@ -1420,6 +1420,11 @@ StoreStatData(interp, varName, statPtr) Tcl_IncrRefCount(var); Tcl_IncrRefCount(field); STORE_ARY("dev", Tcl_NewLongObj((long)statPtr->st_dev)); + /* + * Watch out porters; the inode is meant to be an *unsigned* value, + * so the cast might fail when there isn't a real arithmentic 'long + * long' type... + */ STORE_ARY("ino", Tcl_NewWideIntObj((Tcl_WideInt)statPtr->st_ino)); STORE_ARY("nlink", Tcl_NewLongObj((long)statPtr->st_nlink)); STORE_ARY("uid", Tcl_NewLongObj((long)statPtr->st_uid)); diff --git a/generic/tclIO.c b/generic/tclIO.c index 48811f9..b6ab481 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclIO.c,v 1.35.6.3 2001/09/27 14:23:03 dkf Exp $ + * RCS: @(#) $Id: tclIO.c,v 1.35.6.4 2001/09/28 14:29:23 dkf Exp $ */ #include "tclInt.h" @@ -5464,7 +5464,7 @@ Tcl_Tell(chan) */ curPos = (chanPtr->typePtr->seekProc) (chanPtr->instanceData, - (Tcl_WideInt)0, SEEK_CUR, &result); + Tcl_LongAsWide(0), SEEK_CUR, &result); if (curPos == -1) { Tcl_SetErrno(result); return -1; diff --git a/generic/tclIOCmd.c b/generic/tclIOCmd.c index 5638958..9545162 100644 --- a/generic/tclIOCmd.c +++ b/generic/tclIOCmd.c @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclIOCmd.c,v 1.10.2.3 2001/09/27 14:11:43 dkf Exp $ + * RCS: @(#) $Id: tclIOCmd.c,v 1.10.2.4 2001/09/28 14:29:23 dkf Exp $ */ #include "tclInt.h" @@ -455,7 +455,7 @@ Tcl_SeekObjCmd(clientData, interp, objc, objv) } result = Tcl_Seek(chan, offset, mode); - if (result == (Tcl_WideInt)-1) { + if (result == Tcl_LongAsWide(-1)) { Tcl_AppendResult(interp, "error during seek on \"", chanName, "\": ", Tcl_PosixError(interp), (char *) NULL); return TCL_ERROR; diff --git a/unix/tclUnixChan.c b/unix/tclUnixChan.c index 1a51927..1b43ce7 100644 --- a/unix/tclUnixChan.c +++ b/unix/tclUnixChan.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclUnixChan.c,v 1.21.6.4 2001/09/27 15:48:17 dkf Exp $ + * RCS: @(#) $Id: tclUnixChan.c,v 1.21.6.5 2001/09/28 14:29:23 dkf Exp $ */ #include "tclInt.h" /* Internal definitions for Tcl. */ @@ -1326,7 +1326,7 @@ TclpOpenFileChannel(interp, pathPtr, modeString, permissions) if (native == NULL) { return NULL; } - fd = open(native, mode, permissions); + fd = Tcl_PlatformOpen(native, mode, permissions); if (fd < 0) { if (interp != (Tcl_Interp *) NULL) { diff --git a/unix/tclUnixFCmd.c b/unix/tclUnixFCmd.c index 8bdbcaa..8be096b 100644 --- a/unix/tclUnixFCmd.c +++ b/unix/tclUnixFCmd.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclUnixFCmd.c,v 1.12.6.6 2001/09/27 15:48:17 dkf Exp $ + * RCS: @(#) $Id: tclUnixFCmd.c,v 1.12.6.7 2001/09/28 14:29:23 dkf Exp $ * * Portions of this code were derived from NetBSD source code which has * the following copyright notice: @@ -230,7 +230,7 @@ DoRenameFile(src, dst) if (errno == EINVAL) { char srcPath[MAXPATHLEN], dstPath[MAXPATHLEN]; DIR *dirPtr; - struct dirent *dirEntPtr; + Tcl_DirEntry *dirEntPtr; if ((realpath((char *) src, srcPath) != NULL) /* INTL: Native. */ && (realpath((char *) dst, dstPath) != NULL) /* INTL: Native. */ @@ -238,7 +238,7 @@ DoRenameFile(src, dst) dirPtr = opendir(dst); /* INTL: Native. */ if (dirPtr != NULL) { while (1) { - dirEntPtr = readdir(dirPtr); /* INTL: Native. */ + dirEntPtr = Tcl_PlatformReaddir(dirPtr); /* INTL: Native. */ if (dirEntPtr == NULL) { break; } @@ -415,11 +415,11 @@ CopyFile(src, dst, statBufPtr) char *buffer; /* Data buffer for copy */ size_t nread; - if ((srcFd = open(src, O_RDONLY, 0)) < 0) { /* INTL: Native. */ + if ((srcFd = Tcl_PlatformOpen(src,O_RDONLY,0)) < 0) { /* INTL: Native. */ return TCL_ERROR; } - dstFd = open(dst, O_CREAT | O_TRUNC | O_WRONLY, /* INTL: Native. */ + dstFd = Tcl_PlatformOpen(dst, O_CREAT|O_TRUNC|O_WRONLY,/* INTL: Native. */ statBufPtr->st_mode); if (dstFd < 0) { close(srcFd); @@ -772,7 +772,7 @@ TraverseUnixTree(traverseProc, sourcePtr, targetPtr, errorPtr) CONST char *source, *errfile; int result, sourceLen; int targetLen; - struct dirent *dirEntPtr; + Tcl_DirEntry *dirEntPtr; DIR *dirPtr; errfile = NULL; @@ -816,7 +816,7 @@ TraverseUnixTree(traverseProc, sourcePtr, targetPtr, errorPtr) targetLen = Tcl_DStringLength(targetPtr); } - while ((dirEntPtr = readdir(dirPtr)) != NULL) { /* INTL: Native. */ + while ((dirEntPtr = Tcl_PlatformReaddir(dirPtr)) != NULL) { /* INTL: Native. */ if ((strcmp(dirEntPtr->d_name, ".") == 0) || (strcmp(dirEntPtr->d_name, "..") == 0)) { continue; diff --git a/unix/tclUnixFile.c b/unix/tclUnixFile.c index 97e2da5..35d9eb0 100644 --- a/unix/tclUnixFile.c +++ b/unix/tclUnixFile.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclUnixFile.c,v 1.12.6.5 2001/09/27 15:48:17 dkf Exp $ + * RCS: @(#) $Id: tclUnixFile.c,v 1.12.6.6 2001/09/28 14:29:23 dkf Exp $ */ #include "tclInt.h" @@ -295,9 +295,9 @@ TclpMatchInDirectory(interp, resultPtr, pathPtr, pattern, types) while (1) { Tcl_DString utfDs; char *utf; - struct dirent *entryPtr; + Tcl_DirEntry *entryPtr; - entryPtr = readdir(d); /* INTL: Native. */ + entryPtr = Tcl_PlatformReaddir(d); /* INTL: Native. */ if (entryPtr == NULL) { break; } diff --git a/unix/tclUnixPipe.c b/unix/tclUnixPipe.c index 4d82638..23410fc 100644 --- a/unix/tclUnixPipe.c +++ b/unix/tclUnixPipe.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclUnixPipe.c,v 1.15.6.4 2001/09/27 15:48:17 dkf Exp $ + * RCS: @(#) $Id: tclUnixPipe.c,v 1.15.6.5 2001/09/28 14:29:23 dkf Exp $ */ #include "tclInt.h" @@ -140,7 +140,7 @@ TclpOpenFile(fname, mode) Tcl_DString ds; native = Tcl_UtfToExternalDString(NULL, fname, -1, &ds); - fd = open(native, mode, 0666); /* INTL: Native. */ + fd = Tcl_PlatformOpen(native, mode, 0666); /* INTL: Native. */ Tcl_DStringFree(&ds); if (fd != -1) { fcntl(fd, F_SETFD, FD_CLOEXEC); |