]> Savannah Git Hosting - gnulib.git/commitdiff
get_shared_library_fullname: port to EMX
authorKO Myung-Hun <komh78@gmail.com>
Wed, 3 Dec 2014 06:46:17 +0000 (15:46 +0900)
committerEric Blake <eblake@redhat.com>
Mon, 8 Dec 2014 20:53:40 +0000 (13:53 -0700)
* lib/relocatable.c: Define strcmp and strncmp to stricmp and strnicmp
on EMX, respectively.
(_DLL_InitTerm): New on EMX.
(get_shared_library_fullname): Implement on EMX.

Signed-off-by: Eric Blake <eblake@redhat.com>
ChangeLog
lib/relocatable.c

index 3cb3c688b86a5ee8335cb4d45c49b1ee8f894390..1c61959a9fbe7265fed83f1bebed8d1aba1c88b7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2014-12-08  KO Myung-Hun  <komh78@gmail.com>
 
+       get_shared_library_fullname: port to EMX
+       * lib/relocatable.c: Define strcmp and strncmp to stricmp and strnicmp
+       on EMX, respectively.
+       (_DLL_InitTerm): New on EMX.
+       (get_shared_library_fullname): Implement on EMX.
+
        find_executable: port to EMX
        * lib/progreloc.c (find_executable): Implement on EMX.
 
index 81dcaebe27faaa90c25be7bf85ec31497fc0a5ea..6c6ea1cf6b11fda895c81a27c925399b2ab04b5c 100644 (file)
 # include <windows.h>
 #endif
 
+#ifdef __EMX__
+# define INCL_DOS
+# include <os2.h>
+
+# define strcmp  stricmp
+# define strncmp strnicmp
+#endif
+
 #if DEPENDS_ON_LIBCHARSET
 # include <libcharset.h>
 #endif
@@ -335,6 +343,45 @@ DllMain (HINSTANCE module_handle, DWORD event, LPVOID reserved)
   return TRUE;
 }
 
+#elif defined __EMX__
+
+extern int  _CRT_init (void);
+extern void _CRT_term (void);
+extern void __ctordtorInit (void);
+extern void __ctordtorTerm (void);
+
+unsigned long _System
+_DLL_InitTerm (unsigned long hModule, unsigned long ulFlag)
+{
+  static char location[CCHMAXPATH];
+
+  switch (ulFlag)
+    {
+      case 0:
+        if (_CRT_init () == -1)
+          return 0;
+
+        __ctordtorInit();
+
+        /* See http://cyberkinetica.homeunix.net/os2tk45/cp1/1247_L2H_DosQueryModuleNameSy.html
+           for specification of DosQueryModuleName(). */
+        if (DosQueryModuleName (hModule, sizeof (location), location))
+          return 0;
+
+        _fnslashify (location);
+        shared_library_fullname = strdup (location);
+        break;
+
+      case 1:
+        __ctordtorTerm();
+
+        _CRT_term ();
+        break;
+    }
+
+  return 1;
+}
+
 #else /* Unix */
 
 static void
@@ -390,15 +437,16 @@ find_shared_library_fullname ()
 #endif
 }
 
-#endif /* Native Windows / Unix */
+#endif /* Native Windows / EMX / Unix */
 
 /* Return the full pathname of the current shared library.
    Return NULL if unknown.
-   Guaranteed to work only on Linux, Cygwin, and native Windows.  */
+   Guaranteed to work only on Linux, EMX, Cygwin, and native Windows.  */
 static char *
 get_shared_library_fullname ()
 {
-#if !((defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__)
+#if (!((defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__) \
+     && !defined __EMX__)
   static bool tried_find_shared_library_fullname;
   if (!tried_find_shared_library_fullname)
     {