about summary refs log tree commit diff
path: root/sysdeps/tile/tilegx/string-endian.h
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/tile/tilegx/string-endian.h')
-rw-r--r--sysdeps/tile/tilegx/string-endian.h22
1 files changed, 17 insertions, 5 deletions
diff --git a/sysdeps/tile/tilegx/string-endian.h b/sysdeps/tile/tilegx/string-endian.h
index 47333891e0..2dbc1e4a4f 100644
--- a/sysdeps/tile/tilegx/string-endian.h
+++ b/sysdeps/tile/tilegx/string-endian.h
@@ -16,24 +16,36 @@
    License along with the GNU C Library.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
-/* Provide a mask based on the pointer alignment that
+#include <endian.h>
+#include <stdint.h>
+
+/* Provide a set of macros to help keep endianness #ifdefs out of
+   the string functions.
+
+   MASK: Provide a mask based on the pointer alignment that
    sets up non-zero bytes before the beginning of the string.
    The MASK expression works because shift counts are taken mod 64.
-   Also, specify how to count "first" and "last" bits
-   when the bits have been read as a word.  */
 
-#include <stdint.h>
+   NULMASK: Clear bytes beyond a given point in the string.
+
+   CFZ: Find the first zero bit in the 8 string bytes in a long.
+
+   REVCZ: Find the last zero bit in the 8 string bytes in a long.
+
+   STRSHIFT: Shift N bits towards the start of the string.  */
 
-#ifndef __BIG_ENDIAN__
+#if __BYTE_ORDER == __LITTLE_ENDIAN
 #define MASK(x) (__insn_shl(1ULL, (x << 3)) - 1)
 #define NULMASK(x) ((2ULL << x) - 1)
 #define CFZ(x) __insn_ctz(x)
 #define REVCZ(x) __insn_clz(x)
+#define STRSHIFT(x,n) ((x) >> n)
 #else
 #define MASK(x) (__insn_shl(-2LL, ((-x << 3) - 1)))
 #define NULMASK(x) (-2LL << (63 - x))
 #define CFZ(x) __insn_clz(x)
 #define REVCZ(x) __insn_ctz(x)
+#define STRSHIFT(x,n) ((x) << n)
 #endif
 
 /* Create eight copies of the byte in a uint64_t.  Byte Shuffle uses