WindowsCompatibility.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2005 Palmsource, Inc.
00003  * 
00004  * This software is licensed as described in the file LICENSE, which
00005  * you should have received as part of this distribution. The terms
00006  * are also available at http://www.openbinder.org/license.html.
00007  * 
00008  * This software consists of voluntary contributions made by many
00009  * individuals. For the exact contribution history, see the revision
00010  * history and logs, available at http://www.openbinder.org
00011  */
00012 
00013 #ifndef _WINDOWS_COMPATIBILITY_H
00014 #define _WINDOWS_COMPATIBILITY_H
00015 
00016 #include <BuildDefines.h>
00017 #include <sys/types.h>
00018 #include <stddef.h>
00019 #include <stdint.h>
00020 
00021 #if TARGET_HOST == TARGET_HOST_WIN32
00022 
00023 uint32_t strnlen(const char *str, int32_t maxLength);
00024 
00025 #define atoll _atoi64
00026 
00027 #ifdef __cplusplus
00028 extern "C" {
00029 #endif
00030 
00031 void ErrFatalErrorInContext(const char* fileName, uint32_t lineNum, const char* errMsg);
00032 void init_thread_message_queue();
00033 const char* strerror_r(int errnumber, char *buf, size_t buflen);
00034 
00035 size_t strlcpy(char * dst, char const * src, size_t size);
00036 
00037 int rand_r(unsigned int * seed);
00038 
00039 #ifndef snprintf
00040 #define snprintf _snprintf
00041 #endif
00042 
00043 #ifndef vsnprintf
00044 #define vsnprintf _vsnprintf
00045 #endif
00046 
00047 // ########################################################################################## //
00048 // # NOTE THAT THE FOLLOWING FILES ARE SAFE TO INCLUDE!                                     # //
00049 // ########################################################################################## //
00050 
00051 #if !defined(_68K_) && !defined(_MPPC_) && !defined(_X86_) && !defined(_IA64_) && !defined(_AMD64_) && defined(_M_IX86)
00052 #define _X86_
00053 #endif
00054 
00055 // THIS MAY CAUSE A PROBLEM!
00056 #include <stdarg.h>
00057 
00058 #include <windef.h>
00059 #include <winbase.h>
00060 #include <wingdi.h>
00061 #include <winuser.h>
00062 #include <winver.h>
00063 #include <winnt.h>
00064 #include <dbghelp.h>
00065 #include <tlhelp32.h>
00066 
00067 // DispatchMessage is defined to be DispatchMessageA which reaplaces BHandlers DispatchMessage!
00068 #undef DispatchMessage
00069 // This interferes with SLocker::Yield
00070 #undef Yield
00071 
00072 
00073 #ifdef __cplusplus
00074 }
00075 
00076 #endif
00077 
00078 #define ErrFatalOption_IgnoreAllowed    1
00079 
00080 #define DbgOnlyFatalError(errMsg) ErrFatalErrorInContext(MODULE_NAME, __LINE__, errMsg)
00081 #define DbgOnlyFatalErrorIf(condition, errMsg) ((condition) ? DbgOnlyFatalError(errMsg) : (void)0)
00082 
00083 
00084 #endif // TARGET_HOST == TARGET_HOST_WIN32
00085 
00086 #endif // _WINDOWS_COMPATIBILITY_H