aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKO Myung-Hun <komh78@gmail.com>2017-10-21 13:51:11 +0300
committerEli Zaretskii <eliz@gnu.org>2017-10-21 13:51:11 +0300
commit73a0bda71873bdc095f171d3d8bf322b974a010d (patch)
tree538a70649a8894df1acec5f1257f2dea801e1e21
parent23e8672e421a46f13f9f7b577f6f9e8e5889dd75 (diff)
downloadegawk-73a0bda71873bdc095f171d3d8bf322b974a010d.tar.gz
egawk-73a0bda71873bdc095f171d3d8bf322b974a010d.tar.bz2
egawk-73a0bda71873bdc095f171d3d8bf322b974a010d.zip
Fix the OS/2 build.
-rw-r--r--ChangeLog8
-rw-r--r--io.c6
-rw-r--r--nonposix.h16
-rw-r--r--pc/ChangeLog5
-rw-r--r--pc/gawkmisc.pc46
5 files changed, 81 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 21da5109..1b4234e8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2017-10-21 KO Myung-Hun <komh78@gmail.com>
+
+ * nonposix.h [__KLIBC__]: Include dlfcn.h, declare os2_dlsym, and
+ redirect dlsym to os2_dlsym. Declare os2_fixdllname. Declare
+ os2_dlopen and redirect dlopen to os2_dlopen.
+ * io.h (find_source) [__EMX__]: Truncate extension file basename
+ to 8 characters.
+
2017-10-19 Arnold D. Robbins <arnold@skeeve.com>
* 4.2.0: Release tar ball made.
diff --git a/io.c b/io.c
index 378b1156..7314d8e8 100644
--- a/io.c
+++ b/io.c
@@ -2913,6 +2913,12 @@ find_source(const char *src, struct stat *stb, int *errcode, int is_extlib)
*errcode = 0;
if (src == NULL || *src == '\0')
return NULL;
+#ifdef __EMX__
+ char os2_src[strlen(src) + 1];
+
+ if (is_extlib)
+ src = os2_fixdllname(os2_src, src, sizeof(os2_src));
+#endif /* __EMX__ */
path = do_find_source(src, stb, errcode, pi);
if (path == NULL && is_extlib) {
diff --git a/nonposix.h b/nonposix.h
index b4f52246..19336ee7 100644
--- a/nonposix.h
+++ b/nonposix.h
@@ -75,3 +75,19 @@ int getppid(void);
wint_t btowc (int c);
wint_t putwc (wchar_t wc, FILE *stream);
#endif
+
+#ifdef __EMX__
+
+char *os2_fixdllname(char *dst, const char *src, size_t n);
+
+#ifdef __KLIBC__
+#include <dlfcn.h>
+
+#define dlopen(f, m) os2_dlopen(f, m)
+void *os2_dlopen(const char *file, int mode);
+
+#define dlsym(h, n) os2_dlsym(h, n)
+void *os2_dlsym(void *handle, const char *name);
+#endif /* __KLIBC__ */
+
+#endif /* __EMX__ */
diff --git a/pc/ChangeLog b/pc/ChangeLog
index 9f0f0275..800e6790 100644
--- a/pc/ChangeLog
+++ b/pc/ChangeLog
@@ -1,3 +1,8 @@
+2017-10-21 KO Myung-Hun <komh78@gmail.com>
+
+ * gawkmisc.pc (os2_dlsym, os2_fixdllname, os2_dlopen) [__KLIBC__]:
+ New functions.
+
2017-10-21 Eli Zaretskii <eliz@gnu.org>
* Makefile (install1): Create include/ at desctination, and copy
diff --git a/pc/gawkmisc.pc b/pc/gawkmisc.pc
index 41ffd5ec..1d845cc8 100644
--- a/pc/gawkmisc.pc
+++ b/pc/gawkmisc.pc
@@ -548,6 +548,52 @@ _os2_unixroot_path(const char *path)
return (result) ? (const char*) result : path;
}
+
+/* limit a length of DLL name up to 8 characters. If dst is not enough for
+ a fixed dll name, it is truncated. */
+char *os2_fixdllname(char *dst, const char *src, size_t n)
+{
+ char drive[_MAX_DRIVE];
+ char dir[_MAX_DIR];
+ char name[_MAX_FNAME];
+ char ext[_MAX_EXT];
+ char dll_file[_MAX_PATH];
+
+ _splitpath(src, drive, dir, name, ext);
+ if (strlen(name) > 8)
+ name[8] = '\0';
+ _makepath(dll_file, drive, dir, name, ext);
+
+ strncpy(dst, dll_file, n);
+ dst[n - 1] = '\0';
+
+ return dst;
+}
+
+#ifdef __KLIBC__
+
+/* replacement of dlopen(). This limits a length of a base name up to 8
+ characters. */
+void *os2_dlopen(const char *file, int mode)
+{
+ char dll_file[strlen(file) + 1];
+
+ return (dlopen)(os2_fixdllname(dll_file, file, sizeof(dll_file)), mode);
+}
+
+/* replacement of dlsym(). This prepends '_' to name. */
+void *os2_dlsym(void *handle, const char *name)
+{
+ char sym[strlen(name) + 1 + 1]; /* 1 for '_', 1 for NUL */
+
+ sym[0] = '_';
+ strcpy(sym + 1, name);
+
+ return (dlsym)(handle, sym);
+}
+
+#endif /* __KLIBC__ */
+
#endif /* __EMX__ */
#ifdef __MINGW32__