GM receive events are delivered to the user in network byte order. This enhances the performance of GM programs, but is a minor inconvenience to developers using the GM API. The client must call a special function to convert each field read from the gm_recv_event_t
union to host byte order. Neglecting this conversion will result in undefined program behavior in most cases.
In the absence of automatic checks, endian conversion is typically an error-prone programming task. Therefore, support has been added to GM-1.4 `gm.h' to ensure that no conversion is missing. Note, however, the support is incompatible with the deprecated gm_send()/GM_SENT_EVENT mechanism in GM. All you need to do to activate the checking is add the line
#define GM_STRONG_TYPES 1
\#include "gm.h"
Endian conversion of fields in receive events from network to host order is achieved with the following functions:
Network to host conversion routines.
gm_ntoh_u8() unsigned 8-bit
gm_ntoh_u16() unsigned 16-bit
gm_ntoh_u32() unsigned 32-bit
gm_ntoh_u64() unsigned 64-bit
gm_ntoh_s8() signed 8-bit
gm_ntoh_s16() signed 16-bit
gm_ntoh_s32() signed 32-bit
gm_ntoh_s64() signed 64-bit
Host to network conversion routines.
gm_hton_u8() unsigned 8-bit
gm_hton_u16() unsigned 16-bit
gm_hton_u32() unsigned 32-bit
gm_hton_u64() unsigned 64-bit
gm_hton_s8() signed 8-bit
gm_hton_s16() signed 16-bit
gm_hton_s32() signed 32-bit
gm_hton_s64() signed 64-bit
(1) On 64-bit Solaris machines, the GM_STRONG_TYPES feature can be used during compilation to check for missing conversion, but it the resulting programs will not run and must be recompiled without this feature.