edt_os_mac.h

00001 
00002 #ifndef _EDT_OS_MAC_H_
00003 #define _EDT_OS_MAC_H_
00004 
00005 
00006 #define HANDLE int
00007 #define DIRHANDLE caddr_t
00008 
00009 
00010 typedef unsigned int uint_t;
00011 typedef unsigned char uchar_t;
00012 typedef unsigned short ushort_t;
00013 
00014 #ifndef KERNEL
00015 
00016 #include <sys/types.h>
00017 
00018 #include <stdlib.h>
00019 #include <stdio.h>
00020 #include <fcntl.h>
00021 #include <signal.h>
00022 #include <string.h>
00023 #include <stdint.h>
00024 #include <unistd.h>
00025 #include <sys/time.h>
00026 #include <errno.h>
00027 
00028 #include <sys/ioctl.h>
00029 
00030 #include <pthread.h>
00031 
00032 #include <semaphore.h>
00033 
00034 #ifdef __APPLE__ 
00035 typedef pthread_t mac_thread_t;
00036 #else
00037 typedef pthread_t thread_t;
00038 #endif
00039 
00040 #include <stdlib.h>
00041 
00042 #include <pthread.h>
00043 #include <sys/user.h>
00044 
00045 #include <limits.h>
00046 
00047 #define WINAPI
00048 
00049 #define ASSERT(f) ((void)0)
00050 
00051 /* utility helpers */
00052 
00053 #ifndef TRUE
00054 
00055 #define TRUE (1)
00056 #define FALSE (0)
00057 
00058 #endif
00059 
00060 #ifndef __cplusplus
00061 
00062 
00063 /*#typedef unsigned char bool; */ /* do we need this? cuz it could be a problem */
00064 
00065 #endif
00066 
00067 typedef int BOOL;
00068 typedef unsigned char BYTE;
00069 typedef unsigned int UINT;
00070 typedef unsigned long ULONG;
00071 
00072 typedef off_t EdtFileOffset;
00073 
00074 
00075 #define INFINITE 0
00076 
00077 #define SECTOR_SIZE PAGE_SIZE
00078 
00079 #define _MAX_PATH _POSIX_PATH_MAX
00080 #define MAX_PATH _POSIX_PATH_MAX
00081 
00082 #define THREAD_RETURN void *
00083 #define THREAD_FUNC_MODIFIER
00084 #define THREAD_FUNC_DECLARE THREAD_RETURN
00085 typedef void * (*edt_thread_function)(void *);
00086 
00087 #define LaunchThread(pThread,func,pointer) \
00088                pthread_create(&pThread,NULL,func,pointer);
00089 
00090 #define WaitForThread(pThread,timeout) \
00091 { int return; pthread_join(pThread, &return;}
00092 
00093 #define CRITICAL_SECTION pthread_mutex_t
00094 
00095 typedef pthread_mutex_t mutex_t;
00096 
00097 
00098 #define EnterCriticalSection(lock) pthread_mutex_lock(lock)
00099 #define LeaveCriticalSection(lock) pthread_mutex_unlock(lock)
00100 #define DeleteCriticalSection(lock) pthread_mutex_destroy(lock)
00101 #define InitializeCriticalSection(lock) pthread_mutex_init(lock, NULL)
00102 
00103 
00104 #define create_mutex_named(nm)  pthread_mutex_init(&m, NULL)
00105 #define create_mutex(m)    pthread_mutex_init(&m, NULL)
00106 
00107 #define wait_mutex_timeout(m,timeout) WaitForSingleObject(m,timeout)
00108 #define wait_mutex(m) pthread_mutex_lock(m)
00109 #define release_mutex(m)    pthread_mutex_unlock(m)
00110 
00111 
00112 typedef sem_t event_t;
00113 
00114 #define create_event(evt, manual, init_state) \
00115     sem_init(&evt,0,init_state)
00116 
00117 #define wait_on_event_timeout(m,timeout) edt_wait_event_timeout(&m,timeout)
00118 #define wait_on_event(m) sem_wait(&m )
00119 
00120 #define signal_event(e) sem_post(&e)
00121 
00122 
00123 typedef mac_thread_t thread_type;
00124 
00125 #ifdef _DEBUG
00126 
00127 #define TRACE printf
00128 
00129 #else
00130 
00131 #define TRACE
00132 
00133 #endif
00134 
00135 int
00136 edt_wait_event_timeout(sem_t *p, int timeout);
00137 
00138 #endif
00139 
00140 #define NULL_HANDLE ((HANDLE)-1)
00141 #endif
00142 

Generated on 19 Jun 2015 by  doxygen 1.4.7