+error:
+ LOG("Blocked", "%d, %p, %p", signum, act, old);
+ return -1;
+}
+#endif
+
+
+/*** Locales ***
+ * setlocale() is not thread-safe and has a tendency to crash other threads as
+ * quite many libc and libintl calls depend on the locale.
+ * Use uselocale() instead for thread-safety.
+ */
+#include <locale.h>
+
+char *setlocale (int cat, const char *locale)
+{
+ if (override && locale != NULL)
+ {
+ LOG("Blocked", "%d, \"%s\"", cat, locale);
+ return NULL;
+ }
+ return CALL(setlocale, cat, locale);
+}
+
+
+/* strerror() is not thread-safe in theory (POSIX), nor in practice (glibc).
+ * This caused quite nasty crashes in the history of VLC/Linux. */
+char *strerror (int val)
+{
+ if (override)
+ {
+ static const char msg[] =
+ "Error message unavailable (use strerror_r instead of strerror)!";
+ LOG("Blocked", "%d", val);
+ return (char *)msg;
+ }
+ return CALL(strerror, val);
+}
+
+/*** Xlib ****/
+#ifdef HAVE_X11_XLIB_H
+# include <X11/Xlib.h>
+
+static pthread_mutex_t xlib_lock = PTHREAD_MUTEX_INITIALIZER;
+
+int (*XSetErrorHandler (int (*handler) (Display *, XErrorEvent *)))
+ (Display *, XErrorEvent *)
+{
+ if (override)
+ {
+ int (*ret) (Display *, XErrorEvent *);
+
+ pthread_mutex_lock (&xlib_lock);
+ LOG("Error", "%p", handler);
+ ret = CALL(XSetErrorHandler, handler);
+ pthread_mutex_unlock (&xlib_lock);
+ return ret;
+ }
+ return CALL(XSetErrorHandler, handler);