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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [tcl/] [mac/] [tclMacPort.h] - Blame information for rev 1767

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
/*
2
 * tclMacPort.h --
3
 *
4
 *      This header file handles porting issues that occur because of
5
 *      differences between the Mac and Unix. It should be the only
6
 *      file that contains #ifdefs to handle different flavors of OS.
7
 *
8
 * Copyright (c) 1995-1997 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: tclMacPort.h,v 1.1.1.1 2002-01-16 10:25:30 markom Exp $
14
 */
15
 
16
#ifndef _MACPORT
17
#define _MACPORT
18
 
19
#ifndef _TCL
20
#include "tcl.h"
21
#endif
22
 
23
#include "tclErrno.h"
24
#include <float.h>
25
 
26
/* Includes */
27
#ifdef THINK_C
28
        /*
29
         * The Symantic C code has not been tested
30
         * and probably will not work.
31
         */
32
#   include <pascal.h>
33
#   include <posix.h>
34
#   include <string.h>
35
#   include <fcntl.h>
36
#   include <pwd.h>
37
#   include <sys/param.h>
38
#   include <sys/types.h>
39
#   include <sys/stat.h>
40
#   include <unistd.h>
41
#elif defined(__MWERKS__)
42
#   include <time.h>
43
#   include <unistd.h>
44
/*
45
 * The following definitions are usually found if fcntl.h.
46
 * However, MetroWerks has screwed that file up a couple of times
47
 * and all we need are the defines.
48
 */
49
#define O_RDWR    0x0           /* open the file in read/write mode */
50
#define O_RDONLY  0x1           /* open the file in read only mode */
51
#define O_WRONLY  0x2           /* open the file in write only mode */
52
#define O_APPEND  0x0100        /* open the file in append mode */
53
#define O_CREAT   0x0200        /* create the file if it doesn't exist */
54
#define O_EXCL    0x0400        /* if the file exists don't create it again */
55
#define O_TRUNC   0x0800        /* truncate the file after opening it */
56
 
57
/*
58
 * MetroWerks stat.h file is rather weak.  The defines
59
 * after the include are needed to fill in the missing
60
 * defines.
61
 */
62
#   include <stat.h>
63
#   ifndef S_IFIFO
64
#       define   S_IFIFO        0x0100
65
#   endif
66
#   ifndef S_IFBLK
67
#       define   S_IFBLK        0x0600
68
#   endif
69
#   ifndef S_ISLNK
70
#       define   S_ISLNK(m)     (((m)&(S_IFMT)) == (S_IFLNK))
71
#   endif
72
#   ifndef S_ISSOCK
73
#       define   S_ISSOCK(m)    (((m)&(S_IFMT)) == (S_IFSOCK))
74
#   endif
75
#   ifndef S_IRWXU
76
#       define  S_IRWXU 00007           /* read, write, execute: owner */
77
#       define  S_IRUSR 00004           /* read permission: owner */
78
#       define  S_IWUSR 00002           /* write permission: owner */
79
#       define  S_IXUSR 00001           /* execute permission: owner */
80
#       define  S_IRWXG 00007           /* read, write, execute: group */
81
#       define  S_IRGRP 00004           /* read permission: group */
82
#       define  S_IWGRP 00002           /* write permission: group */
83
#       define  S_IXGRP 00001           /* execute permission: group */
84
#       define  S_IRWXO 00007           /* read, write, execute: other */
85
#       define  S_IROTH 00004           /* read permission: other */
86
#       define  S_IWOTH 00002           /* write permission: other */
87
#       define  S_IXOTH 00001           /* execute permission: other */
88
#   endif
89
 
90
#   define isatty(arg) 1
91
 
92
/*
93
 * Defines used by access function.  This function is provided
94
 * by Mac Tcl as the function TclpAccess.
95
 */
96
 
97
#   define      F_OK            0        /* test for existence of file */
98
#   define      X_OK            0x01    /* test for execute or search permission */
99
#   define      W_OK            0x02    /* test for write permission */
100
#   define      R_OK            0x04    /* test for read permission */
101
 
102
#endif
103
 
104
/*
105
 * waitpid doesn't work on a Mac - the following makes
106
 * Tcl compile without errors.  These would normally
107
 * be defined in sys/wait.h on UNIX systems.
108
 */
109
 
110
#define WNOHANG 1
111
#define WIFSTOPPED(stat) (1)
112
#define WIFSIGNALED(stat) (1)
113
#define WIFEXITED(stat) (1)
114
#define WIFSTOPSIG(stat) (1)
115
#define WIFTERMSIG(stat) (1)
116
#define WIFEXITSTATUS(stat) (1)
117
#define WEXITSTATUS(stat) (1)
118
#define WTERMSIG(status) (1)
119
#define WSTOPSIG(status) (1)
120
 
121
/*
122
 * Define "NBBY" (number of bits per byte) if it's not already defined.
123
 */
124
 
125
#ifndef NBBY
126
#   define NBBY 8
127
#endif
128
 
129
/*
130
 * These functions always return dummy values on Mac.
131
 */
132
#ifndef geteuid
133
#   define geteuid() 1
134
#endif
135
#ifndef getpid
136
#   define getpid() -1
137
#endif
138
 
139
#define NO_SYS_ERRLIST
140
#define WAIT_STATUS_TYPE int
141
 
142
/*
143
 * Make sure that MAXPATHLEN is defined.
144
 */
145
 
146
#ifndef MAXPATHLEN
147
#   ifdef PATH_MAX
148
#       define MAXPATHLEN PATH_MAX
149
#   else
150
#       define MAXPATHLEN 2048
151
#   endif
152
#endif
153
 
154
/*
155
 * The following functions are declared in tclInt.h but don't do anything
156
 * on Macintosh systems.
157
 */
158
 
159
#define TclSetSystemEnv(a,b)
160
 
161
/*
162
 * Many signals are not supported on the Mac and are thus not defined in
163
 * <signal.h>.  They are defined here so that Tcl will compile with less
164
 * modification.
165
  */
166
 
167
#ifndef SIGQUIT
168
#define SIGQUIT 300
169
#endif
170
 
171
#ifndef SIGPIPE
172
#define SIGPIPE 13
173
#endif
174
 
175
#ifndef SIGHUP
176
#define SIGHUP  100
177
#endif
178
 
179
extern char **environ;
180
 
181
/*
182
 * Prototypes needed for compatability
183
 */
184
 
185
EXTERN int      TclMacCreateEnv _ANSI_ARGS_((void));
186
EXTERN int      strncasecmp _ANSI_ARGS_((CONST char *s1,
187
                            CONST char *s2, size_t n));
188
 
189
/*
190
 * The following declarations belong in tclInt.h, but depend on platform
191
 * specific types (e.g. struct tm).
192
 */
193
 
194
EXTERN struct tm *      TclpGetDate _ANSI_ARGS_((const time_t *tp,
195
                            int useGMT));
196
EXTERN size_t           TclStrftime _ANSI_ARGS_((char *s, size_t maxsize,
197
                            const char *format, const struct tm *t));
198
 
199
#define tzset()
200
#define TclpGetPid(pid)     ((unsigned long) (pid))
201
 
202
/*
203
 * The following defines replace the Macintosh version of the POSIX
204
 * functions "stat" and "access".  The various compilier vendors
205
 * don't implement this function well nor consistantly.
206
 */
207
#define lstat(path, bufPtr) TclStat(path, bufPtr)
208
 
209
EXTERN FILE * TclMacFOpenHack _ANSI_ARGS_((const char *path,
210
        const char *mode));
211
#define fopen(path, mode) TclMacFOpenHack(path, mode)
212
EXTERN int TclMacReadlink _ANSI_ARGS_((char *path, char *buf, int size));
213
#define readlink(fileName, buffer, size) TclMacReadlink(fileName, buffer, size)
214
#ifdef TCL_TEST
215
#define chmod(path, mode) TclMacChmod(path, mode)
216
EXTERN int      TclMacChmod(char *path, int mode);
217
#endif
218
 
219
/*
220
 * Defines for Tcl internal commands that aren't really needed on
221
 * the Macintosh.  They all act as no-ops.
222
 */
223
#define TclCreateCommandChannel(out, in, err, num, pidPtr)      NULL
224
#define TclClosePipeFile(x)
225
 
226
/*
227
 * These definitions force putenv & company to use the version
228
 * supplied with Tcl.
229
 */
230
#ifndef putenv
231
#   define unsetenv     TclUnsetEnv
232
#   define putenv       Tcl_PutEnv
233
#   define setenv       TclSetEnv
234
void    TclSetEnv(CONST char *name, CONST char *value);
235
int     Tcl_PutEnv(CONST char *string);
236
void    TclUnsetEnv(CONST char *name);
237
#endif
238
 
239
/*
240
 * The default platform eol translation on Mac is TCL_TRANSLATE_CR:
241
 */
242
 
243
#define TCL_PLATFORM_TRANSLATION        TCL_TRANSLATE_CR
244
 
245
/*
246
 * Declare dynamic loading extension macro.
247
 */
248
 
249
#define TCL_SHLIB_EXT ".shlb"
250
 
251
/*
252
 * TclpFinalize is a noop on the Mac.
253
 */
254
 
255
#define TclpFinalize()
256
 
257
/*
258
 * The following define should really be in tclInt.h, but tclInt.h does
259
 * not include tclPort.h, which includes the "struct stat" definition.
260
 */
261
 
262
EXTERN int              TclpSameFile _ANSI_ARGS_((char *file1, char *file2,
263
                            struct stat *sourceStatBufPtr,
264
                            struct stat *destStatBufPtr)) ;
265
EXTERN int TclpStat _ANSI_ARGS_ ((CONST char *path, struct stat *buf));
266
EXTERN int TclpAccess _ANSI_ARGS_ ((CONST char *path, int mode));
267
 
268
#endif /* _MACPORT */

powered by: WebSVN 2.1.0

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