diff options
author | stanton <stanton> | 1998-09-21 23:39:52 (GMT) |
---|---|---|
committer | stanton <stanton> | 1998-09-21 23:39:52 (GMT) |
commit | 494c2de3a748b449c69ce322a1a741f5a31fd4d5 (patch) | |
tree | c3ece48c0ae3f4ba54787e0e8e729b65752ef3f9 /win/tclWinPort.h | |
parent | 7a698c0488d99c0af42022714638ae1ba2afaa49 (diff) | |
download | tcl-494c2de3a748b449c69ce322a1a741f5a31fd4d5.zip tcl-494c2de3a748b449c69ce322a1a741f5a31fd4d5.tar.gz tcl-494c2de3a748b449c69ce322a1a741f5a31fd4d5.tar.bz2 |
Added contents of Tcl 8.1a2
Diffstat (limited to 'win/tclWinPort.h')
-rw-r--r-- | win/tclWinPort.h | 391 |
1 files changed, 223 insertions, 168 deletions
diff --git a/win/tclWinPort.h b/win/tclWinPort.h index 99183cd..7452739 100644 --- a/win/tclWinPort.h +++ b/win/tclWinPort.h @@ -5,32 +5,58 @@ * differences between Windows and Unix. It should be the only * file that contains #ifdefs to handle different flavors of OS. * - * Copyright (c) 1994-1996 Sun Microsystems, Inc. + * Copyright (c) 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * SCCS: @(#) tclWinPort.h 1.53 97/07/30 14:12:17 + * SCCS: @(#) tclWinPort.h 1.62 98/02/18 14:00:22 */ #ifndef _TCLWINPORT #define _TCLWINPORT -#include <malloc.h> -#include <stdio.h> +#ifndef _TCLINT +# include "tclInt.h" +#endif + +#ifdef CHECK_UNICODE_CALLS + +#define _UNICODE +#define UNICODE + +#define __TCHAR_DEFINED +typedef float *_TCHAR; +#define _TCHAR_DEFINED +typedef float *TCHAR; + +#endif + +/* + *--------------------------------------------------------------------------- + * The following sets of #includes and #ifdefs are required to get Tcl to + * compile under the windows compilers. + *--------------------------------------------------------------------------- + */ + +#include <stdio.h> #include <stdlib.h> -#include <string.h> + +#include <direct.h> #include <errno.h> +#include <fcntl.h> +#include <float.h> +#include <io.h> +#include <malloc.h> #include <process.h> #include <signal.h> -#include <winsock.h> +#include <string.h> #include <sys/stat.h> #include <sys/timeb.h> +#include <tchar.h> #include <time.h> -#include <io.h> -#include <fcntl.h> -#include <float.h> +#include <winsock.h> #define WIN32_LEAN_AND_MEAN #include <windows.h> @@ -53,27 +79,112 @@ #endif /* - * The following defines wrap the system memory allocation routines for - * use by tclAlloc.c. - */ - -#define TclpSysAlloc(size, isBin) ((void*)GlobalAlloc(GMEM_FIXED, \ - (DWORD)size)) -#define TclpSysFree(ptr) (GlobalFree((HGLOBAL)ptr)) -#define TclpSysRealloc(ptr, size) ((void*)GlobalReAlloc((HGLOBAL)ptr, \ - (DWORD)size, 0)) - -/* - * The default platform eol translation on Windows is TCL_TRANSLATE_CRLF: - */ - -#define TCL_PLATFORM_TRANSLATION TCL_TRANSLATE_CRLF - -/* - * Declare dynamic loading extension macro. + * The following defines redefine the Windows Socket errors as + * BSD errors so Tcl_PosixError can do the right thing. */ -#define TCL_SHLIB_EXT ".dll" +#ifndef EWOULDBLOCK +#define EWOULDBLOCK EAGAIN +#endif +#ifndef EALREADY +#define EALREADY 149 /* operation already in progress */ +#endif +#ifndef ENOTSOCK +#define ENOTSOCK 95 /* Socket operation on non-socket */ +#endif +#ifndef EDESTADDRREQ +#define EDESTADDRREQ 96 /* Destination address required */ +#endif +#ifndef EMSGSIZE +#define EMSGSIZE 97 /* Message too long */ +#endif +#ifndef EPROTOTYPE +#define EPROTOTYPE 98 /* Protocol wrong type for socket */ +#endif +#ifndef ENOPROTOOPT +#define ENOPROTOOPT 99 /* Protocol not available */ +#endif +#ifndef EPROTONOSUPPORT +#define EPROTONOSUPPORT 120 /* Protocol not supported */ +#endif +#ifndef ESOCKTNOSUPPORT +#define ESOCKTNOSUPPORT 121 /* Socket type not supported */ +#endif +#ifndef EOPNOTSUPP +#define EOPNOTSUPP 122 /* Operation not supported on socket */ +#endif +#ifndef EPFNOSUPPORT +#define EPFNOSUPPORT 123 /* Protocol family not supported */ +#endif +#ifndef EAFNOSUPPORT +#define EAFNOSUPPORT 124 /* Address family not supported */ +#endif +#ifndef EADDRINUSE +#define EADDRINUSE 125 /* Address already in use */ +#endif +#ifndef EADDRNOTAVAIL +#define EADDRNOTAVAIL 126 /* Can't assign requested address */ +#endif +#ifndef ENETDOWN +#define ENETDOWN 127 /* Network is down */ +#endif +#ifndef ENETUNREACH +#define ENETUNREACH 128 /* Network is unreachable */ +#endif +#ifndef ENETRESET +#define ENETRESET 129 /* Network dropped connection on reset */ +#endif +#ifndef ECONNABORTED +#define ECONNABORTED 130 /* Software caused connection abort */ +#endif +#ifndef ECONNRESET +#define ECONNRESET 131 /* Connection reset by peer */ +#endif +#ifndef ENOBUFS +#define ENOBUFS 132 /* No buffer space available */ +#endif +#ifndef EISCONN +#define EISCONN 133 /* Socket is already connected */ +#endif +#ifndef ENOTCONN +#define ENOTCONN 134 /* Socket is not connected */ +#endif +#ifndef ESHUTDOWN +#define ESHUTDOWN 143 /* Can't send after socket shutdown */ +#endif +#ifndef ETOOMANYREFS +#define ETOOMANYREFS 144 /* Too many references: can't splice */ +#endif +#ifndef ETIMEDOUT +#define ETIMEDOUT 145 /* Connection timed out */ +#endif +#ifndef ECONNREFUSED +#define ECONNREFUSED 146 /* Connection refused */ +#endif +#ifndef ELOOP +#define ELOOP 90 /* Symbolic link loop */ +#endif +#ifndef EHOSTDOWN +#define EHOSTDOWN 147 /* Host is down */ +#endif +#ifndef EHOSTUNREACH +#define EHOSTUNREACH 148 /* No route to host */ +#endif +#ifndef ENOTEMPTY +#define ENOTEMPTY 93 /* directory not empty */ +#endif +#ifndef EUSERS +#define EUSERS 94 /* Too many users (for UFS) */ +#endif +#ifndef EDQUOT +#define EDQUOT 49 /* Disc quota exceeded */ +#endif +#ifndef ESTALE +#define ESTALE 151 /* Stale NFS file handle */ +#endif +#ifndef EREMOTE +#define EREMOTE 66 /* The object is remote */ +#endif /* * Supply definitions for macros to query wait status, if not already @@ -123,17 +234,9 @@ #endif /* - * Define MAXPATHLEN in terms of MAXPATH if available + * Define access mode constants if they aren't already defined. */ -#ifndef MAXPATH -#define MAXPATH MAX_PATH -#endif /* MAXPATH */ - -#ifndef MAXPATHLEN -#define MAXPATHLEN MAXPATH -#endif /* MAXPATHLEN */ - #ifndef F_OK # define F_OK 00 #endif @@ -189,6 +292,18 @@ # endif /* + * Define MAXPATHLEN in terms of MAXPATH if available + */ + +#ifndef MAXPATH +#define MAXPATH MAX_PATH +#endif /* MAXPATH */ + +#ifndef MAXPATHLEN +#define MAXPATHLEN MAXPATH +#endif /* MAXPATHLEN */ + +/* * Define pid_t and uid_t if they're not already defined. */ @@ -200,12 +315,6 @@ #endif /* - * Provide a stub definition for TclGetUserHome(). - */ - -#define TclGetUserHome(name,bufferPtr) (NULL) - -/* * Visual C++ has some odd names for common functions, so we need to * define a few macros to handle them. Also, it defines EDEADLOCK and * EDEADLK as the same value, which confuses Tcl_ErrnoId(). @@ -219,112 +328,24 @@ #endif /* _MSC_VER */ /* - * The following defines redefine the Windows Socket errors as - * BSD errors so Tcl_PosixError can do the right thing. + *--------------------------------------------------------------------------- + * The following macros and declarations represent the interface between + * generic and windows-specific parts of Tcl. Some of the macros may + * override functions declared in tclInt.h. + *--------------------------------------------------------------------------- */ -#ifndef EWOULDBLOCK -#define EWOULDBLOCK EAGAIN -#endif -#ifndef EALREADY -#define EALREADY 149 /* operation already in progress */ -#endif -#ifndef ENOTSOCK -#define ENOTSOCK 95 /* Socket operation on non-socket */ -#endif -#ifndef EDESTADDRREQ -#define EDESTADDRREQ 96 /* Destination address required */ -#endif -#ifndef EMSGSIZE -#define EMSGSIZE 97 /* Message too long */ -#endif -#ifndef EPROTOTYPE -#define EPROTOTYPE 98 /* Protocol wrong type for socket */ -#endif -#ifndef ENOPROTOOPT -#define ENOPROTOOPT 99 /* Protocol not available */ -#endif -#ifndef EPROTONOSUPPORT -#define EPROTONOSUPPORT 120 /* Protocol not supported */ -#endif -#ifndef ESOCKTNOSUPPORT -#define ESOCKTNOSUPPORT 121 /* Socket type not supported */ -#endif -#ifndef EOPNOTSUPP -#define EOPNOTSUPP 122 /* Operation not supported on socket */ -#endif -#ifndef EPFNOSUPPORT -#define EPFNOSUPPORT 123 /* Protocol family not supported */ -#endif -#ifndef EAFNOSUPPORT -#define EAFNOSUPPORT 124 /* Address family not supported */ -#endif -#ifndef EADDRINUSE -#define EADDRINUSE 125 /* Address already in use */ -#endif -#ifndef EADDRNOTAVAIL -#define EADDRNOTAVAIL 126 /* Can't assign requested address */ -#endif -#ifndef ENETDOWN -#define ENETDOWN 127 /* Network is down */ -#endif -#ifndef ENETUNREACH -#define ENETUNREACH 128 /* Network is unreachable */ -#endif -#ifndef ENETRESET -#define ENETRESET 129 /* Network dropped connection on reset */ -#endif -#ifndef ECONNABORTED -#define ECONNABORTED 130 /* Software caused connection abort */ -#endif -#ifndef ECONNRESET -#define ECONNRESET 131 /* Connection reset by peer */ -#endif -#ifndef ENOBUFS -#define ENOBUFS 132 /* No buffer space available */ -#endif -#ifndef EISCONN -#define EISCONN 133 /* Socket is already connected */ -#endif -#ifndef ENOTCONN -#define ENOTCONN 134 /* Socket is not connected */ -#endif -#ifndef ESHUTDOWN -#define ESHUTDOWN 143 /* Can't send after socket shutdown */ -#endif -#ifndef ETOOMANYREFS -#define ETOOMANYREFS 144 /* Too many references: can't splice */ -#endif -#ifndef ETIMEDOUT -#define ETIMEDOUT 145 /* Connection timed out */ -#endif -#ifndef ECONNREFUSED -#define ECONNREFUSED 146 /* Connection refused */ -#endif -#ifndef ELOOP -#define ELOOP 90 /* Symbolic link loop */ -#endif -#ifndef EHOSTDOWN -#define EHOSTDOWN 147 /* Host is down */ -#endif -#ifndef EHOSTUNREACH -#define EHOSTUNREACH 148 /* No route to host */ -#endif -#ifndef ENOTEMPTY -#define ENOTEMPTY 93 /* directory not empty */ -#endif -#ifndef EUSERS -#define EUSERS 94 /* Too many users (for UFS) */ -#endif -#ifndef EDQUOT -#define EDQUOT 49 /* Disc quota exceeded */ -#endif -#ifndef ESTALE -#define ESTALE 151 /* Stale NFS file handle */ -#endif -#ifndef EREMOTE -#define EREMOTE 66 /* The object is remote */ -#endif +/* + * The default platform eol translation on Windows is TCL_TRANSLATE_CRLF: + */ + +#define TCL_PLATFORM_TRANSLATION TCL_TRANSLATE_CRLF + +/* + * Declare dynamic loading extension macro. + */ + +#define TCL_SHLIB_EXT ".dll" /* * The following define ensures that we use the native putenv @@ -333,7 +354,28 @@ */ #define USE_PUTENV 1 - + +/* + * The following defines wrap the system memory allocation routines for + * use by tclAlloc.c. + */ + +#define TclpSysAlloc(size, isBin) ((void*)GlobalAlloc(GMEM_FIXED, \ + (DWORD)size)) +#define TclpSysFree(ptr) (GlobalFree((HGLOBAL)ptr)) +#define TclpSysRealloc(ptr, size) ((void*)GlobalReAlloc((HGLOBAL)ptr, \ + (DWORD)size, 0)) + +/* + * The following declarations belong in tclInt.h, but depend on platform + * specific types (e.g. struct tm). + */ + +EXTERN struct tm * TclpGetDate _ANSI_ARGS_((const time_t *tp, + int useGMT)); +EXTERN size_t TclStrftime _ANSI_ARGS_((char *s, size_t maxsize, + const char *format, const struct tm *t)); + /* * The following defines map from standard socket names to our internal * wrappers that redirect through the winSock function table (see the @@ -346,41 +388,35 @@ #define setsockopt TclWinSetSockOpt /* - * The following implements the Windows method for exiting the process. - */ -#define TclPlatformExit(status) exit(status) - - -/* * The following declarations belong in tclInt.h, but depend on platform * specific types (e.g. struct tm). */ EXTERN struct tm * TclpGetDate _ANSI_ARGS_((const time_t *tp, int useGMT)); -EXTERN unsigned long TclpGetPid _ANSI_ARGS_((Tcl_Pid pid)); EXTERN size_t TclStrftime _ANSI_ARGS_((char *s, size_t maxsize, const char *format, const struct tm *t)); /* - * The following prototypes and defines replace the Windows versions - * of POSIX function that various compilier vendors didn't implement - * well or consistantly. + * The following macros have trivial definitions, allowing generic code to + * address platform-specific issues. */ -#define stat(path, buf) TclWinStat(path, buf) -#define lstat stat -#define access(path, mode) TclWinAccess(path, mode) +#define TclpReleaseFile(file) ckfree((char *) file) -EXTERN int TclWinStat _ANSI_ARGS_((CONST char *path, - struct stat *buf)); -EXTERN int TclWinAccess _ANSI_ARGS_((CONST char *path, - int mode)); +/* + * The following macros and declarations wrap the C runtime library + * functions. + */ -#define TclpReleaseFile(file) ckfree((char *) file) +#define TclpExit exit +#define TclpLstat TclpStat + +EXTERN int TclpStat _ANSI_ARGS_((CONST char *path, + struct stat *buf)); /* - * Declarations for Windows specific functions. + * Declarations for Windows-only functions. */ EXTERN void TclWinConvertError _ANSI_ARGS_((DWORD errCode)); @@ -391,9 +427,28 @@ EXTERN struct servent * PASCAL FAR EXTERN int PASCAL FAR TclWinGetSockOpt _ANSI_ARGS_((SOCKET s, int level, int optname, char FAR * optval, int FAR *optlen)); EXTERN HINSTANCE TclWinGetTclInstance _ANSI_ARGS_((void)); -EXTERN HINSTANCE TclWinLoadLibrary _ANSI_ARGS_((char *name)); EXTERN u_short PASCAL FAR TclWinNToHS _ANSI_ARGS_((u_short ns)); EXTERN int PASCAL FAR TclWinSetSockOpt _ANSI_ARGS_((SOCKET s, int level, int optname, const char FAR * optval, int optlen)); + +/* + * Platform specific mutex definition used by memory allocators. + * These mutexes are statically allocated and explicitly initialized. + * Most modules do not use this, but instead use Tcl_Mutex types and + * Tcl_MutexLock and Tcl_MutexUnlock that are self-initializing. + */ + +#ifdef TCL_THREADS +typedef CRITICAL_SECTION TclpMutex; +EXTERN void TclpMutexInit _ANSI_ARGS_((TclpMutex *mPtr)); +EXTERN void TclpMutexLock _ANSI_ARGS_((TclpMutex *mPtr)); +EXTERN void TclpMutexUnlock _ANSI_ARGS_((TclpMutex *mPtr)); +#else +typedef int TclpMutex; +#define TclpMutexInit(a) +#define TclpMutexLock(a) +#define TclpMutexUnlock(a) +#endif /* TCL_THREADS */ + #endif /* _TCLWINPORT */ |