github.com/ethereum/go-ethereum@v1.16.1/crypto/secp256k1/libsecp256k1/build-aux/m4/bitcoin_secp.m4 (about)

     1  dnl escape "$0x" below using the m4 quadrigaph @S|@, and escape it again with a \ for the shell.
     2  AC_DEFUN([SECP_X86_64_ASM_CHECK],[
     3  AC_MSG_CHECKING(for x86_64 assembly availability)
     4  AC_LINK_IFELSE([AC_LANG_PROGRAM([[
     5    #include <stdint.h>]],[[
     6    uint64_t a = 11, tmp;
     7    __asm__ __volatile__("movq \@S|@0x100000000,%1; mulq %%rsi" : "+a"(a) : "S"(tmp) : "cc", "%rdx");
     8    ]])], [has_x86_64_asm=yes], [has_x86_64_asm=no])
     9  AC_MSG_RESULT([$has_x86_64_asm])
    10  ])
    11  
    12  AC_DEFUN([SECP_ARM32_ASM_CHECK], [
    13    AC_MSG_CHECKING(for ARM32 assembly availability)
    14    SECP_ARM32_ASM_CHECK_CFLAGS_saved_CFLAGS="$CFLAGS"
    15    CFLAGS="-x assembler"
    16    AC_LINK_IFELSE([AC_LANG_SOURCE([[
    17      .syntax unified
    18      .eabi_attribute 24, 1
    19      .eabi_attribute 25, 1
    20      .text
    21      .global main
    22      main:
    23        ldr r0, =0x002A
    24        mov r7, #1
    25        swi 0   
    26      ]])], [has_arm32_asm=yes], [has_arm32_asm=no])
    27    AC_MSG_RESULT([$has_arm32_asm])
    28    CFLAGS="$SECP_ARM32_ASM_CHECK_CFLAGS_saved_CFLAGS"
    29  ])
    30  
    31  AC_DEFUN([SECP_VALGRIND_CHECK],[
    32  AC_MSG_CHECKING([for valgrind support])
    33  if test x"$has_valgrind" != x"yes"; then
    34    CPPFLAGS_TEMP="$CPPFLAGS"
    35    CPPFLAGS="$VALGRIND_CPPFLAGS $CPPFLAGS"
    36    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
    37      #include <valgrind/memcheck.h>
    38    ]], [[
    39      #if defined(NVALGRIND)
    40      #  error "Valgrind does not support this platform."
    41      #endif
    42    ]])], [has_valgrind=yes])
    43    CPPFLAGS="$CPPFLAGS_TEMP"
    44  fi
    45  AC_MSG_RESULT($has_valgrind)
    46  ])
    47  
    48  AC_DEFUN([SECP_MSAN_CHECK], [
    49  AC_MSG_CHECKING(whether MemorySanitizer is enabled)
    50  AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
    51    #if defined(__has_feature)
    52    #  if __has_feature(memory_sanitizer)
    53         /* MemorySanitizer is enabled. */
    54    #  elif
    55    #    error "MemorySanitizer is disabled."
    56    #  endif
    57    #else
    58    #  error "__has_feature is not defined."
    59    #endif
    60    ]])], [msan_enabled=yes], [msan_enabled=no])
    61  AC_MSG_RESULT([$msan_enabled])
    62  ])
    63  
    64  dnl SECP_TRY_APPEND_CFLAGS(flags, VAR)
    65  dnl Append flags to VAR if CC accepts them.
    66  AC_DEFUN([SECP_TRY_APPEND_CFLAGS], [
    67    AC_MSG_CHECKING([if ${CC} supports $1])
    68    SECP_TRY_APPEND_CFLAGS_saved_CFLAGS="$CFLAGS"
    69    CFLAGS="$1 $CFLAGS"
    70    AC_COMPILE_IFELSE([AC_LANG_SOURCE([[char foo;]])], [flag_works=yes], [flag_works=no])
    71    AC_MSG_RESULT($flag_works)
    72    CFLAGS="$SECP_TRY_APPEND_CFLAGS_saved_CFLAGS"
    73    if test x"$flag_works" = x"yes"; then
    74      $2="$$2 $1"
    75    fi
    76    unset flag_works
    77    AC_SUBST($2)
    78  ])
    79  
    80  dnl SECP_SET_DEFAULT(VAR, default, default-dev-mode)
    81  dnl Set VAR to default or default-dev-mode, depending on whether dev mode is enabled
    82  AC_DEFUN([SECP_SET_DEFAULT], [
    83    if test "${enable_dev_mode+set}" != set; then
    84      AC_MSG_ERROR([[Set enable_dev_mode before calling SECP_SET_DEFAULT]])
    85    fi
    86    if test x"$enable_dev_mode" = x"yes"; then
    87      $1="$3"
    88    else
    89      $1="$2"
    90    fi
    91  ])