From c51f5a671e5fc6b78e57df46daf0fdba319dadf7 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 30 Jun 2017 14:07:19 +0300 Subject: Move likely macroses into separate file. --- src/CMakeLists.txt | 1 + src/Makefile.am | 1 + src/being/being.cpp | 1 + src/being/compoundsprite.cpp | 1 + src/localconsts.h | 8 -------- src/particle/particle.cpp | 1 + src/resources/sprite/animatedsprite.cpp | 1 + src/utils/likely.h | 32 ++++++++++++++++++++++++++++++++ 8 files changed, 38 insertions(+), 8 deletions(-) create mode 100644 src/utils/likely.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2a3f68032..e91222219 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -885,6 +885,7 @@ SET(SRCS utils/intmap.h utils/langs.cpp utils/langs.h + utils/likely.h utils/mathutils.h utils/parameters.cpp utils/parameters.h diff --git a/src/Makefile.am b/src/Makefile.am index 0e6a13dd3..87c06296d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -580,6 +580,7 @@ BASE_SRC += events/actionevent.h \ utils/intmap.h \ utils/langs.cpp \ utils/langs.h \ + utils/likely.h \ utils/mathutils.h \ fs/mkdir.cpp \ fs/mkdir.h \ diff --git a/src/being/being.cpp b/src/being/being.cpp index db70e2ab8..bcc3f7d81 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -116,6 +116,7 @@ #include "utils/delete2.h" #include "utils/foreach.h" #include "utils/gettext.h" +#include "utils/likely.h" #include "utils/timer.h" #include "debug.h" diff --git a/src/being/compoundsprite.cpp b/src/being/compoundsprite.cpp index 2bc1d555c..c0b81e715 100644 --- a/src/being/compoundsprite.cpp +++ b/src/being/compoundsprite.cpp @@ -37,6 +37,7 @@ #include "utils/delete2.h" #include "utils/dtor.h" #include "utils/foreach.h" +#include "utils/likely.h" #include "utils/sdlcheckutils.h" #ifndef USE_SDL2 diff --git a/src/localconsts.h b/src/localconsts.h index 64db7f7fb..e669f259b 100644 --- a/src/localconsts.h +++ b/src/localconsts.h @@ -286,14 +286,6 @@ #endif // ENABLE_CILKPLUS #endif // __GNUC__ -#ifdef __GNUC__ -#define A_LIKELY(x) __builtin_expect (!!(x), 1) -#define A_UNLIKELY(x) __builtin_expect (!!(x), 0) -#else // __GNUC__ -#define A_LIKELY(x) (x) -#define A_UNLIKELY(x) (x) -#endif // __GNUC__ - #define notfinal #ifdef ENABLE_CHECKPLUGIN diff --git a/src/particle/particle.cpp b/src/particle/particle.cpp index 92c8a63fe..849464166 100644 --- a/src/particle/particle.cpp +++ b/src/particle/particle.cpp @@ -43,6 +43,7 @@ #include "utils/delete2.h" #include "utils/dtor.h" #include "utils/foreach.h" +#include "utils/likely.h" #include "utils/mathutils.h" #include "utils/mrand.h" diff --git a/src/resources/sprite/animatedsprite.cpp b/src/resources/sprite/animatedsprite.cpp index be620a52c..d2dbc1b72 100644 --- a/src/resources/sprite/animatedsprite.cpp +++ b/src/resources/sprite/animatedsprite.cpp @@ -40,6 +40,7 @@ #include "resources/sprite/animationdelayload.h" #include "utils/delete2.h" +#include "utils/likely.h" #include "utils/mrand.h" #include "debug.h" diff --git a/src/utils/likely.h b/src/utils/likely.h new file mode 100644 index 000000000..0df22a379 --- /dev/null +++ b/src/utils/likely.h @@ -0,0 +1,32 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2017 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * 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 + * 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 . + */ + +#ifndef UTILS_LIKELY_H +#define UTILS_LIKELY_H + +#ifdef __GNUC__ +#define A_LIKELY(x) __builtin_expect (!!(x), 1) +#define A_UNLIKELY(x) __builtin_expect (!!(x), 0) +#else // __GNUC__ +#define A_LIKELY(x) (x) +#define A_UNLIKELY(x) (x) +#endif // __GNUC__ + +#endif // UTILS_LIKELY_H -- cgit v1.2.3-60-g2f50