diff options
| author | Ian Elliott <ian@lunarg.com> | 2015-02-12 17:08:34 -0700 |
|---|---|---|
| committer | Ian Elliott <ian@lunarg.com> | 2015-02-12 17:52:56 -0700 |
| commit | 320a832c98552a6e5b35438fe31cfd856f1e5379 (patch) | |
| tree | bb1da7a336ec98c5aaf5282dfb743ad281e5c74e /loader/loader_platform.h | |
| parent | 48471968352104402c433a8f2b7a03b743de6abd (diff) | |
| download | usermoji-320a832c98552a6e5b35438fe31cfd856f1e5379.tar.xz | |
Win: Attempt to keep from using Linux functions.
This is a hopefully-temporary solution to prevent some of the problems of
people breaking the Windows build while developing on Linux (or vice-versa).
This uses macros of the names of Linux/Windows-specific functions in order to
catch people who use those functions directly, instead of using the
platform-compatibility-layer functions.
In order to avoid problems with the layers #include'ing "loader_platform.h"
before they #include system files (which can mess them up), I #include
"loader_platform.h" twice. The 2nd time, it #define's the hopefully-temporary
macros.
Note: For some reason, we can't #define LoadLibrary(). It generates warnings
on Windows.
Diffstat (limited to 'loader/loader_platform.h')
| -rw-r--r-- | loader/loader_platform.h | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/loader/loader_platform.h b/loader/loader_platform.h index 6c0d14d6..dc0fa5ca 100644 --- a/loader/loader_platform.h +++ b/loader/loader_platform.h @@ -277,4 +277,52 @@ static void loader_platform_thread_delete_mutex(loader_platform_thread_mutex* pM #endif // defined(_WIN32) +#else /* LOADER_PLATFORM_H */ +#ifndef LOADER_PLATFORM_H_TEMP +#define LOADER_PLATFORM_H_TEMP + +// NOTE: The following are hopefully-temporary macros to ensure that people +// don't forget to use the loader_platform_*() functions above: + +#if defined(__linux__) +/* Linux-specific common code: */ + +// Dynamic Loading: +#define dlopen PLEASE USE THE loader_platform_open_library() FUNCTION +#define dlerror PLEASE DO NOT USE THE dlerror() FUNCTION DIRECTLY +#define dlclose PLEASE USE THE loader_platform_close_library() FUNCTION +#define dlsym PLEASE USE THE loader_platform_get_proc_address() FUNCTION + +// Threads: +#define pthread_once PLEASE USE THE loader_platform_thread_once() FUNCTION +#define pthread_self PLEASE USE THE loader_platform_get_thread_id() FUNCTION + +// Thread mutex: +#define pthread_mutex_init PLEASE USE THE loader_platform_thread_create_mutex() FUNCTION +#define pthread_mutex_lock PLEASE USE THE loader_platform_thread_lock_mutex() FUNCTION +#define pthread_mutex_unlock PLEASE USE THE loader_platform_thread_unlock_mutex() FUNCTION +#define pthread_mutex_destroy PLEASE USE THE loader_platform_thread_delete_mutex() FUNCTION + + +#elif defined(_WIN32) // defined(__linux__) +/* Windows-specific common code: */ + +// Dynamic Loading: +//#define LoadLibrary PLEASE USE THE loader_platform_open_library() FUNCTION +#define FreeLibrary PLEASE USE THE loader_platform_close_library() FUNCTION +#define GetProcAddress PLEASE USE THE loader_platform_get_proc_address() FUNCTION + +// Threads: +#define InitOnceExecuteOnce PLEASE USE THE loader_platform_thread_once() FUNCTION +#define GetCurrentThreadId PLEASE USE THE loader_platform_get_thread_id() FUNCTION + +// Thread mutex: +#define InitializeCriticalSection PLEASE USE THE loader_platform_thread_create_mutex() FUNCTION +#define EnterCriticalSection PLEASE USE THE loader_platform_thread_lock_mutex() FUNCTION +#define LeaveCriticalSection PLEASE USE THE loader_platform_thread_unlock_mutex() FUNCTION +#define DeleteCriticalSection PLEASE USE THE loader_platform_thread_delete_mutex() FUNCTION + + +#endif // defined(_WIN32) +#endif /* LOADER_PLATFORM_H_TEMP */ #endif /* LOADER_PLATFORM_H */ |
