eina: fix siginfo detection.
authorCedric BAIL <cedric.bail@samsung.com>
Mon, 18 Feb 2013 07:39:49 +0000 (16:39 +0900)
committerCedric BAIL <cedric.bail@samsung.com>
Mon, 18 Feb 2013 07:46:52 +0000 (16:46 +0900)
Signal are not a portable way to detect memory mapped file corruption.
So let's disable it for system without signal and later find a way to
detect it on other system.

configure.ac
src/lib/eina/eina_mmap.c

index 2ab49ca..bef64ae 100644 (file)
@@ -327,6 +327,14 @@ AC_SUBST([EINA_SIZEOF_WCHAR_T])
 AC_CHECK_SIZEOF(int, 4)
 AC_CHECK_SIZEOF(long, 4)
 
+AC_CHECK_TYPES([siginfo_t], [], [],
+   [[
+#include <signal.h>
+#if HAVE_SIGINFO_H
+# include <siginfo.h>
+#endif
+   ]])
+
 #### Checks for structures
 
 
index 9da97fd..bed7e07 100644 (file)
@@ -20,6 +20,8 @@
 # include "config.h"
 #endif
 
+#ifdef HAVE_SIGINFO_T
+
 #ifdef STDC_HEADERS
 # include <stdlib.h>
 # include <stddef.h>
 #include <fcntl.h>
 #include <unistd.h>
 
+#if HAVE_SIGINFO_H
+# include <siginfo.h>
+#endif
+
+#endif
+
 #include "eina_config.h"
 #include "eina_private.h"
 #include "eina_log.h"
@@ -51,6 +59,7 @@
  *============================================================================*/
 
 static Eina_Bool mmap_safe = EINA_FALSE;
+#ifdef HAVE_SIGINFO_T
 
 static int _eina_mmap_log_dom = -1;
 static int _eina_mmap_zero_fd = -1;
@@ -106,6 +115,7 @@ _eina_mmap_safe_sigbus(int sig EINA_UNUSED,
    /* restore previous errno */
    errno = perrno;
 }
+#endif
 
 /*============================================================================*
  *                                   API                                      *
@@ -114,6 +124,10 @@ _eina_mmap_safe_sigbus(int sig EINA_UNUSED,
 EAPI Eina_Bool
 eina_mmap_safety_enabled_set(Eina_Bool enabled)
 {
+#ifndef HAVE_SIGINFO_T
+   (void) enabled;
+   return EINA_FALSE;
+#else
    if (_eina_mmap_log_dom < 0)
      {
         _eina_mmap_log_dom = eina_log_domain_register("eina_mmap",
@@ -155,7 +169,7 @@ eina_mmap_safety_enabled_set(Eina_Bool enabled)
              flags |= FD_CLOEXEC;
              fcntl(_eina_mmap_zero_fd, F_SETFD, flags);
 #endif
-
+            
           }
         /* set up signal handler for SIGBUS */
         sa.sa_sigaction = _eina_mmap_safe_sigbus;
@@ -180,6 +194,7 @@ eina_mmap_safety_enabled_set(Eina_Bool enabled)
 done:   
    mmap_safe = enabled;
    return mmap_safe;
+#endif
 }
 
 EAPI Eina_Bool