summaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2002-06-28 09:56:53 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2002-06-28 09:56:53 (GMT)
commit162d8a6442e7b0ff9c4e72433af6f403b6c61de8 (patch)
treeb63c3be4e760bb55b6a54bd129b721c82b935145 /unix
parent955c45431fce7b8b9490a2d5ae3132e4f21da0f6 (diff)
downloadtcl-162d8a6442e7b0ff9c4e72433af6f403b6c61de8.zip
tcl-162d8a6442e7b0ff9c4e72433af6f403b6c61de8.tar.gz
tcl-162d8a6442e7b0ff9c4e72433af6f403b6c61de8.tar.bz2
Changed all the Tcl_Platform* symbols to TclOS*; they weren't public so their
names were really badly chosen. Also prevented a double-#def.
Diffstat (limited to 'unix')
-rw-r--r--unix/tclUnixChan.c33
-rw-r--r--unix/tclUnixFCmd.c28
-rw-r--r--unix/tclUnixFile.c30
-rw-r--r--unix/tclUnixPipe.c8
-rw-r--r--unix/tclUnixPort.h33
-rw-r--r--unix/tclUnixThrd.c27
6 files changed, 86 insertions, 73 deletions
diff --git a/unix/tclUnixChan.c b/unix/tclUnixChan.c
index 53ada2b..8bc67e2 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.35 2002/05/24 21:19:08 dkf Exp $
+ * RCS: @(#) $Id: tclUnixChan.c,v 1.36 2002/06/28 09:56:54 dkf Exp $
*/
#include "tclInt.h" /* Internal definitions for Tcl. */
@@ -602,7 +602,7 @@ FileSeekProc(instanceData, offset, mode, errorCodePtr)
/*
* Save our current place in case we need to roll-back the seek.
*/
- oldLoc = Tcl_PlatformSeek(fsPtr->fd, (Tcl_SeekOffset) 0, SEEK_CUR);
+ oldLoc = TclOSseek(fsPtr->fd, (Tcl_SeekOffset) 0, SEEK_CUR);
if (oldLoc == Tcl_LongAsWide(-1)) {
/*
* Bad things are happening. Error out...
@@ -611,14 +611,14 @@ FileSeekProc(instanceData, offset, mode, errorCodePtr)
return -1;
}
- newLoc = Tcl_PlatformSeek(fsPtr->fd, (Tcl_SeekOffset) offset, mode);
+ newLoc = TclOSseek(fsPtr->fd, (Tcl_SeekOffset) offset, mode);
/*
* Check for expressability in our return type, and roll-back otherwise.
*/
if (newLoc > Tcl_LongAsWide(INT_MAX)) {
*errorCodePtr = EOVERFLOW;
- Tcl_PlatformSeek(fsPtr->fd, (Tcl_SeekOffset) oldLoc, SEEK_SET);
+ TclOSseek(fsPtr->fd, (Tcl_SeekOffset) oldLoc, SEEK_SET);
return -1;
} else {
*errorCodePtr = (newLoc == Tcl_LongAsWide(-1)) ? errno : 0;
@@ -658,7 +658,7 @@ FileWideSeekProc(instanceData, offset, mode, errorCodePtr)
FileState *fsPtr = (FileState *) instanceData;
Tcl_WideInt newLoc;
- newLoc = Tcl_PlatformSeek(fsPtr->fd, (Tcl_SeekOffset) offset, mode);
+ newLoc = TclOSseek(fsPtr->fd, (Tcl_SeekOffset) offset, mode);
*errorCodePtr = (newLoc == -1) ? errno : 0;
return newLoc;
@@ -1794,7 +1794,7 @@ TclpOpenFileChannel(interp, pathPtr, modeString, permissions)
if (native == NULL) {
return NULL;
}
- fd = Tcl_PlatformOpen(native, mode, permissions);
+ fd = TclOSopen(native, mode, permissions);
#ifdef SUPPORTS_TTY
ctl_tty = (strcmp (native, "/dev/tty") == 0);
#endif /* SUPPORTS_TTY */
@@ -2954,10 +2954,16 @@ TclpGetDefaultStdChannel(type)
int mode = 0; /* compiler warning (used before set). */
char *bufMode = NULL;
+ /*
+ * Some #def's to make the code a little clearer!
+ */
+#define ZERO_OFFSET ((Tcl_SeekOffset) 0)
+#define ERROR_OFFSET ((Tcl_SeekOffset) -1)
+
switch (type) {
case TCL_STDIN:
- if ((Tcl_PlatformSeek(0, (Tcl_SeekOffset) 0,
- SEEK_CUR) == (Tcl_SeekOffset)-1) && (errno == EBADF)) {
+ if ((TclOSseek(0, ZERO_OFFSET, SEEK_CUR) == ERROR_OFFSET)
+ && (errno == EBADF)) {
return (Tcl_Channel) NULL;
}
fd = 0;
@@ -2965,8 +2971,8 @@ TclpGetDefaultStdChannel(type)
bufMode = "line";
break;
case TCL_STDOUT:
- if ((Tcl_PlatformSeek(1, (Tcl_SeekOffset) 0,
- SEEK_CUR) == (Tcl_SeekOffset)-1) && (errno == EBADF)) {
+ if ((TclOSseek(1, ZERO_OFFSET, SEEK_CUR) == ERROR_OFFSET)
+ && (errno == EBADF)) {
return (Tcl_Channel) NULL;
}
fd = 1;
@@ -2974,8 +2980,8 @@ TclpGetDefaultStdChannel(type)
bufMode = "line";
break;
case TCL_STDERR:
- if ((Tcl_PlatformSeek(2, (Tcl_SeekOffset) 0,
- SEEK_CUR) == (Tcl_SeekOffset)-1) && (errno == EBADF)) {
+ if ((TclOSseek(2, ZERO_OFFSET, SEEK_CUR) == ERROR_OFFSET)
+ && (errno == EBADF)) {
return (Tcl_Channel) NULL;
}
fd = 2;
@@ -2987,6 +2993,9 @@ TclpGetDefaultStdChannel(type)
break;
}
+#undef ZERO_OFFSET
+#undef ERROR_OFFSET
+
channel = Tcl_MakeFileChannel((ClientData) fd, mode);
if (channel == NULL) {
return NULL;
diff --git a/unix/tclUnixFCmd.c b/unix/tclUnixFCmd.c
index 51e354e..4e8ca21 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.24 2002/06/27 12:27:35 vincentdarley Exp $
+ * RCS: @(#) $Id: tclUnixFCmd.c,v 1.25 2002/06/28 09:56:54 dkf Exp $
*
* Portions of this code were derived from NetBSD source code which has
* the following copyright notice:
@@ -260,7 +260,7 @@ DoRenameFile(src, dst)
dirPtr = opendir(dst); /* INTL: Native. */
if (dirPtr != NULL) {
while (1) {
- dirEntPtr = Tcl_PlatformReaddir(dirPtr); /* INTL: Native. */
+ dirEntPtr = TclOSreaddir(dirPtr); /* INTL: Native. */
if (dirEntPtr == NULL) {
break;
}
@@ -344,7 +344,7 @@ DoCopyFile(src, dst)
* Have to do a stat() to determine the filetype.
*/
- if (Tcl_PlatformLStat(src, &srcStatBuf) != 0) { /* INTL: Native. */
+ if (TclOSlstat(src, &srcStatBuf) != 0) { /* INTL: Native. */
return TCL_ERROR;
}
if (S_ISDIR(srcStatBuf.st_mode)) {
@@ -357,7 +357,7 @@ DoCopyFile(src, dst)
* exists, so we remove it first
*/
- if (Tcl_PlatformLStat(dst, &dstStatBuf) == 0) { /* INTL: Native. */
+ if (TclOSlstat(dst, &dstStatBuf) == 0) { /* INTL: Native. */
if (S_ISDIR(dstStatBuf.st_mode)) {
errno = EISDIR;
return TCL_ERROR;
@@ -438,12 +438,12 @@ CopyFile(src, dst, statBufPtr)
char *buffer; /* Data buffer for copy */
size_t nread;
- if ((srcFd = Tcl_PlatformOpen(src, O_RDONLY, 0)) < 0) { /* INTL: Native. */
+ if ((srcFd = TclOSopen(src, O_RDONLY, 0)) < 0) { /* INTL: Native. */
return TCL_ERROR;
}
- dstFd = Tcl_PlatformOpen(dst, /* INTL: Native. */
- O_CREAT | O_TRUNC | O_WRONLY, statBufPtr->st_mode);
+ dstFd = TclOSopen(dst, O_CREAT|O_TRUNC|O_WRONLY, /* INTL: Native. */
+ statBufPtr->st_mode);
if (dstFd < 0) {
close(srcFd);
return TCL_ERROR;
@@ -718,7 +718,7 @@ DoRemoveDirectory(pathPtr, recursive, errorPtr)
Tcl_StatBuf statBuf;
int newPerm;
- if (Tcl_PlatformStat(path, &statBuf) == 0) {
+ if (TclOSstat(path, &statBuf) == 0) {
oldPerm = (mode_t) (statBuf.st_mode & 0x00007FFF);
}
@@ -803,7 +803,7 @@ TraverseUnixTree(traverseProc, sourcePtr, targetPtr, errorPtr)
targetLen = 0; /* lint. */
source = Tcl_DStringValue(sourcePtr);
- if (Tcl_PlatformLStat(source, &statBuf) != 0) { /* INTL: Native. */
+ if (TclOSlstat(source, &statBuf) != 0) { /* INTL: Native. */
errfile = source;
goto end;
}
@@ -838,8 +838,8 @@ TraverseUnixTree(traverseProc, sourcePtr, targetPtr, errorPtr)
Tcl_DStringAppend(targetPtr, "/", 1);
targetLen = Tcl_DStringLength(targetPtr);
}
-
- while ((dirEntPtr = Tcl_PlatformReaddir(dirPtr)) != NULL) { /* INTL: Native. */
+
+ while ((dirEntPtr = TclOSreaddir(dirPtr)) != NULL) { /* INTL: Native. */
if ((strcmp(dirEntPtr->d_name, ".") == 0)
|| (strcmp(dirEntPtr->d_name, "..") == 0)) {
continue;
@@ -904,8 +904,8 @@ TraverseUnixTree(traverseProc, sourcePtr, targetPtr, errorPtr)
*
* TraversalCopy
*
- * Called from TraverseUnixTree in order to execute a recursive copy of a
- * directory.
+ * Called from TraverseUnixTree in order to execute a recursive copy
+ * of a directory.
*
* Results:
* Standard Tcl result.
@@ -931,7 +931,7 @@ TraversalCopy(srcPtr, dstPtr, statBufPtr, type, errorPtr)
switch (type) {
case DOTREE_F:
if (DoCopyFile(Tcl_DStringValue(srcPtr),
- Tcl_DStringValue(dstPtr)) == TCL_OK) {
+ Tcl_DStringValue(dstPtr)) == TCL_OK) {
return TCL_OK;
}
break;
diff --git a/unix/tclUnixFile.c b/unix/tclUnixFile.c
index 6724778..955f12e 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.24 2002/06/21 14:22:29 vincentdarley Exp $
+ * RCS: @(#) $Id: tclUnixFile.c,v 1.25 2002/06/28 09:56:54 dkf Exp $
*/
#include "tclInt.h"
@@ -118,8 +118,8 @@ TclpFindExecutable(argv0)
* strings directly.
*/
- if ((access(name, X_OK) == 0) /* INTL: Native. */
- && (Tcl_PlatformStat(name, &statBuf) == 0) /* INTL: Native. */
+ if ((access(name, X_OK) == 0) /* INTL: Native. */
+ && (TclOSstat(name, &statBuf) == 0) /* INTL: Native. */
&& S_ISREG(statBuf.st_mode)) {
goto gotName;
}
@@ -273,7 +273,7 @@ TclpMatchInDirectory(interp, resultPtr, pathPtr, pattern, types)
native = Tcl_UtfToExternalDString(NULL, dirName, -1, &ds);
- if ((Tcl_PlatformStat(native, &statBuf) != 0) /* INTL: UTF-8. */
+ if ((TclOSstat(native, &statBuf) != 0) /* INTL: Native. */
|| !S_ISDIR(statBuf.st_mode)) {
Tcl_DStringFree(&dsOrig);
Tcl_DStringFree(&ds);
@@ -313,7 +313,7 @@ TclpMatchInDirectory(interp, resultPtr, pathPtr, pattern, types)
CONST char *utf;
Tcl_DirEntry *entryPtr;
- entryPtr = Tcl_PlatformReaddir(d); /* INTL: Native. */
+ entryPtr = TclOSreaddir(d); /* INTL: Native. */
if (entryPtr == NULL) {
break;
}
@@ -378,12 +378,12 @@ NativeMatchType(
* doesn't exist (since that case would not show up
* if we used 'access' or 'stat')
*/
- if (Tcl_PlatformLStat(nativeEntry, &buf) != 0) {
+ if (TclOSlstat(nativeEntry, &buf) != 0) {
return 0;
}
} else {
if (types->perm != 0) {
- if (Tcl_PlatformStat(nativeEntry, &buf) != 0) {
+ if (TclOSstat(nativeEntry, &buf) != 0) {
/*
* Either the file has disappeared between the
* 'readdir' call and the 'stat' call, or
@@ -417,7 +417,7 @@ NativeMatchType(
if (types->type != 0) {
if (types->perm == 0) {
/* We haven't yet done a stat on the file */
- if (Tcl_PlatformStat(nativeEntry, &buf) != 0) {
+ if (TclOSstat(nativeEntry, &buf) != 0) {
/* Posix error occurred */
return 0;
}
@@ -436,22 +436,22 @@ NativeMatchType(
S_ISFIFO(buf.st_mode)) ||
((types->type & TCL_GLOB_TYPE_FILE) &&
S_ISREG(buf.st_mode))
- #ifdef S_ISSOCK
+#ifdef S_ISSOCK
|| ((types->type & TCL_GLOB_TYPE_SOCK) &&
S_ISSOCK(buf.st_mode))
- #endif
+#endif /* S_ISSOCK */
) {
/* Do nothing -- this file is ok */
} else {
- #ifdef S_ISLNK
+#ifdef S_ISLNK
if (types->type & TCL_GLOB_TYPE_LINK) {
- if (Tcl_PlatformLStat(nativeEntry, &buf) == 0) {
+ if (TclOSlstat(nativeEntry, &buf) == 0) {
if (S_ISLNK(buf.st_mode)) {
return 1;
}
}
}
- #endif
+#endif /* S_ISLNK */
return 0;
}
}
@@ -581,7 +581,7 @@ TclpObjLstat(pathPtr, bufPtr)
Tcl_Obj *pathPtr; /* Path of file to stat */
Tcl_StatBuf *bufPtr; /* Filled with results of stat call. */
{
- return Tcl_PlatformLStat(Tcl_FSGetNativePath(pathPtr), bufPtr);
+ return TclOSlstat(Tcl_FSGetNativePath(pathPtr), bufPtr);
}
/*
@@ -716,7 +716,7 @@ TclpObjStat(pathPtr, bufPtr)
if (path == NULL) {
return -1;
} else {
- return Tcl_PlatformStat(path, bufPtr);
+ return TclOSstat(path, bufPtr);
}
}
diff --git a/unix/tclUnixPipe.c b/unix/tclUnixPipe.c
index f3f67f5..4c17c17 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.21 2002/02/15 14:28:50 dkf Exp $
+ * RCS: @(#) $Id: tclUnixPipe.c,v 1.22 2002/06/28 09:56:54 dkf Exp $
*/
#include "tclInt.h"
@@ -140,7 +140,7 @@ TclpOpenFile(fname, mode)
Tcl_DString ds;
native = Tcl_UtfToExternalDString(NULL, fname, -1, &ds);
- fd = Tcl_PlatformOpen(native, mode, 0666); /* INTL: Native. */
+ fd = TclOSopen(native, mode, 0666); /* INTL: Native. */
Tcl_DStringFree(&ds);
if (fd != -1) {
fcntl(fd, F_SETFD, FD_CLOEXEC);
@@ -151,7 +151,7 @@ TclpOpenFile(fname, mode)
*/
if (mode & O_WRONLY) {
- Tcl_PlatformSeek(fd, (Tcl_SeekOffset) 0, SEEK_END);
+ TclOSseek(fd, (Tcl_SeekOffset) 0, SEEK_END);
}
/*
@@ -215,7 +215,7 @@ TclpCreateTempFile(contents)
return NULL;
}
Tcl_DStringFree(&dstring);
- Tcl_PlatformSeek(fd, (Tcl_SeekOffset) 0, SEEK_SET);
+ TclOSseek(fd, (Tcl_SeekOffset) 0, SEEK_SET);
}
return MakeFile(fd);
}
diff --git a/unix/tclUnixPort.h b/unix/tclUnixPort.h
index cf1ec22..ef39fc5 100644
--- a/unix/tclUnixPort.h
+++ b/unix/tclUnixPort.h
@@ -19,7 +19,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclUnixPort.h,v 1.25 2002/06/07 08:50:22 dkf Exp $
+ * RCS: @(#) $Id: tclUnixPort.h,v 1.26 2002/06/28 09:56:54 dkf Exp $
*/
#ifndef _TCLUNIXPORT
@@ -59,30 +59,30 @@
#ifdef HAVE_STRUCT_DIRENT64
typedef struct dirent64 Tcl_DirEntry;
-# define Tcl_PlatformReaddir readdir64
-# define Tcl_PlatformReaddir_r readdir64_r
+# define TclOSreaddir readdir64
+# define TclOSreaddir_r readdir64_r
#else
typedef struct dirent Tcl_DirEntry;
-# define Tcl_PlatformReaddir readdir
-# define Tcl_PlatformReaddir_r readdir_r
+# define TclOSreaddir readdir
+# define TclOSreaddir_r readdir_r
#endif
#ifdef HAVE_TYPE_OFF64_T
typedef off64_t Tcl_SeekOffset;
-# define Tcl_PlatformSeek lseek64
-# define Tcl_PlatformOpen open64
+# define TclOSseek lseek64
+# define TclOSopen open64
#else
typedef off_t Tcl_SeekOffset;
-# define Tcl_PlatformSeek lseek
-# define Tcl_PlatformOpen open
+# define TclOSseek lseek
+# define TclOSopen open
#endif
#ifdef HAVE_STRUCT_STAT64
-# define Tcl_PlatformStat stat64
-# define Tcl_PlatformLStat lstat64
+# define TclOSstat stat64
+# define TclOSlstat lstat64
#else
-# define Tcl_PlatformStat stat
-# define Tcl_PlatformLStat lstat
+# define TclOSstat stat
+# define TclOSlstat lstat
#endif
#if !HAVE_STRTOLL && defined(TCL_WIDE_INT_TYPE) && !TCL_WIDE_INT_IS_LONG
@@ -324,9 +324,10 @@ EXTERN int gettimeofday _ANSI_ARGS_((struct timeval *tp,
*/
#ifndef S_IFLNK
+# undef TclOSlstat
# define lstat stat
# define lstat64 stat64
-# define Tcl_PlatformLStat Tcl_PlatformStat
+# define TclOSlstat TclOSstat
#endif
/*
@@ -560,8 +561,8 @@ EXTERN char * TclpInetNtoa(struct in_addr);
#define localtime(x) TclpLocaltime(x)
#define gmtime(x) TclpGmtime(x)
#define inet_ntoa(x) TclpInetNtoa(x)
-#undef Tcl_PlatformReaddir
-#define Tcl_PlatformReaddir(x) TclpReaddir(x)
+#undef TclOSreaddir
+#define TclOSreaddir(x) TclpReaddir(x)
#else
typedef int TclpMutex;
#define TclpMutexInit(a)
diff --git a/unix/tclUnixThrd.c b/unix/tclUnixThrd.c
index daa49be..c0640cd 100644
--- a/unix/tclUnixThrd.c
+++ b/unix/tclUnixThrd.c
@@ -803,23 +803,26 @@ TclpReaddir(DIR * dir)
#ifdef HAVE_READDIR_R
ent = &tsdPtr->rdbuf.ent;
- if (Tcl_PlatformReaddir_r(dir, ent, &ent) != 0) {
+ if (TclOSreaddir_r(dir, ent, &ent) != 0) {
ent = NULL;
}
-#else
- Tcl_MutexLock( &rdMutex );
-#ifdef HAVE_STRUCT_DIRENT64
+
+#else /* !HAVE_READDIR_R */
+
+ Tcl_MutexLock(&rdMutex);
+# ifdef HAVE_STRUCT_DIRENT64
ent = readdir64(dir);
-#else
+# else /* !HAVE_STRUCT_DIRENT64 */
ent = readdir(dir);
-#endif
- if(ent != NULL) {
- memcpy( (VOID *) &tsdPtr->rdbuf.ent, (VOID *) ent,
- sizeof (Tcl_DirEntry) + sizeof (char) * (PATH_MAX+1) );
- ent = &tsdPtr->rdbuf.ent;
+# endif /* HAVE_STRUCT_DIRENT64 */
+ if (ent != NULL) {
+ memcpy((VOID *) &tsdPtr->rdbuf.ent, (VOID *) ent,
+ sizeof(Tcl_DirEntry) + sizeof(char) * (PATH_MAX+1));
+ ent = &tsdPtr->rdbuf.ent;
}
- Tcl_MutexUnlock( &rdMutex );
-#endif
+ Tcl_MutexUnlock(&rdMutex);
+
+#endif /* HAVE_READDIR_R */
return ent;
}