summaryrefslogtreecommitdiffstats
path: root/libsyscalls_get_datatype_description.c
diff options
context:
space:
mode:
Diffstat (limited to 'libsyscalls_get_datatype_description.c')
-rw-r--r--libsyscalls_get_datatype_description.c36
1 files changed, 17 insertions, 19 deletions
diff --git a/libsyscalls_get_datatype_description.c b/libsyscalls_get_datatype_description.c
index a418eb3..974c0fe 100644
--- a/libsyscalls_get_datatype_description.c
+++ b/libsyscalls_get_datatype_description.c
@@ -5,7 +5,8 @@
#include "generated/types.c"
enum libsyscalls_error
-libsyscalls_get_datatype_description(enum libsyscalls_os os, enum libsyscalls_arch arch, enum libsyscalls_datatype datatype,
+libsyscalls_get_datatype_description(enum libsyscalls_os os, enum libsyscalls_arch arch,
+ enum libsyscalls_datatype datatype,
struct libsyscalls_datatype_description *description_out)
{
struct libsyscalls_datatype_description description_discard, larger_type;
@@ -19,7 +20,7 @@ libsyscalls_get_datatype_description(enum libsyscalls_os os, enum libsyscalls_ar
if (!description_out)
description_out = &description_discard;
- if ((unsigned)datatype & ~(LIBSYSCALLS_TYPEBITSMASK | (LIBSYSCALLS_TYPEBITSMASK - 1U)))
+ if ((unsigned)datatype & ~SET_MASK_TRAIL(LIBSYSCALLS_TYPEBITSMASK))
return LIBSYSCALLS_E_INVAL;
datatype ^= class = datatype & LIBSYSCALLS_TYPEBITSMASK;
@@ -63,7 +64,7 @@ libsyscalls_get_datatype_description(enum libsyscalls_os os, enum libsyscalls_ar
memset(description_out->byteorder, ~0, sizeof(description_out->byteorder));
-#define CASE(ARCH, CHARBITS, INTPTR_BITS, SIZE_BITS, ENDIAN, SIGN)\
+#define CASE(ARCH, CHARBITS, INTPTR_BITS, SIZE_BITS, INTMAX_ALIGN, ENDIAN, SIGN)\
case ARCH: description_out->sign_representation = LIBSYSCALLS_SIGN_##SIGN; break
switch ((int)arch) {
LIST_ARCH_SPECS(CASE, ;);
@@ -147,7 +148,8 @@ libsyscalls_get_datatype_description(enum libsyscalls_os os, enum libsyscalls_ar
} else if (datatype >= LIBSYSCALLS_TYPEOFFSET_UNANNOTATED_NUMERICALS) {
unannotated:
- if (datatype - LIBSYSCALLS_TYPEOFFSET_UNANNOTATED_NUMERICALS >= COUNT_LIST(LIBSYSCALLS_LIST_UNANNOTATED_NUMERICALS)) {
+ if (datatype - LIBSYSCALLS_TYPEOFFSET_UNANNOTATED_NUMERICALS
+ >= COUNT_LIST(LIBSYSCALLS_LIST_UNANNOTATED_NUMERICALS)) {
return LIBSYSCALLS_E_INVAL;
} else if (datatype == LIBSYSCALLS_TYPE_MEMORY_ADDRESS) {
datatype = LIBSYSCALLS_TYPE_INTPTR;
@@ -163,7 +165,8 @@ libsyscalls_get_datatype_description(enum libsyscalls_os os, enum libsyscalls_ar
} else if (datatype >= LIBSYSCALLS_TYPEOFFSET_COMPOSITE_PRIMITIVES) {
if (class != LIBSYSCALLS_TYPEBITS_SCALAR)
return LIBSYSCALLS_E_INVAL;
- if (datatype - LIBSYSCALLS_TYPEOFFSET_COMPOSITE_PRIMITIVES >= COUNT_LIST(LIBSYSCALLS_LIST_COMPOSITE_PRIMITIVES))
+ if (datatype - LIBSYSCALLS_TYPEOFFSET_COMPOSITE_PRIMITIVES
+ >= COUNT_LIST(LIBSYSCALLS_LIST_COMPOSITE_PRIMITIVES))
return LIBSYSCALLS_E_INVAL;
datatype = LIBSYSCALLS_TYPE_MEMORY_ADDRESS;
goto unannotated;
@@ -258,7 +261,7 @@ arch_dependent:
goto not_os_dependent;
case LIBSYSCALLS_TYPE_INTPTR:
case LIBSYSCALLS_TYPE_PTRDIFF:
-#define CASE(ARCH, CHARBITS, INTPTR_BITS, SIZE_BITS, ENDIAN, SIGN)\
+#define CASE(ARCH, CHARBITS, INTPTR_BITS, SIZE_BITS, INTMAX_ALIGN, ENDIAN, SIGN)\
case ARCH: description_out->width_in_bits = INTPTR_BITS; break
switch ((int)arch) {
LIST_ARCH_SPECS(CASE, ;);
@@ -268,7 +271,7 @@ arch_dependent:
goto not_os_dependent;
#undef CASE
case LIBSYSCALLS_TYPE_SSIZE:
-#define CASE(ARCH, CHARBITS, INTPTR_BITS, SIZE_BITS, ENDIAN, SIGN)\
+#define CASE(ARCH, CHARBITS, INTPTR_BITS, SIZE_BITS, INTMAX_ALIGN, ENDIAN, SIGN)\
case ARCH: description_out->width_in_bits = SIZE_BITS; break
switch ((int)arch) {
LIST_ARCH_SPECS(CASE, ;);
@@ -314,7 +317,7 @@ not_os_dependent:
if (divide_array_size_with_type_size_out)
description_out->array_size /= description_out->width_in_bits;
-#define CASE(ARCH, CHARBITS, INTPTR_BITS, SIZE_BITS, ENDIAN, SIGN)\
+#define CASE(ARCH, CHARBITS, INTPTR_BITS, SIZE_BITS, INTMAX_ALIGN, ENDIAN, SIGN)\
case ARCH: charbits = CHARBITS; endian = ENDIAN; break
switch ((int)arch) {
LIST_ARCH_SPECS(CASE, ;);
@@ -377,17 +380,12 @@ not_os_dependent:
/* we known from the code above that we are working with split 64-bit integers */
if (half == +1)
- coverage ^= 0xFFFFFFFFFFFFFFFFull;
- if (coverage == 0xFFFFFFFF00000000ull) description_out->section = LIBSYSCALLS_SECTION_UPPER_HALF;
- else if (coverage == 0x00000000FFFFFFFFull) description_out->section = LIBSYSCALLS_SECTION_LOWER_HALF;
- else if (coverage == 0x0000FFFFFFFF0000ull) description_out->section = LIBSYSCALLS_SECTION_INNER_HALF;
- else if (coverage == 0xFFFF00000000FFFFull) description_out->section = LIBSYSCALLS_SECTION_OUTER_HALF;
- else if (coverage == 0x0000FFFF0000FFFFull) description_out->section = LIBSYSCALLS_SECTION_EVEN_QUARTERS_AS_HALF;
- else if (coverage == 0xFFFF0000FFFF0000ull) description_out->section = LIBSYSCALLS_SECTION_ODD_QUARTERS_AS_HALF;
- else if (coverage == 0x00FF00FF00FF00FFull) description_out->section = LIBSYSCALLS_SECTION_EVEN_BYTES_AS_HALF;
- else if (coverage == 0xFF00FF00FF00FF00ull) description_out->section = LIBSYSCALLS_SECTION_ODD_BYTES_AS_HALF;
- else
- abort();
+ coverage ^= 0xFFFFFFFFFFFFFFFFULL;
+#define CASE(SECTION, PAT16_FIRST, PAT16, PAT32_FIRST, PAT32, PAT64_FIRST, PAT64)\
+ if (PAT64_FIRST && LIBSYSCALLS_GET_SECTION_FRACTION(SECTION) && coverage == PAT64##ULL)\
+ description_out->section = SECTION
+ LIBSYSCALLS_LIST_SECTIONS(CASE, ; else); else abort();
+#undef CASE
}
return LIBSYSCALLS_E_OK;