_l4v2.h revision 677833bc953b6cb418c701facbdcf4aa18d6c44e
/* -*- 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 nspr_l4v2_defs_h___
#define nspr_l4v2_defs_h___
/**
* I have "#if 0"ed a lot of this out, and plan to add most of it manually as the
* compiler complains about it in order to get a better idea of what is here and
* what it does. Not to mention which bits are needed by the runtime itself, and
* which only by the unix port.
*/
#include "prthread.h"
/*
* Internal configuration macros
*/
#define PR_LINKER_ARCH "l4v2"
#define _PR_SI_SYSNAME "L4ENV"
#define _PR_SI_ARCHITECTURE "x86"
#define PR_DLL_SUFFIX ".s.so"
#define _MD_DEFAULT_STACK_SIZE 65536L
#define _MD_MMAP_FLAGS MAP_PRIVATE
/*
* L4env supports dl* functions
*/
#define HAVE_DLL
#define USE_DLFCN
#define USE_SETJMP
#define _PR_STAT_HAS_ONLY_ST_ATIME
#define _PR_HAVE_OFF64_T
#include <setjmp.h>
#define PR_CONTEXT_TYPE jmp_buf
/* Now come the things specifically added for the l4v2 target */
/* Don't know quite what this means yet, except that we don't have "it" */
/* #define TCP_NODELAY _PR_NO_SUCH_SOCKOPT */
/* And what is this? Something to do with memory... Used in
/**
*/
struct _MDSegment {
};
extern void
_MD_InitSegs(void);
#define _MD_INIT_SEGS _MD_InitSegs
extern PRStatus
#define _MD_ALLOC_SEGMENT _MD_AllocSegment
extern void
#define _MD_FREE_SEGMENT _MD_FreeSegment
/**
*/
extern void
_MD_IntervalInit(void);
#define _MD_INTERVAL_INIT()
/**
*/
extern void
_MD_EarlyInit(void);
#define _MD_EARLY_INIT() _MD_EarlyInit()
extern void
_MD_StartInterrupts(void);
extern void
_MD_StopInterrupts(void);
extern void
_MD_DisableClockInterrupts(void);
extern void
_MD_EnableClockInterrupts(void);
extern void
_MD_BlockClockInterrupts(void);
extern void
_MD_UnblockClockInterrupts(void);
#define __USE_SVID /* for now, to get putenv */
#include <stdlib.h>
/**
*/
#if defined(__i386__)
#define _PR_HAVE_ATOMIC_OPS
#define _MD_INIT_ATOMIC()
extern PRInt32
extern PRInt32
extern PRInt32
#define _MD_ATOMIC_ADD _PR_x86_AtomicAdd
extern PRInt32
#define _MD_ATOMIC_SET _PR_x86_AtomicSet
#endif
/**
*/
#define _PR_LOCAL_THREADS_ONLY
#if 0
struct _MDThread {
};
struct _MDThreadStack {
};
#endif /* 0 */
#ifndef _PR_LOCAL_THREADS_ONLY
extern PR_IMPLEMENT(PRThread*)
PR_GetCurrentThread(void);
#define _MD_CURRENT_THREAD() PR_GetCurrentThread()
#endif /* _PR_LOCAL_THREADS_ONLY */
#define _MD_EXIT_THREAD(thread)
#ifndef _PR_LOCAL_THREADS_ONLY
extern PR_IMPLEMENT(struct _PRCPU *)
PR_GetCurrentCPU(void);
#define _MD_CURRENT_CPU() PR_GetCurrentCPU()
#endif /* _PR_LOCAL_THREADS_ONLY */
#if 0
#define _L4_GET_NUMBER_OF_CPUS() 1
#define _MD_SET_INTSOFF(_val)
#define _MD_GET_INTSOFF() 1
#endif /* 0 */
#if 0 /* these are the Win32 versions of the above macros - all other versions are defined
as here. */
#define _MD_GET_INTSOFF() \
#define _MD_SET_INTSOFF(_val) \
if (_pr_use_static_tls) { \
_pr_ints_off = (_val); \
} else { \
} \
#endif /* 0 */
/**
*/
/* Memory-mapped files */
extern PRStatus
#define _MD_CREATE_FILE_MAP _MD_CreateFileMap
extern PRStatus
#define _MD_CLOSE_FILE_MAP _MD_CloseFileMap
#define _MD_GET_MEM_MAP_ALIGNMENT() PR_GetPageSize()
extern void *
#define _MD_MEM_MAP _MD_MemMap
extern PRStatus
#define _MD_MEM_UNMAP _MD_MemUnmap
/**
*/
#define PR_DIRECTORY_SEPARATOR '/'
#define PR_DIRECTORY_SEPARATOR_STR "/"
#define PR_PATH_SEPARATOR ':'
#define PR_PATH_SEPARATOR_STR ":"
#define GCPTR
#if 0
typedef int (*FARPROC)(); /* Where is this used? */
#endif
extern PRInt32
extern void
/**
*/
extern PRStatus
#define _MD_GETSOCKOPT _MD_getsockopt
extern PRStatus
#define _MD_SETSOCKOPT _MD_setsockopt
extern PRStatus
#define _MD_GETHOSTNAME _MD_gethostname
/**
*/
struct _MDSemaphore {
};
struct _MDCVar {
};
struct _MDLock {
int unused;
};
/* Intel based Linux, err sorry, L4 */
#define _MD_SP_TYPE __ptr_t
#define PR_NUM_GCREGS 6
/*
** Initialize a thread context to run "_main()" when started
*/
{ \
_main(); \
} \
_MD_SET_FP(_thread, 0); \
}
#define _MD_SWITCH_CONTEXT(_thread) \
_PR_Schedule(); \
}
/*
** Restore a thread context, saved by _MD_SWITCH_CONTEXT
*/
#define _MD_RESTORE_CONTEXT(_thread) \
{ \
}
/* Machine-dependent (MD) data structures */
struct _MDThread {
/* The next two are purely for debugging purposes */
int sp;
int fp;
int id;
int errcode;
};
struct _MDThreadStack {
};
/*
* md-specific cpu structure field
*/
#define _PR_MD_MAX_OSFD FD_SETSIZE
struct _MDCPU_Unix {
#ifndef _PR_USE_POLL
#else
struct pollfd *ioq_pollfds;
int ioq_pollfds_size;
#endif /* _PR_USE_POLL */
};
struct _MDCPU {
struct _MDCPU_Unix md_unix;
};
#define _MD_INIT_LOCKS()
#define _MD_FREE_LOCK(lock)
#define _MD_UNLOCK(lock)
#define _MD_INIT_IO()
#define _MD_IOQ_LOCK()
#define _MD_IOQ_UNLOCK()
#if 0
#endif /* 0 */
#define _MD_INIT_THREAD _MD_InitializeThread
#if 0
#define _MD_EXIT_THREAD(thread)
#endif /* 0 */
#define _MD_CLEAN_THREAD(_thread)
#if 0
extern PRStatus _MD_CREATE_THREAD(
void (*start) (void *),
#endif /* 0 */
#if 0
extern void _MD_YIELD(void);
extern void _MD_EarlyInit(void);
#endif /* 0 */
extern PRIntervalTime _PR_UNIX_GetInterval(void);
extern PRIntervalTime _PR_UNIX_TicksPerSecond(void);
#if 0
#define _MD_EARLY_INIT _MD_EarlyInit
#endif /* 0 */
#define _MD_FINAL_INIT _PR_UnixInit
#define _MD_GET_INTERVAL _PR_UNIX_GetInterval
/*
* We wrapped the select() call. _MD_SELECT refers to the built-in,
* unwrapped version.
*/
#if 0
#define _MD_SELECT __select
#else
#define _MD_SELECT select
#endif
#ifdef _PR_POLL_AVAILABLE
int timeout);
#define _MD_POLL __syscall_poll
#endif
#if 0
/* For writev() */
extern void _MD_l4_map_sendfile_error(int err);
#include <dirent.h>
#include "prio.h"
#include "prmem.h"
#include "prclist.h"
#endif /* 0 */
#if 0
/*
* intervals at which GLOBAL threads wakeup to check for pending interrupt
*/
#define _PR_INTERRUPT_CHECK_INTERVAL_SECS 5
extern PRIntervalTime intr_timeout_ticks;
#define _PR_POLLQUEUE_PTR(_qp) \
#endif /* 0 */
#if 0
struct _MDDir {
DIR *d;
};
struct _PRCPU;
#endif /* 0 */
/*
** Make a redzone at both ends of the stack segment. Disallow access
** to those pages of memory. It's ok if the mprotect call's don't
** work - it just means that we don't really have a functional
** redzone.
*/
#if 0
#ifndef PROT_NONE
#define PROT_NONE 0x0
#endif
#define _MD_CLEAR_STACK(ts)
#define PR_SET_INTSOFF(newval)
#endif
#if 0
struct PRProcess;
struct PRProcessAttr;
/* Create a new process (fork() + exec()) */
/* When the compiler complains about this, we will do something about it. */
/* Wait for a child process to terminate */
#define _MD_WAIT_PROCESS _MD_l4WaitProcess
#define _MD_KILL_PROCESS _MD_l4KillProcess
#endif
/************************************************************************/
#if 0
extern void _MD_EnableClockInterrupts(void);
extern void _MD_DisableClockInterrupts(void);
#endif
/************************************************************************/
#if 0
extern void _MD_InitCPUS(void);
#define _MD_INIT_CPUS _MD_InitCPUS
extern void _MD_Wakeup_CPUs(void);
#define _MD_WAKEUP_CPUS _MD_Wakeup_CPUs
#define _MD_PAUSE_CPU _MD_PauseCPU
#if defined(_PR_LOCAL_THREADS_ONLY) || defined(_PR_GLOBAL_THREADS_ONLY)
#define _MD_CLEANUP_BEFORE_EXIT()
#endif
#endif
/************************************************************************/
#if 0
#define _MD_GET_ENV getenv
#define _MD_PUT_ENV putenv
#endif /* 0 */
/************************************************************************/
#if 0
#define _MD_INIT_FILEDESC(fd)
#define _MD_MAKE_NONBLOCK _MD_MakeNonblock
#endif
/************************************************************************/
#if 0
#if !defined(_PR_PTHREADS)
extern void _MD_InitSegs(void);
void *vaddr);
#define _MD_INIT_SEGS _MD_InitSegs
#define _MD_ALLOC_SEGMENT _MD_AllocSegment
#define _MD_FREE_SEGMENT _MD_FreeSegment
#endif /* !defined(_PR_PTHREADS) */
#endif /* 0 */
/************************************************************************/
#if 0
#define _MD_INTERVAL_INIT()
#endif
/************************************************************************/
#if 0
#define _MD_GET_SOCKET_ERROR() (errno)
#endif
/************************************************************************/
#if 0
extern void _MD_StartInterrupts(void);
extern void _MD_StopInterrupts(void);
extern void _MD_DisableClockInterrupts(void);
extern void _MD_BlockClockInterrupts(void);
extern void _MD_UnblockClockInterrupts(void);
#endif /* 0 */
#if 0
#define _MD_ACCEPT_READ(sock, newSock, raddr, buf, amount) _MD_accept_read(sock, newSock, raddr, buf, amount)
#define _MD_LOCKFILE _MD_LockFile
#define _MD_TLOCKFILE _MD_TLockFile
#define _MD_UNLOCKFILE _MD_UnlockFile
#endif /* 0 */
#if 0
#define _MD_SOCKET _MD_socket
#define _MD_CONNECT _MD_connect
#define _MD_ACCEPT _MD_accept
#define _MD_LISTEN _MD_listen
#define _MD_SHUTDOWN _MD_shutdown
#define _MD_RECVFROM _MD_recvfrom
#define _MD_SENDTO _MD_sendto
#define _MD_WRITEV _MD_writev
#define _MD_PIPEAVAILABLE _MD_socketavailable
#define _MD_PR_POLL _MD_pr_poll
#endif /* 0 */
#if 0
#define _MD_CLOSE_FILE _MD_close
#define _MD_LSEEK64 _MD_lseek64
#endif /* 0 */
#if 0
#define _MD_SOCKETPAIR _MD_socketpair
#define _MD_CLOSE_SOCKET _MD_close
#ifndef NO_NSPR_10_SUPPORT
#endif
#define _MD_GETPEERNAME _MD_getpeername
#define _MD_GETSOCKNAME _MD_getsockname
#define _MD_GETSOCKOPT _MD_getsockopt
#define _MD_SETSOCKOPT _MD_setsockopt
#define _MD_GETHOSTNAME _MD_gethostname
#define _MD_GETSYSINFO _MD_getsysinfo
#endif /* 0 */
#if 0
struct _MDFileMap {
};
#define _MD_CREATE_FILE_MAP _MD_CreateFileMap
#define _MD_GET_MEM_MAP_ALIGNMENT() PR_GetPageSize()
#define _MD_MEM_MAP _MD_MemMap
#define _MD_MEM_UNMAP _MD_MemUnmap
#define _MD_CLOSE_FILE_MAP _MD_CloseFileMap
#endif /* 0 */
#if 0
#if defined(_PR_PTHREADS) && !defined(_PR_POLL_AVAILABLE)
#define _PR_NEED_FAKE_POLL
#endif
/*
** A vector of the UNIX I/O calls we use. These are here to smooth over
** the rough edges needed for large files. All of NSPR's implmentaions
** go through this vector using syntax of the form
** result = _md_iovector.xxx64(args);
*/
typedef off_t _MDOff64_t;
typedef void* (*_MD_Mmap64)(
struct _MD_IOVector
{
};
extern struct _MD_IOVector _md_iovector;
#endif /* 0 */
#endif /* nspr_l4v2_defs_h___ */