diff options
author | stanton <stanton> | 1999-04-16 00:46:29 (GMT) |
---|---|---|
committer | stanton <stanton> | 1999-04-16 00:46:29 (GMT) |
commit | 97464e6cba8eb0008cf2727c15718671992b913f (patch) | |
tree | ce9959f2747257d98d52ec8d18bf3b0de99b9535 /win/tclWinPort.h | |
parent | a8c96ddb94d1483a9de5e340b740cb74ef6cafa7 (diff) | |
download | tcl-97464e6cba8eb0008cf2727c15718671992b913f.zip tcl-97464e6cba8eb0008cf2727c15718671992b913f.tar.gz tcl-97464e6cba8eb0008cf2727c15718671992b913f.tar.bz2 |
merged tcl 8.1 branch back into the main trunk
Diffstat (limited to 'win/tclWinPort.h')
-rw-r--r-- | win/tclWinPort.h | 371 |
1 files changed, 221 insertions, 150 deletions
diff --git a/win/tclWinPort.h b/win/tclWinPort.h index 2bb6b72..4843383 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. * - * RCS: @(#) $Id: tclWinPort.h,v 1.7 1999/03/10 05:52:53 stanton Exp $ + * RCS: @(#) $Id: tclWinPort.h,v 1.8 1999/04/16 00:48:09 stanton Exp $ */ #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> @@ -58,28 +84,112 @@ #endif /* - * The following defines wrap the system memory allocation routines for - * use by tclAlloc.c. - */ - -#define TclpSysAlloc(size, isBin) ((void*)HeapAlloc(GetProcessHeap(), \ - (DWORD)0, (DWORD)size)) -#define TclpSysFree(ptr) (HeapFree(GetProcessHeap(), \ - (DWORD)0, (HGLOBAL)ptr)) -#define TclpSysRealloc(ptr, size) ((void*)HeapReAlloc(GetProcessHeap(), \ - (DWORD)0, (LPVOID)ptr, (DWORD)size)) - -/* - * 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 @@ -129,17 +239,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 @@ -195,6 +297,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. */ @@ -219,112 +333,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 +359,19 @@ */ #define USE_PUTENV 1 - + +/* + * The following defines wrap the system memory allocation routines for + * use by tclAlloc.c. + */ + +#define TclpSysAlloc(size, isBin) ((void*)HeapAlloc(GetProcessHeap(), \ + (DWORD)0, (DWORD)size)) +#define TclpSysFree(ptr) (HeapFree(GetProcessHeap(), \ + (DWORD)0, (HGLOBAL)ptr)) +#define TclpSysRealloc(ptr, size) ((void*)HeapReAlloc(GetProcessHeap(), \ + (DWORD)0, (LPVOID)ptr, (DWORD)size)) + /* * The following defines map from standard socket names to our internal * wrappers that redirect through the winSock function table (see the @@ -346,20 +384,53 @@ #define setsockopt TclWinSetSockOpt /* - * The following implements the Windows method for exiting the process. + * The following macros have trivial definitions, allowing generic code to + * address platform-specific issues. */ -#define TclPlatformExit(status) exit(status) +#define TclpReleaseFile(file) ckfree((char *) file) /* - * The following prototypes and defines replace the Windows versions - * of POSIX function that various compiler vendors didn't implement - * well or consistantly. + * The following macros and declarations wrap the C runtime library + * functions. */ -#define lstat TclStat +#define TclpExit exit +#define TclpLstat TclpStat -#define TclpReleaseFile(file) ckfree((char *) file) +/* + * Declarations for Windows-only functions. + */ + +EXTERN Tcl_Channel TclWinOpenSerialChannel _ANSI_ARGS_((HANDLE handle, + char *channelName, int permissions)); + +EXTERN Tcl_Channel TclWinOpenConsoleChannel _ANSI_ARGS_((HANDLE handle, + char *channelName, int permissions)); + +EXTERN Tcl_Channel TclWinOpenFileChannel _ANSI_ARGS_((HANDLE handle, + char *channelName, int permissions, int appendMode)); + +EXTERN TclFile TclWinMakeFile _ANSI_ARGS_((HANDLE handle)); + +/* + * 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 */ #include "tclPlatDecls.h" #include "tclIntPlatDecls.h" |