KallistiOS git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches
lock.h
Go to the documentation of this file.
1/* KallistiOS ##version##
2
3 lock_common.h
4 Copyright (C) 2004 Megan Potter
5
6 This file is patched into the dc-chain newlib's <sys/lock.h>, by newlib.mk
7 in \utils\dc-chain\scripts.
8*/
9
10/** \file
11 \brief KOS-specific patching for newlib's <sys/lock.h>
12
13 This file contains an implementation of the KOS threading back-end
14 that will be patched into newlib by the toolchain make scripts.
15
16 \author Megan Potter
17*/
18
19#ifndef __SYS_LOCK_H__
20#define __SYS_LOCK_H__
21
22/** \cond */
23
24typedef struct {
25 void* owner;
26 int nest;
27 volatile int lock;
28} __newlib_recursive_lock_t;
29
30#define __NEWLIB_RECURSIVE_LOCK_INIT { (void *)0, 0, 0 }
31
32typedef volatile int __newlib_lock_t;
33#define __NEWLIB_LOCK_INIT 0
34
35typedef unsigned long int _COND_T;
36typedef __newlib_lock_t _LOCK_T;
37typedef __newlib_recursive_lock_t _LOCK_RECURSIVE_T;
38
39#define __LOCK_INIT(class,lock) class _LOCK_T lock = __NEWLIB_LOCK_INIT;
40#define __LOCK_INIT_RECURSIVE(class,lock) class _LOCK_RECURSIVE_T lock = __NEWLIB_RECURSIVE_LOCK_INIT;
41#define __lock_init(lock) __newlib_lock_init(&(lock))
42#define __lock_init_recursive(lock) __newlib_lock_init_recursive(&(lock))
43#define __lock_close(lock) __newlib_lock_close(&(lock))
44#define __lock_close_recursive(lock) __newlib_lock_close_recursive(&(lock))
45#define __lock_acquire(lock) __newlib_lock_acquire(&(lock))
46#define __lock_acquire_recursive(lock) __newlib_lock_acquire_recursive(&(lock))
47#define __lock_try_acquire(lock) __newlib_lock_try_acquire(&(lock))
48#define __lock_try_acquire_recursive(lock) __newlib_lock_try_acquire_recursive(&(lock))
49#define __lock_release(lock) __newlib_lock_release(&(lock))
50#define __lock_release_recursive(lock) __newlib_lock_release_recursive(&(lock))
51
52void __newlib_lock_init(__newlib_lock_t*);
53void __newlib_lock_close(__newlib_lock_t*);
54void __newlib_lock_acquire(__newlib_lock_t*);
55void __newlib_lock_try_acquire(__newlib_lock_t*);
56void __newlib_lock_release(__newlib_lock_t*);
57
58void __newlib_lock_init_recursive(__newlib_recursive_lock_t*);
59void __newlib_lock_close_recursive(__newlib_recursive_lock_t*);
60void __newlib_lock_acquire_recursive(__newlib_recursive_lock_t*);
61void __newlib_lock_try_acquire_recursive(__newlib_recursive_lock_t*);
62void __newlib_lock_release_recursive(__newlib_recursive_lock_t*);
63
64/** \endcond */
65
66#endif // __NEWLIB_LOCK_COMMON_H
67