libtool-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] GNU Libtool branch, master, updated. v2.2.6-177-g16362c6


From: Peter Rosin
Subject: [SCM] GNU Libtool branch, master, updated. v2.2.6-177-g16362c6
Date: Mon, 18 Jan 2010 08:53:49 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Libtool".

The branch, master has been updated
       via  16362c656aac5daf7337f2ed27aae1fe4838d03a (commit)
      from  a75f8acf28774a6f9e9b9b7c015b51c378be1221 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 16362c656aac5daf7337f2ed27aae1fe4838d03a
Author: Peter Rosin <address@hidden>
Date:   Mon Jan 18 09:48:23 2010 +0100

    Use GetErrorMode if it is available.
    
    * libltdl/loaders/loadlibrary.c (wrap_geterrormode): New
    function that checks if GetErrorMode is supported by the
    system and makes use of it if it is.
    (fallback_geterrormode): New function that is used otherwise
    that implements the old workaround.
    (geterrormode): New function pointer that points at either
    of the above or directly at GetErrorMode.
    (vm_open): Make use of the above.
    
    Signed-off-by: Peter Rosin <address@hidden>

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                     |   12 +++++++++
 libltdl/loaders/loadlibrary.c |   51 +++++++++++++++++++++++++++++++++++-----
 2 files changed, 56 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b244706..5f2518c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2010-01-02  Peter Rosin  <address@hidden>
+
+       Use GetErrorMode if it is available.
+       * libltdl/loaders/loadlibrary.c (wrap_geterrormode): New
+       function that checks if GetErrorMode is supported by the
+       system and makes use of it if it is.
+       (fallback_geterrormode): New function that is used otherwise
+       that implements the old workaround.
+       (geterrormode): New function pointer that points at either
+       of the above or directly at GetErrorMode.
+       (vm_open): Make use of the above.
+
 2010-01-11  Ralf Wildenhues  <address@hidden>
 
        Ensure functions from resident modules work in atexit handlers.
diff --git a/libltdl/loaders/loadlibrary.c b/libltdl/loaders/loadlibrary.c
index 97fddf4..40435fe 100644
--- a/libltdl/loaders/loadlibrary.c
+++ b/libltdl/loaders/loadlibrary.c
@@ -1,7 +1,7 @@
 /* loader-loadlibrary.c --  dynamic linking for Win32
 
    Copyright (C) 1998, 1999, 2000, 2004, 2005, 2006,
-                 2007, 2008 Free Software Foundation, Inc.
+                 2007, 2008, 2010 Free Software Foundation, Inc.
    Written by Thomas Tanner, 1998
 
    NOTE: The canonical source of this file is maintained with the
@@ -98,6 +98,14 @@ get_vtable (lt_user_data loader_data)
 
 #include <windows.h>
 
+static UINT WINAPI wrap_geterrormode (void);
+static UINT WINAPI fallback_geterrormode (void);
+
+typedef UINT (WINAPI geterrormode_type) (void);
+
+static geterrormode_type *geterrormode = wrap_geterrormode;
+
+
 /* A function called through the vtable when this loader is no
    longer needed by the application.  */
 static int
@@ -170,16 +178,14 @@ vm_open (lt_user_data LT__UNUSED loader_data, const char 
*filename,
     }
 
   {
-    /* Silence dialog from LoadLibrary on some failures.
-       No way to get the error mode, but to set it,
-       so set it twice to preserve any previous flags. */
-    UINT errormode = SetErrorMode(SEM_FAILCRITICALERRORS);
-    SetErrorMode(errormode | SEM_FAILCRITICALERRORS);
+    /* Silence dialog from LoadLibrary on some failures. */
+    UINT errormode = geterrormode ();
+    SetErrorMode (errormode | SEM_FAILCRITICALERRORS);
 
     module = LoadLibrary (wpath);
 
     /* Restore the error mode. */
-    SetErrorMode(errormode);
+    SetErrorMode (errormode);
   }
 
   /* libltdl expects this function to fail if it is unable
@@ -249,3 +255,34 @@ vm_sym (lt_user_data LT__UNUSED loader_data, lt_module 
module, const char *name)
 
   return address;
 }
+
+
+
+/* --- HELPER FUNCTIONS --- */
+
+
+/* A function called through the geterrormode variable which checks
+   if the system supports GetErrorMode and arranges for it or a
+   fallback implementation to be called directly in the future. The
+   selected version is then called. */
+static UINT WINAPI
+wrap_geterrormode (void)
+{
+  HMODULE kernel32 = GetModuleHandleA ("kernel32.dll");
+  geterrormode = (geterrormode_type *) GetProcAddress (kernel32,
+                                                       "GetErrorMode");
+  if (!geterrormode)
+    geterrormode = fallback_geterrormode;
+  return geterrormode ();
+}
+
+/* A function called through the geterrormode variable for cases
+   where the system does not support GetErrorMode */
+static UINT WINAPI
+fallback_geterrormode (void)
+{
+  /* Prior to Windows Vista, the only way to get the current error
+     mode was to set a new one. In our case, we are setting a new
+     error mode right after "getting" it, so that's fairly ok. */
+  return SetErrorMode (SEM_FAILCRITICALERRORS);
+}


hooks/post-receive
-- 
GNU Libtool




reply via email to

[Prev in Thread] Current Thread [Next in Thread]