aboutsummaryrefslogtreecommitdiffstats
path: root/testing/motion/pthread_key_create.patch
blob: afedce75b5a0e28510d48d65cf1dba4265b9e242 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
make sure we create the tls key before we access in any way.

we also fix the check for broken glibc strerror_r

--- ./motion.c.orig
+++ ./motion.c
@@ -2267,6 +2267,9 @@
     struct sigaction sigchild_action;
     setup_signals(&sig_handler_action, &sigchild_action);
 
+    /* Create the TLS key for thread number. */
+    pthread_key_create(&tls_key_threadnr, NULL);
+
     motion_startup(1, argc, argv);
 
 #ifdef HAVE_FFMPEG
@@ -2290,9 +2293,6 @@
     pthread_attr_init(&thread_attr);
     pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_DETACHED);
 
-    /* Create the TLS key for thread number. */
-    pthread_key_create(&tls_key_threadnr, NULL);
-
     do {
         if (restart) {
             /* Handle the restart situation. Currently the approach is to
@@ -2745,9 +2745,6 @@
 {
     int errno_save, n;
     char buf[1024];
-#if (!defined(BSD)) && (!(_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE)
-    char msg_buf[100];
-#endif
     va_list ap;
     int threadnr;
 
@@ -2780,12 +2778,13 @@
          * version of strerror_r, which doesn't actually put the message into
          * my buffer :-(.  I have put in a 'hack' to get around this.
          */
-#if (defined(BSD))
-        strerror_r(errno_save, buf + n, sizeof(buf) - n);    /* 2 for the ': ' */
-#elif (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE
+#if !defined(__GLIBC__) || ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! defined(_GNU_SOURCE))
         strerror_r(errno_save, buf + n, sizeof(buf) - n);
 #else
+	{
+        char msg_buf[100];
         strncat(buf, strerror_r(errno_save, msg_buf, sizeof(msg_buf)), 1024 - strlen(buf));
+	}
 #endif
     }
     /* If 'level' is not negative, send the message to the syslog */