]> Kevux Git Server - fll/commitdiff
Update: Lay out the foundation for proper endianness support.
authorKevin Day <thekevinday@gmail.com>
Sat, 15 Jan 2022 23:01:53 +0000 (17:01 -0600)
committerKevin Day <thekevinday@gmail.com>
Sat, 15 Jan 2022 23:01:53 +0000 (17:01 -0600)
The endianness support is not currently a direct goal of the 0.4 versions.
The 0.6 versions will deal with networking and will most certainly need proper endianness support.

Ultimate the FLL needs to properly handle endianness.
Provide the initial functionality needed to make this possible.

The BIG_ENDIAN and LITTLE_ENDIAN cannot be directly relied on.
Provide custom _is_F_endian_big and _is_F_endian_little macros where when BIG_ENDIAN is not defined default to little endian.
By using the custom _is_F_endian_big and _is_F_endian_little, allow for the endianness to be explicit set at compile time.
This should make it easy to configure in cases where BIG_ENDIAN and LITTLE_ENDIAN are not defined.

level_0/f_status/c/status.h
level_0/f_status_string/c/status_string.c
level_0/f_status_string/c/status_string.h
level_0/f_string/c/string-common.h
level_2/fll_status_string/c/status_string.c

index 3e134fdbfd1bc8a82a5758fa91ca409c8b5ec47e..d9ab37f30b9592bb123433dc87cd63771eac3dd7 100644 (file)
@@ -20,9 +20,27 @@ extern "C" {
 #endif
 
 /**
+ * Endianness.
+ *
+ * This is placed here because status is first and endianness must be set before everything else.
+ *
+ * Define either _is_F_endian_big or _is_F_endian_little (but not both) to override compiler detected endianness or to manually set endianness if not detected.
+ */
+#if !defined(_is_F_endian_big) && !defined(_is_F_endian_little)
+  #ifdef BIG_ENDIAN
+    #define _is_F_endian_big
+    #undef _is_F_endian_little
+  #else
+    #undef _is_F_endian_big
+    #define _is_F_endian_little
+  #endif // BIG_ENDIAN
+#endif // !defined(_is_F_endian_big) && !defined(_is_F_endian_little)
+
+/**
  * Status masks.
  */
 #ifndef _di_F_status_masks_
+
   // f_status_t is required to be exactly 16 bits, the first two high order bits represent error and warning respectively.
   #define F_status_bit_error   0x8000 // 1000 0000 0000 0000
   #define F_status_bit_signal  0xc000 // 1100 0000 0000 0000
@@ -209,6 +227,10 @@ extern "C" {
       F_encoding_not,
       F_end,
       F_end_not,
+      F_endian,
+      F_endian_big,
+      F_endian_little,
+      F_endian_not,
       F_eoa,
       F_eoa_not,
       F_eof,
index c08902653bf5a45d068bc1cfb9558b63cb261865..036dd4e62367d9a896b4e4c34b76215aec909f8d 100644 (file)
@@ -143,6 +143,10 @@ extern "C" {
     const f_string_t f_status_encoding_not_s = F_status_encoding_not_s;
     const f_string_t f_status_end_s = F_status_end_s;
     const f_string_t f_status_end_not_s = F_status_end_not_s;
+    const f_string_t f_status_endian_s = F_status_endian_s;
+    const f_string_t f_status_endian_big_s = F_status_endian_big_s;
+    const f_string_t f_status_endian_little_s = F_status_endian_little_s;
+    const f_string_t f_status_endian_not_s = F_status_endian_not_s;
     const f_string_t f_status_eoa_s = F_status_eoa_s;
     const f_string_t f_status_eoa_not_s = F_status_eoa_not_s;
     const f_string_t f_status_eof_s = F_status_eof_s;
@@ -1120,6 +1124,22 @@ extern "C" {
           *string = f_status_end_not_s;
           break;
 
+        case F_endian:
+          *string = f_status_endian_s;
+          break;
+
+        case F_endian_big:
+          *string = f_status_endian_big_s;
+          break;
+
+        case F_endian_little:
+          *string = f_status_endian_little_s;
+          break;
+
+        case F_endian_not:
+          *string = f_status_endian_not_s;
+          break;
+
         case F_eoa:
           *string = f_status_eoa_s;
           break;
index ec28f3f05b4a1da57b956167a001ddd106119ebb..7d6f8ccd945120867b3b6659e573adb7be213605 100644 (file)
@@ -296,6 +296,10 @@ extern "C" {
     #define F_status_encoding_not_s      "F_encoding_not"
     #define F_status_end_s               "F_end"
     #define F_status_end_not_s           "F_end_not"
+    #define F_status_endian_s            "F_endian"
+    #define F_status_endian_big_s        "F_endian_big"
+    #define F_status_endian_little_s     "F_endian_little"
+    #define F_status_endian_not_s        "F_endian_not"
     #define F_status_eoa_s               "F_eoa"
     #define F_status_eoa_not_s           "F_eoa_not"
     #define F_status_eof_s               "F_eof"
@@ -536,6 +540,10 @@ extern "C" {
     #define F_status_encoding_not_s_length      14
     #define F_status_end_s_length               5
     #define F_status_end_not_s_length           9
+    #define F_status_endian_s_length            8
+    #define F_status_endian_big_s_length        12
+    #define F_status_endian_little_s_length     19
+    #define F_status_endian_not_s_length        12
     #define F_status_eoa_s_length               5
     #define F_status_eoa_not_s_length           9
     #define F_status_eof_s_length               5
@@ -776,6 +784,10 @@ extern "C" {
     extern const f_string_t f_status_encoding_not_s;
     extern const f_string_t f_status_end_s;
     extern const f_string_t f_status_end_not_s;
+    extern const f_string_t f_status_endian_s;
+    extern const f_string_t f_status_endian_big_s;
+    extern const f_string_t f_status_endian_little_s;
+    extern const f_string_t f_status_endian_not_s;
     extern const f_string_t f_status_eoa_s;
     extern const f_string_t f_status_eoa_not_s;
     extern const f_string_t f_status_eof_s;
index 639dde2efb3a991d2182262f5f480478891c5f2a..479bc0a7f0cabb837c6b6be3a33202eb2c06108a 100644 (file)
@@ -80,6 +80,7 @@ extern "C" {
 #ifndef _di_f_string_eol_s_
   #define f_string_eol_s f_string_ascii_feed_line_s
   #define F_string_eol_s F_string_ascii_feed_line_s
+
   #define F_string_eol_s_length 1
 #endif // _di_f_string_eol_s_
 
@@ -90,12 +91,14 @@ extern "C" {
 #ifndef _di_f_string_placeholder_s_
   #define f_string_placeholder_s f_string_empty_s
   #define F_string_placeholder_s F_string_empty_s
+
   #define F_string_placeholder_s_length 1
 #endif // _di_f_string_placeholder_s_
 
 #ifndef _di_f_string_space_s_
   #define f_string_space_s f_string_ascii_space_s
   #define F_string_space_s F_string_ascii_space_s
+
   #define F_string_space_s_length 1
 #endif // _di_f_string_space_s_
 
index df898df56d4a388883dcccd04d0bdb8c8c64f73d..5c3d2ebabf90ac975c3a904ace84d0f1b5f0e441 100644 (file)
@@ -817,6 +817,30 @@ extern "C" {
         return F_none;
       }
 
+      if (fl_string_compare(string, f_status_endian_s, length, F_status_endian_s_length) == F_equal_to) {
+        *code = F_endian;
+
+        return F_none;
+      }
+
+      if (fl_string_compare(string, f_status_endian_big_s, length, F_status_endian_big_s_length) == F_equal_to) {
+        *code = F_endian_big;
+
+        return F_none;
+      }
+
+      if (fl_string_compare(string, f_status_endian_little_s, length, F_status_endian_little_s_length) == F_equal_to) {
+        *code = F_endian_little;
+
+        return F_none;
+      }
+
+      if (fl_string_compare(string, f_status_endian_not_s, length, F_status_endian_not_s_length) == F_equal_to) {
+        *code = F_endian_not;
+
+        return F_none;
+      }
+
       if (fl_string_compare(string, f_status_eoa_s, length, F_status_eoa_s_length) == F_equal_to) {
         *code = F_eoa;