/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is the Netscape Portable Runtime (NSPR).
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998-2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef prmacos_h___
#define prmacos_h___
//
// This file contains all changes and additions which need to be made to the NSPR runtime
// for the Macintosh platform (specifically the Metrowerks environment). This file should
// only be incluced in Macintosh builds.
//
#define _PR_LOCAL_THREADS_ONLY
#include "prinit.h"
#include "prio.h"
#include "prlong.h"
#include "prlock.h"
#include "prcvar.h"
#include "prsem.h"
#include "prthread.h"
#include "prtime.h"
#include "prproces.h"
#if !defined(MAC_NSPR_STANDALONE)
#include "macstdlibextras.h"
#endif
#include <stddef.h>
#include <setjmp.h>
#include <Errors.h>
#include <OpenTransport.h>
#include <DriverServices.h>
#define _PR_HAVE_PEEK_BUFFER
struct _MDProcess {
};
struct _MDThread {
int osErrCode;
};
struct _MDThreadStack {
};
struct _MDLock {
};
struct _MDCVar {
};
struct _MDSemaphore {
};
struct _MDSegment {
};
struct _MDCPU {
};
typedef struct _MDSocketCallerInfo {
void * cookie;
struct _MDFileDesc {
/* Server sockets: listen bit tells the notifier func what to do */
/* stored error for non-blocking connects, as a Unix-style error code */
};
/*
** Iinitialization Related definitions
*/
/*
** Interrupts Related definitions
*/
(_is) = _PR_MD_GET_INTSOFF(); \
_PR_MD_SET_INTSOFF(1); \
#if TARGET_CARBON
#else /* not TARGET_CARBON */
#endif /* TARGET_CARBON */
#define _MD_BLOCK_CLOCK_INTERRUPTS()
#define _MD_UNBLOCK_CLOCK_INTERRUPTS()
#define _MD_DISABLE_CLOCK_INTERRUPTS()
#define _MD_ENABLE_CLOCK_INTERRUPTS()
/*
** CPU Related definitions
*/
#define _MD_CLEANUP_BEFORE_EXIT()
#define _MD_INIT_CPUS()
/*
** Process Related definitions
*/
extern struct PRProcess * _MD_CreateProcess(
const char *path,
char *const *argv,
char *const *envp,
const PRProcessAttr *attr);
/*
** Memory Segments Related definitions
*/
#define _MD_INIT_SEGS()
/*
** Thread Stacks Debugging Related definitions
*/
/*
** Locks Related definitions
*/
#define _MD_INIT_LOCKS()
/*
** Thread Related definitions
*/
#else
#endif
/*
** Initialize the thread machine dependent data structure
*/
/*
** Clean-up the thread machine dependent data structure
*/
/*
** Initialize the thread context preparing it to execute _main.
** *sp = 0 zeros out the sp for the first stack frame so that
** stack walking code can find the top of the stack.
*/
unsigned char *sp; \
unsigned long *tvect; \
*sp = 0; \
#else
unsigned char *sp; \
#endif
/*
** Switch away from the current thread context by saving its state and
** calling the thread scheduler. Reload cpu when we come back from the
** context switch because it might have changed.
*/
/* ResetTimer(); before _PR_Schedule() */
_PR_Schedule(); \
} else { \
_MD_LAST_THREAD()->no_sched = 0; \
} \
/*
** Restore a thread context that was saved by _MD_SWITCH_CONTEXT or
** initialized by _MD_INIT_CONTEXT.
*/
/*
** Combined thread model related definitions
*/
#define _MD_WAKEUP_WAITER(a)
#define _MD_SET_PRIORITY(a,b)
/*
** File I/O Related definitions
*/
struct _MDDir {
short ioVRefNum;
long ioDirID;
short ioFDirIndex;
char *currentEntryName;
};
typedef enum IOOperation {
} IOOperation;
#define _MD_INIT_IO()
/* to be implemented */
#define _MD_IOQ_LOCK()
#define _MD_IOQ_UNLOCK()
/*
** File Manipulation definitions
*/
/*
** Directory enumeration related definitions
*/
/*
** Pipe I/O Related definitions (not implemented)
*/
/*
** Socket I/O Related definitions
*/
#if UNIVERSAL_INTERFACES_VERSION >= 0x0330
/* In Universal Interfaces 3.3 and later, these are enums. */
#endif
extern PRStatus _MD_getsockopt(PRFileDesc *fd, PRInt32 level, PRInt32 optname, char* optval, PRInt32* optlen);
extern PRStatus _MD_setsockopt(PRFileDesc *fd, PRInt32 level, PRInt32 optname, const char* optval, PRInt32 optlen);
#define _PR_MD_MAP_SELECT_ERROR(x) (x)
/*
** Netdb Related definitions
*/
#define _PR_GET_HOST_ADDR_AS_NAME
/*
XXX _MD_WRITEV, _MD_SHUTDOWN & _MD_GETPEERNAME not done yet!!!
*/
#ifdef OLD_MACSOCK_LIBRARY
#define _MD_SENDTO(fd,buf,amount,flags,addr,addrlen,timeout) macsock_sendto(fd->secret->md.osfd,buf,amount,flags,(struct sockaddr *)addr,addrlen)
#define _MD_RECVFROM(fd,buf,amount,flags,addr,addrlen,timeout) macsock_recvfrom(fd->secret->md.osfd,buf,amount,flags,(struct sockaddr *)addr,addrlen)
#define _MD_SHUTDOWN(a,b) (0)
#define _MD_ACCEPT(fd,addr,addrlen,timeout) macsock_accept(fd->secret->md.osfd,(struct sockaddr *)addr,addrlen)
#define _MD_CONNECT(fd,name,namelen,timeout) macsock_connect(fd->secret->md.osfd,(struct sockaddr *)name,namelen)
#define _MD_GETSOCKNAME(fd,name,namelen) macsock_getsockname(fd->secret->md.osfd,(struct sockaddr *)name,namelen)
#define _MD_GETPEERNAME(fd,name,namelen) macsock_getpeername(fd->secret->md.osfd,(struct sockaddr *)name,namelen)
#define _MD_GETSOCKOPT(fd,level,optname,optval,optlen) macsock_getsockopt(fd->secret->md.osfd,level,optname,optval,optlen)
#define _MD_SETSOCKOPT(fd,level,optname,optval,optlen) macsock_setsockopt(fd->secret->md.osfd,level,optname,optval,optlen)
#endif
/*
** Memory Segements Related definitions
*/
#define _MD_INIT_SEGS()
/*
** Time Related definitions
*/
#define _MD_INTERVAL_INIT()
/*
** Environemnt Related definitions
*/
extern char *_MD_GetEnv(const char *name);
extern int _MD_PutEnv(const char *variableCopy);
/*
** Following is old stuff to be looked at.
*/
#define GCPTR
#define CALLBACK
typedef int (*FARPROC)();
extern long gTimeSlicesOnNonPrimaryThread;
extern struct PRThread *gPrimaryThread;
// Errors not found in the Mac StdCLib
#if !defined(MAC_NSPR_STANDALONE)
#endif
// Alias a few names
#if defined(MAC_NSPR_STANDALONE)
typedef void (*PreAllocationHookProc)(void);
#endif
extern char *PR_GetDLLSearchPath(void);
#if defined(MAC_NSPR_STANDALONE)
#endif
extern void MapFullToPartialMacFile(char *);
extern char *MapPartialToFullMacFile(const char *);
extern void ResetTimer(void);
extern void PR_PeriodicIdle(void);
extern void ActivateTimer(void);
extern void DeactivateTimer(void);
extern void PR_InitMemory(void);
extern short GetVolumeRefNumFromName(const char *);
#include <stdio.h> // Needed to get FILE typedef
//
// Macintosh only private parts.
//
// Entry into the memory system's cache flushing
#if defined(MAC_NSPR_STANDALONE)
#endif
#if defined(MAC_NSPR_STANDALONE)
#endif
/*
** PR_GetSystemInfo related definitions
*/
/*
* Memory-mapped files
*/
struct _MDFileMap {
};
extern PRInt32 _MD_GetMemMapAlignment(void);
extern void SetLogFileTypeCreator(const char *logFile);
/*
* Critical section support
*/
extern void InitCriticalRegion();
extern void TermCriticalRegion();
extern void EnterCritialRegion();
extern void LeaveCritialRegion();
#else
#define INIT_CRITICAL_REGION()
#define TERM_CRITICAL_REGION()
#define ENTER_CRITICAL_REGION()
#define LEAVE_CRITICAL_REGION()
#endif
/*
* CPU Idle support
*/
extern void InitIdleSemaphore();
extern void TermIdleSemaphore();
extern void WaitOnIdleSemaphore();
extern void SignalIdleSemaphore();
/*
* Atomic operations
*/
#ifdef _PR_HAVE_ATOMIC_OPS
#define _MD_INIT_ATOMIC()
#endif /* _PR_HAVE_ATOMIC_OPS */
#endif /* prmacos_h___ */