File: thread.cmake

package info (click to toggle)
tarantool 2.6.0-1.2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 85,396 kB
  • sloc: ansic: 513,775; cpp: 69,493; sh: 25,650; python: 19,190; perl: 14,973; makefile: 4,176; yacc: 1,329; sql: 1,074; pascal: 620; ruby: 190; awk: 18; lisp: 7
file content (66 lines) | stat: -rw-r--r-- 2,564 bytes parent folder | download | duplicates (3)
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
54
55
56
57
58
59
60
61
62
63
64
65
66
#
# Doing it in a function to avoid polluting the toplevel namespace
function (do_pthread_checks)
    check_include_file(pthread_np.h HAVE_PTHREAD_NP_H)
    if (HAVE_PTHREAD_NP_H)
        set(INCLUDE_MISC_PTHREAD_HEADERS "#include <pthread_np.h>")
    endif ()
    set(CMAKE_REQUIRED_FLAGS -pedantic-errors)
    set(CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE -D_DARWIN_C_SOURCE)
    set(CMAKE_REQUIRED_LIBRARIES pthread)
    # pthread_setname_np(<thread_id>, <name>) - Linux
    check_c_source_compiles("
        #include <pthread.h>
        ${INCLUDE_MISC_PTHREAD_HEADERS}
        int main() { pthread_setname_np(pthread_self(), \"\"); }
        " HAVE_PTHREAD_SETNAME_NP)
    # pthread_setname_np(<name>) - OSX
    check_c_source_compiles("
        #include <pthread.h>
        ${INCLUDE_MISC_PTHREAD_HEADERS}
        int main() { pthread_setname_np(\"\"); }
        " HAVE_PTHREAD_SETNAME_NP_1)
    # pthread_set_name_np(<thread_id>, <name>) - *BSD
    check_c_source_compiles("
        #include <pthread.h>
        ${INCLUDE_MISC_PTHREAD_HEADERS}
        int main() { pthread_set_name_np(pthread_self(), \"\"); }
        " HAVE_PTHREAD_SET_NAME_NP)
    # pthread_getattr_np - Glibc
    check_c_source_compiles("
        #include <pthread.h>
        ${INCLUDE_MISC_PTHREAD_HEADERS}
        int main() { pthread_attr_t a; pthread_getattr_np(pthread_self(), &a); }
        " HAVE_PTHREAD_GETATTR_NP)
    # pthread_stackseg_np - OpenBSD
    check_c_source_compiles("
        #include <pthread.h>
        #ifdef __OpenBSD__
        #include <sys/signal.h>
        #include <pthread_np.h>
        #endif
        ${INCLUDE_MISC_PTHREAD_HEADERS}
        stack_t ss;
        int main() { pthread_stackseg_np(pthread_self(), &ss);
        " HAVE_PTHREAD_STACKSEG_NP)
    # pthread_attr_get_np - xBSD/macOS
    check_c_source_compiles("
        #include <pthread.h>
        ${INCLUDE_MISC_PTHREAD_HEADERS}
        int main() { pthread_attr_t a; pthread_attr_get_np(pthread_self(), &a); }
        " HAVE_PTHREAD_ATTR_GET_NP)
    # pthread_get_stacksize_np - OSX
    check_c_source_compiles("
        #include <pthread.h>
        ${INCLUDE_MISC_PTHREAD_HEADERS}
        int main() { (void)pthread_get_stacksize_np(pthread_self()); }
        " HAVE_PTHREAD_GET_STACKSIZE_NP)
    # pthread_get_stackaddr_np - OSX
    check_c_source_compiles("
        #include <pthread.h>
        ${INCLUDE_MISC_PTHREAD_HEADERS}
        int main() { (void)pthread_get_stackaddr_np(pthread_self()); }
        " HAVE_PTHREAD_GET_STACKADDR_NP)
endfunction (do_pthread_checks)
do_pthread_checks()