From 3b76db1166132d7704788e5c21f3ecd9f465b1e7 Mon Sep 17 00:00:00 2001 From: nick black Date: Fri, 14 Aug 2020 04:18:29 -0400 Subject: [PATCH] fuck the bullshit it's time to throw down --- include/notcurses/endianness.h | 4 ++++ include/notcurses/notcurses.h | 35 +++++++++++++--------------------- 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/include/notcurses/endianness.h b/include/notcurses/endianness.h index 10bf99ba5..3cdcf67f0 100644 --- a/include/notcurses/endianness.h +++ b/include/notcurses/endianness.h @@ -17,9 +17,11 @@ enum ncendianness_t { // Sprinkle parentheses of salt and recite the ancient incantation... #ifdef __BIG_ENDIAN__ enum { NC_ENDIANNESS = NC_BIGENDIAN }; +#define NC_LITTLEENDIAN 0 #else #ifdef __LITTLE_ENDIAN__ enum { NC_ENDIANNESS = NC_LITENDIAN }; +#define NC_LITTLEENDIAN 1 #else #ifdef BSD #include @@ -28,8 +30,10 @@ enum { NC_ENDIANNESS = NC_LITENDIAN }; #endif #if __BYTE_ORDER == __BIG_ENDIAN enum { NC_ENDIANNESS = NC_BIGENDIAN }; +#define NC_LITTLEENDIAN 0 #elif __BYTE_ORDER == __LITTLE_ENDIAN enum { NC_ENDIANNESS = NC_LITENDIAN }; +#define NC_LITTLEENDIAN 1 #else #error "Couldn't determine endianness" #endif diff --git a/include/notcurses/notcurses.h b/include/notcurses/notcurses.h index 1df35a4e8..795258162 100644 --- a/include/notcurses/notcurses.h +++ b/include/notcurses/notcurses.h @@ -587,30 +587,21 @@ API void cell_release(struct ncplane* n, cell* c); // We want the 2 bytes at the highest address of a 32-bit word, so that the // octet adjacent to g->clusters is left undisturbed as zero. -#ifdef NC_BIGENDIAN -#define NCSTYLE_MASK 0x0000fffful -#define NCSTYLE_STANDOUT 0x00000080ul -#define NCSTYLE_UNDERLINE 0x00000040ul -#define NCSTYLE_REVERSE 0x00000020ul -#define NCSTYLE_BLINK 0x00000010ul -#define NCSTYLE_DIM 0x00000008ul -#define NCSTYLE_BOLD 0x00000004ul -#define NCSTYLE_INVIS 0x00000002ul -#define NCSTYLE_PROTECT 0x00000001ul -#define NCSTYLE_ITALIC 0x00000100ul +#ifdef NC_LITTLEENDIAN +#define NCSTYLE_MASK (0x0000fffful << (16u * !NC_LITTLEENDIAN)) +#define NCSTYLE_STANDOUT (0x00000080ul << (16u * !NC_LITTLEENDIAN)) +#define NCSTYLE_UNDERLINE (0x00000040ul << (16u * !NC_LITTLEENDIAN)) +#define NCSTYLE_REVERSE (0x00000020ul << (16u * !NC_LITTLEENDIAN)) +#define NCSTYLE_BLINK (0x00000010ul << (16u * !NC_LITTLEENDIAN)) +#define NCSTYLE_DIM (0x00000008ul << (16u * !NC_LITTLEENDIAN)) +#define NCSTYLE_BOLD (0x00000004ul << (16u * !NC_LITTLEENDIAN)) +#define NCSTYLE_INVIS (0x00000002ul << (16u * !NC_LITTLEENDIAN)) +#define NCSTYLE_PROTECT (0x00000001ul << (16u * !NC_LITTLEENDIAN)) +#define NCSTYLE_ITALIC (0x00000100ul << (16u * !NC_LITTLEENDIAN)) +#define NCSTYLE_NONE 0 #else -#define NCSTYLE_MASK 0xffff0000ul -#define NCSTYLE_STANDOUT 0x00800000ul -#define NCSTYLE_UNDERLINE 0x00400000ul -#define NCSTYLE_REVERSE 0x00200000ul -#define NCSTYLE_BLINK 0x00100000ul -#define NCSTYLE_DIM 0x00080000ul -#define NCSTYLE_BOLD 0x00040000ul -#define NCSTYLE_INVIS 0x00020000ul -#define NCSTYLE_PROTECT 0x00010000ul -#define NCSTYLE_ITALIC 0x01000000ul +#error "Groping blindly through an uncaring universe, I know not my endianness" #endif -#define NCSTYLE_NONE 0 // Set the specified style bits for the cell 'c', whether they're actively // supported or not.