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