From aaa085ed3478326fe1092c2e5501f7a1fbccdf09 Mon Sep 17 00:00:00 2001 From: Ian Henriksen Date: Mon, 16 Sep 2024 11:25:11 -0700 Subject: [PATCH] Remove detection config for the restrict keyword. This can be done easily in the preprocessor instead. --- config/ax_c_restrict.m4 | 102 ------------------------------------ configure.ac | 1 - include/qthread/common.h.in | 11 ++-- 3 files changed, 6 insertions(+), 108 deletions(-) delete mode 100644 config/ax_c_restrict.m4 diff --git a/config/ax_c_restrict.m4 b/config/ax_c_restrict.m4 deleted file mode 100644 index 9bfe58d59..000000000 --- a/config/ax_c_restrict.m4 +++ /dev/null @@ -1,102 +0,0 @@ -# -*- Autoconf -*- -# -# This file contains a function from Autoconf 2.64 (renamed AX_C_RESTRICT from -# AC_C_RESTRICT, to avoid conflicts), for compatibility with older Autoconfs. -# Original copyright below. -# Remove this file when we drop support for AC 2.59 and older - -# This file is part of Autoconf. -*- Autoconf -*- -# Programming languages support. -# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Free Software -# Foundation, Inc. -# -# 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, 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. -# -# As a special exception, the Free Software Foundation gives unlimited -# permission to copy, distribute and modify the configure scripts that -# are the output of Autoconf. You need not follow the terms of the GNU -# General Public License when using or distributing such scripts, even -# though portions of the text of Autoconf appear in them. The GNU -# General Public License (GPL) does govern all other use of the material -# that constitutes the Autoconf program. -# -# Certain portions of the Autoconf source text are designed to be copied -# (in certain cases, depending on the input) into the output of -# Autoconf. We call these the "data" portions. The rest of the Autoconf -# source text consists of comments plus executable code that decides which -# of the data portions to output in any given case. We call these -# comments and executable code the "non-data" portions. Autoconf never -# copies any of the non-data portions into its output. -# -# This special exception to the GPL applies to versions of Autoconf -# released by the Free Software Foundation. When you make and -# distribute a modified version of Autoconf, you may extend this special -# exception to the GPL to apply to your modified version as well, *unless* -# your modified version has the potential to copy into its output some -# of the text that was the non-data portion of the version that you started -# with. (In other words, unless your change moves or copies text from -# the non-data portions to the data portions.) If your modification has -# such potential, you must delete any notice of this special exception -# to the GPL from your modified version. -# -# Written by David MacKenzie, with help from -# Akim Demaille, Paul Eggert, -# Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor, -# Roland McGrath, Noah Friedman, david d zuhn, and many others. - -# AC_C_RESTRICT -# ------------- -# based on acx_restrict.m4, from the GNU Autoconf Macro Archive at: -# http://autoconf-archive.cryp.to/acx_restrict.html -# -# Determine whether the C/C++ compiler supports the "restrict" keyword -# introduced in ANSI C99, or an equivalent. Define "restrict" to the alternate -# spelling, if any; these are more likely to work in both C and C++ compilers of -# the same family, and in the presence of varying compiler options. If only -# plain "restrict" works, do nothing. Here are some variants: -# - GCC supports both __restrict and __restrict__ -# Otherwise, define "restrict" to be empty. -AN_IDENTIFIER([restrict], [AX_C_RESTRICT]) -AC_DEFUN([AX_C_RESTRICT], -[AC_CACHE_CHECK([for C/C++ restrict keyword], ac_cv_c_restrict, - [ac_cv_c_restrict=no - # The order here caters to the fact that C++ does not require restrict. - for ac_kw in __restrict __restrict__ _Restrict restrict; do - AC_COMPILE_IFELSE([AC_LANG_PROGRAM( - [[typedef int * int_ptr; - int foo (int_ptr $ac_kw ip) { - return ip[0]; - }]], - [[int s[1]; - int * $ac_kw t = s; - t[0] = 0; - return foo(t)]])], - [ac_cv_c_restrict=$ac_kw]) - test "$ac_cv_c_restrict" != no && break - done - ]) - AH_VERBATIM([restrict], -[/* Define to the equivalent of the C99 'restrict' keyword, or to - nothing if this is not supported. Do not define if restrict is - supported directly. */ -#undef restrict -]) - case $ac_cv_c_restrict in - restrict) ;; - no) AC_DEFINE([restrict], []) ;; - *) AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;; - esac -])# AC_C_RESTRICT diff --git a/configure.ac b/configure.ac index 95eac16db..1f8c6415a 100644 --- a/configure.ac +++ b/configure.ac @@ -592,7 +592,6 @@ AS_IF([test "x$qthread_cv_cxx_compiler_type" = "xIntel"], AC_C_CONST AC_C_INLINE -AX_C_RESTRICT AC_C_VOLATILE AS_IF([test "x$enable_third_party_benchmarks" = xyes], [AX_OPENMP([have_openmp=yes], [have_openmp=no]) diff --git a/include/qthread/common.h.in b/include/qthread/common.h.in index f75ffe142..9e0ac5a07 100644 --- a/include/qthread/common.h.in +++ b/include/qthread/common.h.in @@ -71,11 +71,12 @@ /* Last resort, if no function name macros can be found */ #undef __FUNCTION__ -/* Define to the equivalent of the C99 'restrict' keyword, or to - nothing if this is not supported. Do not define if restrict is - supported directly. */ -#ifndef restrict -#undef restrict +#ifdef __cplusplus +#ifdef __GNUC__ +#define restrict __restrict +#else +#define restrict +#endif #endif /* If __builtin_trap can be used */