From: John Wolfe Date: Mon, 22 Feb 2021 17:36:59 +0000 (-0800) Subject: Clean up pre-gcc-4.4 macros X-Git-Tag: stable-11.3.0~144 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f200cb67cd75913c0850df7758a3adc5a462a688;p=thirdparty%2Fopen-vm-tools.git Clean up pre-gcc-4.4 macros Gcc is now "always" at least gcc-4.4 (checked in vm_basic_types.h), which means many conditionals for earlier gcc can be removed. --- diff --git a/open-vm-tools/lib/include/vm_basic_asm.h b/open-vm-tools/lib/include/vm_basic_asm.h index b9ebdec4f..2b6b3181b 100644 --- a/open-vm-tools/lib/include/vm_basic_asm.h +++ b/open-vm-tools/lib/include/vm_basic_asm.h @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2003-2020 VMware, Inc. All rights reserved. + * Copyright (C) 2003-2021 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -236,10 +236,6 @@ mssb64_0(const uint64 value) * ********************************************************** */ -#if __GNUC__ < 4 -#define FEWER_BUILTINS -#endif - static INLINE int lssb32_0(uint32 v) { @@ -258,7 +254,6 @@ lssb32_0(uint32 v) return __builtin_ffs(value) - 1; } -#ifndef FEWER_BUILTINS static INLINE int mssb32_0(uint32 value) { @@ -311,46 +306,6 @@ lssb64_0(const uint64 v) #endif return __builtin_ffsll(value) - 1; } -#endif /* !FEWER_BUILTINS */ - -#ifdef FEWER_BUILTINS -/* GCC 3.3.x does not like __bulitin_clz or __builtin_ffsll. */ -static INLINE int -mssb32_0(uint32 value) -{ - if (UNLIKELY(value == 0)) { - return -1; - } else { - int pos; - __asm__ __volatile__("bsrl %1, %0\n" : "=r" (pos) : "rm" (value) : "cc"); - return pos; - } -} - -static INLINE int -lssb64_0(const uint64 value) -{ - if (UNLIKELY(value == 0)) { - return -1; - } else { - intptr_t pos; - -#ifdef VM_X86_64 - __asm__ __volatile__("bsf %1, %0\n" : "=r" (pos) : "rm" (value) : "cc"); -#else - /* The coding was chosen to minimize conditionals and operations */ - pos = lssb32_0((uint32) value); - if (pos == -1) { - pos = lssb32_0((uint32) (value >> 32)); - if (pos != -1) { - return pos + 32; - } - } -#endif /* VM_X86_64 */ - return pos; - } -} -#endif /* FEWER_BUILTINS */ static INLINE int @@ -1169,7 +1124,7 @@ RoundUpPow2_32(uint32 value) static INLINE unsigned PopCount32(uint32 value) { -#if defined(__GNUC__) && !defined(FEWER_BUILTINS) && defined(__POPCNT__) +#if defined(__GNUC__) && defined(__POPCNT__) return __builtin_popcount(value); #else /* @@ -1238,7 +1193,7 @@ PopCount32(uint32 value) static INLINE unsigned PopCount64(uint64 value) { -#if defined(__GNUC__) && !defined(FEWER_BUILTINS) && defined(__POPCNT__) +#if defined(__GNUC__) && defined(__POPCNT__) #if defined(VM_X86_64) return __builtin_popcountll(value); #else diff --git a/open-vm-tools/lib/include/vm_basic_asm_x86.h b/open-vm-tools/lib/include/vm_basic_asm_x86.h index 167f9815e..9cdb26248 100644 --- a/open-vm-tools/lib/include/vm_basic_asm_x86.h +++ b/open-vm-tools/lib/include/vm_basic_asm_x86.h @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 1998-2019 VMware, Inc. All rights reserved. + * Copyright (C) 1998-2021 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -342,9 +342,7 @@ Div643264(uint64 dividend, // IN *----------------------------------------------------------------------------- */ -#if defined(__GNUC__) && \ - (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) && \ - !defined(MUL64_NO_ASM) +#if defined(__GNUC__) && !defined(MUL64_NO_ASM) static INLINE uint64 Mul64x3264(uint64 multiplicand, uint32 multiplier, uint32 shift) @@ -449,9 +447,7 @@ Mul64x3264(uint64 multiplicand, uint32 multiplier, uint32 shift) *----------------------------------------------------------------------------- */ -#if defined(__GNUC__) && \ - (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) && \ - !defined(MUL64_NO_ASM) +#if defined(__GNUC__) && !defined(MUL64_NO_ASM) static INLINE int64 Muls64x32s64(int64 multiplicand, uint32 multiplier, uint32 shift) diff --git a/open-vm-tools/lib/include/vm_basic_defs.h b/open-vm-tools/lib/include/vm_basic_defs.h index 2a4e1c8cb..eae9d6a94 100644 --- a/open-vm-tools/lib/include/vm_basic_defs.h +++ b/open-vm-tools/lib/include/vm_basic_defs.h @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2003-2020 VMware, Inc. All rights reserved. + * Copyright (C) 2003-2021 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -454,34 +454,14 @@ void *_ReturnAddress(void); #ifdef __GNUC__ -#ifndef sun - -/* - * A bug in __builtin_frame_address was discovered in gcc 4.1.1, and - * fixed in 4.2.0; assume it originated in 4.0. PR 147638 and 554369. - */ -#if !(__GNUC__ == 4 && (__GNUC_MINOR__ == 0 || __GNUC_MINOR__ == 1)) #define GetFrameAddr() __builtin_frame_address(0) -#endif - -#endif // sun #endif // __GNUC__ -/* - * Data prefetch was added in gcc 3.1.1 - * http://www.gnu.org/software/gcc/gcc-3.1/changes.html - */ #ifdef __GNUC__ -# if ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ > 1) || \ - (__GNUC__ == 3 && __GNUC_MINOR__ == 1 && __GNUC_PATCHLEVEL__ >= 1)) -# define PREFETCH_R(var) __builtin_prefetch((var), 0 /* read */, \ - 3 /* high temporal locality */) -# define PREFETCH_W(var) __builtin_prefetch((var), 1 /* write */, \ - 3 /* high temporal locality */) -# else -# define PREFETCH_R(var) ((void)(var)) -# define PREFETCH_W(var) ((void)(var)) -# endif +# define PREFETCH_R(var) __builtin_prefetch((var), 0 /* read */, \ + 3 /* high temporal locality */) +# define PREFETCH_W(var) __builtin_prefetch((var), 1 /* write */, \ + 3 /* high temporal locality */) #endif /* __GNUC__ */ @@ -544,14 +524,6 @@ typedef int pid_t; // The macOS kernel SDK defines va_copy in stdarg.h. #include -#elif defined(__GNUC__) && (__GNUC__ < 3) - -/* - * Old versions of gcc recognize __va_copy, but not va_copy. - */ - -#define va_copy(dest, src) __va_copy(dest, src) - #endif // _WIN32 #endif // va_copy @@ -812,7 +784,7 @@ typedef int pid_t; * Bug 827422 and 838523. */ -#if defined __GNUC__ && __GNUC__ >= 4 +#if defined __GNUC__ #define VISIBILITY_HIDDEN __attribute__((visibility("hidden"))) #else #define VISIBILITY_HIDDEN /* nothing */ diff --git a/open-vm-tools/lib/include/vm_basic_types.h b/open-vm-tools/lib/include/vm_basic_types.h index fe9589b72..674940f02 100644 --- a/open-vm-tools/lib/include/vm_basic_types.h +++ b/open-vm-tools/lib/include/vm_basic_types.h @@ -866,7 +866,7 @@ typedef void * UserVA; * Note that there is no annotation for "neither." */ -#if defined __GNUC__ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) +#if defined __GNUC__ #define HOT __attribute__((hot)) #define COLD __attribute__((cold)) #else