From 70058a8a8405a36c66235a56b482c4c0c7a46780 Mon Sep 17 00:00:00 2001
From: Chris Robinson <chris.kcat@gmail.com>
Date: Sat, 10 Aug 2019 21:54:30 -0700
Subject: Move the dynload decls and defs to common

---
 alc/backends/alsa.cpp       |  2 +-
 alc/backends/dsound.cpp     |  1 +
 alc/backends/jack.cpp       |  2 +-
 alc/backends/portaudio.cpp  |  2 +-
 alc/backends/pulseaudio.cpp |  3 ++-
 alc/compat.h                | 16 ----------------
 alc/helpers.cpp             | 45 ---------------------------------------------
 7 files changed, 6 insertions(+), 65 deletions(-)

(limited to 'alc')

diff --git a/alc/backends/alsa.cpp b/alc/backends/alsa.cpp
index c133df68..64f9cf46 100644
--- a/alc/backends/alsa.cpp
+++ b/alc/backends/alsa.cpp
@@ -44,7 +44,7 @@
 #include "alnumeric.h"
 #include "aloptional.h"
 #include "alu.h"
-#include "compat.h"
+#include "dynload.h"
 #include "logging.h"
 #include "ringbuffer.h"
 #include "threads.h"
diff --git a/alc/backends/dsound.cpp b/alc/backends/dsound.cpp
index 5a156d54..b9e52c0c 100644
--- a/alc/backends/dsound.cpp
+++ b/alc/backends/dsound.cpp
@@ -48,6 +48,7 @@
 #include "alu.h"
 #include "ringbuffer.h"
 #include "compat.h"
+#include "dynload.h"
 #include "threads.h"
 
 /* MinGW-w64 needs this for some unknown reason now. */
diff --git a/alc/backends/jack.cpp b/alc/backends/jack.cpp
index 3f81d08c..e688b96b 100644
--- a/alc/backends/jack.cpp
+++ b/alc/backends/jack.cpp
@@ -32,9 +32,9 @@
 #include "alcmain.h"
 #include "alu.h"
 #include "alconfig.h"
+#include "dynload.h"
 #include "ringbuffer.h"
 #include "threads.h"
-#include "compat.h"
 
 #include <jack/jack.h>
 #include <jack/ringbuffer.h>
diff --git a/alc/backends/portaudio.cpp b/alc/backends/portaudio.cpp
index 73e972c5..fcfd4b01 100644
--- a/alc/backends/portaudio.cpp
+++ b/alc/backends/portaudio.cpp
@@ -29,8 +29,8 @@
 #include "alcmain.h"
 #include "alu.h"
 #include "alconfig.h"
+#include "dynload.h"
 #include "ringbuffer.h"
-#include "compat.h"
 
 #include <portaudio.h>
 
diff --git a/alc/backends/pulseaudio.cpp b/alc/backends/pulseaudio.cpp
index 2ddcc86d..ca2ecb43 100644
--- a/alc/backends/pulseaudio.cpp
+++ b/alc/backends/pulseaudio.cpp
@@ -37,8 +37,9 @@
 #include "alcmain.h"
 #include "alu.h"
 #include "alconfig.h"
-#include "compat.h"
 #include "alexcpt.h"
+#include "compat.h"
+#include "dynload.h"
 
 #include <pulse/pulseaudio.h>
 
diff --git a/alc/compat.h b/alc/compat.h
index 4ffc40bf..648fa5b1 100644
--- a/alc/compat.h
+++ b/alc/compat.h
@@ -1,8 +1,6 @@
 #ifndef AL_COMPAT_H
 #define AL_COMPAT_H
 
-#ifdef __cplusplus
-
 #ifdef _WIN32
 
 #define WIN32_LEAN_AND_MEAN
@@ -86,8 +84,6 @@ public:
 
 } // namespace al
 
-#define HAVE_DYNLOAD 1
-
 #else /* _WIN32 */
 
 #include <fstream>
@@ -99,10 +95,6 @@ using ifstream = std::ifstream;
 
 } // namespace al
 
-#if defined(HAVE_DLFCN_H)
-#define HAVE_DYNLOAD 1
-#endif
-
 #endif /* _WIN32 */
 
 #include <string>
@@ -110,12 +102,4 @@ using ifstream = std::ifstream;
 struct PathNamePair { std::string path, fname; };
 const PathNamePair &GetProcBinary(void);
 
-#ifdef HAVE_DYNLOAD
-void *LoadLib(const char *name);
-void CloseLib(void *handle);
-void *GetSymbol(void *handle, const char *name);
-#endif
-
-#endif /* __cplusplus */
-
 #endif /* AL_COMPAT_H */
diff --git a/alc/helpers.cpp b/alc/helpers.cpp
index d1401c3c..b952c5ed 100644
--- a/alc/helpers.cpp
+++ b/alc/helpers.cpp
@@ -81,9 +81,6 @@ DEFINE_PROPERTYKEY(PKEY_AudioEndpoint_GUID, 0x1da5d803, 0xd492, 0x4edd, 0x8c, 0x
 #endif
 #endif /* AL_NO_UID_DEFS */
 
-#ifdef HAVE_DLFCN_H
-#include <dlfcn.h>
-#endif
 #ifdef HAVE_INTRIN_H
 #include <intrin.h>
 #endif
@@ -454,21 +451,6 @@ const PathNamePair &GetProcBinary()
 }
 
 
-void *LoadLib(const char *name)
-{
-    std::wstring wname{utf8_to_wstr(name)};
-    return LoadLibraryW(wname.c_str());
-}
-void CloseLib(void *handle)
-{ FreeLibrary(static_cast<HMODULE>(handle)); }
-void *GetSymbol(void *handle, const char *name)
-{
-    void *ret{reinterpret_cast<void*>(GetProcAddress(static_cast<HMODULE>(handle), name))};
-    if(!ret) ERR("Failed to load %s\n", name);
-    return ret;
-}
-
-
 void al_print(FILE *logfile, const char *fmt, ...)
 {
     al::vector<char> dynmsg;
@@ -683,33 +665,6 @@ const PathNamePair &GetProcBinary()
 }
 
 
-#ifdef HAVE_DLFCN_H
-
-void *LoadLib(const char *name)
-{
-    dlerror();
-    void *handle{dlopen(name, RTLD_NOW)};
-    const char *err{dlerror()};
-    if(err) handle = nullptr;
-    return handle;
-}
-void CloseLib(void *handle)
-{ dlclose(handle); }
-void *GetSymbol(void *handle, const char *name)
-{
-    dlerror();
-    void *sym{dlsym(handle, name)};
-    const char *err{dlerror()};
-    if(err)
-    {
-        WARN("Failed to load %s: %s\n", name, err);
-        sym = nullptr;
-    }
-    return sym;
-}
-
-#endif /* HAVE_DLFCN_H */
-
 void al_print(FILE *logfile, const char *fmt, ...)
 {
     va_list ap;
-- 
cgit v1.2.3