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#include <sys/cdefs.h>
23__BEGIN_DECLS
24
25/** \cond */
26
27typedef struct {
28 void* owner;
29 int nest;
30 volatile int lock;
31} __newlib_recursive_lock_t;
32
33#define __NEWLIB_RECURSIVE_LOCK_INIT { (void *)0, 0, 0 }
34
35typedef volatile int __newlib_lock_t;
36#define __NEWLIB_LOCK_INIT 0
37
38typedef unsigned long int _COND_T;
39typedef __newlib_lock_t _LOCK_T;
40typedef __newlib_recursive_lock_t _LOCK_RECURSIVE_T;
41
42#define __LOCK_INIT(class,lock) class _LOCK_T lock = __NEWLIB_LOCK_INIT;
43#define __LOCK_INIT_RECURSIVE(class,lock) class _LOCK_RECURSIVE_T lock = __NEWLIB_RECURSIVE_LOCK_INIT;
44#define __lock_init(lock) __newlib_lock_init(&(lock))
45#define __lock_init_recursive(lock) __newlib_lock_init_recursive(&(lock))
46#define __lock_close(lock) __newlib_lock_close(&(lock))
47#define __lock_close_recursive(lock) __newlib_lock_close_recursive(&(lock))
48#define __lock_acquire(lock) __newlib_lock_acquire(&(lock))
49#define __lock_acquire_recursive(lock) __newlib_lock_acquire_recursive(&(lock))
50#define __lock_try_acquire(lock) __newlib_lock_try_acquire(&(lock))
51#define __lock_try_acquire_recursive(lock) __newlib_lock_try_acquire_recursive(&(lock))
52#define __lock_release(lock) __newlib_lock_release(&(lock))
53#define __lock_release_recursive(lock) __newlib_lock_release_recursive(&(lock))
54
55void __newlib_lock_init(__newlib_lock_t*);
56void __newlib_lock_close(__newlib_lock_t*);
57void __newlib_lock_acquire(__newlib_lock_t*);
58int __newlib_lock_try_acquire(__newlib_lock_t*);
59void __newlib_lock_release(__newlib_lock_t*);
60
61void __newlib_lock_init_recursive(__newlib_recursive_lock_t*);
62void __newlib_lock_close_recursive(__newlib_recursive_lock_t*);
63void __newlib_lock_acquire_recursive(__newlib_recursive_lock_t*);
64int __newlib_lock_try_acquire_recursive(__newlib_recursive_lock_t*);
65void __newlib_lock_release_recursive(__newlib_recursive_lock_t*);
66
67/** \endcond */
68
69__END_DECLS
70
71#endif /* __SYS_LOCK_H__ */