00001
00002 #ifndef _EDT_OS_LNX_H_
00003 #define _EDT_OS_LNX_H_
00004
00005
00006
00007 typedef int HANDLE;
00008
00009 #define DIRHANDLE caddr_t
00010 #define NULL_HANDLE ((HANDLE)-1)
00011
00012 typedef unsigned int uint_t;
00013 typedef unsigned char uchar_t;
00014 typedef unsigned short ushort_t;
00015
00016 #ifndef __KERNEL__
00017
00018 #ifndef _GNU_SOURCE
00019
00020 #define _GNU_SOURCE
00021
00022 #endif
00023
00024 #include <sys/types.h>
00025 #include <sys/stat.h>
00026
00027 #include <stdlib.h>
00028 #include <stdio.h>
00029 #include <fcntl.h>
00030 #include <signal.h>
00031 #include <string.h>
00032 #include <stdint.h>
00033 #include <unistd.h>
00034 #include <sys/time.h>
00035 #include <errno.h>
00036
00037 #include <linux/ioctl.h>
00038
00039 #include <pthread.h>
00040
00041 #include <semaphore.h>
00042
00043 typedef pthread_t thread_t;
00044
00045 #include <stdlib.h>
00046
00047 #include <pthread.h>
00048 #include <sys/user.h>
00049
00050 #include <limits.h>
00051
00052 #define WINAPI
00053
00054 #define ASSERT(f) ((void)0)
00055
00056
00057
00058 #ifndef TRUE
00059
00060 #define TRUE (1)
00061 #define FALSE (0)
00062
00063 #endif
00064
00065 typedef int BOOL;
00066 typedef unsigned char BYTE;
00067 typedef unsigned int UINT;
00068 typedef unsigned long ULONG;
00069
00070 typedef off_t EdtFileOffset;
00071
00072
00073 #define INFINITE 0
00074
00075 #define PAGESIZE PAGE_SIZE
00076 #define SECTOR_SIZE PAGE_SIZE
00077
00078 #define _MAX_PATH _POSIX_PATH_MAX
00079 #define MAX_PATH _POSIX_PATH_MAX
00080
00081 #define THREAD_RETURN void *
00082 #define THREAD_FUNC_MODIFIER
00083 #define THREAD_FUNC_DECLARE THREAD_RETURN
00084 typedef void * (*edt_thread_function)(void *);
00085
00086 #define LaunchThread(pThread,func,pointer) \
00087 pthread_create(&pThread,NULL,func,pointer);
00088
00089 #define WaitForThread(pThread,timeout) \
00090 { int return; pthread_join(pThread, &return;}
00091
00092 #define CRITICAL_SECTION pthread_mutex_t
00093
00094 typedef pthread_mutex_t mutex_t;
00095
00096
00097 #define EnterCriticalSection(lock) pthread_mutex_lock(lock)
00098 #define LeaveCriticalSection(lock) pthread_mutex_unlock(lock)
00099 #define DeleteCriticalSection(lock) pthread_mutex_destroy(lock)
00100 #define InitializeCriticalSection(lock) pthread_mutex_init(lock, NULL)
00101
00102
00103 #define create_mutex_named(nm) pthread_mutex_init(&m, NULL)
00104 #define create_mutex(m) pthread_mutex_init(&m, NULL)
00105 #define delete_mutex(m) pthread_mutex_destroy(&m)
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 typedef thread_t thread_type;
00123
00124 #ifdef _DEBUG
00125
00126 #define TRACE printf
00127
00128 #else
00129
00130 #define TRACE
00131
00132 #endif
00133
00134 int
00135 edt_wait_event_timeout(sem_t *p, int timeout);
00136
00137 #else
00138
00139 typedef HANDLE thread_t;
00140
00141 #endif
00142
00143
00144 #endif
00145