]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Clean up pre-gcc-4.4 macros
authorJohn Wolfe <jwolfe@vmware.com>
Mon, 22 Feb 2021 17:36:59 +0000 (09:36 -0800)
committerJohn Wolfe <jwolfe@vmware.com>
Mon, 22 Feb 2021 17:36:59 +0000 (09:36 -0800)
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.

open-vm-tools/lib/include/vm_basic_asm.h
open-vm-tools/lib/include/vm_basic_asm_x86.h
open-vm-tools/lib/include/vm_basic_defs.h
open-vm-tools/lib/include/vm_basic_types.h

index b9ebdec4f0a1f8ded9b25b2e3d1ac200686b62fe..2b6b3181b8a4c8c5f21398cb745b2d758eb04a09 100644 (file)
@@ -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
index 167f9815e053ab758de6657c01367f42e5466333..9cdb262489d1e327e2bb57ac1a72c85ac4a7c6ec 100644 (file)
@@ -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)
index 2a4e1c8cb120b5e951bcf923f746a9c80c337c16..eae9d6a9431ad2abfa3099c471c01404298e4662 100644 (file)
@@ -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 <stdarg.h>
 
-#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 */
index fe9589b72d9b34bfee850301ec35b1f359b3a822..674940f02ff34e465cd64e5e61110fbb09bd8fd2 100644 (file)
@@ -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