⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mycompat.h

📁 基于linux环境的ns2多机并行仿真补丁
💻 H
字号:
/*---------------------------------------------------------------------------*//* Author(s): Kalyan Perumalla <http://www.cc.gatech.edu/~kalyan> 02Oct2003  *//* $Revision: 1.7 $ $Name: v26apr05 $ $Date: 2004/11/04 21:45:12 $ *//*---------------------------------------------------------------------------*/#ifndef __MYCOMPAT_H#define __MYCOMPAT_H/*---------------------------------------------------------------------------*/#if defined(_WIN32) || defined(_WIN32_WCE)    #define PLATFORM_WIN 1#endif#ifdef _WIN32_WCE    #define PLATFORM_WINCE 1#endif/*---------------------------------------------------------------------------*/#if PLATFORM_WIN    #if !PLATFORM_WINCE        #include <time.h>        #define sleep(_s) \            do{clock_t c=clock()+(_s)*1000;while(c>clock()){}}while(0)    #else        #include <winbase.h>        #define time(_pt)     (*(_pt)=0)        #define sleep(_s)     Sleep((_s)*1000)        #define strdup(_s)    strcpy(((char*)malloc(strlen(_s)+1)),_s)        #define perror(_s)    ((void)0)        #define system(_s)    ((int)-1)        char *getenv( const char *s );        int putenv( char *s );    #endif    #include <process.h>    #define getpid() _getpid()    #include <winsock.h>	#if PLATFORM_WINCE        typedef time_t TIMER_TYPE;        #define TIMER_NOW(_t) time(&_t)        #define TIMER_SECONDS(_t) (_t)	#else        typedef struct { LARGE_INTEGER cntr, freq; } TIMER_TYPE;        #define TIMER_NOW(_t) if(1) { \		    QueryPerformanceFrequency(&((_t).freq)); \			QueryPerformanceCounter(&((_t).cntr)); } else        #define TIMER_SECONDS(_t) ((_t).cntr.QuadPart*1.0/(_t).freq.QuadPart)	#endif    #define SIGPIPE SIGSEGV    #define SIGHUP SIGSEGV    #define SHM_AVAILABLE 0#else    #include <netinet/in.h>    #include <sys/time.h>    #include <unistd.h>    typedef struct timeval TIMER_TYPE;    #define TIMER_NOW(_t) gettimeofday(&_t,NULL)    #define TIMER_SECONDS(_t) ((double)(_t).tv_sec + (_t).tv_usec*1e-6)    typedef char BOOLEAN;    #define SHM_AVAILABLE 1#endif/*---------------------------------------------------------------------------*/#if PLATFORM_WINCE    /*Application should define the callback to handle the failed assertion*/    void assert_callback( const TCHAR *fname, int line, const TCHAR *condition);    #define MYASSERT( _cond, _act ) \       do{if( !(_cond) ) { printf _act; printf("\n"); \          assert_callback( TEXT(__FILE__), __LINE__, TEXT(#_cond) );}}while(0)    #define assert( _cond ) MYASSERT( _cond, ("Failed assertion") )#else    #include <assert.h>    #define MYASSERT( _cond, _act ) \       do{if( !(_cond) ) { printf _act; printf("\n"); assert( _cond );}}while(0)#endif/*---------------------------------------------------------------------------*/#endif /* __MYCOMPAT_H */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -