-
Notifications
You must be signed in to change notification settings - Fork 5
/
stub.c
113 lines (81 loc) · 1.62 KB
/
stub.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*
This file contains some stub routines to cover up the differences
between the BeOS and the rest of the world.
THIS CODE COPYRIGHT DOMINIC GIAMPAOLO. NO WARRANTY IS EXPRESSED
OR IMPLIED. YOU MAY USE THIS CODE AND FREELY DISTRIBUTE IT FOR
NON-COMMERCIAL USE AS LONG AS THIS NOTICE REMAINS ATTACHED.
FOR COMMERCIAL USE, CONTACT DOMINIC GIAMPAOLO ([email protected]).
Dominic Giampaolo
*/
#include <stdio.h>
#include <stdlib.h>
#include "myfs.h"
void
unload_kernel_addon(aid)
{
}
sem_id
create_sem(long count, const char *name)
{
int *ptr;
ptr = (int *)malloc(sizeof(int) + strlen(name) + 1); /* a hack */
*ptr = count;
memcpy(ptr+1, name, strlen(name));
return (sem_id)ptr;
}
long
delete_sem(sem_id semid)
{
int *ptr = (int *)semid;
free(ptr);
return 0;
}
long
acquire_sem(sem_id sem)
{
int *ptr = (int *)sem;
if (*ptr <= 0) {
myfs_die("You lose sucka! acquire of sem with count == %d\n", *ptr);
}
*ptr -= 1;
return 0;
}
long
acquire_sem_etc(sem_id sem, int count, int j1, bigtime_t j2)
{
int *ptr = (int *)sem;
if (*ptr <= 0) {
myfs_die("You lose sucka! acquire_sem_etc of sem with count == %d\n",
*ptr);
}
*ptr -= count;
return 0;
}
long
release_sem(sem_id sem)
{
int *ptr = (int *)sem;
*ptr += 1;
return 0;
}
long
release_sem_etc(sem_id sem, long count, long j1)
{
int *ptr = (int *)sem;
*ptr += count;
return 0;
}
long
atomic_add(long *ptr, long val)
{
int old = *ptr;
*ptr += val;
return old;
}
int
snooze(bigtime_t f)
{
sleep(1);
return 1;
}