File: sb_concurrency_kit.m4

package info (click to toggle)
sysbench 1.0.20%2Bds-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,840 kB
  • sloc: ansic: 11,830; sh: 1,752; xml: 736; makefile: 195
file content (99 lines) | stat: -rw-r--r-- 3,364 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# Copyright (C) 2016-2017 Alexey Kopytov <akopytov@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

# ---------------------------------------------------------------------------
# Macro: SB_CONCURRENCY_KIT
# ---------------------------------------------------------------------------
AC_DEFUN([SB_CONCURRENCY_KIT], [

AC_ARG_WITH([system-ck],
  AC_HELP_STRING([--with-system-ck],
  [Use system-provided Concurrency Kit headers and library (requires pkg-config)]),
  [sb_use_ck="system"],
  [sb_use_ck="bundled"])

AC_CACHE_CHECK([whether to build with system or bundled Concurrency Kit],
  [sb_cv_lib_ck], [
    AS_IF([test "x$sb_use_ck" = "xsystem"],
    [
      sb_cv_lib_ck=[system]
    ], [
      sb_cv_lib_ck=[bundled]
    ])
  ])

AS_IF([test "x$sb_cv_lib_ck" = "xsystem"],
  # let PKG_CHECK_MODULES set CK_CFLAGS and CK_LIBS for system libck
  [PKG_CHECK_MODULES([CK], [ck])],
  # Set CK_CFLAGS and CK_LIBS manually for bundled libck
  [
    CK_CFLAGS="-I\$(abs_top_builddir)/third_party/concurrency_kit/include"
    CK_LIBS="\$(abs_top_builddir)/third_party/concurrency_kit/lib/libck.a"

    case $target_cpu in
      powerpc*|aarch64)
        # Assume 128-byte cache line on AArch64 and PowerPC
        CPPFLAGS="${CPPFLAGS} -DCK_MD_CACHELINE=128"
        ;;
        # Force --platform=i*86 for CK, otherwise its configure script
        # autodetects target based on 'uname -m' which doesn't work for
        # cross-compiliation
      i486*|i586*)
        CK_CONFIGURE_FLAGS="--platform=i586"
        ;;
      i686*)
        CK_CONFIGURE_FLAGS="--platform=i686"
        ;;
      mips64*)
        CK_CONFIGURE_FLAGS="--use-cc-builtins"
        ;;
    esac
    # Add --enable-lse to CK build flags, if LSE instructions are supported by
    # the target architecture
    if test "$cross_compiling" = no -a "$host_cpu" = aarch64; then
      AC_MSG_CHECKING([whether LSE instructions are supported])
      AC_COMPILE_IFELSE(
        [AC_LANG_PROGRAM(,
        [[
          unsigned long long d = 1, a = 1;
          unsigned long long *t = &a;

          __asm__ __volatile__(
                               "stadd %0, [%1];"
                                  : "+&r" (d)
                                  : "r"   (t)
                                  : "memory");
        ]])],
        [
          CK_CONFIGURE_FLAGS="--enable-lse"
          AC_MSG_RESULT([yes])
        ],
        [
          CK_CONFIGURE_FLAGS=""
          AC_MSG_RESULT([no])
        ]
      )

      AC_SUBST([CK_CONFIGURE_FLAGS])
    fi
  ]
)

AC_DEFINE_UNQUOTED([SB_WITH_CK], ["$sb_use_ck"],
  [Whether system or bundled Concurrency Ki is used])

AM_CONDITIONAL([USE_BUNDLED_CK], [test "x$sb_use_ck" = xbundled])
])