NetSim Source Code Help
v14.4
All 13 Components
Loading...
Searching...
No Matches
Linux.h
1
/************************************************************************************
2
* Copyright (C) 2015 *
3
* TETCOS, Bangalore. India *
4
* *
5
* Tetcos owns the intellectual property rights in the Product and its content. *
6
* The copying, redistribution, reselling or publication of any or all of the *
7
* Product or its content without express prior written consent of Tetcos is *
8
* prohibited. Ownership and / or any other right relating to the software and all *
9
* intellectual property rights therein shall remain at all times with Tetcos. *
10
* *
11
* Author: Shashi kant suman *
12
* *
13
* ---------------------------------------------------------------------------------*/
14
15
#ifndef LINUX_HEADER
16
#define LINUX_HEADER
17
18
#include <string.h>
19
#include <errno.h>
20
#include <math.h>
21
#include <ctype.h>
22
#include <dlfcn.h>
23
#include <pthread.h>
24
#include <time.h>
25
#include <malloc.h>
// _msize
26
#include <unistd.h>
//for close()
27
#include <sys/time.h>
//gettimeofday
28
#include <sys/types.h>
29
30
#define INT8 int8_t
31
#define UINT8 uint8_t
32
#define INT16 int16_t
33
#define UINT16 uint16_t
34
#define INT32 int32_t
35
#define UINT32 uint32_t
36
#define INT64 int64_t
37
#define UINT64 uint64_t
38
#define UINT unsigned int
39
40
#define _declspec(dllexport) extern
41
#define _declspec(dllimport) extern
42
#define GetLastError() errno
43
//#define _putenv putenv
44
#define _getch();
45
#define getch();
46
#define PVOID void*
47
# define HINSTANCE void*
48
# define LoadLibraryA(x) dlopen(x,RTLD_NOW)
49
# define LoadLibrary(x) dlopen(x,RTLD_NOW)
50
# define GetProcAddress(x,y) dlsym(x,y)
51
# define FreeLibrary dlclose
52
# define MessageBoxA(a,b,c,d) printf("%s\t%s\n",b,c);
53
# define MessageBox(a,b,c,d) printf("%s\t%s\n",b,c);
54
# define fnDlError(x){printf("Error: %s\n",dlerror());}
55
# define fnSystemError(x,...){printf("Error No:%d in %s line no %d: %s\n",errno,__FILE__,__LINE__,x);}
56
# define fnNetSimError(x,...){printf("In %s line no %d: %s",__FILE__,__LINE__,x);}
57
# define GetCurrentThreadId() pthread_self()
58
# define WriteFile(file,str,size,a,b) write(file,str,size)
59
#define BOOLEAN BOOL
60
61
typedef
enum
62
{
63
FALSE=0,
64
TRUE=1,
65
}BOOL;
66
67
68
typedef
struct
_LARGE_INTEGER
{
69
long
long
QuadPart;
70
} LARGE_INTEGER;
71
static
const
char
pathSeperator[5] =
"/"
;
72
// static const char libext[10] = ".so";
73
#define HANDLE void *
74
#define HMODULE void*
75
#define pthread_mutex_destroy(a) ReleaseMutex(a)
76
#define FALSE 0
77
#define TRUE 1
78
#define WORD unsigned short
79
#define DWORD unsigned int
80
#define WINAPI
81
#define LPVOID void *
82
#define INFINITE INFINITY
83
#define WaitForSingleObject(mutexObject,b) pthread_mutex_lock( mutexObject )
84
#define ReleaseMutex(mutexObject) pthread_mutex_unlock(mutexObject)
85
typedef
struct
_SYSTEMTIME
{
86
WORD wYear;
87
WORD wMonth;
88
WORD wDayOfWeek;
89
WORD wDay;
90
WORD wHour;
91
WORD wMinute;
92
WORD wSecond;
93
WORD wMilliseconds;
94
} SYSTEMTIME;
95
#define _popen(a,b) popen(a,b)
96
#define _pclose(a) pclose(a)
97
#define CRITICAL_SECTION pthread_mutex_t;
98
#define FARPROC void *
99
#define EnterCriticalSection(a) pthread_mutex_lock (a);
100
#define LeaveCriticalSection(a) pthread_mutex_unlock (a);
101
#define DeleteCriticalSection(a) pthread_mutex_destroy (a);
102
#define CreateMutexA CreateMutex
103
#define CloseHandle(mutex) pthread_mutex_destroy(mutex);
104
#define Sleep(x) usleep(1000*x)
//usleep takes in microscecond
105
#define _fcloseall() fcloseall()
106
#define min(a,b) !(b<a)?a:b
107
#define max(a,b) !(b>a)?a:b
108
#define __debugbreak()
109
typedef
unsigned
char
u_char;
110
typedef
unsigned
short
u_short;
111
typedef
unsigned
int
u_int;
112
typedef
unsigned
long
u_long;
113
#define __in
114
#define __out
115
116
//Thread function
117
void
* CreateMutex(
void
* att,
int
a,
char
* name);
118
void
WaitForMultipleObjects(DWORD nCount,
const
pthread_mutex_t *lpHandles,
int
bWaitAll, DWORD dwMilliseconds);
119
120
121
//String macros
122
#define _strrev strrev
123
#ifdef _strdup
124
#undef _strdup
125
#endif
126
#define _strdup(x) x==NULL?NULL:strdup(x)
127
#define _stricmp strcasecmp
128
#define stricmp strcasecmp
129
130
//String function
131
char
*_strrev(
char
*str);
132
char
* _strupr(
char
* s );
133
134
135
136
137
//Time function
138
void
GetSystemTime(
struct
_SYSTEMTIME
*lp);
139
DWORD GetTickCount();
140
141
142
//Memory function
143
int
_msize(
void
* p);
144
145
//error function
146
#define SetLastError(x) errno=x
147
148
//environment function
149
void
_putenv(
char
* s);
150
#endif
//LINUX_HEADER
_LARGE_INTEGER
Definition
Linux.h:68
_SYSTEMTIME
Definition
Linux.h:85
ALL
Component 1
Part 4
Include
Linux.h
Generated by
1.13.2