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.
diff --git a/loader/loader_platform.h b/loader/loader_platform.h
index 6c0d14d..dc0fa5c 100644
--- a/loader/loader_platform.h
+++ b/loader/loader_platform.h
@@ -277,4 +277,52 @@
#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 */