File: SuiteSparse__thread.cmake

package info (click to toggle)
suitesparse 1%3A7.10.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 254,920 kB
  • sloc: ansic: 1,134,743; cpp: 46,133; makefile: 4,875; fortran: 2,087; java: 1,826; sh: 996; ruby: 725; python: 495; asm: 371; sed: 166; awk: 44
file content (72 lines) | stat: -rw-r--r-- 1,989 bytes parent folder | download | duplicates (4)
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
67
68
69
70
71
72
#-------------------------------------------------------------------------------
# GraphBLAS/cmake_modules/SuiteSparse__thread.cmake
#-------------------------------------------------------------------------------

# Copyright (c) 2017-2025, Timothy A. Davis.  All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0

#-------------------------------------------------------------------------------

# determine if the __thread keyword is available, which is an extension by
# gcc but supported by many compilers, to indicate thread-local-storage.

include ( CheckCSourceCompiles )

set ( thread_src
"   #include <stdio.h>
    __thread int x = 1 ;
    int main (void)
    {
        x = 0 ;
        return (x) ;
    }
" )

set ( declspec_thread_src
"   #include <stdio.h>
    __declspec ( thread ) int x = 1 ;
    int main (void)
    {
        x = 0 ;
        return (x) ;
    }
" )

set ( thread_local_src
"   #include <stdio.h>
    #include <threads.h>
    _Thread_local int x = 1 ;
    int main (void)
    {
        x = 0 ;
        return (x) ;
    }
" )

check_c_source_compiles ( "${declspec_thread_src}" HAVE_KEYWORD__DECLSPEC_THREAD )

check_c_source_compiles ( "${thread_src}" HAVE_KEYWORD__THREAD )

check_c_source_compiles ( "${thread_local_src}" HAVE_KEYWORD__THREAD_LOCAL )

if ( HAVE_KEYWORD__DECLSPEC_THREAD )
    add_compile_definitions ( HAVE_KEYWORD__DECLSPEC_THREAD )
    message ( STATUS "__declspec(thread) keyword: available" )
else ( )
    message ( STATUS "__declspec(thread) keyword: not available" )
endif ( )

if ( HAVE_KEYWORD__THREAD )
    add_compile_definitions ( HAVE_KEYWORD__THREAD )
    message ( STATUS "__thread keyword: available" )
else ( )
    message ( STATUS "__thread keyword: not available" )
endif ( )

if ( HAVE_KEYWORD__THREAD_LOCAL )
    add_compile_definitions ( HAVE_KEYWORD__THREAD_LOCAL )
    message ( STATUS "_Thread_local keyword: available" )
else ( )
    message ( STATUS "_Thread_local_thread keyword: not available" )
endif ( )