am7xxx-play: check if sigaction is available
authorAntonio Ospite <ospite@studenti.unina.it>
Tue, 22 May 2012 14:21:25 +0000 (16:21 +0200)
committerAntonio Ospite <ospite@studenti.unina.it>
Tue, 22 May 2012 14:21:25 +0000 (16:21 +0200)
If sigaction is not available just stub out the set_signal_handler()
function.

examples/CMakeLists.txt
examples/am7xxx-play.c

index 7e7b455..e24442b 100644 (file)
@@ -32,6 +32,13 @@ if(BUILD_AM7XXX-PLAY)
   include_directories(${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS})
   include_directories(${FFMPEG_LIBSWSCALE_INCLUDE_DIRS})
 
+  set(CMAKE_REQUIRED_DEFINITIONS -D_POSIX_SOURCE)
+  check_symbol_exists(sigaction "signal.h" HAVE_SIGACTION)
+  if (HAVE_SIGACTION)
+    add_definitions("-DHAVE_SIGACTION")
+  endif()
+  set(CMAKE_REQUIRED_DEFINITIONS)
+
   # xcb is used to retrieve the full screen dimensions when using x11grab
   # as input format
   find_package(XCB)
index 49b5234..352ba2f 100644 (file)
@@ -539,6 +539,7 @@ static void unset_run(int signo)
        run = 0;
 }
 
+#ifdef HAVE_SIGACTION
 static int set_signal_handler(void (*signal_handler)(int))
 {
        struct sigaction new_action;
@@ -566,6 +567,15 @@ static int set_signal_handler(void (*signal_handler)(int))
 out:
        return ret;
 }
+#else
+static int set_signal_handler(void (*signal_handler)(int))
+{
+       (void)signal_handler;
+       fprintf(stderr, "set_signal_handler() not implemented, sigaction not available\n");
+       return 0;
+}
+#endif
+
 
 static void usage(char *name)
 {