summaryrefslogtreecommitdiffstats
path: root/libsyscalls.h
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2023-12-05 20:10:48 +0100
committerMattias Andrée <maandree@kth.se>2023-12-05 20:10:48 +0100
commit6d77b155bcd4725e09837604e6ea86f5f124ba9c (patch)
tree7cfdf466bb94bbbe3e7929432bc048da5eaa2349 /libsyscalls.h
parentSecond commit (diff)
downloadlibsyscalls-6d77b155bcd4725e09837604e6ea86f5f124ba9c.tar.gz
libsyscalls-6d77b155bcd4725e09837604e6ea86f5f124ba9c.tar.bz2
libsyscalls-6d77b155bcd4725e09837604e6ea86f5f124ba9c.tar.xz
Third commit
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'libsyscalls.h')
-rw-r--r--libsyscalls.h25
1 files changed, 20 insertions, 5 deletions
diff --git a/libsyscalls.h b/libsyscalls.h
index 4c904b7..066de20 100644
--- a/libsyscalls.h
+++ b/libsyscalls.h
@@ -1129,8 +1129,9 @@ struct libsyscalls_datatype_description {
enum libsyscalls_datatype_section section;
/**
- * This is a ~0 terminated array describing the order
- * of the bytes the the data type
+ * This is a ~0 terminated array — but, it can also
+ * be terminated by the end of the array — describing
+ * the order of the bytes the the data type
*
* The lowest non-zero values contains the width of
* a byte (in bytes), however no such value exists
@@ -1146,8 +1147,17 @@ struct libsyscalls_datatype_description {
* there is always a value in .byteorder that is 0,
* unless .byteorder[0] is ~0
*
- * To avoid problems checking for ~0, use
- * the LIBSYSCALLS_IS_BYTEORDER_END macro
+ * To avoid problems checking for ~0, use the
+ * LIBSYSCALLS_IS_BYTEORDER_END macro; please also be
+ * aware that both the type and length can change in
+ * the future: do not assume it's `unsigned char`,
+ * and do not assume it has 32 elements, do not only
+ * `LIBSYSCALLS_IS_BYTEORDER_END` to detect ~0, but
+ * also check that no more than
+ * `sizeof(x.byteorder) / sizeof(*x.byteorder)`
+ * elements are read (where x is the instance of the
+ * structure) (you should definitely have your own
+ * macro for that one)
*/
unsigned char byteorder[32];
@@ -1160,8 +1170,13 @@ struct libsyscalls_datatype_description {
* @param SHIFT The value to test `struct libsyscalls_datatype_description.byteorder`
* @return :int Whether the value is ~0
*/
-#define LIBSYSCALLS_IS_BYTEORDER_END(SHIFT)\
+#ifdef UINTMAX_C
+# define LIBSYSCALLS_IS_BYTEORDER_END(SHIFT)\
+ (!~((SHIFT) | ~LIBSYSCALLS_FIELD_MASK_(UINTMAX_C(1), struct libsyscalls_datatype_description, byteorder[0])))
+#else
+# define LIBSYSCALLS_IS_BYTEORDER_END(SHIFT)\
(!~((SHIFT) | ~LIBSYSCALLS_FIELD_MASK_(1ULL, struct libsyscalls_datatype_description, byteorder[0])))
+#endif
};