1 /* Copyright (C) 2012 Matthew Fluet.
2 * Copyright (C) 1999-2006 Henry Cejtin, Matthew Fluet, Suresh
3 * Jagannathan, and Stephen Weeks.
4 * Copyright (C) 1997-2000 NEC Research Institute.
6 * MLton is released under a BSD-style license.
7 * See the file MLton-LICENSE for details.
10 static inline bool isBigEndian(void) {
13 /* gcc optimizes the following code to just return the result. */
14 memcpy(&y
, &x
, sizeof(uint8_t));
15 if (y
== 0xAB) return TRUE
; /* big endian */
16 if (y
== 0xCD) return FALSE
; /* little endian */
17 die ("Could not detect endian --- neither big nor little!\n");
21 static inline bool isLittleEndian(void) {
22 return not (isBigEndian());