[RFC,3/5] xtensa: support dynconfig on windows
Commit Message
2017-05-22 Max Filippov <jcmvbkbc@gmail.com>
bfd/
* xtensa-config.c (windows.h): New #include'd header.
(RTLD_LAZY): New macro definition.
(dlopen, dlsym, dlclose, dlerror): New functions.
---
bfd/xtensa-config.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
Comments
Hi Max,
> 2017-05-22 Max Filippov <jcmvbkbc@gmail.com>
> bfd/
> * xtensa-config.c (windows.h): New #include'd header.
> (RTLD_LAZY): New macro definition.
> (dlopen, dlsym, dlclose, dlerror): New functions.
Approved - please apply.
Cheers
Nick
@@ -3,6 +3,8 @@
#if defined (HAVE_DLFCN_H)
#include <dlfcn.h>
+#elif defined (HAVE_WINDOWS_H)
+#include <windows.h>
#endif
#include <stdio.h>
#include <stdlib.h>
@@ -12,6 +14,37 @@
static struct xtensa_config xtensa_defconfig = XTENSA_CONFIG_INITIALIZER;
+#if !defined (HAVE_DLFCN_H) && defined (HAVE_WINDOWS_H)
+
+#define RTLD_LAZY 0 /* Dummy value. */
+
+static void *
+dlopen (const char *file, int mode ATTRIBUTE_UNUSED)
+{
+ return LoadLibrary (file);
+}
+
+static void *
+dlsym (void *handle, const char *name)
+{
+ return GetProcAddress (handle, name);
+}
+
+static int ATTRIBUTE_UNUSED
+dlclose (void *handle)
+{
+ FreeLibrary (handle);
+ return 0;
+}
+
+static const char *
+dlerror (void)
+{
+ return "Unable to load DLL.";
+}
+
+#endif /* !defined (HAVE_DLFCN_H) && defined (HAVE_WINDOWS_H) */
+
void *xtensa_load_config (const char *name ATTRIBUTE_UNUSED, void *def)
{
static int init;