From 6e4d45b644fcd67de1085edfa1365f1c60cd7c3f Mon Sep 17 00:00:00 2001 From: Moinak Ghosh Date: Wed, 1 May 2013 19:27:43 +0530 Subject: [PATCH] Fix crash with some older GCC versions. Reported in issue #7. --- utils/cpuid.c | 14 +++++++++----- utils/utils.h | 2 ++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/utils/cpuid.c b/utils/cpuid.c index 7af7fcc..3fe06c7 100644 --- a/utils/cpuid.c +++ b/utils/cpuid.c @@ -14,10 +14,10 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program. - * If not, see . + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program. + * If not, see . * * moinakg@belenix.org, http://moinakg.wordpress.com/ */ @@ -112,8 +112,12 @@ cpu_exec_cpuid_ext(uint32_t* regs) exec_cpuid(regs); } +/* + * The function below is not inlined as it appears to bork optimized + * code generation on some older buggy GCC versions. + */ void -cpuid_get_raw_data(struct cpu_raw_data_t* data) +NOINLINE_ATTR cpuid_get_raw_data(struct cpu_raw_data_t* data) { unsigned i; for (i = 0; i < 32; i++) diff --git a/utils/utils.h b/utils/utils.h index a22092e..f6c9720 100644 --- a/utils/utils.h +++ b/utils/utils.h @@ -116,11 +116,13 @@ typedef int32_t bsize_t; # define ATOMIC_SUB(var, val) __sync_fetch_and_sub(&var, val) # define PREFETCH_WRITE(x, n) __builtin_prefetch((x), 1, (n)) # define PREFETCH_READ(x, n) __builtin_prefetch((x), 0, (n)) +# define NOINLINE_ATTR __attribute__((noinline)) #else # define likely(expr) (expr) # define unlikely(expr) (expr) # define PREFETCH_WRITE(x, n) # define PREFETCH_READ(x, n) +# define NOINLINE_ATTR # if defined(sun) || defined (__sun) # include # define ATOMIC_ADD(var, val) atomic_add_int(&var, val)