nsprpub/pr/include/md/_beos.h

Fri, 16 Jan 2015 04:50:19 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 04:50:19 +0100
branch
TOR_BUG_9701
changeset 13
44a2da4a2ab2
permissions
-rw-r--r--

Replace accessor implementation with direct member state manipulation, by
request https://trac.torproject.org/projects/tor/ticket/9701#comment:32

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

mercurial