~ubuntu-branches/ubuntu/quantal/nspr/quantal-security

« back to all changes in this revision

Viewing changes to mozilla/nsprpub/pr/include/md/_macos.h

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Sack
  • Date: 2009-08-10 11:34:26 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20090810113426-3uv4diflrkcbdimm
Tags: 4.8-0ubuntu1
* New upstream release: 4.8 (LP: #387812)
* adjust patches to changed upstreanm codebase
  - update debian/patches/99_configure.patch
* update shlibs symbols to include new API elements
  - update debian/libnspr4-0d.symbols

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
 
/* ***** BEGIN LICENSE BLOCK *****
3
 
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4
 
 *
5
 
 * The contents of this file are subject to the Mozilla Public License Version
6
 
 * 1.1 (the "License"); you may not use this file except in compliance with
7
 
 * the License. You may obtain a copy of the License at
8
 
 * http://www.mozilla.org/MPL/
9
 
 *
10
 
 * Software distributed under the License is distributed on an "AS IS" basis,
11
 
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12
 
 * for the specific language governing rights and limitations under the
13
 
 * License.
14
 
 *
15
 
 * The Original Code is the Netscape Portable Runtime (NSPR).
16
 
 *
17
 
 * The Initial Developer of the Original Code is
18
 
 * Netscape Communications Corporation.
19
 
 * Portions created by the Initial Developer are Copyright (C) 1998-2000
20
 
 * the Initial Developer. All Rights Reserved.
21
 
 *
22
 
 * Contributor(s):
23
 
 *
24
 
 * Alternatively, the contents of this file may be used under the terms of
25
 
 * either the GNU General Public License Version 2 or later (the "GPL"), or
26
 
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27
 
 * in which case the provisions of the GPL or the LGPL are applicable instead
28
 
 * of those above. If you wish to allow use of your version of this file only
29
 
 * under the terms of either the GPL or the LGPL, and not to allow others to
30
 
 * use your version of this file under the terms of the MPL, indicate your
31
 
 * decision by deleting the provisions above and replace them with the notice
32
 
 * and other provisions required by the GPL or the LGPL. If you do not delete
33
 
 * the provisions above, a recipient may use your version of this file under
34
 
 * the terms of any one of the MPL, the GPL or the LGPL.
35
 
 *
36
 
 * ***** END LICENSE BLOCK ***** */
37
 
 
38
 
#ifndef prmacos_h___
39
 
#define prmacos_h___
40
 
 
41
 
//
42
 
// This file contains all changes and additions which need to be made to the NSPR runtime 
43
 
// for the Macintosh platform (specifically the Metrowerks environment).  This file should 
44
 
// only be incluced in Macintosh builds.
45
 
//
46
 
 
47
 
#define PR_DLL_SUFFIX           ""
48
 
#define _PR_LOCAL_THREADS_ONLY
49
 
#define _PR_NO_PREEMPT  1
50
 
#define _PR_HAVE_ATOMIC_OPS 1
51
 
 
52
 
#include "prinit.h"
53
 
#include "prio.h"
54
 
#include "prlong.h"
55
 
#include "prlock.h"
56
 
#include "prcvar.h"
57
 
#include "prsem.h"
58
 
#include "prthread.h"
59
 
#include "prtime.h"
60
 
#include "prproces.h"
61
 
 
62
 
#if !defined(MAC_NSPR_STANDALONE)
63
 
#include "macstdlibextras.h"
64
 
#endif
65
 
 
66
 
#include <stddef.h>
67
 
#include <setjmp.h>
68
 
 
69
 
#include <Errors.h>
70
 
#include <OpenTransport.h>
71
 
#include <DriverServices.h>
72
 
 
73
 
#define _PR_HAVE_PEEK_BUFFER
74
 
#define _PR_PEEK_BUFFER_MAX (16 * 1024)
75
 
#define _PR_FD_NEED_EMULATE_MSG_PEEK(fd) 1
76
 
 
77
 
struct _MDProcess {
78
 
    PRInt8 notused;
79
 
};
80
 
 
81
 
struct _MDThread {
82
 
    jmp_buf      jb;
83
 
    int          osErrCode;
84
 
        PRLock *     asyncIOLock;
85
 
        PRCondVar *  asyncIOCVar;
86
 
    PRBool       missedIONotify;
87
 
    PRBool       missedAsyncNotify;
88
 
    PRBool       asyncNotifyPending;
89
 
};
90
 
 
91
 
struct _MDThreadStack {
92
 
    PRInt8 notused;
93
 
};
94
 
 
95
 
struct _MDLock {
96
 
    PRInt8 notused;
97
 
};
98
 
 
99
 
struct _MDCVar {
100
 
    PRInt8 notused;
101
 
};
102
 
 
103
 
struct _MDSemaphore {
104
 
    PRInt8 notused;
105
 
};
106
 
 
107
 
struct _MDSegment {
108
 
    PRInt8 notused;
109
 
};
110
 
 
111
 
struct _MDCPU {
112
 
    AbsoluteTime    lastThreadSwitch;
113
 
    AbsoluteTime    lastWakeUpProcess;
114
 
    PRBool          trackScheduling;
115
 
};
116
 
 
117
 
typedef struct _MDSocketCallerInfo {
118
 
        PRThread *      thread;
119
 
        void *          cookie;
120
 
} _MDSocketCallerInfo;
121
 
 
122
 
struct _MDFileDesc {
123
 
    PRInt32         osfd;
124
 
    PRPackedBool    orderlyDisconnect;
125
 
    PRPackedBool    readReady;
126
 
    PRPackedBool    writeReady;
127
 
    PRPackedBool    exceptReady;
128
 
    PRLock *        miscLock;
129
 
 
130
 
    /* Server sockets: listen bit tells the notifier func what to do */
131
 
    PRBool          doListen;
132
 
 
133
 
    /* stored error for non-blocking connects, as a Unix-style error code */
134
 
    OTReason        disconnectError;
135
 
 
136
 
    _MDSocketCallerInfo  misc;
137
 
    _MDSocketCallerInfo  read;
138
 
    _MDSocketCallerInfo  write;
139
 
};
140
 
 
141
 
/*
142
 
** Iinitialization Related definitions
143
 
*/
144
 
 
145
 
#define _MD_EARLY_INIT          _MD_EarlyInit
146
 
#define _MD_FINAL_INIT          _MD_FinalInit
147
 
 
148
 
/*
149
 
** Interrupts Related definitions
150
 
*/
151
 
 
152
 
#define _MD_GET_INTSOFF()               (_pr_intsOff)
153
 
 
154
 
#define _MD_INTSOFF(_is)                                  \
155
 
    PR_BEGIN_MACRO                                        \
156
 
        ENTER_CRITICAL_REGION();                          \
157
 
        (_is) = _PR_MD_GET_INTSOFF();                     \
158
 
        _PR_MD_SET_INTSOFF(1);                            \
159
 
        LEAVE_CRITICAL_REGION();                          \
160
 
    PR_END_MACRO
161
 
 
162
 
#if TARGET_CARBON
163
 
extern void _MD_SetIntsOff(PRInt32 ints);
164
 
#define _MD_SET_INTSOFF(_val)           _MD_SetIntsOff(_val)
165
 
#else /* not TARGET_CARBON */
166
 
#define _MD_SET_INTSOFF(_val)           (_pr_intsOff = _val)
167
 
#endif /* TARGET_CARBON */
168
 
 
169
 
#define _MD_START_INTERRUPTS                    _MD_StartInterrupts
170
 
#define _MD_STOP_INTERRUPTS                     _MD_StopInterrupts
171
 
#define _MD_BLOCK_CLOCK_INTERRUPTS()
172
 
#define _MD_UNBLOCK_CLOCK_INTERRUPTS()
173
 
#define _MD_DISABLE_CLOCK_INTERRUPTS()
174
 
#define _MD_ENABLE_CLOCK_INTERRUPTS()
175
 
 
176
 
/*
177
 
** CPU Related definitions
178
 
*/
179
 
 
180
 
#define _MD_PAUSE_CPU           _MD_PauseCPU
181
 
#define _MD_CLEANUP_BEFORE_EXIT()
182
 
#define _MD_EXIT(status)        exit(status)
183
 
#define _MD_INIT_CPUS()
184
 
#define _MD_INIT_RUNNING_CPU(cpu) _MD_InitRunningCPU(cpu)
185
 
 
186
 
/*
187
 
** Process Related definitions
188
 
*/
189
 
 
190
 
extern struct PRProcess * _MD_CreateProcess(
191
 
    const char *path,
192
 
    char *const *argv,
193
 
    char *const *envp,
194
 
    const PRProcessAttr *attr);
195
 
#define _MD_CREATE_PROCESS _MD_CreateProcess
196
 
 
197
 
extern PRStatus _MD_DetachProcess(PRProcess *process);
198
 
#define _MD_DETACH_PROCESS _MD_DetachProcess
199
 
 
200
 
extern PRStatus _MD_WaitProcess(PRProcess *process, PRInt32 *exitCode);
201
 
#define _MD_WAIT_PROCESS _MD_WaitProcess
202
 
 
203
 
extern PRStatus _MD_KillProcess(PRProcess *process);
204
 
#define _MD_KILL_PROCESS _MD_KillProcess
205
 
 
206
 
/*
207
 
** Memory Segments Related definitions
208
 
*/
209
 
 
210
 
#define _MD_INIT_SEGS()
211
 
 
212
 
/*
213
 
** Thread Stacks Debugging Related definitions
214
 
*/
215
 
 
216
 
#define _MD_INIT_STACK          _MD_InitStack
217
 
#define _MD_CLEAR_STACK         _MD_ClearStack
218
 
 
219
 
/*
220
 
** Locks Related definitions
221
 
*/
222
 
 
223
 
#define _MD_INIT_LOCKS()
224
 
#define _MD_NEW_LOCK(lock) (PR_SUCCESS)
225
 
#define _MD_FREE_LOCK(lock)
226
 
#define _MD_LOCK(lock)
227
 
#define _MD_UNLOCK(lock)
228
 
 
229
 
/*
230
 
** Thread Related definitions
231
 
*/
232
 
 
233
 
NSPR_API(PRThread *) PR_GetPrimaryThread();
234
 
 
235
 
#if defined(powerc) || defined(__powerc)
236
 
#define _MD_GET_PC(_t) (*((PRUint32 *)((_t)->md.jb)))
237
 
#define _MD_GET_SP(_t) (*((PRUint32 *)((_t)->md.jb) + 2))
238
 
#define _MD_GET_TOC(_t) (*((PRUint32 *)((_t)->md.jb) + 3))
239
 
#define INIT_STACKPTR(stackTop) ((unsigned char*)stackTop - 128)
240
 
#define PR_NUM_GCREGS 70
241
 
#else
242
 
#define _MD_GET_PC(_t) (*((PRUint32 *)((_t)->md.jb) + 6))
243
 
#define _MD_GET_SP(_t) (*((PRUint32 *)((_t)->md.jb) + 12))
244
 
#define INIT_STACKPTR(stackTop) ((unsigned char*)stackTop - 4)
245
 
#define PR_NUM_GCREGS 13
246
 
#endif
247
 
 
248
 
#define _MD_DEFAULT_STACK_SIZE (58 * 1024)
249
 
#define _MD_MINIMUM_STACK_SIZE (58 * 1024)
250
 
 
251
 
/*
252
 
** Initialize the thread machine dependent data structure
253
 
*/
254
 
extern PRStatus _MD_InitThread(PRThread *thread);
255
 
#define _MD_INIT_THREAD _MD_InitThread
256
 
 
257
 
/*
258
 
** Clean-up the thread machine dependent data structure
259
 
*/
260
 
#define _MD_CLEAN_THREAD(_thread)                                               \
261
 
    PR_BEGIN_MACRO                                                                      \
262
 
        PR_DestroyCondVar(_thread->md.asyncIOCVar);                     \
263
 
        PR_DestroyLock(_thread->md.asyncIOLock);                        \
264
 
    PR_END_MACRO
265
 
 
266
 
 
267
 
/*
268
 
** Initialize the thread context preparing it to execute _main.
269
 
** *sp = 0 zeros out the sp for the first stack frame so that
270
 
** stack walking code can find the top of the stack.
271
 
*/
272
 
#if defined(powerc) || defined(__powerc)
273
 
#define _MD_INIT_CONTEXT(_thread, _sp, _main, _status)  \
274
 
    PR_BEGIN_MACRO                                                                      \
275
 
        unsigned char *sp;                                                                      \
276
 
        unsigned long *tvect;                                                           \
277
 
        long **jb = (_thread)->md.jb;                                   \
278
 
    *((PRBool *)_status) = PR_TRUE;                             \
279
 
        (void) setjmp(jb);                                                              \
280
 
    sp = INIT_STACKPTR(_sp);                                                    \
281
 
    *sp = 0;                                            \
282
 
    (_MD_GET_SP(_thread)) = (long) sp;                                  \
283
 
        tvect = (unsigned long *)_main;                                         \
284
 
    (_MD_GET_PC(_thread)) = (int) *tvect;                       \
285
 
    (_MD_GET_TOC(_thread)) = (int) *(tvect+1);                  \
286
 
        _thread->no_sched = 0;                              \
287
 
    PR_END_MACRO
288
 
#else
289
 
#define _MD_INIT_CONTEXT(_thread, _sp, _main, _status)  \
290
 
    PR_BEGIN_MACRO                                                                      \
291
 
        unsigned char *sp;                                                                      \
292
 
        long **jb = (_thread)->md.jb;                                   \
293
 
    *((PRBool *)_status) = PR_TRUE;                             \
294
 
        (void) setjmp(jb);                                                              \
295
 
    sp = INIT_STACKPTR(_sp);                                                    \
296
 
    (_MD_GET_SP(_thread)) = (long) sp;                                  \
297
 
    (_MD_GET_PC(_thread)) = (int) _main;                                \
298
 
        _thread->no_sched = 0;                              \
299
 
    PR_END_MACRO
300
 
#endif
301
 
 
302
 
/*
303
 
** Switch away from the current thread context by saving its state and
304
 
** calling the thread scheduler. Reload cpu when we come back from the
305
 
** context switch because it might have changed.
306
 
*/
307
 
/*      ResetTimer();   before _PR_Schedule()                           */
308
 
 
309
 
 
310
 
#define _MD_SWITCH_CONTEXT(_thread)                                 \
311
 
    PR_BEGIN_MACRO                                                  \
312
 
    PR_ASSERT(_thread->no_sched);                                   \
313
 
    if (!setjmp(_thread->md.jb)) {                                  \
314
 
        _MD_SET_LAST_THREAD(_thread);                               \
315
 
        if (_PR_MD_CURRENT_CPU()->md.trackScheduling)               \
316
 
            _PR_MD_CURRENT_CPU()->md.lastThreadSwitch = UpTime();   \
317
 
        _PR_Schedule();                                             \
318
 
    } else {                                                        \
319
 
        PR_ASSERT(_MD_LAST_THREAD() !=_MD_CURRENT_THREAD());        \
320
 
        _MD_LAST_THREAD()->no_sched = 0;                            \
321
 
    }                                                               \
322
 
    PR_END_MACRO
323
 
 
324
 
/*
325
 
** Restore a thread context that was saved by _MD_SWITCH_CONTEXT or
326
 
** initialized by _MD_INIT_CONTEXT.
327
 
*/
328
 
#define _MD_RESTORE_CONTEXT(_newThread)     \
329
 
    PR_BEGIN_MACRO                                              \
330
 
        long **jb = (_newThread)->md.jb;            \
331
 
        _MD_SET_CURRENT_THREAD(_newThread);     \
332
 
    _newThread->no_sched = 1;                   \
333
 
        longjmp(jb, 1);                                         \
334
 
    PR_END_MACRO
335
 
 
336
 
 
337
 
#define _MD_ERRNO()      _MD_CURRENT_THREAD()->md.osErrCode
338
 
 
339
 
extern PRStatus _MD_wait(PRThread *thread, PRIntervalTime timeout);
340
 
#define _MD_WAIT        _MD_wait
341
 
 
342
 
/*
343
 
** Combined thread model related definitions
344
 
*/
345
 
 
346
 
#define _MD_CREATE_THREAD(a,b,c,d,e,f) (PR_SUCCESS)
347
 
#define _MD_WAKEUP_WAITER(a)
348
 
#define _MD_SET_PRIORITY(a,b)
349
 
 
350
 
/*
351
 
** File I/O Related definitions
352
 
*/
353
 
 
354
 
extern PRInt32 _PR_MD_WRITE_SYNC(PRFileDesc *fd, void *buf, PRInt32 amount);
355
 
#define    _PR_MD_WRITE_SYNC _MD_WRITE_SYNC
356
 
 
357
 
struct _MDDir {
358
 
        short           ioVRefNum;
359
 
        long            ioDirID;
360
 
        short           ioFDirIndex;
361
 
        char            *currentEntryName;
362
 
};
363
 
 
364
 
#define PR_DIRECTORY_SEPARATOR          '/'
365
 
#define PR_DIRECTORY_SEPARATOR_STR      "/"
366
 
#define PR_PATH_SEPARATOR               ':'
367
 
#define PR_PATH_SEPARATOR_STR           ":"
368
 
 
369
 
typedef enum IOOperation {
370
 
    READ_ASYNC,
371
 
    WRITE_ASYNC
372
 
} IOOperation;
373
 
 
374
 
 
375
 
#define _MD_INIT_IO()
376
 
 
377
 
#define _MD_OPEN                                        _MD_Open
378
 
#define _MD_OPEN_FILE                           _MD_Open
379
 
#define _MD_CLOSE_FILE                          FSClose
380
 
#define _MD_READ(fd,buf,amount)         ReadWriteProc(fd,buf,amount,READ_ASYNC)
381
 
#define _MD_WRITE(fd,buf,amount)        ReadWriteProc(fd,buf,amount,WRITE_ASYNC)
382
 
#define _MD_WRITE_SYNC(fd,buf,amount) WriteSyncProc(fd,buf,amount)
383
 
#define _MD_GET_FILE_ERROR()            _PR_MD_CURRENT_THREAD()->md.osErrCode
384
 
#define _MD_LSEEK                                       _MD_LSeek
385
 
#define _MD_FSYNC                                       _MD_FSync
386
 
 
387
 
/* to be implemented */
388
 
#define _MD_LSEEK64(a,b,c)           LL_ZERO
389
 
#define _MD_GETOPENFILEINFO64(fd,info)   -1
390
 
#define _MD_GETFILEINFO64(fd,info)   -1
391
 
 
392
 
#define _MD_IOQ_LOCK()
393
 
#define _MD_IOQ_UNLOCK()
394
 
 
395
 
/*
396
 
** File Manipulation definitions
397
 
*/
398
 
 
399
 
#define _MD_RENAME                      _MD_Rename
400
 
#define _MD_ACCESS                      _MD_Access
401
 
 
402
 
#define _MD_GETFILEINFO         _MD_GetFileInfo
403
 
#define _MD_GETOPENFILEINFO _MD_GetOpenFileInfo
404
 
 
405
 
#define _MD_STAT                        _MD_Stat
406
 
 
407
 
#define _MD_DELETE                      _MD_Delete
408
 
 
409
 
extern PRStatus _MD_LockFile(PRInt32 osfd);
410
 
#define _MD_LOCKFILE            _MD_LockFile
411
 
extern PRStatus _MD_TLockFile(PRInt32 osfd);
412
 
#define _MD_TLOCKFILE           _MD_TLockFile
413
 
extern PRStatus _MD_UnlockFile(PRInt32 osfd);
414
 
#define _MD_UNLOCKFILE          _MD_UnlockFile
415
 
 
416
 
/* 
417
 
** Directory enumeration related definitions 
418
 
*/
419
 
 
420
 
extern PRStatus _MD_OpenDir(struct _MDDir *md,const char *name);
421
 
#define _MD_OPEN_DIR            _MD_OpenDir
422
 
 
423
 
extern char* _MD_ReadDir(struct _MDDir *md,PRIntn flags);
424
 
#define _MD_READ_DIR            _MD_ReadDir
425
 
 
426
 
#define _MD_CLOSE_DIR           _MD_CloseDir
427
 
 
428
 
#define _MD_MKDIR                       _MD_MkDir
429
 
#define _MD_MAKE_DIR            _MD_MkDir
430
 
#define _MD_RMDIR                       _MD_Delete
431
 
 
432
 
/*
433
 
** Pipe I/O Related definitions (not implemented)
434
 
*/
435
 
 
436
 
#define _MD_PIPEAVAILABLE(fd) -1
437
 
 
438
 
/*
439
 
** Socket I/O Related definitions
440
 
*/
441
 
 
442
 
#if UNIVERSAL_INTERFACES_VERSION >= 0x0330
443
 
/* In Universal Interfaces 3.3 and later, these are enums. */
444
 
#define IP_TTL IP_TTL
445
 
#define IP_TOS IP_TOS
446
 
#define IP_ADD_MEMBERSHIP IP_ADD_MEMBERSHIP
447
 
#define IP_DROP_MEMBERSHIP IP_DROP_MEMBERSHIP
448
 
#define IP_MULTICAST_IF IP_MULTICAST_IF
449
 
#define IP_MULTICAST_TTL IP_MULTICAST_TTL
450
 
#define IP_MULTICAST_LOOP IP_MULTICAST_LOOP
451
 
#define TCP_NODELAY TCP_NODELAY
452
 
#define TCP_MAXSEG TCP_MAXSEG
453
 
#endif
454
 
 
455
 
#define _MD_SOCKET                      _MD_socket
456
 
#define _MD_BIND                        _MD_bind
457
 
#define _MD_LISTEN                      _MD_listen
458
 
#define _MD_GETSOCKNAME         _MD_getsockname
459
 
 
460
 
extern PRStatus _MD_getsockopt(PRFileDesc *fd, PRInt32 level, PRInt32 optname, char* optval, PRInt32* optlen);
461
 
#define _MD_GETSOCKOPT          _MD_getsockopt
462
 
 
463
 
extern PRStatus _MD_setsockopt(PRFileDesc *fd, PRInt32 level, PRInt32 optname, const char* optval, PRInt32 optlen);
464
 
#define _MD_SETSOCKOPT          _MD_setsockopt
465
 
 
466
 
#define _MD_SOCKETAVAILABLE     _MD_socketavailable
467
 
#define _MD_ACCEPT                      _MD_accept
468
 
#define _MD_CONNECT                     _MD_connect
469
 
#define _MD_SEND                        _MD_send
470
 
#define _MD_RECV                        _MD_recv
471
 
#define _MD_CLOSE_SOCKET        _MD_closesocket
472
 
#define _MD_SENDTO                      _MD_sendto
473
 
#define _MD_RECVFROM            _MD_recvfrom
474
 
#define _MD_PR_POLL                     _MD_poll
475
 
#define _MD_INIT_FILEDESC       _MD_initfiledesc
476
 
#define _MD_FREE_FILEDESC       _MD_freefiledesc
477
 
#define _MD_MAKE_NONBLOCK       _MD_makenonblock
478
 
#define _MD_INIT_FD_INHERITABLE _MD_initfdinheritable
479
 
#define _MD_QUERY_FD_INHERITABLE _MD_queryfdinheritable
480
 
 
481
 
#define _MD_GET_SOCKET_ERROR()          _PR_MD_CURRENT_THREAD()->md.osErrCode
482
 
 
483
 
#define _PR_MD_MAP_SELECT_ERROR(x)      (x)
484
 
/*
485
 
** Netdb Related definitions
486
 
*/
487
 
extern PRStatus _MD_gethostname(char *name, int namelen);
488
 
#define _MD_GETHOSTNAME         _MD_gethostname
489
 
#define _PR_GET_HOST_ADDR_AS_NAME
490
 
 
491
 
/* 
492
 
        XXX _MD_WRITEV, _MD_SHUTDOWN & _MD_GETPEERNAME not done yet!!!
493
 
*/
494
 
#define _MD_WRITEV                      _MD_writev
495
 
#define _MD_SHUTDOWN            _MD_shutdown
496
 
#define _MD_GETPEERNAME         _MD_getpeername
497
 
 
498
 
 
499
 
#ifdef OLD_MACSOCK_LIBRARY
500
 
#define _MD_SOCKET                      macsock_socket
501
 
#define _MD_LISTEN                      macsock_listen
502
 
#define _MD_SEND(fd,buf,amount,flags,timeout)   macsock_send(fd->secret->md.osfd,buf,amount,flags)
503
 
#define _MD_SENDTO(fd,buf,amount,flags,addr,addrlen,timeout)    macsock_sendto(fd->secret->md.osfd,buf,amount,flags,(struct sockaddr *)addr,addrlen)
504
 
#define _MD_RECV(fd,buf,amount,flags,timeout)   macsock_recv(fd->secret->md.osfd,buf,amount,flags)
505
 
#define _MD_RECVFROM(fd,buf,amount,flags,addr,addrlen,timeout)  macsock_recvfrom(fd->secret->md.osfd,buf,amount,flags,(struct sockaddr *)addr,addrlen)
506
 
#define _MD_CLOSE_SOCKET        macsock_close
507
 
#define _MD_SHUTDOWN(a,b)       (0)
508
 
 
509
 
#define _MD_ACCEPT(fd,addr,addrlen,timeout)     macsock_accept(fd->secret->md.osfd,(struct sockaddr *)addr,addrlen)
510
 
#define _MD_CONNECT(fd,name,namelen,timeout)    macsock_connect(fd->secret->md.osfd,(struct sockaddr *)name,namelen)
511
 
#define _MD_BIND(fd,name,namelen)                               macsock_bind(fd->secret->md.osfd,(struct sockaddr *)name,namelen)
512
 
#define _MD_GETSOCKNAME(fd,name,namelen)                macsock_getsockname(fd->secret->md.osfd,(struct sockaddr *)name,namelen)
513
 
#define _MD_GETPEERNAME(fd,name,namelen)                macsock_getpeername(fd->secret->md.osfd,(struct sockaddr *)name,namelen)
514
 
#define _MD_GETSOCKOPT(fd,level,optname,optval,optlen)          macsock_getsockopt(fd->secret->md.osfd,level,optname,optval,optlen)
515
 
#define _MD_SETSOCKOPT(fd,level,optname,optval,optlen)          macsock_setsockopt(fd->secret->md.osfd,level,optname,optval,optlen)
516
 
#define _MD_SOCKETAVAILABLE(fd,bytes)           macsock_socketavailable(fd->secret->md.osfd,bytes)
517
 
#endif
518
 
 
519
 
/*
520
 
** Memory Segements Related definitions
521
 
*/
522
 
 
523
 
#define _MD_INIT_SEGS()         
524
 
#define _MD_ALLOC_SEGMENT       _MD_AllocSegment
525
 
#define _MD_FREE_SEGMENT        _MD_FreeSegment
526
 
 
527
 
/*
528
 
** Time Related definitions
529
 
*/
530
 
 
531
 
#define _MD_GET_INTERVAL                                _MD_GetInterval
532
 
#define _MD_INTERVAL_PER_SEC()                  PR_MSEC_PER_SEC
533
 
#define _MD_INTERVAL_INIT()
534
 
 
535
 
/*
536
 
** Environemnt Related definitions
537
 
*/
538
 
 
539
 
extern char *_MD_GetEnv(const char *name);
540
 
#define _MD_GET_ENV                     _MD_GetEnv
541
 
 
542
 
extern int _MD_PutEnv(const char *variableCopy);
543
 
#define _MD_PUT_ENV                     _MD_PutEnv
544
 
 
545
 
/*
546
 
** Following is old stuff to be looked at.
547
 
*/
548
 
 
549
 
#define GCPTR
550
 
#define CALLBACK
551
 
typedef int (*FARPROC)();
552
 
 
553
 
 
554
 
#define MAX_NON_PRIMARY_TIME_SLICES     6
555
 
 
556
 
extern long gTimeSlicesOnNonPrimaryThread;
557
 
extern struct PRThread *gPrimaryThread;
558
 
 
559
 
// Errors not found in the Mac StdCLib
560
 
#define EACCES                  13              // Permission denied
561
 
#define ENOENT                  -43                     // No such file or directory
562
 
#define _OS_INVALID_FD_VALUE -1
563
 
 
564
 
#define STDERR_FILENO   2
565
 
 
566
 
#if !defined(MAC_NSPR_STANDALONE)
567
 
#define PATH_SEPARATOR                                  ':'
568
 
#define PATH_SEPARATOR_STR                      ":"
569
 
#define DIRECTORY_SEPARATOR                             '/'
570
 
#define DIRECTORY_SEPARATOR_STR                 "/"
571
 
#endif
572
 
 
573
 
#define UNIX_THIS_DIRECTORY_STR                 "./"
574
 
#define UNIX_PARENT_DIRECTORY_STR               "../"
575
 
 
576
 
 
577
 
// Alias a few names
578
 
#define getenv  PR_GetEnv
579
 
#define putenv  _MD_PutEnv
580
 
 
581
 
#if defined(MAC_NSPR_STANDALONE)
582
 
typedef unsigned char (*MemoryCacheFlusherProc)(size_t size);
583
 
typedef void (*PreAllocationHookProc)(void);
584
 
 
585
 
extern char *strdup(const char *source);
586
 
 
587
 
extern void InstallPreAllocationHook(PreAllocationHookProc newHook);
588
 
extern void InstallMemoryCacheFlusher(MemoryCacheFlusherProc newFlusher);
589
 
#endif
590
 
 
591
 
extern char *PR_GetDLLSearchPath(void);
592
 
 
593
 
#if defined(MAC_NSPR_STANDALONE)
594
 
extern int strcmp(const char *str1, const char *str2);
595
 
extern int strcasecmp(const char *str1, const char *str2);
596
 
#endif
597
 
 
598
 
extern void MapFullToPartialMacFile(char *);
599
 
extern char *MapPartialToFullMacFile(const char *);
600
 
 
601
 
extern void ResetTimer(void);
602
 
extern void PR_PeriodicIdle(void);
603
 
extern void ActivateTimer(void);
604
 
extern void DeactivateTimer(void);
605
 
extern void PR_InitMemory(void);
606
 
 
607
 
extern struct hostent *gethostbyaddr(const void *addr, int addrlen, int type);
608
 
 
609
 
extern short GetVolumeRefNumFromName(const char *);
610
 
 
611
 
#include <stdio.h>                      // Needed to get FILE typedef
612
 
extern FILE *_OS_FOPEN(const char *filename, const char *mode);
613
 
//
614
 
//      Macintosh only private parts.
615
 
//
616
 
 
617
 
#define dprintTrace                     ";dprintf;doTrace"
618
 
#define dprintNoTrace           ";dprintf"
619
 
extern void dprintf(const char *format, ...);
620
 
 
621
 
 
622
 
// Entry into the memory system's cache flushing
623
 
#if defined(MAC_NSPR_STANDALONE)
624
 
extern PRUint8 CallCacheFlushers(size_t blockSize);
625
 
#endif
626
 
 
627
 
#if defined(MAC_NSPR_STANDALONE)
628
 
extern void* reallocSmaller(void* block, size_t newSize);
629
 
#endif
630
 
 
631
 
 
632
 
/*
633
 
** PR_GetSystemInfo related definitions
634
 
*/
635
 
#define _PR_SI_SYSNAME          "MacOS"
636
 
#define _PR_SI_ARCHITECTURE     "PowerPC"
637
 
 
638
 
/*
639
 
 * Memory-mapped files
640
 
 */
641
 
 
642
 
struct _MDFileMap {
643
 
    PRInt8 unused;
644
 
};
645
 
 
646
 
extern PRStatus _MD_CreateFileMap(struct PRFileMap *fmap, PRInt64 size);
647
 
#define _MD_CREATE_FILE_MAP _MD_CreateFileMap
648
 
 
649
 
extern PRInt32 _MD_GetMemMapAlignment(void);
650
 
#define _MD_GET_MEM_MAP_ALIGNMENT _MD_GetMemMapAlignment
651
 
 
652
 
extern void * _MD_MemMap(struct PRFileMap *fmap, PRInt64 offset,
653
 
        PRUint32 len);
654
 
#define _MD_MEM_MAP _MD_MemMap
655
 
 
656
 
extern PRStatus _MD_MemUnmap(void *addr, PRUint32 size);
657
 
#define _MD_MEM_UNMAP _MD_MemUnmap
658
 
 
659
 
extern PRStatus _MD_CloseFileMap(struct PRFileMap *fmap);
660
 
#define _MD_CLOSE_FILE_MAP _MD_CloseFileMap
661
 
 
662
 
extern void SetLogFileTypeCreator(const char *logFile);
663
 
extern int _MD_mac_get_nonblocking_connect_error(PRFileDesc* fd);
664
 
 
665
 
 
666
 
/*
667
 
 * Critical section support
668
 
 */
669
 
 
670
 
#define MAC_CRITICAL_REGIONS  TARGET_CARBON
671
 
 
672
 
#if MAC_CRITICAL_REGIONS
673
 
 
674
 
extern void InitCriticalRegion();
675
 
extern void TermCriticalRegion();
676
 
 
677
 
extern void EnterCritialRegion();
678
 
extern void LeaveCritialRegion();
679
 
 
680
 
#define INIT_CRITICAL_REGION()     InitCriticalRegion()
681
 
#define TERM_CRITICAL_REGION()     TermCriticalRegion()
682
 
 
683
 
#define ENTER_CRITICAL_REGION()     EnterCritialRegion()
684
 
#define LEAVE_CRITICAL_REGION()     LeaveCritialRegion()
685
 
 
686
 
#else
687
 
 
688
 
#define INIT_CRITICAL_REGION()
689
 
#define TERM_CRITICAL_REGION()
690
 
 
691
 
#define ENTER_CRITICAL_REGION()
692
 
#define LEAVE_CRITICAL_REGION()
693
 
 
694
 
#endif
695
 
 
696
 
 
697
 
 
698
 
/*
699
 
 * CPU Idle support
700
 
 */
701
 
 
702
 
extern void InitIdleSemaphore();
703
 
extern void TermIdleSemaphore();
704
 
 
705
 
extern void WaitOnIdleSemaphore();
706
 
extern void SignalIdleSemaphore();
707
 
 
708
 
 
709
 
/*
710
 
 * Atomic operations
711
 
 */
712
 
#ifdef _PR_HAVE_ATOMIC_OPS
713
 
 
714
 
extern PRInt32 _MD_AtomicSet(PRInt32 *val, PRInt32 newval);
715
 
 
716
 
#define _MD_INIT_ATOMIC()
717
 
#define _MD_ATOMIC_INCREMENT(val)   OTAtomicAdd32(1, (SInt32 *)val)
718
 
#define _MD_ATOMIC_ADD(ptr, val)    OTAtomicAdd32(val, (SInt32 *)ptr)
719
 
#define _MD_ATOMIC_DECREMENT(val)   OTAtomicAdd32(-1, (SInt32 *)val)
720
 
#define _MD_ATOMIC_SET(val, newval) _MD_AtomicSet(val, newval)
721
 
 
722
 
#endif /* _PR_HAVE_ATOMIC_OPS */
723
 
 
724
 
 
725
 
#endif /* prmacos_h___ */