gdb: add target_ops::supports_displaced_step
[deliverable/binutils-gdb.git] / gold / reloc.h
index 72f6c4681ead72e691f19ad373f742d264372dd8..492c3fadfd1326201a6de1a6e8c0d886cddc8331 100644 (file)
@@ -1,6 +1,6 @@
 // reloc.h -- relocate input files for gold   -*- C++ -*-
 
-// Copyright (C) 2006-2016 Free Software Foundation, Inc.
+// Copyright (C) 2006-2020 Free Software Foundation, Inc.
 // Written by Ian Lance Taylor <iant@google.com>.
 
 // This file is part of gold.
@@ -974,6 +974,26 @@ class Relocate_functions
                              CHECK_NONE); }
 };
 
+// Convenience class for min and max values of a given BITS length.
+
+template<int bits>
+class Limits
+{
+ public:
+  static const uint64_t MAX_UNSIGNED = (1ULL << bits) - 1;
+  static const int64_t MAX_SIGNED = MAX_UNSIGNED >> 1;
+  static const int64_t MIN_SIGNED = -MAX_SIGNED - 1;
+};
+
+template<>
+class Limits<64>
+{
+ public:
+  static const uint64_t MAX_UNSIGNED = ~0ULL;
+  static const int64_t MAX_SIGNED = MAX_UNSIGNED >> 1;
+  static const int64_t MIN_SIGNED = -MAX_SIGNED - 1;
+};
+
 // Integer manipulation functions used by various targets when
 // performing relocations.
 
@@ -1006,8 +1026,8 @@ class Bits
     gold_assert(bits > 0 && bits <= 32);
     if (bits == 32)
       return false;
-    int32_t max = (1 << (bits - 1)) - 1;
-    int32_t min = -(1 << (bits - 1));
+    const int32_t max = static_cast<int32_t>(Limits<bits>::MAX_SIGNED);
+    const int32_t min = static_cast<int32_t>(Limits<bits>::MIN_SIGNED);
     int32_t as_signed = static_cast<int32_t>(val);
     return as_signed > max || as_signed < min;
   }
@@ -1020,7 +1040,7 @@ class Bits
     gold_assert(bits > 0 && bits <= 32);
     if (bits == 32)
       return false;
-    uint32_t max = static_cast<uint32_t>((1U << bits) - 1);
+    const uint32_t max = static_cast<uint32_t>(Limits<bits>::MAX_UNSIGNED);
     return val > max;
   }
 
@@ -1034,8 +1054,8 @@ class Bits
     gold_assert(bits > 0 && bits <= 32);
     if (bits == 32)
       return false;
-    int32_t max = static_cast<int32_t>((1U << bits) - 1);
-    int32_t min = -(1 << (bits - 1));
+    const int32_t max = static_cast<int32_t>(Limits<bits>::MAX_UNSIGNED);
+    const int32_t min = static_cast<int32_t>(Limits<bits>::MIN_SIGNED);
     int32_t as_signed = static_cast<int32_t>(val);
     return as_signed > max || as_signed < min;
   }
@@ -1072,8 +1092,8 @@ class Bits
     gold_assert(bits > 0 && bits <= 64);
     if (bits == 64)
       return false;
-    int64_t max = (static_cast<int64_t>(1) << (bits - 1)) - 1;
-    int64_t min = -(static_cast<int64_t>(1) << (bits - 1));
+    const int64_t max = Limits<bits>::MAX_SIGNED;
+    const int64_t min = Limits<bits>::MIN_SIGNED;
     int64_t as_signed = static_cast<int64_t>(val);
     return as_signed > max || as_signed < min;
   }
@@ -1086,7 +1106,7 @@ class Bits
     gold_assert(bits > 0 && bits <= 64);
     if (bits == 64)
       return false;
-    uint64_t max = (static_cast<uint64_t>(1) << bits) - 1;
+    const uint64_t max = Limits<bits>::MAX_UNSIGNED;
     return val > max;
   }
 
@@ -1100,8 +1120,8 @@ class Bits
     gold_assert(bits > 0 && bits <= 64);
     if (bits == 64)
       return false;
-    int64_t max = static_cast<int64_t>((static_cast<uint64_t>(1) << bits) - 1);
-    int64_t min = -(static_cast<int64_t>(1) << (bits - 1));
+    const int64_t max = static_cast<int64_t>(Limits<bits>::MAX_UNSIGNED);
+    const int64_t min = Limits<bits>::MIN_SIGNED;
     int64_t as_signed = static_cast<int64_t>(val);
     return as_signed > max || as_signed < min;
   }
This page took 0.025958 seconds and 4 git commands to generate.