Subversion Repositories shark

Rev

Rev 3 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 pj 1
 
2
#ifndef __GLUE_H
3
#define __GLUE_H
4
 
5
#include <fs/glue.h>
6
 
7
#include <fs/const.h>
8
#include <fs/util.h>
9
#include <fs/assert.h>
10
#include <fs/maccess.h>
11
#include <fs/irq.h>
12
 
13
#include <kernel/model.h>
14
#include <kernel/func.h>
15
#include <kernel/assert.h>
16
#include <kernel/int_sem.h>
17
 
18
/*
19
 * mutex
20
 */
21
 
22
#include <kernel/int_sem.h>
80 pj 23
#include "ll/sys/cdefs.h"
2 pj 24
 
80 pj 25
__BEGIN_DECLS
26
 
2 pj 27
/*+ a semaphore object +*/
28
typedef internal_sem_t __b_mutex_t;
29
 
30
/*
31
  The following macros can be used to synchronize events; all
32
  require a pointer to a semaphore object and return nothing;
33
  a semaphore can have "val" resource free.
34
 */
35
 
36
/*+ Initialize a semaphore (to integer val) +*/
37
#define __b_mutex_init(ptr)     internal_sem_init((ptr),1)
38
 
39
/*+ Wait for a semaphore +*/
40
#define __b_mutex_lock(ptr)     (internal_sem_wait(ptr))
41
 
42
/*+ Try to wait for a semaphore (return 0 on success) +*/
43
#define __b_mutex_trylock(ptr)  (internal_sem_wait(ptr))
44
 
45
/*+ Signal a semaphore +*/
46
#define __b_mutex_unlock(ptr)   (internal_sem_post(ptr))
47
 
48
#if 0
49
 
50
/*+ a mutex object +*/
51
typedef mutex_t  __b_mutex_t;
52
 
53
/*
54
  The following macros require a pointer to a mutex object and
55
  return nothing.
56
*/
57
 
58
extern void *bmutexattr;
59
 
60
/* Initialize a mutex object */
61
#define __b_mutex_init(ptr)    assertk(mutex_init(ptr,bmutexattr)==0)
62
 
63
/*+ Lock a mutex object +*/
64
#define __b_mutex_lock(ptr)    assertk(mutex_lock((ptr))==0)
65
 
66
/*+ Try to lock a mutex (return 0 on success locking) +*/
67
#define __b_mutex_trylock(ptr) mutex_trylock((ptr))
68
 
69
/*+ Unlock a mutex +*/
70
#define __b_mutex_unlock(ptr)  assertk(mutex_unlock(ptr)==0)
71
 
72
#endif
73
 
74
/*
75
 * fast mutex
76
 */
77
 
78
typedef SYS_FLAGS  __b_fastmutex_t;
79
 
80
/*+ Mutex initialization +*/
81
#define __b_fastmutex_init(ptr) 
82
 
83
/*+ Lock a mutex object +*/
84
#define __b_fastmutex_lock(ptr)    *(ptr)=kern_fsave()
85
 
86
/*+ Unlock a mutex +*/
87
#define __b_fastmutex_unlock(ptr)  kern_frestore(*(ptr))
88
 
89
/*
90
 *semaphores
91
 */
92
 
93
/*+ a semaphore object +*/
94
typedef internal_sem_t __b_sem_t;
95
 
96
/*
97
  The following macros can be used to synchronize events; all
98
  require a pointer to a semaphore object and return nothing;
99
  a semaphore can have "val" resource free.
100
 */
101
 
102
/*+ Initialize a semaphore (to integer val) +*/
103
#define __b_sem_init(ptr,val) internal_sem_init((ptr),(val))
104
 
105
/*+ Wait for a semaphore +*/
106
#define __b_sem_wait(ptr)     internal_sem_wait(ptr)
107
 
108
/*+ Try to wait for a semaphore (return 0 on success) +*/
109
#define __b_sem_trywait(ptr)  internal_sem_trywait(ptr)
110
 
111
/*+ Signal a semaphore +*/
112
#define __b_sem_signal(ptr)   internal_sem_post(ptr)
113
 
114
/*
115
 *
116
 */
117
 
118
#define panic(x) sys_panic(x)
119
 
120
/* timer functions */
121
 
122
#include <ll/time.h>
123
 
124
/* all in usec */
125
 
126
#define __gettimer() sys_gettime(NULL)
127
 
128
/* I need an active delay! */
129
#define __delayk(delta) {       \
130
  TIME t=__gettimer()+delta;    \
131
  while (__gettimer()<t);       \
132
}
133
 
80 pj 134
__END_DECLS
2 pj 135
#endif