From 6e284b80db8accc5546516fbac0c21a6d0c7890c Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Wed, 15 Dec 2021 11:19:08 -0500 Subject: [PATCH] configure: enable extended compiler warnings Import the compiler warning flag detection system from liburcu and enable extended compiler warnings. Change-Id: I13bfbaed702c28e2816b13b78fb006462d6d5f92 Signed-off-by: Michael Jeanson Signed-off-by: Mathieu Desnoyers --- configure.ac | 53 ++++++- m4/ae_config_feature.m4 | 258 ++++++++++++++++++++++++++++++++++ m4/ax_append_compile_flags.m4 | 46 ++++++ m4/ax_append_flag.m4 | 50 +++++++ m4/ax_check_compile_flag.m4 | 53 +++++++ m4/ax_require_defined.m4 | 37 +++++ tests/basic_percpu_ops_test.c | 18 +-- tests/basic_test.c | 2 +- tests/param_test.c | 38 ++--- 9 files changed, 524 insertions(+), 31 deletions(-) create mode 100644 m4/ae_config_feature.m4 create mode 100644 m4/ax_append_compile_flags.m4 create mode 100644 m4/ax_append_flag.m4 create mode 100644 m4/ax_check_compile_flag.m4 create mode 100644 m4/ax_require_defined.m4 diff --git a/configure.ac b/configure.ac index 4d04530..9075904 100644 --- a/configure.ac +++ b/configure.ac @@ -80,6 +80,44 @@ AC_TYPE_SIZE_T AC_TYPE_UINT32_T AC_TYPE_UINT64_T +# Detect warning flags supported by the C compiler and append them to +# WARN_CFLAGS. +m4_define([WARN_FLAGS_LIST], [ dnl + -Wall dnl + -Wextra dnl + -Wmissing-prototypes dnl + -Wmissing-declarations dnl + -Wnull-dereference dnl + -Wundef dnl + -Wshadow dnl + -Wjump-misses-init dnl + -Wsuggest-attribute=format dnl + -Wtautological-constant-out-of-range-compare dnl + -Wnested-externs dnl + -Wwrite-strings dnl + -Wformat=2 dnl + -Wstrict-aliasing dnl + -Wmissing-noreturn dnl + -Winit-self dnl + -Wduplicated-cond dnl + -Wduplicated-branches dnl + -Wlogical-op dnl + -Wredundant-decls dnl +]) + +# Pass -Werror as an extra flag during the test: this is needed to make the +# -Wunknown-warning-option diagnostic fatal with clang. +AC_LANG_PUSH([C]) +AX_APPEND_COMPILE_FLAGS([WARN_FLAGS_LIST], [WARN_CFLAGS], [-Werror]) +AC_LANG_POP([C]) + +AC_LANG_PUSH([C++]) +AX_APPEND_COMPILE_FLAGS([WARN_FLAGS_LIST], [WARN_CXXFLAGS], [-Werror]) +AC_LANG_POP([C++]) + +AE_IF_FEATURE_ENABLED([Werror], [WARN_CFLAGS="${WARN_CFLAGS} -Werror"]) +AE_IF_FEATURE_ENABLED([Werror], [WARN_CXXFLAGS="${WARN_CXXFLAGS} -Werror"]) + ## ## ## C++ compiler checks ## @@ -148,6 +186,17 @@ AC_CHECK_LIB([dl], [dlopen], [ ]) AC_SUBST(DL_LIBS) + +## ## +## Optional features selection ## +## ## + +# When given, add -Werror to WARN_CFLAGS and WARN_CXXFLAGS. +# Disabled by default +AE_FEATURE_DEFAULT_DISABLE +AE_FEATURE([Werror], [Treat compiler warnings as errors.]) + + ## ## ## Substitute variables for use in Makefile.am ## ## ## @@ -161,10 +210,10 @@ AC_SUBST([RSEQ_LIBRARY_VERSION], [rseq_lib_version]) AM_CPPFLAGS="-I\$(top_builddir)/include -I\$(top_srcdir)/include -include config.h" AC_SUBST(AM_CPPFLAGS) -AM_CFLAGS="-Wall -Wextra $PTHREAD_CFLAGS" +AM_CFLAGS="$WARN_CFLAGS $PTHREAD_CFLAGS" AC_SUBST(AM_CFLAGS) -AM_CXXFLAGS="-Wall -Wextra $PTHREAD_CFLAGS" +AM_CXXFLAGS="$WARN_CXXFLAGS $PTHREAD_CFLAGS" AC_SUBST(AM_CXXFLAGS) diff --git a/m4/ae_config_feature.m4 b/m4/ae_config_feature.m4 new file mode 100644 index 0000000..1d7cd58 --- /dev/null +++ b/m4/ae_config_feature.m4 @@ -0,0 +1,258 @@ +# +# SYNOPSIS +# +# AE_FEATURE(FEATURE-NAME, FEATURE-DESCRIPTION, +# ACTION-IF-GIVEN?, ACTION-IF-NOT-GIVEN?, +# ACTION-IF-ENABLED?, ACTION-IF-NOT-ENABLED?) +# +# DESCRIPTION +# +# AE_FEATURE is a simple wrapper for AC_ARG_ENABLE. +# +# FEATURE-NAME should consist only of alphanumeric characters, dashes, +# plus signs, and dots. +# +# FEATURE-DESCRIPTION will be formatted with AS_HELP_STRING. +# +# If the user gave configure the option --enable-FEATURE or --disable-FEATURE, +# run shell commands ACTION-IF-GIVEN. If neither option was given, run shell +# commands ACTION-IF-NOT-GIVEN. The name feature indicates an optional +# +# If the feature is enabled, run shell commands ACTION-IF-ENABLED, if it is +# disabled, run shell commands ACTION-IF-NOT-ENABLED. +# +# A FEATURE has 3 different states, enabled, disabled and undefined. The first +# two are self explanatory, the third state means it's disabled by default +# and it was not explicitly enabled or disabled by the user or by the +# AE_FEATURE_ENABLE and AE_FEATURE_DISABLE macros. +# +# A feature is disabled by default, in order to change this behaviour use the +# AE_FEATURE_DEFAULT_ENABLE and AE_FEATURE_DEFAULT_DISABLE +# macros. +# +# A simple example: +# +# AE_FEATURE_DEFAULT_ENABLE +# AE_FEATURE(feature_xxxxx, [turns on/off XXXXX support]) +# +# ... +# +# AE_FEATURE_DEFAULT_DISABLE +# AE_FEATURE(feature_yyyyy, [turns on/off YYYYY support]) +# AM_CONDITIONAL(YYYYY, AE_IS_FEATURE_ENABLED([feature_yyyyy])) +# +# AE_FEATURE_DEFAULT_ENABLE +# AE_FEATURE(...) +# +# ... +# +# Use AE_FEATURE_ENABLE or AE_FEATURE_DISABLE in order to +# enable or disable a specific feature. +# +# Another simple example: +# +# AS_IF([some_test_here],[AE_FEATURE_ENABLE(feature_xxxxx)],[]) +# +# AE_FEATURE(feature_xxxxx, [turns on/off XXXXX support], +# HAVE_XXXXX, [Define if you want XXXXX support]) +# AE_FEATURE(feature_yyyyy, [turns on/off YYYYY support], +# HAVE_YYYYY, [Define if you want YYYYY support]) +# +# ... +# +# NOTE: AE_FEATURE_ENABLE/DISABLE() must be placed first of the relative +# AE_FEATURE() macro if you want the the proper ACTION-IF-ENABLED and +# ACTION-IF-NOT-ENABLED to run. +# +# LICENSE +# +# Copyright (c) 2020 Michael Jeanson +# Copyright (c) 2008 Francesco Salvestrini +# +# 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, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. 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 the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 2 + + +# AE_FEATURE_DEFAULT_ENABLE: The next feature defined with AE_FEATURE will +# default to enable. +AC_DEFUN([AE_FEATURE_DEFAULT_ENABLE], [ + m4_define([ae_feature_default_arg], [yes]) + m4_define([ae_feature_default_switch], [disable]) +]) + + +# AE_FEATURE_DEFAULT_DISABLE: The next feature defined with AE_FEATURE will +# default to disable. +# +AC_DEFUN([AE_FEATURE_DEFAULT_DISABLE], [ + m4_define([ae_feature_default_arg], [no]) + m4_define([ae_feature_default_switch], [enable]) +]) + + +# AE_FEATURE_ENABLE(FEATURE-NAME): Enable the FEATURE, this will override the +# user's choice if it was made. +# +AC_DEFUN([AE_FEATURE_ENABLE],[ dnl + enable_[]patsubst([$1], -, _)[]=yes +]) + + +# AE_FEATURE_DISABLE(FEATURE-NAME): Disable the FEATURE, this will override the +# user's choice if it was made. +# +AC_DEFUN([AE_FEATURE_DISABLE],[ dnl + enable_[]patsubst([$1], -, _)[]=no +]) + + +# AE_IF_FEATURE_ENABLED(FEATURE-NAME, ACTION-IF-ENABLED, ACTION-IF-NOT-ENABLED?): +# Run shell code ACTION-IF-ENABLED if the FEATURE is enabled, otherwise run +# shell code ACTION-IF-NOT-ENABLED. +# +AC_DEFUN([AE_IF_FEATURE_ENABLED],[ dnl +m4_pushdef([FEATURE], patsubst([$1], -, _))dnl + + AS_IF([test "$enable_[]FEATURE[]" = yes],[ dnl + $2 + ],[: dnl + $3 + ]) +]) + + +# AE_IF_FEATURE_NOT_ENABLED(FEATURE-NAME, ACTION-IF-NOT-ENABLED, +# ACTION-IF-NOT-NOT-ENABLED?): +# Run shell code ACTION-IF-NOT-ENABLED if the FEATURE is not explicitly +# enabled, otherwise run shell code ACTION-IF-NOT-NOT-DISABLED. +# +# The distinction with AE_IF_FEATURE_DISABLED is that this will also +# match a feature that is undefined. +# +# A feature is undefined when it's disabled by default and was not explicitly +# enabled or disabled by the user or by AE_FEATURE_ENABLE/DISABLE. +# +AC_DEFUN([AE_IF_FEATURE_NOT_ENABLED],[ dnl +m4_pushdef([FEATURE], patsubst([$1], -, _))dnl + + AS_IF([test "$enable_[]FEATURE[]" != yes],[ dnl + $2 + ],[: dnl + $3 + ]) +]) + + +# AE_IF_FEATURE_DISABLED(FEATURE-NAME, ACTION-IF-DISABLED, ACTION-IF-NOT-DISABLED?): +# Run shell code ACTION-IF-DISABLED if the FEATURE is disabled, otherwise run +# shell code ACTION-IF-NOT-DISABLED. +# +AC_DEFUN([AE_IF_FEATURE_DISABLED],[ dnl +m4_pushdef([FEATURE], patsubst([$1], -, _))dnl + + AS_IF([test "$enable_[]FEATURE[]" = no],[ dnl + $2 + ],[: dnl + $3 + ]) +]) + + +# AE_IF_FEATURE_UNDEF(FEATURE-NAME, ACTION-IF-UNDEF, ACTION-IF-NOT-UNDEF?): +# Run shell code ACTION-IF-UNDEF if the FEATURE is undefined, otherwise run +# shell code ACTION-IF-NOT-UNDEF. +# +# A feature is undefined when it's disabled by default and was not explicitly +# enabled or disabled by the user or by AE_FEATURE_ENABLE/DISABLE. +# +AC_DEFUN([AE_IF_FEATURE_UNDEF],[ dnl +m4_pushdef([FEATURE], patsubst([$1], -, _))dnl + + AS_IF([test "x$enable_[]FEATURE[]" = x],[ dnl + $2 + ],[: dnl + $3 + ]) +]) + + +# AE_IS_FEATURE_ENABLED(FEATURE-NAME): outputs a shell condition (suitable +# for use in a shell if statement) that will return true if the FEATURE is +# enabled. +# +AC_DEFUN([AE_IS_FEATURE_ENABLED],[dnl +m4_pushdef([FEATURE], patsubst([$1], -, _))dnl + test "x$enable_[]FEATURE[]" = xyes dnl +]) + + +dnl Disabled by default, unless already overridden +m4_ifndef([ae_feature_default_arg],[AE_FEATURE_DEFAULT_DISABLE]) + + +# AE_FEATURE(FEATURE-NAME, FEATURE-DESCRIPTION, +# ACTION-IF-GIVEN?, ACTION-IF-NOT-GIVEN?, +# ACTION-IF-ENABLED?, ACTION-IF-NOT-ENABLED?): +# +# +AC_DEFUN([AE_FEATURE],[ dnl +m4_pushdef([FEATURE], patsubst([$1], -, _))dnl + +dnl If the option wasn't specified and the default is enabled, set enable_FEATURE to yes +AS_IF([test "x$enable_[]FEATURE[]" = x && test "ae_feature_default_arg" = yes],[ dnl + enable_[]FEATURE[]="ae_feature_default_arg" +]) + +AC_ARG_ENABLE([$1], + AS_HELP_STRING([--ae_feature_default_switch-$1],dnl + [$2]),[ +case "${enableval}" in + yes) + enable_[]FEATURE[]=yes + ;; + no) + enable_[]FEATURE[]=no + ;; + *) + AC_MSG_ERROR([bad value ${enableval} for feature --$1]) + ;; +esac + +$3 +],[: dnl +$4 +]) + +AS_IF([test "$enable_[]FEATURE[]" = yes],[: dnl + $5 +],[: dnl + $6 +]) + +m4_popdef([FEATURE])dnl +]) diff --git a/m4/ax_append_compile_flags.m4 b/m4/ax_append_compile_flags.m4 new file mode 100644 index 0000000..9c85635 --- /dev/null +++ b/m4/ax_append_compile_flags.m4 @@ -0,0 +1,46 @@ +# ============================================================================ +# https://www.gnu.org/software/autoconf-archive/ax_append_compile_flags.html +# ============================================================================ +# +# SYNOPSIS +# +# AX_APPEND_COMPILE_FLAGS([FLAG1 FLAG2 ...], [FLAGS-VARIABLE], [EXTRA-FLAGS], [INPUT]) +# +# DESCRIPTION +# +# For every FLAG1, FLAG2 it is checked whether the compiler works with the +# flag. If it does, the flag is added FLAGS-VARIABLE +# +# If FLAGS-VARIABLE is not specified, the current language's flags (e.g. +# CFLAGS) is used. During the check the flag is always added to the +# current language's flags. +# +# If EXTRA-FLAGS is defined, it is added to the current language's default +# flags (e.g. CFLAGS) when the check is done. The check is thus made with +# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to +# force the compiler to issue an error when a bad flag is given. +# +# INPUT gives an alternative input source to AC_COMPILE_IFELSE. +# +# NOTE: This macro depends on the AX_APPEND_FLAG and +# AX_CHECK_COMPILE_FLAG. Please keep this macro in sync with +# AX_APPEND_LINK_FLAGS. +# +# LICENSE +# +# Copyright (c) 2011 Maarten Bosmans +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 7 + +AC_DEFUN([AX_APPEND_COMPILE_FLAGS], +[AX_REQUIRE_DEFINED([AX_CHECK_COMPILE_FLAG]) +AX_REQUIRE_DEFINED([AX_APPEND_FLAG]) +for flag in $1; do + AX_CHECK_COMPILE_FLAG([$flag], [AX_APPEND_FLAG([$flag], [$2])], [], [$3], [$4]) +done +])dnl AX_APPEND_COMPILE_FLAGS diff --git a/m4/ax_append_flag.m4 b/m4/ax_append_flag.m4 new file mode 100644 index 0000000..dd6d8b6 --- /dev/null +++ b/m4/ax_append_flag.m4 @@ -0,0 +1,50 @@ +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_append_flag.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_APPEND_FLAG(FLAG, [FLAGS-VARIABLE]) +# +# DESCRIPTION +# +# FLAG is appended to the FLAGS-VARIABLE shell variable, with a space +# added in between. +# +# If FLAGS-VARIABLE is not specified, the current language's flags (e.g. +# CFLAGS) is used. FLAGS-VARIABLE is not changed if it already contains +# FLAG. If FLAGS-VARIABLE is unset in the shell, it is set to exactly +# FLAG. +# +# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. +# +# LICENSE +# +# Copyright (c) 2008 Guido U. Draheim +# Copyright (c) 2011 Maarten Bosmans +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 8 + +AC_DEFUN([AX_APPEND_FLAG], +[dnl +AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_SET_IF +AS_VAR_PUSHDEF([FLAGS], [m4_default($2,_AC_LANG_PREFIX[FLAGS])]) +AS_VAR_SET_IF(FLAGS,[ + AS_CASE([" AS_VAR_GET(FLAGS) "], + [*" $1 "*], [AC_RUN_LOG([: FLAGS already contains $1])], + [ + AS_VAR_APPEND(FLAGS,[" $1"]) + AC_RUN_LOG([: FLAGS="$FLAGS"]) + ]) + ], + [ + AS_VAR_SET(FLAGS,[$1]) + AC_RUN_LOG([: FLAGS="$FLAGS"]) + ]) +AS_VAR_POPDEF([FLAGS])dnl +])dnl AX_APPEND_FLAG diff --git a/m4/ax_check_compile_flag.m4 b/m4/ax_check_compile_flag.m4 new file mode 100644 index 0000000..bd753b3 --- /dev/null +++ b/m4/ax_check_compile_flag.m4 @@ -0,0 +1,53 @@ +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT]) +# +# DESCRIPTION +# +# Check whether the given FLAG works with the current language's compiler +# or gives an error. (Warnings, however, are ignored) +# +# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on +# success/failure. +# +# If EXTRA-FLAGS is defined, it is added to the current language's default +# flags (e.g. CFLAGS) when the check is done. The check is thus made with +# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to +# force the compiler to issue an error when a bad flag is given. +# +# INPUT gives an alternative input source to AC_COMPILE_IFELSE. +# +# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this +# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG. +# +# LICENSE +# +# Copyright (c) 2008 Guido U. Draheim +# Copyright (c) 2011 Maarten Bosmans +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 6 + +AC_DEFUN([AX_CHECK_COMPILE_FLAG], +[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF +AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl +AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [ + ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS + _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1" + AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])], + [AS_VAR_SET(CACHEVAR,[yes])], + [AS_VAR_SET(CACHEVAR,[no])]) + _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags]) +AS_VAR_IF(CACHEVAR,yes, + [m4_default([$2], :)], + [m4_default([$3], :)]) +AS_VAR_POPDEF([CACHEVAR])dnl +])dnl AX_CHECK_COMPILE_FLAGS diff --git a/m4/ax_require_defined.m4 b/m4/ax_require_defined.m4 new file mode 100644 index 0000000..17c3eab --- /dev/null +++ b/m4/ax_require_defined.m4 @@ -0,0 +1,37 @@ +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_require_defined.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_REQUIRE_DEFINED(MACRO) +# +# DESCRIPTION +# +# AX_REQUIRE_DEFINED is a simple helper for making sure other macros have +# been defined and thus are available for use. This avoids random issues +# where a macro isn't expanded. Instead the configure script emits a +# non-fatal: +# +# ./configure: line 1673: AX_CFLAGS_WARN_ALL: command not found +# +# It's like AC_REQUIRE except it doesn't expand the required macro. +# +# Here's an example: +# +# AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG]) +# +# LICENSE +# +# Copyright (c) 2014 Mike Frysinger +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 2 + +AC_DEFUN([AX_REQUIRE_DEFINED], [dnl + m4_ifndef([$1], [m4_fatal([macro ]$1[ is not defined; is a m4 file missing?])]) +])dnl AX_REQUIRE_DEFINED diff --git a/tests/basic_percpu_ops_test.c b/tests/basic_percpu_ops_test.c index 8628862..051a0e2 100644 --- a/tests/basic_percpu_ops_test.c +++ b/tests/basic_percpu_ops_test.c @@ -51,7 +51,7 @@ struct percpu_list { }; /* A simple percpu spinlock. Returns the cpu lock was acquired on. */ -int rseq_this_cpu_lock(struct percpu_lock *lock) +static int rseq_this_cpu_lock(struct percpu_lock *lock) { int cpu; @@ -73,7 +73,7 @@ int rseq_this_cpu_lock(struct percpu_lock *lock) return cpu; } -void rseq_percpu_unlock(struct percpu_lock *lock, int cpu) +static void rseq_percpu_unlock(struct percpu_lock *lock, int cpu) { assert(lock->c[cpu].v == 1); /* @@ -83,7 +83,7 @@ void rseq_percpu_unlock(struct percpu_lock *lock, int cpu) rseq_smp_store_release(&lock->c[cpu].v, 0); } -void *test_percpu_spinlock_thread(void *arg) +static void *test_percpu_spinlock_thread(void *arg) { struct spinlock_test_data *data = (struct spinlock_test_data *) arg; int i, cpu; @@ -113,7 +113,7 @@ void *test_percpu_spinlock_thread(void *arg) * per-cpu increment; however, this is reasonable for a test and the * lock can be extended to synchronize more complicated operations. */ -void test_percpu_spinlock(void) +static void test_percpu_spinlock(void) { const int num_threads = 200; int i; @@ -140,7 +140,7 @@ void test_percpu_spinlock(void) ok(sum == (uint64_t)data.reps * num_threads, "sum"); } -void this_cpu_list_push(struct percpu_list *list, +static void this_cpu_list_push(struct percpu_list *list, struct percpu_list_node *node, int *_cpu) { @@ -170,7 +170,7 @@ void this_cpu_list_push(struct percpu_list *list, * rseq primitive allows us to implement pop without concerns over * ABA-type races. */ -struct percpu_list_node *this_cpu_list_pop(struct percpu_list *list, +static struct percpu_list_node *this_cpu_list_pop(struct percpu_list *list, int *_cpu) { for (;;) { @@ -201,7 +201,7 @@ struct percpu_list_node *this_cpu_list_pop(struct percpu_list *list, * __percpu_list_pop is not safe against concurrent accesses. Should * only be used on lists that are not concurrently modified. */ -struct percpu_list_node *__percpu_list_pop(struct percpu_list *list, int cpu) +static struct percpu_list_node *__percpu_list_pop(struct percpu_list *list, int cpu) { struct percpu_list_node *node; @@ -212,7 +212,7 @@ struct percpu_list_node *__percpu_list_pop(struct percpu_list *list, int cpu) return node; } -void *test_percpu_list_thread(void *arg) +static void *test_percpu_list_thread(void *arg) { int i; struct percpu_list *list = (struct percpu_list *)arg; @@ -242,7 +242,7 @@ void *test_percpu_list_thread(void *arg) } /* Simultaneous modification to a per-cpu linked list from many threads. */ -void test_percpu_list(void) +static void test_percpu_list(void) { int i, j; uint64_t sum = 0, expected_sum = 0; diff --git a/tests/basic_test.c b/tests/basic_test.c index 2813cff..2cf3f95 100644 --- a/tests/basic_test.c +++ b/tests/basic_test.c @@ -17,7 +17,7 @@ #include "tap.h" -void test_cpu_pointer(void) +static void test_cpu_pointer(void) { cpu_set_t affinity, test_affinity; int ret, i; diff --git a/tests/param_test.c b/tests/param_test.c index b423767..3e2ec69 100644 --- a/tests/param_test.c +++ b/tests/param_test.c @@ -357,7 +357,7 @@ static void rseq_percpu_unlock(struct percpu_lock *lock, int cpu) rseq_smp_store_release(&lock->c[cpu].v, 0); } -void *test_percpu_spinlock_thread(void *arg) +static void *test_percpu_spinlock_thread(void *arg) { struct spinlock_thread_test_data *thread_data = (struct spinlock_thread_test_data *) arg; struct spinlock_test_data *data = thread_data->data; @@ -393,7 +393,7 @@ void *test_percpu_spinlock_thread(void *arg) * per-cpu increment; however, this is reasonable for a test and the * lock can be extended to synchronize more complicated operations. */ -void test_percpu_spinlock(void) +static void test_percpu_spinlock(void) { const int num_threads = opt_threads; int i, ret; @@ -436,7 +436,7 @@ void test_percpu_spinlock(void) assert(sum == (uint64_t)opt_reps * num_threads); } -void *test_percpu_inc_thread(void *arg) +static void *test_percpu_inc_thread(void *arg) { struct inc_thread_test_data *thread_data = (struct inc_thread_test_data *) arg; struct inc_test_data *data = thread_data->data; @@ -469,7 +469,7 @@ void *test_percpu_inc_thread(void *arg) return NULL; } -void test_percpu_inc(void) +static void test_percpu_inc(void) { const int num_threads = opt_threads; int i, ret; @@ -512,7 +512,7 @@ void test_percpu_inc(void) assert(sum == (uint64_t)opt_reps * num_threads); } -void this_cpu_list_push(struct percpu_list *list, +static void this_cpu_list_push(struct percpu_list *list, struct percpu_list_node *node, int *_cpu) { @@ -542,7 +542,7 @@ void this_cpu_list_push(struct percpu_list *list, * rseq primitive allows us to implement pop without concerns over * ABA-type races. */ -struct percpu_list_node *this_cpu_list_pop(struct percpu_list *list, +static struct percpu_list_node *this_cpu_list_pop(struct percpu_list *list, int *_cpu) { struct percpu_list_node *node = NULL; @@ -578,7 +578,7 @@ struct percpu_list_node *this_cpu_list_pop(struct percpu_list *list, * __percpu_list_pop is not safe against concurrent accesses. Should * only be used on lists that are not concurrently modified. */ -struct percpu_list_node *__percpu_list_pop(struct percpu_list *list, int cpu) +static struct percpu_list_node *__percpu_list_pop(struct percpu_list *list, int cpu) { struct percpu_list_node *node; @@ -589,7 +589,7 @@ struct percpu_list_node *__percpu_list_pop(struct percpu_list *list, int cpu) return node; } -void *test_percpu_list_thread(void *arg) +static void *test_percpu_list_thread(void *arg) { long long i, reps; struct percpu_list *list = (struct percpu_list *)arg; @@ -617,7 +617,7 @@ void *test_percpu_list_thread(void *arg) } /* Simultaneous modification to a per-cpu linked list from many threads. */ -void test_percpu_list(void) +static void test_percpu_list(void) { const int num_threads = opt_threads; int i, j, ret; @@ -685,7 +685,7 @@ void test_percpu_list(void) assert(sum == expected_sum); } -bool this_cpu_buffer_push(struct percpu_buffer *buffer, +static bool this_cpu_buffer_push(struct percpu_buffer *buffer, struct percpu_buffer_node *node, int *_cpu) { @@ -725,7 +725,7 @@ bool this_cpu_buffer_push(struct percpu_buffer *buffer, return result; } -struct percpu_buffer_node *this_cpu_buffer_pop(struct percpu_buffer *buffer, +static struct percpu_buffer_node *this_cpu_buffer_pop(struct percpu_buffer *buffer, int *_cpu) { struct percpu_buffer_node *head; @@ -762,7 +762,7 @@ struct percpu_buffer_node *this_cpu_buffer_pop(struct percpu_buffer *buffer, * __percpu_buffer_pop is not safe against concurrent accesses. Should * only be used on buffers that are not concurrently modified. */ -struct percpu_buffer_node *__percpu_buffer_pop(struct percpu_buffer *buffer, +static struct percpu_buffer_node *__percpu_buffer_pop(struct percpu_buffer *buffer, int cpu) { struct percpu_buffer_node *head; @@ -776,7 +776,7 @@ struct percpu_buffer_node *__percpu_buffer_pop(struct percpu_buffer *buffer, return head; } -void *test_percpu_buffer_thread(void *arg) +static void *test_percpu_buffer_thread(void *arg) { long long i, reps; struct percpu_buffer *buffer = (struct percpu_buffer *)arg; @@ -808,7 +808,7 @@ void *test_percpu_buffer_thread(void *arg) } /* Simultaneous modification to a per-cpu buffer from many threads. */ -void test_percpu_buffer(void) +static void test_percpu_buffer(void) { const int num_threads = opt_threads; int i, j, ret; @@ -891,7 +891,7 @@ void test_percpu_buffer(void) assert(sum == expected_sum); } -bool this_cpu_memcpy_buffer_push(struct percpu_memcpy_buffer *buffer, +static bool this_cpu_memcpy_buffer_push(struct percpu_memcpy_buffer *buffer, struct percpu_memcpy_buffer_node item, int *_cpu) { @@ -935,7 +935,7 @@ bool this_cpu_memcpy_buffer_push(struct percpu_memcpy_buffer *buffer, return result; } -bool this_cpu_memcpy_buffer_pop(struct percpu_memcpy_buffer *buffer, +static bool this_cpu_memcpy_buffer_pop(struct percpu_memcpy_buffer *buffer, struct percpu_memcpy_buffer_node *item, int *_cpu) { @@ -977,7 +977,7 @@ bool this_cpu_memcpy_buffer_pop(struct percpu_memcpy_buffer *buffer, * __percpu_memcpy_buffer_pop is not safe against concurrent accesses. Should * only be used on buffers that are not concurrently modified. */ -bool __percpu_memcpy_buffer_pop(struct percpu_memcpy_buffer *buffer, +static bool __percpu_memcpy_buffer_pop(struct percpu_memcpy_buffer *buffer, struct percpu_memcpy_buffer_node *item, int cpu) { @@ -991,7 +991,7 @@ bool __percpu_memcpy_buffer_pop(struct percpu_memcpy_buffer *buffer, return true; } -void *test_percpu_memcpy_buffer_thread(void *arg) +static void *test_percpu_memcpy_buffer_thread(void *arg) { long long i, reps; struct percpu_memcpy_buffer *buffer = (struct percpu_memcpy_buffer *)arg; @@ -1024,7 +1024,7 @@ void *test_percpu_memcpy_buffer_thread(void *arg) } /* Simultaneous modification to a per-cpu buffer from many threads. */ -void test_percpu_memcpy_buffer(void) +static void test_percpu_memcpy_buffer(void) { const int num_threads = opt_threads; int i, j, ret; -- 2.34.1