Bump to m4 1.4.19
[platform/upstream/m4.git] / m4 / sparcv8+.m4
1 # sparcv8+.m4 serial 1
2 dnl Copyright (C) 2020-2021 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
6
7 dnl When compiling for SPARC in 32-bit mode, make sure that instructions for
8 dnl SPARC v8+ are accepted.  This is necessary for multiprocessing (for
9 dnl instructions like 'membar' or 'cas').  All SPARC CPUs made since 1993
10 dnl support this instruction set.  But GCC in its default configuration, in
11 dnl 32-bit mode (64-bit mode assumes SPARC v9 or newer), still defaults to
12 dnl SPARC v7 instruction set: "By default (unless configured otherwise), GCC
13 dnl generates code for the V7 variant of the SPARC architecture."  See
14 dnl <https://gcc.gnu.org/onlinedocs/gcc-4.6.4/gcc/SPARC-Options.html>
15 dnl <https://gcc.gnu.org/onlinedocs/gcc-10.2.0/gcc/SPARC-Options.html>
16
17 AC_DEFUN([gl_SPARC_V8PLUS],
18 [
19   AC_REQUIRE([AC_CANONICAL_HOST])
20
21   case "$host_cpu" in
22     sparc*)
23       if test -n "$GCC"; then
24         AC_CACHE_CHECK([whether SPARC v8+ instructions are supported],
25           [gl_cv_sparc_v8plus],
26           [AC_COMPILE_IFELSE(
27              [AC_LANG_PROGRAM(
28                 [[]],
29                 [[asm volatile ("membar 2");]])],
30              [gl_cv_sparc_v8plus=yes],
31              [gl_cv_sparc_v8plus=no])
32           ])
33         if test $gl_cv_sparc_v8plus = no; then
34           dnl Strangely enough, '-mv8plus' does not have the desired effect.
35           dnl But '-mcpu=v9' does.
36           CC="$CC -mcpu=v9"
37           CXX="$CXX -mcpu=v9"
38         fi
39       fi
40       ;;
41   esac
42 ])