home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / nsprpub / pr / include / md / _sony.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  4.2 KB  |  150 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /*
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  * 
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  * 
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. #ifndef nspr_sony_defs_h___
  20. #define nspr_sony_defs_h___
  21.  
  22. #define PR_LINKER_ARCH        "sony"
  23. #define _PR_SI_SYSNAME        "SONY"
  24. #define _PR_SI_ARCHITECTURE    "mips"
  25. #define PR_DLL_SUFFIX        ".so"
  26.  
  27. #define _PR_VMBASE        0x30000000
  28. #define _PR_STACK_VMBASE    0x50000000
  29. #define _MD_DEFAULT_STACK_SIZE    65536L
  30. #define _MD_MMAP_FLAGS          MAP_PRIVATE
  31.  
  32. #define _MD_GET_INTERVAL    _PR_UNIX_GetInterval
  33. #define _MD_INTERVAL_PER_SEC    _PR_UNIX_TicksPerSecond
  34.  
  35. #if defined(_PR_LOCAL_THREADS_ONLY)
  36. #include <ucontext.h>
  37. #include <sys/regset.h>
  38.  
  39. #define PR_NUM_GCREGS    NGREG
  40. #define PR_CONTEXT_TYPE    ucontext_t
  41.  
  42. #define CONTEXT(_thread)    (&(_thread)->md.context)
  43.  
  44. #define _MD_GET_SP(_t)        (_t)->md.context.uc_mcontext.gregs[CXT_SP]
  45.  
  46. /*
  47. ** Initialize the thread context preparing it to execute _main()
  48. */
  49. #define _MD_INIT_CONTEXT(_thread, _sp, _main, status)               \
  50. {                                                                   \
  51.     *status = PR_TRUE;  \
  52.     getcontext(CONTEXT(_thread));                                    \
  53.     CONTEXT(_thread)->uc_stack.ss_sp = (char*) (_thread)->stack->stackBottom; \
  54.     CONTEXT(_thread)->uc_stack.ss_size = (_thread)->stack->stackSize; \
  55.     _MD_GET_SP(_thread) = (greg_t) (_sp) - 64;             \
  56.     makecontext(CONTEXT(_thread), _main, 0);              \
  57. }
  58.  
  59. #define _MD_SWITCH_CONTEXT(_thread)      \
  60.     if (!getcontext(CONTEXT(_thread))) { \
  61.         (_thread)->md.errcode = errno;      \
  62.         _PR_Schedule();                  \
  63.     }
  64.  
  65. /*
  66. ** Restore a thread context, saved by _MD_SWITCH_CONTEXT
  67. */
  68. #define _MD_RESTORE_CONTEXT(_thread)   \
  69. {                                      \
  70.     ucontext_t *uc = CONTEXT(_thread); \
  71.     uc->uc_mcontext.gregs[CXT_V0] = 1; \
  72.     uc->uc_mcontext.gregs[CXT_A3] = 0; \
  73.     _MD_SET_CURRENT_THREAD(_thread);      \
  74.     errno = (_thread)->md.errcode;        \
  75.     setcontext(uc);                    \
  76. }
  77.  
  78. /* Machine-dependent (MD) data structures */
  79.  
  80. struct _MDThread {
  81.     PR_CONTEXT_TYPE context;
  82.     int id;
  83.     int errcode;
  84. };
  85.  
  86. struct _MDThreadStack {
  87.     PRInt8 notused;
  88. };
  89.  
  90. struct _MDLock {
  91.     PRInt8 notused;
  92. };
  93.  
  94. struct _MDSemaphore {
  95.     PRInt8 notused;
  96. };
  97.  
  98. struct _MDCVar {
  99.     PRInt8 notused;
  100. };
  101.  
  102. struct _MDSegment {
  103.     PRInt8 notused;
  104. };
  105.  
  106. struct _MDCPU {
  107.     struct _MDCPU_Unix md_unix;
  108. };
  109.  
  110. #define _MD_INIT_LOCKS()
  111. #define _MD_NEW_LOCK(lock) PR_SUCCESS
  112. #define _MD_FREE_LOCK(lock)
  113. #define _MD_LOCK(lock)
  114. #define _MD_UNLOCK(lock)
  115. #define _MD_INIT_IO()
  116. #define _MD_IOQ_LOCK()
  117. #define _MD_IOQ_UNLOCK()
  118.  
  119. #define _MD_EARLY_INIT              _MD_EarlyInit
  120. #define _MD_FINAL_INIT            _PR_UnixInit
  121. #define _MD_INIT_RUNNING_CPU(cpu)    _MD_unix_init_running_cpu(cpu)
  122. #define _MD_INIT_THREAD            _MD_InitializeThread
  123. #define _MD_EXIT_THREAD(thread)
  124. #define    _MD_SUSPEND_THREAD(thread)
  125. #define    _MD_RESUME_THREAD(thread)
  126. #define _MD_CLEAN_THREAD(_thread)
  127.  
  128. /* The following defines unwrapped versions of select() and poll(). */
  129. extern int _select (int, fd_set *, fd_set *, fd_set *, struct timeval *);
  130. #define _MD_SELECT              _select
  131.  
  132. #include <sys/poll.h>
  133. extern int _poll(struct pollfd *fds, unsigned long nfds, int timeout);
  134. #define _MD_POLL _poll
  135.  
  136. #endif /* _PR_LOCAL_THREADS_ONLY */
  137.  
  138. #undef    HAVE_STACK_GROWING_UP
  139. #define    HAVE_DLL
  140. #define    USE_DLFCN
  141. #define    NEED_TIME_R
  142. #define NEED_STRFTIME_LOCK
  143.  
  144. /*
  145. ** Missing function prototypes
  146. */
  147. extern int gethostname(char *name, int namelen);
  148.  
  149. #endif /* nspr_sony_defs_h___ */
  150.