_beos.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
  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. #ifndef nspr_beos_defs_h___
  38. #define nspr_beos_defs_h___
  39. #include "prtypes.h"
  40. #include "prio.h"
  41. #include "prthread.h"
  42. #include "prproces.h"
  43. #include "prmem.h"
  44. #include "obsolete/prsem.h"
  45. #include <errno.h>
  46. #include <support/SupportDefs.h>
  47. #include <kernel/OS.h>
  48. #include <dirent.h>
  49. /*
  50. * Internal configuration macros
  51. */
  52. #ifdef BONE_VERSION
  53. #define _PR_HAVE_SOCKADDR_LEN
  54. #endif
  55. #define PR_LINKER_ARCH "beos"
  56. #define _PR_SI_SYSNAME "BEOS"
  57. #ifdef __powerpc__
  58. #define _PR_SI_ARCHITECTURE "ppc"
  59. #else
  60. #define _PR_SI_ARCHITECTURE "x86"
  61. #endif
  62. #define PR_DLL_SUFFIX ".so"
  63. #define _PR_VMBASE 0x30000000
  64. #define _PR_STACK_VMBASE 0x50000000
  65. #define _MD_DEFAULT_STACK_SIZE 65536L
  66. #define _MD_MMAP_FLAGS MAP_PRIVATE
  67. #undef HAVE_STACK_GROWING_UP
  68. #define HAVE_DLL
  69. #define _PR_NO_CLOCK_TIMER
  70. /*
  71. * The Atomic operations
  72. */
  73. #define _PR_HAVE_ATOMIC_OPS
  74. #define _MD_INIT_ATOMIC _MD_AtomicInit
  75. #define _MD_ATOMIC_INCREMENT _MD_AtomicIncrement
  76. #define _MD_ATOMIC_ADD _MD_AtomicAdd
  77. #define _MD_ATOMIC_DECREMENT _MD_AtomicDecrement
  78. #define _MD_ATOMIC_SET _MD_AtomicSet
  79. #define HAVE_CVAR_BUILT_ON_SEM
  80. #define _PR_GLOBAL_THREADS_ONLY
  81. #define _PR_BTHREADS
  82. #define _PR_NEED_FAKE_POLL
  83. #define _PR_HAVE_PEEK_BUFFER
  84. #define _PR_PEEK_BUFFER_MAX (16 * 1024)
  85. #define _PR_FD_NEED_EMULATE_MSG_PEEK(fd) 1
  86. #define _PR_CONNECT_DOES_NOT_BIND
  87. #define _PR_HAVE_O_APPEND
  88. /* Define threading functions and objects as native BeOS */
  89. struct _MDThread {
  90. thread_id tid; /* BeOS thread handle */
  91. sem_id joinSem; /* sems used to synchronzie joining */
  92. PRBool is_joining; /* TRUE if someone is currently waiting to
  93. join this thread */
  94. };
  95. struct _MDThreadStack {
  96. PRInt8 notused;
  97. };
  98. /*
  99. * Lock and Semaphore related definitions
  100. */
  101. struct _MDLock {
  102. sem_id semaphoreID;
  103. int32 benaphoreCount;
  104. };
  105. struct _MDCVar {
  106. sem_id sem1;
  107. sem_id sem2;
  108. int16 count;
  109. };
  110. struct _MDSemaphore {
  111. sem_id sid;
  112. };
  113. /*
  114. ** CPU-related definitions
  115. */
  116. struct _MDCPU {
  117. int8 unused;
  118. };
  119. /*
  120. ** Process-related definitions
  121. */
  122. struct _MDProcess {
  123. pid_t pid;
  124. };
  125. struct _MDSegment {
  126. PRInt8 notused;
  127. };
  128. /*
  129. ** File- and directory-related definitions
  130. */
  131. #ifndef BONE_VERSION
  132. #define BE_SOCK_SHUTDOWN_READ 0x01
  133. #define BE_SOCK_SHUTDOWN_WRITE 0x02
  134. #endif
  135. struct _MDFileDesc {
  136. PRInt32 osfd;
  137. PRInt32 sock_state;
  138. PRBool accepted_socket;
  139. PRNetAddr peer_addr;
  140. #ifndef BONE_VERSION
  141. PRBool connectValueValid;
  142. int connectReturnValue;
  143. int connectReturnError;
  144. #endif
  145. };
  146. struct _MDDir {
  147. DIR *d;
  148. };
  149. #define PR_DIRECTORY_SEPARATOR '/'
  150. #define PR_DIRECTORY_SEPARATOR_STR "/"
  151. #define PR_PATH_SEPARATOR ':'
  152. #define PR_PATH_SEPARATOR_STR ":"
  153. #define GETTIMEOFDAY(tp) gettimeofday((tp), NULL)
  154. /* --- Memory-mapped files stuff --- not implemented on BeOS */
  155. struct _MDFileMap {
  156. PRInt8 unused;
  157. };
  158. /*
  159. * Network related definitions.
  160. */
  161. #ifndef BONE_VERSION
  162. #define IPPROTO_IP 0
  163. #define AF_UNIX 2
  164. #define TCP_NODELAY SO_NONBLOCK
  165. #define SO_LINGER -1
  166. #define SO_ERROR 4
  167. #endif
  168. #define _PR_INTERRUPT_CHECK_INTERVAL_SECS 5
  169. #ifndef BONE_VERSION
  170. /* these aren't actually used. if they are, we're screwed */
  171. struct protoent {
  172. char *p_name; /* official protocol name */
  173. char **p_aliases; /* alias list */
  174. int p_proto; /* protocol # */
  175. };
  176. struct protoent* getprotobyname(const char* name);
  177. struct protoent* getprotobynumber(int number);
  178. #endif
  179. /*
  180. * malloc() related definitions.
  181. */
  182. #undef _PR_OVERRIDE_MALLOC
  183. /* Miscellaneous */
  184. #define _MD_ERRNO() (errno)
  185. #define _MD_CLEANUP_BEFORE_EXIT _MD_cleanup_before_exit
  186. #define _MD_EXIT _MD_exit
  187. #define _MD_GET_ENV getenv
  188. #define _MD_PUT_ENV putenv
  189. #define _MD_EARLY_INIT _MD_early_init
  190. #define _MD_FINAL_INIT _MD_final_init
  191. /* CPU Stuff */
  192. #define _MD_INIT_CPUS _MD_init_cpus
  193. #define _MD_WAKEUP_CPUS _MD_wakeup_cpus
  194. #define _MD_START_INTERRUPTS _MD_start_interrupts
  195. #define _MD_STOP_INTERRUPTS _MD_stop_interrupts
  196. #define _MD_DISABLE_CLOCK_INTERRUPTS _MD_disable_clock_interrupts
  197. #define _MD_BLOCK_CLOCK_INTERRUPTS _MD_block_clock_interrupts
  198. #define _MD_UNBLOCK_CLOCK_INTERRUPTS _MD_unblock_clock_interrupts
  199. #define _MD_CLOCK_INTERRUPT _MD_clock_interrupt
  200. #define _MD_INIT_STACK _MD_init_stack
  201. #define _MD_CLEAR_STACK _MD_clear_stack
  202. // #define _MD_GET_INTSOFF _MD_get_intsoff
  203. // #define _MD_SET_INTSOFF _MD_set_intsoff
  204. #define _MD_CURRENT_CPU _MD_current_cpu
  205. #define _MD_SET_CURRENT_CPU _MD_set_current_cpu
  206. #define _MD_INIT_RUNNING_CPU _MD_init_running_cpu
  207. #define _MD_PAUSE_CPU _MD_pause_cpu
  208. /* Thread stuff */
  209. #define _MD_CURRENT_THREAD() PR_GetCurrentThread()
  210. // #define _MD_GET_ATTACHED_THREAD _MD_get_attached_thread
  211. #define _MD_LAST_THREAD _MD_last_thread
  212. #define _MD_SET_CURRENT_THREAD _MD_set_current_THREAD
  213. #define _MD_SET_LAST_THREAD _MD_set_last_thread
  214. #define _MD_INIT_THREAD _MD_init_thread
  215. #define _MD_EXIT_THREAD _MD_exit_thread
  216. #define _MD_INIT_ATTACHED_THREAD _MD_init_attached_thread
  217. #define _MD_SUSPEND_THREAD _MD_suspend_thread
  218. #define _MD_RESUME_THREAD _MD_resume_thread
  219. #define _MD_SUSPEND_CPU _MD_suspend_cpu
  220. #define _MD_RESUME_CPU _MD_resume_cpu
  221. #define _MD_BEGIN_SUSPEND_ALL _MD_begin_suspend_all
  222. #define _MD_END_SUSPEND_ALL _MD_end_suspend_all
  223. #define _MD_BEGIN_RESUME_ALL _MD_begin_resume_all
  224. #define _MD_END_RESUME_ALL _MD_end_resume_all
  225. #define _MD_GET_SP _MD_get_sp
  226. #define _MD_CLEAN_THREAD _MD_clean_thread
  227. #define _MD_CREATE_PRIMORDIAL_USER_THREAD _MD_create_primordial_user_thread
  228. #define _MD_CREATE_USER_THREAD _MD_create_user_thread
  229. #define _MD_INIT_PRIMORDIAL_THREAD _MD_init_primordial_thread
  230. #define _MD_CREATE_THREAD _MD_create_thread
  231. #define _MD_YIELD _MD_yield
  232. #define _MD_SET_PRIORITY _MD_set_priority
  233. #define _MD_SUSPENDALL _MD_suspendall
  234. #define _MD_RESUMEALL _MD_resumeall
  235. #define _MD_SWITCH_CONTEXT _MD_switch_context
  236. #define _MD_RESTORE_CONTEXT _MD_restore_context
  237. #define _MD_WAIT _MD_wait
  238. #define _MD_WAKEUP_WAITER _MD_wakeup_waiter
  239. #define _MD_SETTHREADAFFINITYMASK _MD_setthreadaffinitymask
  240. #define _MD_GETTHREADAFFINITYMASK _MD_getthreadaffinitymask
  241. /* Thread Synchronization */
  242. #define _MD_INIT_LOCKS _MD_init_locks
  243. #define _MD_NEW_LOCK _MD_new_lock
  244. #define _MD_FREE_LOCK _MD_free_lock
  245. #define _MD_LOCK _MD_lock
  246. #define _MD_TEST_AND_LOCK _MD_test_and_lock
  247. #define _MD_UNLOCK _MD_unlock
  248. #define _MD_IOQ_LOCK _MD_ioq_lock
  249. #define _MD_IOQ_UNLOCK _MD_ioq_unlock
  250. #define _MD_NEW_SEM _MD_new_sem
  251. #define _MD_DESTROY_SEM _MD_destroy_sem
  252. #define _MD_TIMED_WAIT_SEM _MD_timed_wait_sem
  253. #define _MD_WAIT_SEM _MD_wait_sem
  254. #define _MD_POST_SEM _MD_post_sem
  255. // #define _MD_NEW_CV _MD_new_cv
  256. // #define _MD_FREE_CV _MD_free_cv
  257. // #define _MD_WAIT_CV _MD_wait_cv
  258. // #define _MD_NOTIFY_CV _MD_notify_cv
  259. // #define _MD_NOTIFYALL_CV _MD_notifyall_cv
  260. /* File I/O */
  261. /* don't need any I/O initializations */
  262. #define _MD_INIT_IO()
  263. #define _MD_INIT_FILEDESC(fd)
  264. #define _MD_OPEN_DIR _MD_open_dir
  265. #define _MD_READ_DIR _MD_read_dir
  266. #define _MD_CLOSE_DIR _MD_close_dir
  267. #define _MD_MAKE_NONBLOCK _MD_make_nonblock
  268. #define _MD_SET_FD_INHERITABLE _MD_set_fd_inheritable
  269. #define _MD_INIT_FD_INHERITABLE _MD_init_fd_inheritable
  270. #define _MD_QUERY_FD_INHERITABLE _MD_query_fd_inheritable
  271. #define _MD_OPEN _MD_open
  272. #define _MD_OPEN_FILE _MD_open
  273. #define _MD_CLOSE_FILE _MD_close_file
  274. #define _MD_READ _MD_read
  275. #define _MD_WRITE _MD_write
  276. #define _MD_WRITEV _MD_writev
  277. #define _MD_LSEEK _MD_lseek
  278. #define _MD_LSEEK64 _MD_lseek64
  279. #define _MD_FSYNC _MD_fsync
  280. #define _MD_DELETE _MD_delete
  281. #define _MD_GETFILEINFO _MD_getfileinfo
  282. #define _MD_GETFILEINFO64 _MD_getfileinfo64
  283. #define _MD_GETOPENFILEINFO _MD_getopenfileinfo
  284. #define _MD_GETOPENFILEINFO64 _MD_getopenfileinfo64
  285. #define _MD_RENAME _MD_rename
  286. #define _MD_ACCESS _MD_access
  287. #define _MD_STAT stat
  288. #define _MD_MKDIR _MD_mkdir
  289. #define _MD_MAKE_DIR _MD_mkdir
  290. #define _MD_RMDIR _MD_rmdir
  291. #define _MD_PR_POLL _MD_pr_poll
  292. /* Network I/O */
  293. #define _MD_CLOSE_SOCKET _MD_close_socket
  294. #define _MD_CONNECT _MD_connect
  295. #define _MD_ACCEPT _MD_accept
  296. #define _MD_BIND _MD_bind
  297. #define _MD_LISTEN _MD_listen
  298. #define _MD_SHUTDOWN _MD_shutdown
  299. #define _MD_RECV _MD_recv
  300. #define _MD_SEND _MD_send
  301. #define _MD_ACCEPT_READ _MD_accept_read
  302. #define _MD_GETSOCKNAME _MD_getsockname
  303. #define _MD_GETPEERNAME _MD_getpeername
  304. #define _MD_GETSOCKOPT _MD_getsockopt
  305. #define _MD_SETSOCKOPT _MD_setsockopt
  306. #define _MD_RECVFROM _MD_recvfrom
  307. #define _MD_SENDTO _MD_sendto
  308. #define _MD_SOCKETPAIR _MD_socketpair
  309. #define _MD_SOCKET _MD_socket
  310. #define _MD_SOCKETAVAILABLE _MD_socketavailable
  311. #define _MD_PIPEAVAILABLE _MD_socketavailable
  312. #define _MD_GET_SOCKET_ERROR() (errno)
  313. #define _MD_GETHOSTNAME _MD_gethostname
  314. #define _MD_SELECT select
  315. /* Process management */
  316. #define _MD_CREATE_PROCESS _MD_create_process
  317. #define _MD_DETACH_PROCESS _MD_detach_process
  318. #define _MD_WAIT_PROCESS _MD_wait_process
  319. #define _MD_KILL_PROCESS _MD_kill_process
  320. /* Atomic data operations */
  321. // #define _MD_INIT_ATOMIC _MD_init_atomic
  322. // #define _MD_ATOMIC_INCREMENT _MD_atomic_increment
  323. // #define _MD_ATOMIC_DECREMENT _MD_atomic_decrement
  324. // #define _MD_ATOMIC_SET _MD_atomic_set
  325. /* memory management */
  326. #define _MD_INIT_SEGS _MD_init_segs
  327. #define _MD_ALLOC_SEGMENT _MD_alloc_segment
  328. #define _MD_FREE_SEGMENT _MD_free_segment
  329. /* Memory mapped file I/O */
  330. #define _MD_CREATE_FILE_MAP _MD_create_file_map
  331. #define _MD_GET_MEM_MAP_ALIGNMENT _MD_get_mem_map_alignment
  332. #define _MD_MEM_MAP _MD_mem_map
  333. #define _MD_MEM_UNMAP _MD_mem_unmap
  334. #define _MD_CLOSE_FILE_MAP _MD_close_file_map
  335. /* Time related */
  336. #define _MD_NOW _MD_now
  337. #define _MD_INTERVAL_INIT _MD_interval_init
  338. #define _MD_GET_INTERVAL _MD_get_interval
  339. #define _MD_INTERVAL_PER_SEC _MD_interval_per_sec
  340. /* File locking */
  341. #define _MD_LOCKFILE _MD_lockfile
  342. #define _MD_TLOCKFILE _MD_tlockfile
  343. #define _MD_UNLOCKFILE _MD_unlockfile
  344. /**
  345. * Prototypes for machine dependent function implementations. (Too bad
  346. * NSPR's MD system blows so much that we have to reiterate every stinking
  347. * thing we implement here in our MD header file.)
  348. */
  349. /* Miscellaneous */
  350. NSPR_API(void) _MD_cleanup_before_exit(void);
  351. NSPR_API(void) _MD_exit(PRIntn status);
  352. NSPR_API(char*) _MD_get_env(const char *name);
  353. NSPR_API(PRIntn) _MD_put_env(const char *name);
  354. NSPR_API(void) _MD_early_init(void);
  355. NSPR_API(void) _MD_final_init(void);
  356. /* CPU Stuff */
  357. NSPR_API(void) _MD_init_cpus();
  358. NSPR_API(void) _MD_wakeup_cpus();
  359. NSPR_API(void) _MD_start_interrupts(void);
  360. NSPR_API(void) _MD_stop_interrupts(void);
  361. NSPR_API(void) _MD_disable_clock_interrupts(void);
  362. NSPR_API(void) _MD_block_clock_interrupts(void);
  363. NSPR_API(void) _MD_unblock_clock_interrupts(void);
  364. NSPR_API(void) _MD_clock_interrupt(void);
  365. // NSPR_API(void) _MD_init_stack(PRThreadStack *ts, PRIntn redzone);
  366. // NSPR_API(void) _MD_clear_stack(PRThreadStack* ts);
  367. // NSPR_API(PRInt32) _MD_get_intsoff(void);
  368. // NSPR_API(void) _MD_set_intsoff(PRInt32 _val);
  369. // NSPR_API(_PRCPU*) _MD_current_cpu(void);
  370. // NSPR_API(void) _MD_set_current_cpu(_PRCPU *cpu);
  371. // NSPR_API(void) _MD_init_running_cpu(_PRCPU *cpu);
  372. NSPR_API(PRInt32) _MD_pause_cpu(PRIntervalTime timeout);
  373. /* Thread stuff */
  374. // NSPR_API(PRThread*) _MD_current_thread(void);
  375. NSPR_API(PRThread*) _MD_get_attached_thread(void);
  376. NSPR_API(PRThread*) _MD_last_thread(void);
  377. NSPR_API(void) _MD_set_current_thread(PRThread *thread);
  378. NSPR_API(void) _MD_set_last_thread(PRThread *thread);
  379. NSPR_API(PRStatus) _MD_init_thread(PRThread *thread);
  380. NSPR_API(void) _MD_exit_thread(PRThread *thread);
  381. NSPR_API(PRStatus) _MD_init_attached_thread(PRThread *thread);
  382. NSPR_API(void) _MD_suspend_thread(PRThread *thread);
  383. NSPR_API(void) _MD_resume_thread(PRThread *thread);
  384. // NSPR_API(void) _MD_suspend_cpu(_PRCPU *cpu);
  385. // NSPR_API(void) _MD_resume_cpu(_PRCPU *cpu);
  386. NSPR_API(void) _MD_begin_suspend_all(void);
  387. NSPR_API(void) _MD_end_suspend_all(void);
  388. NSPR_API(void) _MD_begin_resume_all(void);
  389. NSPR_API(void) _MD_end_resume_all(void);
  390. NSPR_API(void *) _MD_get_sp(PRThread *thread);
  391. NSPR_API(void) _MD_clean_thread(PRThread *thread);
  392. NSPR_API(void) _MD_create_primordial_user_thread(PRThread *);
  393. NSPR_API(PRThread*) _MD_create_user_thread(PRUint32 stacksize, void (*start)(void *), void *arg);
  394. NSPR_API(void) _MD_init_primordial_thread(PRThread *thread);
  395. NSPR_API(PRStatus) _MD_create_thread(PRThread *thread, void (*start)(void *), PRThreadPriority priority, PRThreadScope scope, PRThreadState state, PRUint32 stackSize);
  396. NSPR_API(void) _MD_yield(void);
  397. NSPR_API(void) _MD_set_priority(struct _MDThread *md, PRThreadPriority newPri);
  398. NSPR_API(void) _MD_suspendall(void);
  399. NSPR_API(void) _MD_resumeall(void);
  400. NSPR_API(void) _MD_init_context(PRThread *thread, char *top, void (*start) (void), PRBool *status);
  401. NSPR_API(void) _MD_switch_context(PRThread *thread);
  402. NSPR_API(void) _MD_restore_context(PRThread *thread);
  403. NSPR_API(PRStatus) _MD_wait(PRThread *, PRIntervalTime timeout);
  404. NSPR_API(PRStatus) _MD_wakeup_waiter(PRThread *);
  405. NSPR_API(PRInt32) _MD_setthreadaffinitymask(PRThread *thread, PRUint32 mask );
  406. NSPR_API(PRInt32) _MD_getthreadaffinitymask(PRThread *thread, PRUint32 *mask);
  407. /* Thread Synchronization */
  408. NSPR_API(void) _MD_init_locks(void);
  409. NSPR_API(PRStatus) _MD_new_lock(struct _MDLock *md);
  410. NSPR_API(void) _MD_free_lock(struct _MDLock *md);
  411. NSPR_API(void) _MD_lock(struct _MDLock *md);
  412. NSPR_API(PRIntn) _MD_test_and_lock(struct _MDLock *md);
  413. NSPR_API(void) _MD_unlock(struct _MDLock *md);
  414. NSPR_API(void) _MD_ioq_lock(void);
  415. NSPR_API(void) _MD_ioq_unlock(void);
  416. NSPR_API(void) _MD_new_sem(struct _MDSemaphore *md, PRUintn value);
  417. NSPR_API(void) _MD_destroy_sem(struct _MDSemaphore *md);
  418. NSPR_API(PRStatus) _MD_timed_wait_sem(struct _MDSemaphore *md, PRIntervalTime timeout);
  419. NSPR_API(PRStatus) _MD_wait_sem(struct _MDSemaphore *md);
  420. NSPR_API(void) _MD_post_sem(struct _MDSemaphore *md);
  421. // NSPR_API(PRInt32) _MD_new_cv(struct _MDCVar *md);
  422. // NSPR_API(void) _MD_free_cv(struct _MDCVar *md);
  423. // NSPR_API(void) _MD_wait_cv(struct _MDCVar *mdCVar, struct _MDLock *mdLock, PRIntervalTime timeout);
  424. // NSPR_API(void) _MD_notify_cv(struct _MDCVar *md, struct _MDLock *lock);
  425. // NSPR_API(void) _MD_notifyall_cv(struct _MDCVar *md, struct _MDLock *lock);
  426. /* File I/O */
  427. // NSPR_API(void) _MD_init_io(void);
  428. NSPR_API(PRStatus) _MD_open_dir(struct _MDDir *md,const char *name);
  429. NSPR_API(char *) _MD_read_dir(struct _MDDir *md, PRIntn flags);
  430. NSPR_API(PRInt32) _MD_close_dir(struct _MDDir *md);
  431. NSPR_API(void) _MD_make_nonblock(PRFileDesc *fd);
  432. NSPR_API(void) _MD_init_fd_inheritable(PRFileDesc *fd, PRBool imported);
  433. NSPR_API(void) _MD_query_fd_inheritable(PRFileDesc *fd);
  434. NSPR_API(PRInt32) _MD_open(const char *name, PRIntn osflags, PRIntn mode);
  435. NSPR_API(PRInt32) _MD_close_file(PRInt32 osfd);
  436. NSPR_API(PRInt32) _MD_read(PRFileDesc *fd, void *buf, PRInt32 amount);
  437. NSPR_API(PRInt32) _MD_write(PRFileDesc *fd, const void *buf, PRInt32 amount);
  438. NSPR_API(PRInt32) _MD_writev(PRFileDesc *fd, const PRIOVec *iov, PRInt32 iov_size, PRIntervalTime timeout);
  439. NSPR_API(PRInt32) _MD_lseek(PRFileDesc *fd, PRInt32 offset, int whence);
  440. NSPR_API(PRInt64) _MD_lseek64(PRFileDesc *fd, PRInt64 offset, int whence);
  441. NSPR_API(PRInt32) _MD_fsync(PRFileDesc *fd);
  442. NSPR_API(PRInt32) _MD_delete(const char *name);
  443. NSPR_API(PRInt32) _MD_getfileinfo(const char *fn, PRFileInfo *info);
  444. NSPR_API(PRInt32) _MD_getfileinfo64(const char *fn, PRFileInfo64 *info);
  445. NSPR_API(PRInt32) _MD_getopenfileinfo(const PRFileDesc *fd, PRFileInfo *info);
  446. NSPR_API(PRInt32) _MD_getopenfileinfo64(const PRFileDesc *fd, PRFileInfo64 *info);
  447. NSPR_API(PRInt32) _MD_rename(const char *from, const char *to);
  448. NSPR_API(PRInt32) _MD_access(const char *name, PRIntn how);
  449. NSPR_API(PRInt32) _MD_stat(const char *name, struct stat *buf);
  450. NSPR_API(PRInt32) _MD_mkdir(const char *name, PRIntn mode);
  451. NSPR_API(PRInt32) _MD_rmdir(const char *name);
  452. NSPR_API(PRInt32) _MD_pr_poll(PRPollDesc *pds, PRIntn npds, PRIntervalTime timeout);
  453. /* Network I/O */
  454. NSPR_API(PRInt32) _MD_close_socket(PRInt32 osfd);
  455. NSPR_API(PRInt32) _MD_connect(PRFileDesc *fd, const PRNetAddr *addr, PRUint32 addrlen, PRIntervalTime timeout);
  456. NSPR_API(PRInt32) _MD_accept(PRFileDesc *fd, PRNetAddr *addr, PRUint32 *addrlen, PRIntervalTime timeout);
  457. NSPR_API(PRInt32) _MD_bind(PRFileDesc *fd, const PRNetAddr *addr, PRUint32 addrlen);
  458. NSPR_API(PRInt32) _MD_listen(PRFileDesc *fd, PRIntn backlog);
  459. NSPR_API(PRInt32) _MD_shutdown(PRFileDesc *fd, PRIntn how);
  460. NSPR_API(PRInt32) _MD_recv(PRFileDesc *fd, void *buf, PRInt32 amount, PRIntn flags, PRIntervalTime timeout);
  461. NSPR_API(PRInt32) _MD_send(PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags, PRIntervalTime timeout);
  462. NSPR_API(PRInt32) _MD_accept_read(PRFileDesc *sd, PRInt32 *newSock, PRNetAddr **raddr, void *buf, PRInt32 amount, PRIntervalTime timeout);
  463. // NSPR_API(PRInt32) _MD_fast_accept(PRFileDesc *fd, PRNetAddr *addr, PRUint32 *addrlen, PRIntervalTime timeout, PRBool fast, _PR_AcceptTimeoutCallback callback, void *callbackArg);
  464. // NSPR_API(PRInt32) _MD_fast_accept_read(PRFileDesc *sd, PRInt32 *newSock, PRNetAddr **raddr, void *buf, PRInt32 amount, PRIntervalTime timeout, PRBool fast, _PR_AcceptTimeoutCallback callback, void *callbackArg);
  465. // NSPR_API(void) _MD_update_accept_context(PRInt32 s, PRInt32 ls);
  466. NSPR_API(PRStatus) _MD_getsockname(PRFileDesc *fd, PRNetAddr *addr, PRUint32 *addrlen);
  467. NSPR_API(PRStatus) _MD_getpeername(PRFileDesc *fd, PRNetAddr *addr, PRUint32 *addrlen);
  468. NSPR_API(PRStatus) _MD_getsockopt(PRFileDesc *fd, PRInt32 level, PRInt32 optname, char* optval, PRInt32* optlen);
  469. NSPR_API(PRStatus) _MD_setsockopt(PRFileDesc *fd, PRInt32 level, PRInt32 optname, const char* optval, PRInt32 optlen);
  470. NSPR_API(PRInt32) _MD_recvfrom(PRFileDesc *fd, void *buf, PRInt32 amount, PRIntn flags, PRNetAddr *addr, PRUint32 *addrlen, PRIntervalTime timeout);
  471. NSPR_API(PRInt32) _MD_sendto(PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags, const PRNetAddr *addr, PRUint32 addrlen, PRIntervalTime timeout);
  472. NSPR_API(PRInt32) _MD_socketpair(int af, int type, int flags, PRInt32 *osfd);
  473. NSPR_API(PRInt32) _MD_socket(int af, int type, int flags);
  474. NSPR_API(PRInt32) _MD_socketavailable(PRFileDesc *fd);
  475. // NSPR_API(PRInt32) _MD_get_socket_error(void);
  476. NSPR_API(PRStatus) _MD_gethostname(char *name, PRUint32 namelen);
  477. /* Process management */
  478. NSPR_API(PRProcess *) _MD_create_process(const char *path, char *const *argv, char *const *envp, const PRProcessAttr *attr);
  479. NSPR_API(PRStatus) _MD_detach_process(PRProcess *process);
  480. NSPR_API(PRStatus) _MD_wait_process(PRProcess *process, PRInt32 *exitCode);
  481. NSPR_API(PRStatus) _MD_kill_process(PRProcess *process);
  482. /* Atomic data operations */
  483. // NSPR_API(void) _MD_init_atomic(void);
  484. // NSPR_API(PRInt32) _MD_atomic_increment(PRInt32 *);
  485. // NSPR_API(PRInt32) _MD_atomic_decrement(PRInt32 *);
  486. // NSPR_API(PRInt32) _MD_atomic_set(PRInt32 *, PRInt32);
  487. /* Memory management */
  488. NSPR_API(void) _MD_init_segs(void);
  489. NSPR_API(PRStatus) _MD_alloc_segment(PRSegment *seg, PRUint32 size, void *vaddr);
  490. NSPR_API(void) _MD_free_segment(PRSegment *seg);
  491. /* Memory mapped file I/O */
  492. NSPR_API(PRStatus) _MD_create_file_map(PRFileMap *fmap, PRInt64 size);
  493. NSPR_API(PRInt32) _MD_get_mem_map_alignment(void);
  494. NSPR_API(void *) _MD_mem_map(PRFileMap *fmap, PRInt64 offset, PRUint32 len);
  495. NSPR_API(PRStatus) _MD_mem_unmap(void *addr, PRUint32 size);
  496. NSPR_API(PRStatus) _MD_close_file_map(PRFileMap *fmap);
  497. /* Time related */
  498. NSPR_API(PRTime) _MD_now(void);
  499. NSPR_API(void) _MD_interval_init(void);
  500. NSPR_API(PRIntervalTime) _MD_get_interval(void);
  501. NSPR_API(PRIntervalTime) _MD_interval_per_sec(void);
  502. /* File locking */
  503. NSPR_API(PRStatus) _MD_lockfile(PRInt32 osfd);
  504. NSPR_API(PRStatus) _MD_tlockfile(PRInt32 osfd);
  505. NSPR_API(PRStatus) _MD_unlockfile(PRInt32 osfd);
  506. #endif /* _nspr_beos_defs_h___*/