-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathos_dummy.c
103 lines (84 loc) · 2.31 KB
/
os_dummy.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
// os_dummy: for non-multithreaded systems only
// Lots of stubs.
//
// Copyright (c) 2019, Adrian "vifino" Pistol <vifino@tty.sh>
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "../types.h"
#include "../oscore.h"
#include "../main.h"
#include "../timers.h"
#include <sys/time.h>
#include <unistd.h>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
// Main entry point.
int main(int argc, char** argv) {
return sled_main(argc, argv);
}
// -- event
oscore_event oscore_event_new(void) {
return NULL;
}
int oscore_event_wait_until(oscore_event ev, oscore_time desired_usec) {
oscore_time tnow = udate();
if (tnow >= desired_usec)
return tnow;
oscore_time sleeptime = desired_usec - tnow;
usleep(sleeptime);
return 0;
}
void oscore_event_signal(oscore_event ev) {
}
void oscore_event_free(oscore_event ev) {
}
// Time keeping.
// Note, this should be replaced.
oscore_time oscore_udate(void) {
struct timeval tv;
if (gettimeofday(&tv, NULL) == -1) {
printf("Failed to get the time???\n");
exit(1);
}
return T_SECOND * tv.tv_sec + tv.tv_usec;
}
// Threading
oscore_task oscore_thread_create(const char* name, oscore_task_function func, void* ctx) {
// uuh
return NULL;
}
void oscore_task_yield(void) {
// nothing.
};
void oscore_task_exit(void * status) {
// nope
};
void * oscore_task_join(oscore_task task) {
// ye ok
return 0;
};
int oscore_ncpus(void) {
return 1;
}
void oscore_task_pin(oscore_task task, int cpu) {}
// -- mutex
oscore_mutex oscore_mutex_new(void) {
return NULL;
}
void oscore_mutex_lock(oscore_mutex m) {
}
void oscore_mutex_unlock(oscore_mutex m) {
}
void oscore_mutex_free(oscore_mutex m) {
}