ctdb-tests: Use replace headers instead of system headers
authorAmitay Isaacs <amitay@gmail.com>
Tue, 31 Jan 2017 05:49:14 +0000 (16:49 +1100)
committerStefan Metzmacher <metze@samba.org>
Tue, 31 Jan 2017 10:57:01 +0000 (11:57 +0100)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12469

This ensures that PTHREAD_MUTEX_ROBUST, pthread_mutexattr_setrobust()
and pthread_mutex_consistent() are always defined.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Tue Jan 31 11:57:01 CET 2017 on sn-devel-144

ctdb/tests/src/test_mutex_raw.c

index 8e3cae34c8995eced21b6f3010645a9b0e1b34f6..ab7aff9d119e8227fb68244e087f7838aa4ee17c 100644 (file)
  *  If no pid is printed, then no process is holding the mutex.
  */
 
-#include <stdio.h>
-#include <unistd.h>
-#include <inttypes.h>
-#include <sys/types.h>
-#include <sys/fcntl.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/wait.h>
-#include <sched.h>
-#include <sys/mman.h>
-#include <pthread.h>
-#include <errno.h>
-#include <stdbool.h>
-
-int pthread_mutex_consistent_np(pthread_mutex_t *);
+#include "replace.h"
+#include "system/filesys.h"
+#include "system/wait.h"
+#include "system/shmem.h"
+#include "system/threads.h"
 
 static void set_realtime(void)
 {
@@ -99,7 +89,7 @@ static void run_child(const char *filename)
 again:
        ret = pthread_mutex_lock(mutex);
        if (ret == EOWNERDEAD) {
-               ret = pthread_mutex_consistent_np(mutex);
+               ret = pthread_mutex_consistent(mutex);
        } else if (ret == EAGAIN) {
                goto again;
        }
@@ -172,7 +162,7 @@ int main(int argc, const char **argv)
        if (strcmp(argv[2], "debug") == 0) {
                ret = pthread_mutex_trylock(mutex);
                if (ret == EOWNERDEAD) {
-                       ret = pthread_mutex_consistent_np(mutex);
+                       ret = pthread_mutex_consistent(mutex);
                        if (ret == 0) {
                                pthread_mutex_unlock(mutex);
                        }