GCOBOL: Refactor character type handling for big-endian architectures.
GCOBOL compiler on big-endian systems now handles character data correctly, fixing little-endian assumptions.
This commit refactors the handling of cbl_char_t in the GCOBOL compiler to eliminate assumptions about little-endian architectures. The changes ensure that 32-bit cbl_char_t has consistent meaning on both big-endian and little-endian systems, particularly important when using different execution character sets like EBCDIC or UTF16BE on big-endian platforms such as IBM System Z. Several routines in libgcobol and gcc/cobol have been updated to behave correctly on big-endian machines.
In Details
This change addresses endianness issues in GCOBOL's character handling, particularly affecting big-endian targets like System Z. Previously, assumptions about little-endian byte order in cbl_char_t and related routines (e.g., charmap_load_unaligned, store_uint16) caused incorrect behavior. This commit refactors code in gcc/cobol and libgcobol to ensure consistent representation and manipulation of character data regardless of the host's endianness, supporting GCOBOL's multi-charset and multi-endian capabilities.
- cbl_char_t
- A character type used in GCOBOL, typically 32 bits, whose interpretation can be endianness-dependent.
- GCOBOL
- An implementation of the COBOL programming language, developed as part of the GNU Project.
- endianness
- The order in which a sequence of bytes are stored in computer memory. Big-endian stores the most significant byte first, while little-endian stores the least significant byte first.
- EBCDIC
- Extended Binary Coded Decimal Interchange Code, an 8-bit character encoding used by IBM mainframe and midrange operating systems.
- UTF16BE
- UTF-16 Big Endian, a Unicode encoding scheme that uses 16-bit units and stores the most significant byte first.