OpenCores
URL https://opencores.org/ocsvn/or1k_old/or1k_old/trunk

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [insight/] [tcl/] [win/] [tclWinPort.h] - Blame information for rev 1782

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
/*
2
 * tclWinPort.h --
3
 *
4
 *      This header file handles porting issues that occur because of
5
 *      differences between Windows and Unix. It should be the only
6
 *      file that contains #ifdefs to handle different flavors of OS.
7
 *
8
 * Copyright (c) 1994-1996 Sun Microsystems, Inc.
9
 *
10
 * See the file "license.terms" for information on usage and redistribution
11
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
12
 *
13
 * RCS: @(#) $Id: tclWinPort.h,v 1.1.1.1 2002-01-16 10:25:39 markom Exp $
14
 */
15
 
16
#ifndef _TCLWINPORT
17
#define _TCLWINPORT
18
 
19
#define WIN32_LEAN_AND_MEAN
20
#define __USE_W32_SOCKETS
21
#include <windows.h>
22
#undef WIN32_LEAN_AND_MEAN
23
#include <winsock.h>
24
 
25
#include <malloc.h>
26
#include <stdio.h>
27
 
28
#include <stdlib.h>
29
#include <string.h>
30
#include <errno.h>
31
#include <process.h>
32
#include <signal.h>
33
#include <sys/stat.h>
34
#include <sys/timeb.h>
35
#include <time.h>
36
#include <io.h>
37
#include <fcntl.h>
38
#include <float.h>
39
 
40
#ifdef _MSC_VER
41
#define PASCAL
42
#endif
43
 
44
#ifdef BUILD_tcl
45
# undef TCL_STORAGE_CLASS
46
# define TCL_STORAGE_CLASS DLLEXPORT
47
#endif
48
 
49
/*
50
 * Define EINPROGRESS in terms of WSAEINPROGRESS.
51
 */
52
 
53
#ifndef EINPROGRESS
54
#define EINPROGRESS WSAEINPROGRESS
55
#endif
56
 
57
/*
58
 * If ENOTSUP is not defined, define it to a value that will never occur.
59
 */
60
 
61
#ifndef ENOTSUP
62
#define ENOTSUP         -1030507
63
#endif
64
 
65
/*
66
 * The following defines wrap the system memory allocation routines for
67
 * use by tclAlloc.c.
68
 */
69
 
70
/* On cygwin, we just use the supplied malloc and free, rather than
71
   using tclAlloc.c.  The cygwin32 malloc is derived from the same
72
   sources as tclAlloc.c, anyhow.  */
73
#ifdef __CYGWIN__
74
#define TclpAlloc(size)         malloc(size)
75
#define TclpFree(ptr)           free(ptr)
76
#define TclpRealloc(ptr, size)  realloc(ptr, size)
77
#else
78
#define TclpSysAlloc(size, isBin)       ((void*)HeapAlloc(GetProcessHeap(), \
79
                                            (DWORD)0, (DWORD)size))
80
#define TclpSysFree(ptr)                (HeapFree(GetProcessHeap(), \
81
                                            (DWORD)0, (HGLOBAL)ptr))
82
#define TclpSysRealloc(ptr, size)       ((void*)HeapReAlloc(GetProcessHeap(), \
83
                                            (DWORD)0, (LPVOID)ptr, (DWORD)size))
84
#endif
85
 
86
/*
87
 * The default platform eol translation on Windows is TCL_TRANSLATE_CRLF:
88
 */
89
 
90
#define TCL_PLATFORM_TRANSLATION        TCL_TRANSLATE_CRLF
91
 
92
/*
93
 * Declare dynamic loading extension macro.
94
 */
95
 
96
#define TCL_SHLIB_EXT ".dll"
97
 
98
/*
99
 * Supply definitions for macros to query wait status, if not already
100
 * defined in header files above.
101
 */
102
 
103
#if TCL_UNION_WAIT
104
#   define WAIT_STATUS_TYPE union wait
105
#else
106
#   define WAIT_STATUS_TYPE int
107
#endif
108
 
109
#ifndef WIFEXITED
110
#   define WIFEXITED(stat)  (((*((int *) &(stat))) & 0xff) == 0)
111
#endif
112
 
113
#ifndef WEXITSTATUS
114
#   define WEXITSTATUS(stat) (((*((int *) &(stat))) >> 8) & 0xff)
115
#endif
116
 
117
#ifndef WIFSIGNALED
118
#   define WIFSIGNALED(stat) (((*((int *) &(stat)))) && ((*((int *) &(stat))) == ((*((int *) &(stat))) & 0x00ff)))
119
#endif
120
 
121
#ifndef WTERMSIG
122
#   define WTERMSIG(stat)    ((*((int *) &(stat))) & 0x7f)
123
#endif
124
 
125
#ifndef WIFSTOPPED
126
#   define WIFSTOPPED(stat)  (((*((int *) &(stat))) & 0xff) == 0177)
127
#endif
128
 
129
#ifndef WSTOPSIG
130
#   define WSTOPSIG(stat)    (((*((int *) &(stat))) >> 8) & 0xff)
131
#endif
132
 
133
/*
134
 * Define constants for waitpid() system call if they aren't defined
135
 * by a system header file.
136
 */
137
 
138
#ifndef WNOHANG
139
#   define WNOHANG 1
140
#endif
141
#ifndef WUNTRACED
142
#   define WUNTRACED 2
143
#endif
144
 
145
/*
146
 * Define MAXPATHLEN in terms of MAXPATH if available
147
 */
148
 
149
#ifndef MAXPATH
150
#define MAXPATH MAX_PATH
151
#endif /* MAXPATH */
152
 
153
#ifndef MAXPATHLEN
154
#define MAXPATHLEN MAXPATH
155
#endif /* MAXPATHLEN */
156
 
157
#ifndef F_OK
158
#    define F_OK 00
159
#endif
160
#ifndef X_OK
161
#    define X_OK 01
162
#endif
163
#ifndef W_OK
164
#    define W_OK 02
165
#endif
166
#ifndef R_OK
167
#    define R_OK 04
168
#endif
169
 
170
/*
171
 * Define macros to query file type bits, if they're not already
172
 * defined.
173
 */
174
 
175
#ifndef S_ISREG
176
#   ifdef S_IFREG
177
#       define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
178
#   else
179
#       define S_ISREG(m) 0
180
#   endif
181
# endif
182
#ifndef S_ISDIR
183
#   ifdef S_IFDIR
184
#       define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
185
#   else
186
#       define S_ISDIR(m) 0
187
#   endif
188
# endif
189
#ifndef S_ISCHR
190
#   ifdef S_IFCHR
191
#       define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
192
#   else
193
#       define S_ISCHR(m) 0
194
#   endif
195
# endif
196
#ifndef S_ISBLK
197
#   ifdef S_IFBLK
198
#       define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
199
#   else
200
#       define S_ISBLK(m) 0
201
#   endif
202
# endif
203
#ifndef S_ISFIFO
204
#   ifdef S_IFIFO
205
#       define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
206
#   else
207
#       define S_ISFIFO(m) 0
208
#   endif
209
# endif
210
 
211
/*
212
 * Define pid_t and uid_t if they're not already defined.
213
 */
214
 
215
#if ! TCL_PID_T
216
#   define pid_t int
217
#endif
218
#if ! TCL_UID_T
219
#   define uid_t int
220
#endif
221
 
222
/*
223
 * Provide a stub definition for TclGetUserHome().
224
 */
225
 
226
#define TclGetUserHome(name,bufferPtr) (NULL)
227
 
228
/*
229
 * Visual C++ has some odd names for common functions, so we need to
230
 * define a few macros to handle them.  Also, it defines EDEADLOCK and
231
 * EDEADLK as the same value, which confuses Tcl_ErrnoId().
232
 */
233
 
234
#ifdef _MSC_VER
235
#    define environ _environ
236
#    define hypot _hypot
237
#    define exception _exception
238
#    undef EDEADLOCK
239
#endif /* _MSC_VER */
240
 
241
/*
242
 * When building DLLs using GCC on mingw32, we must import environ via
243
 * indirection. This hack will eventually go away once GCC understands
244
 * dllimport attribute and mingw32 headers are fixed.
245
 */
246
 
247
#ifdef __MINGW32__
248
     extern char *** __imp__environ_dll;
249
#    define environ (*__imp__environ_dll)
250
#    define hypot _hypot
251
#    define exception _exception
252
#    undef EDEADLOCK
253
#endif /* __MINGW32__ */
254
 
255
/*
256
 * The following defines redefine the Windows Socket errors as
257
 * BSD errors so Tcl_PosixError can do the right thing.
258
 */
259
 
260
#ifndef EWOULDBLOCK
261
#define EWOULDBLOCK             EAGAIN
262
#endif
263
#ifndef EALREADY
264
#define EALREADY        149     /* operation already in progress */
265
#endif
266
#ifndef ENOTSOCK
267
#define ENOTSOCK        95      /* Socket operation on non-socket */
268
#endif
269
#ifndef EDESTADDRREQ
270
#define EDESTADDRREQ    96      /* Destination address required */
271
#endif
272
#ifndef EMSGSIZE
273
#define EMSGSIZE        97      /* Message too long */
274
#endif
275
#ifndef EPROTOTYPE
276
#define EPROTOTYPE      98      /* Protocol wrong type for socket */
277
#endif
278
#ifndef ENOPROTOOPT
279
#define ENOPROTOOPT     99      /* Protocol not available */
280
#endif
281
#ifndef EPROTONOSUPPORT
282
#define EPROTONOSUPPORT 120     /* Protocol not supported */
283
#endif
284
#ifndef ESOCKTNOSUPPORT
285
#define ESOCKTNOSUPPORT 121     /* Socket type not supported */
286
#endif
287
#ifndef EOPNOTSUPP
288
#define EOPNOTSUPP      122     /* Operation not supported on socket */
289
#endif
290
#ifndef EPFNOSUPPORT
291
#define EPFNOSUPPORT    123     /* Protocol family not supported */
292
#endif
293
#ifndef EAFNOSUPPORT
294
#define EAFNOSUPPORT    124     /* Address family not supported */
295
#endif
296
#ifndef EADDRINUSE
297
#define EADDRINUSE      125     /* Address already in use */
298
#endif
299
#ifndef EADDRNOTAVAIL
300
#define EADDRNOTAVAIL   126     /* Can't assign requested address */
301
#endif
302
#ifndef ENETDOWN
303
#define ENETDOWN        127     /* Network is down */
304
#endif
305
#ifndef ENETUNREACH
306
#define ENETUNREACH     128     /* Network is unreachable */
307
#endif
308
#ifndef ENETRESET
309
#define ENETRESET       129     /* Network dropped connection on reset */
310
#endif
311
#ifndef ECONNABORTED
312
#define ECONNABORTED    130     /* Software caused connection abort */
313
#endif
314
#ifndef ECONNRESET
315
#define ECONNRESET      131     /* Connection reset by peer */
316
#endif
317
#ifndef ENOBUFS
318
#define ENOBUFS         132     /* No buffer space available */
319
#endif
320
#ifndef EISCONN
321
#define EISCONN         133     /* Socket is already connected */
322
#endif
323
#ifndef ENOTCONN
324
#define ENOTCONN        134     /* Socket is not connected */
325
#endif
326
#ifndef ESHUTDOWN
327
#define ESHUTDOWN       143     /* Can't send after socket shutdown */
328
#endif
329
#ifndef ETOOMANYREFS
330
#define ETOOMANYREFS    144     /* Too many references: can't splice */
331
#endif
332
#ifndef ETIMEDOUT
333
#define ETIMEDOUT       145     /* Connection timed out */
334
#endif
335
#ifndef ECONNREFUSED
336
#define ECONNREFUSED    146     /* Connection refused */
337
#endif
338
#ifndef ELOOP
339
#define ELOOP           90      /* Symbolic link loop */
340
#endif
341
#ifndef EHOSTDOWN
342
#define EHOSTDOWN       147     /* Host is down */
343
#endif
344
#ifndef EHOSTUNREACH
345
#define EHOSTUNREACH    148     /* No route to host */
346
#endif
347
#ifndef ENOTEMPTY
348
#define ENOTEMPTY       93      /* directory not empty */
349
#endif
350
#ifndef EUSERS
351
#define EUSERS          94      /* Too many users (for UFS) */
352
#endif
353
#ifndef EDQUOT
354
#define EDQUOT          49      /* Disc quota exceeded */
355
#endif
356
#ifndef ESTALE
357
#define ESTALE          151     /* Stale NFS file handle */
358
#endif
359
#ifndef EREMOTE
360
#define EREMOTE         66      /* The object is remote */
361
#endif
362
 
363
/*
364
 * The following define ensures that we use the native putenv
365
 * implementation to modify the environment array.  This keeps
366
 * the C level environment in synch with the system level environment.
367
 */
368
 
369
#define USE_PUTENV      1
370
 
371
/*
372
 * The following defines map from standard socket names to our internal
373
 * wrappers that redirect through the winSock function table (see the
374
 * file tclWinSock.c).
375
 */
376
 
377
#define getservbyname   TclWinGetServByName
378
#define getsockopt      TclWinGetSockOpt
379
#define ntohs           TclWinNToHS
380
#define setsockopt      TclWinSetSockOpt
381
 
382
/*
383
 * The following implements the Windows method for exiting the process.
384
 */
385
#define TclPlatformExit(status) exit(status)
386
 
387
 
388
/*
389
 * The following declarations belong in tclInt.h, but depend on platform
390
 * specific types (e.g. struct tm).
391
 */
392
 
393
EXTERN struct tm *      TclpGetDate _ANSI_ARGS_((const time_t *tp,
394
                            int useGMT));
395
EXTERN unsigned long    TclpGetPid _ANSI_ARGS_((Tcl_Pid pid));
396
EXTERN size_t           TclStrftime _ANSI_ARGS_((char *s, size_t maxsize,
397
                            const char *format, const struct tm *t));
398
 
399
/*
400
 * The following prototypes and defines replace the Windows versions
401
 * of POSIX function that various compilier vendors didn't implement
402
 * well or consistantly.
403
 */
404
 
405
#define lstat           TclStat
406
 
407
EXTERN int              TclpStat _ANSI_ARGS_((CONST char *path,
408
                            struct stat *buf));
409
EXTERN int              TclpAccess _ANSI_ARGS_((CONST char *path,
410
                            int mode));
411
 
412
#define TclpReleaseFile(file)   ckfree((char *) file)
413
 
414
/*
415
 * Declarations for Windows specific functions.
416
 */
417
 
418
EXTERN void             TclWinConvertError _ANSI_ARGS_((DWORD errCode));
419
EXTERN void             TclWinConvertWSAError _ANSI_ARGS_((DWORD errCode));
420
EXTERN struct servent * PASCAL FAR
421
                        TclWinGetServByName _ANSI_ARGS_((const char FAR *nm,
422
                            const char FAR *proto));
423
EXTERN int PASCAL FAR   TclWinGetSockOpt _ANSI_ARGS_((SOCKET s, int level,
424
                            int optname, char FAR * optval, int FAR *optlen));
425
EXTERN HINSTANCE        TclWinGetTclInstance _ANSI_ARGS_((void));
426
EXTERN HINSTANCE        TclWinLoadLibrary _ANSI_ARGS_((char *name));
427
EXTERN u_short PASCAL FAR
428
                        TclWinNToHS _ANSI_ARGS_((u_short ns));
429
EXTERN int PASCAL FAR   TclWinSetSockOpt _ANSI_ARGS_((SOCKET s, int level,
430
                            int optname, const char FAR * optval, int optlen));
431
 
432
# undef TCL_STORAGE_CLASS
433
# define TCL_STORAGE_CLASS DLLIMPORT
434
 
435
#endif /* _TCLWINPORT */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.