1/* 2 Driver for USB Ethernet Control Model devices 3 Copyright (C) 2008 Michael Lotz <mmlr@mlotz.ch> 4 Distributed under the terms of the MIT license. 5*/ 6#ifndef HAIKU_TARGET_PLATFORM_HAIKU 7#ifndef _BEOS_COMPATIBILITY_H_ 8#define _BEOS_COMPATIBILITY_H_ 9 10#include <OS.h> 11 12#define USB_ENDPOINT_ATTR_CONTROL 0x00 13#define USB_ENDPOINT_ATTR_ISOCHRONOUS 0x01 14#define USB_ENDPOINT_ATTR_BULK 0x02 15#define USB_ENDPOINT_ATTR_INTERRUPT 0x03 16#define USB_ENDPOINT_ATTR_MASK 0x03 17 18#define USB_ENDPOINT_ADDR_DIR_IN 0x80 19#define USB_ENDPOINT_ADDR_DIR_OUT 0x00 20 21typedef struct mutex { 22 sem_id sem; 23 int32 count; 24} mutex; 25 26 27static inline void 28mutex_init(mutex *lock, const char *name) 29{ 30 lock->sem = create_sem(0, name); 31 lock->count = 0; 32} 33 34 35static inline void 36mutex_destroy(mutex *lock) 37{ 38 delete_sem(lock->sem); 39} 40 41 42static inline status_t 43mutex_lock(mutex *lock) 44{ 45 if (atomic_add(&lock->count, -1) < 0) 46 return acquire_sem(lock->sem); 47 return B_OK; 48} 49 50 51static inline void 52mutex_unlock(mutex *lock) 53{ 54 if (atomic_add(&lock->count, 1) < -1) 55 release_sem(lock->sem); 56} 57 58#endif /* !HAIKU_TARGET_PLATFORM_HAIKU */ 59#endif /* _BEOS_COMPATIBILITY_H_ */ 60