1/* 2 This file contains some stub routines to cover up the differences 3 between the BeOS and the rest of the world. 4 5 6 THIS CODE COPYRIGHT DOMINIC GIAMPAOLO. NO WARRANTY IS EXPRESSED 7 OR IMPLIED. YOU MAY USE THIS CODE AND FREELY DISTRIBUTE IT FOR 8 NON-COMMERCIAL USE AS LONG AS THIS NOTICE REMAINS ATTACHED. 9 10 FOR COMMERCIAL USE, CONTACT DOMINIC GIAMPAOLO (dbg@be.com). 11 12 Dominic Giampaolo 13 dbg@be.com 14*/ 15#include "compat.h" 16 17#include <errno.h> 18#include <stdio.h> 19#include <stdlib.h> 20 21#include <fs_attr.h> 22#include <KernelExport.h> 23#include <OS.h> 24 25#include "myfs.h" 26 27 28#if (!defined(__BEOS__) && !defined(__HAIKU__)) 29 30static void 31myfs_die(const char *format,...) 32{ 33 va_list list; 34 va_start(list, format); 35 vfprintf(stderr, format, list); 36 va_end(list); 37 38 exit(1); 39} 40 41 42//void 43//unload_kernel_addon(aid) 44//{ 45//} 46 47sem_id 48create_sem(long count, const char *name) 49{ 50 int *ptr; 51 ptr = (int *)malloc(sizeof(int) + strlen(name) + 1); /* a hack */ 52 *ptr = count; 53 memcpy(ptr+1, name, strlen(name)); 54 55 return (sem_id)ptr; 56} 57 58 59long 60delete_sem(sem_id semid) 61{ 62 int *ptr = (int *)semid; 63 64 free(ptr); 65 return 0; 66} 67 68long 69acquire_sem(sem_id sem) 70{ 71 int *ptr = (int *)sem; 72 73 if (*ptr <= 0) { 74 myfs_die("You lose sucka! acquire of sem with count == %d\n", *ptr); 75 } 76 77 *ptr -= 1; 78 79 return 0; 80} 81 82 83long 84acquire_sem_etc(sem_id sem, int32 count, uint32 j1, bigtime_t j2) 85{ 86 int *ptr = (int *)sem; 87 88 if (*ptr <= 0) { 89 myfs_die("You lose sucka! acquire_sem_etc of sem with count == %d\n", 90 *ptr); 91 } 92 93 *ptr -= count; 94 95 return 0; 96} 97 98long 99release_sem(sem_id sem) 100{ 101 int *ptr = (int *)sem; 102 103 *ptr += 1; 104 105 return 0; 106} 107 108long 109release_sem_etc(sem_id sem, long count, uint32 j1) 110{ 111 int *ptr = (int *)sem; 112 113 *ptr += count; 114 115 return 0; 116} 117 118 119long 120atomic_add(vint32 *ptr, long val) 121{ 122 int old = *ptr; 123 124 *ptr += val; 125 126 return old; 127} 128 129status_t 130snooze(bigtime_t f) 131{ 132 sleep(1); 133 return 1; 134} 135 136 137// #pragma mark - 138 139void 140debugger(const char *message) 141{ 142 myfs_die("debugger() call: `%s'\n", message); 143} 144 145 146// #pragma mark - 147 148thread_id 149find_thread(const char *name) 150{ 151 if (!name) 152 return 42; 153 154 return FS_EINVAL; 155} 156 157 158thread_id 159spawn_thread(thread_func func, const char *name, int32 priority, void *data) 160{ 161 fprintf(stderr, "spawn_thread() not supported on this platform.\n"); 162 return FS_EINVAL; 163} 164 165 166status_t 167resume_thread(thread_id thread) 168{ 169 fprintf(stderr, "resume_thread() not supported on this platform.\n"); 170 return FS_EINVAL; 171} 172 173 174status_t 175wait_for_thread(thread_id thread, status_t *returnValue) 176{ 177 fprintf(stderr, "wait_for_thread() not supported on this platform.\n"); 178 return FS_EINVAL; 179} 180 181 182// #pragma mark - 183 184port_id 185create_port(int32 capacity, const char *name) 186{ 187 fprintf(stderr, "create_port() not supported on this platform.\n"); 188 return FS_EINVAL; 189} 190 191 192ssize_t 193read_port(port_id port, int32 *code, void *buffer, size_t bufferSize) 194{ 195 fprintf(stderr, "read_port() not supported on this platform.\n"); 196 return FS_EINVAL; 197} 198 199 200status_t 201write_port(port_id port, int32 code, const void *buffer, size_t bufferSize) 202{ 203 fprintf(stderr, "write_port() not supported on this platform.\n"); 204 return FS_EINVAL; 205} 206 207 208status_t 209delete_port(port_id port) 210{ 211 fprintf(stderr, "delete_port() not supported on this platform.\n"); 212 return FS_EINVAL; 213} 214 215#endif /* ! __BEOS__ */ 216