[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 3/5] m4: support to load modules on OS/2
From: |
KO Myung-Hun |
Subject: |
[PATCH 3/5] m4: support to load modules on OS/2 |
Date: |
Mon, 22 Sep 2014 18:00:20 +0900 |
---
m4/module.c | 20 +++++++++++++++++---
m4/path.c | 9 ++++++++-
2 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/m4/module.c b/m4/module.c
index 6f2a2a9..2917240 100644
--- a/m4/module.c
+++ b/m4/module.c
@@ -67,6 +67,12 @@
#define MODULE_SELF_NAME "!myself!"
+#ifdef __OS2__
+# define SYMBOL_PREFIX "_"
+#else
+# define SYMBOL_PREFIX ""
+#endif
+
static const char* module_dlerror (void);
static void install_builtin_table (m4*, m4_module *);
@@ -97,7 +103,9 @@ m4_module_import (m4 *context, const char *module_name,
if (module)
{
- symbol_address = dlsym (module->handle, symbol_name);
+ char *import_name = xasprintf (SYMBOL_PREFIX "%s", symbol_name);
+ symbol_address = dlsym (module->handle, import_name);
+ free (import_name);
if (!symbol_address)
m4_error (context, 0, 0, NULL,
@@ -265,7 +273,7 @@ compare_builtin_CB (const void *a, const void *b)
m4_module *
m4__module_open (m4 *context, const char *name, m4_obstack *obs)
{
- static const char * suffixes[] = { "", ".so", NULL };
+ static const char * suffixes[] = { "", ".so", ".dll", NULL };
m4_module * module = NULL;
assert (context);
@@ -273,6 +281,12 @@ m4__module_open (m4 *context, const char *name, m4_obstack
*obs)
char *filepath = m4_path_search (context, name, suffixes);
void *handle = NULL;
+#ifdef __OS2__
+ /* if m4_path_search () fails, then use a system path. */
+ if (!filepath)
+ filepath = xstrdup (name);
+#endif
+
if (filepath)
{
handle = dlopen (filepath, RTLD_NOW|RTLD_GLOBAL);
@@ -296,7 +310,7 @@ m4__module_open (m4 *context, const char *name, m4_obstack
*obs)
/* Find and run any initializing function in the opened module,
the first time the module is opened. */
- char *entry_point = xasprintf ("include_%s", name);
+ char *entry_point = xasprintf (SYMBOL_PREFIX "include_%s", name);
m4_module_init_func *init_func =
(m4_module_init_func *) dlsym (handle, entry_point);
free (entry_point);
diff --git a/m4/path.c b/m4/path.c
index 3a93289..0724225 100644
--- a/m4/path.c
+++ b/m4/path.c
@@ -37,11 +37,18 @@
/* Define this to see runtime debug info. Implied by DEBUG. */
/*#define DEBUG_INCL */
+#ifdef __OS2__
+# define PATH_SEPARATOR ';'
+#else
+# define PATH_SEPARATOR ':'
+#endif
+
static const char *FILE_SUFFIXES[] = {
"",
".m4f",
".m4",
".so",
+ ".dll",
NULL
};
@@ -100,7 +107,7 @@ search_path_env_init (m4__search_path_info *info, char
*path, bool isabs)
do
{
- path_end = strchr (path, ':');
+ path_end = strchr (path, PATH_SEPARATOR);
if (path_end)
*path_end = '\0';
if (!isabs || *path == '/')
--
1.7.3.2
- [PATCH] OS/2 patches, KO Myung-Hun, 2014/09/22
- [PATCH 1/5] bootstrap: set and use PATH_SEPARATOR, KO Myung-Hun, 2014/09/22
- [PATCH 4/5] configury: specify a OS/2 DLL name for m4/m4 to libm4, KO Myung-Hun, 2014/09/22
- [PATCH 5/5] configure: add -Zargs-resp and -no-undefined to LDFLAGS on OS/2, KO Myung-Hun, 2014/09/22
- [PATCH 2/5] configury: append $EXEEXT suffix to the executable, /bin/sh, KO Myung-Hun, 2014/09/22
- [PATCH 3/5] m4: support to load modules on OS/2,
KO Myung-Hun <=
- Re: [PATCH] OS/2 patches, Eric Blake, 2014/09/22