Skip to content

Commit

Permalink
core-pragma: move pragma related macros to new header
Browse files Browse the repository at this point in the history
Move pragma macros from stress-ng.h to core-pragma.h as these macros
are only required for just several stressors and it makes cppchecking
faster.

Signed-off-by: Colin Ian King <[email protected]>
  • Loading branch information
ColinIanKing committed Jan 24, 2022
1 parent 2628100 commit d7d5cfc
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 38 deletions.
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,8 @@ OBJS += $(CONFIG_OBJS)

.o: Makefile

%.o: %.c stress-ng.h config.h git-commit-id.h core-capabilities.h core-put.h core-target-clones.h
%.o: %.c stress-ng.h config.h git-commit-id.h core-capabilities.h core-put.h \
core-target-clones.h core-pragma.h
$(Q)echo "CC $<"
$(V)$(CC) $(CFLAGS) -c -o $@ $<

Expand Down Expand Up @@ -492,7 +493,7 @@ dist:
mkdir stress-ng-$(VERSION)
cp -rp Makefile Makefile.config $(SRC) stress-ng.h stress-ng.1 \
core-capabilities.h core-put.h core-target-clones.h \
core-personality.c core-io-uring.c \
core-pragma.h core-personality.c core-io-uring.c \
COPYING syscalls.txt mascot README.md \
stress-af-alg-defconfigs.h README.Android test snap \
TODO core-perf-event.c usr.bin.pulseaudio.eg \
Expand Down
44 changes: 44 additions & 0 deletions core-pragma.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright (C) 2022 Colin Ian King
*
* 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.
*
*/
#ifndef CORE_PRAGMA_H
#define CORE_PRAGMA_H

#if defined(__clang__) && \
NEED_CLANG(4, 0, 0) && \
defined(HAVE_PRAGMA)
#define STRESS_PRAGMA_PUSH _Pragma("GCC diagnostic push")
#define STRESS_PRAGMA_POP _Pragma("GCC diagnostic pop")
#define STRESS_PRAGMA_WARN_OFF _Pragma("GCC diagnostic ignored \"-Weverything\"")
#elif defined(__GNUC__) && \
defined(HAVE_PRAGMA) && \
NEED_GNUC(4, 4, 0)
#define STRESS_PRAGMA_PUSH _Pragma("GCC diagnostic push")
#define STRESS_PRAGMA_POP _Pragma("GCC diagnostic pop")
#define STRESS_PRAGMA_WARN_OFF _Pragma("GCC diagnostic ignored \"-Wall\"") \
_Pragma("GCC diagnostic ignored \"-Wextra\"") \
_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") \
_Pragma("GCC diagnostic ignored \"-Wcast-qual\"") \
_Pragma("GCC diagnostic ignored \"-Wnonnull\"")
#else
#define STRESS_PRAGMA_PUSH
#define STRESS_PRAGMA_POP
#define STRESS_PRAGMA_WARN_OFF
#endif

#endif
1 change: 1 addition & 0 deletions stress-bad-altstack.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/
#include "stress-ng.h"
#include "core-put.h"
#include "core-pragma.h"

static const stress_help_t help[] =
{
Expand Down
1 change: 1 addition & 0 deletions stress-enosys.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*
*/
#include "stress-ng.h"
#include "core-pragma.h"

static const stress_help_t help[] = {
{ NULL, "enosys N", "start N workers that call non-existent system calls" },
Expand Down
1 change: 1 addition & 0 deletions stress-fork.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*
*/
#include "stress-ng.h"
#include "core-pragma.h"

#define MIN_FORKS (1)
#define MAX_FORKS (16000)
Expand Down
22 changes: 0 additions & 22 deletions stress-ng.h
Original file line number Diff line number Diff line change
Expand Up @@ -1410,28 +1410,6 @@ static inline void shim_builtin_prefetch(const void *addr, ...)
#define FORCE_DO_NOTHING() while (0)
#endif

#if defined(__clang__) && \
NEED_CLANG(4, 0, 0) && \
defined(HAVE_PRAGMA)
#define STRESS_PRAGMA_PUSH _Pragma("GCC diagnostic push")
#define STRESS_PRAGMA_POP _Pragma("GCC diagnostic pop")
#define STRESS_PRAGMA_WARN_OFF _Pragma("GCC diagnostic ignored \"-Weverything\"")
#elif defined(__GNUC__) && \
defined(HAVE_PRAGMA) && \
NEED_GNUC(4, 4, 0)
#define STRESS_PRAGMA_PUSH _Pragma("GCC diagnostic push")
#define STRESS_PRAGMA_POP _Pragma("GCC diagnostic pop")
#define STRESS_PRAGMA_WARN_OFF _Pragma("GCC diagnostic ignored \"-Wall\"") \
_Pragma("GCC diagnostic ignored \"-Wextra\"") \
_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") \
_Pragma("GCC diagnostic ignored \"-Wcast-qual\"") \
_Pragma("GCC diagnostic ignored \"-Wnonnull\"")
#else
#define STRESS_PRAGMA_PUSH
#define STRESS_PRAGMA_POP
#define STRESS_PRAGMA_WARN_OFF
#endif

/* Logging helpers */
extern int pr_msg(FILE *fp, const uint64_t flag,
const char *const fmt, va_list va) FORMAT(printf, 3, 0);
Expand Down
10 changes: 2 additions & 8 deletions stress-rseq.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2013-2021 Canonical, Ltd.
* Copyright (C) 2022 Colin Ian King.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
Expand All @@ -14,23 +15,16 @@
* 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.
*
* This code is a complete clean re-write of the stress tool by
* Colin Ian King <[email protected]> and attempts to be
* backwardly compatible with the stress tool by Amos Waterland
* <[email protected]> but has more stress tests and more
* functionality.
*
*/
#include "stress-ng.h"
#include "core-pragma.h"

static const stress_help_t help[] = {
{ NULL, "rseq N", "start N workers that exercise restartable sequences" },
{ NULL, "rseq-ops N", "stop after N bogo restartable sequence operations" },
{ NULL, NULL, NULL }
};


#if defined(HAVE_LINUX_RSEQ_H) && \
defined(HAVE_ASM_NOP) && \
defined(__NR_rseq) && \
Expand Down
8 changes: 2 additions & 6 deletions stress-utime.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2013-2021 Canonical, Ltd.
* Copyright (C) 2022 Colin Ian King.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
Expand All @@ -15,14 +16,9 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* This code is a complete clean re-write of the stress tool by
* Colin Ian King <[email protected]> and attempts to be
* backwardly compatible with the stress tool by Amos Waterland
* <[email protected]> but has more stress tests and more
* functionality.
*
*/
#include "stress-ng.h"
#include "core-pragma.h"

static const stress_help_t help[] = {
{ NULL, "utime N", "start N workers updating file timestamps" },
Expand Down

0 comments on commit d7d5cfc

Please sign in to comment.