+2017-11-22 Janne Blomqvist <jb@gcc.gnu.org>
+
+ PR libfortran/83097
+ * io/inquire.c (inquire_via_unit): Use __BYTE_ORDER__ predefined
+ macro.
+ * io/open.c (st_open): Likewise.
+ * io/transfer.c (data_transfer_init): Likewise.
+ * io/write.c (btoa_big): Likewise.
+ (otoa_big): Likewise.
+ (ztoa_big): Likewise.
+ * libgfortran.h (big_endian): Remove variable.
+ (GFOR_POINTER_TO_L1): Use __BYTE_ORDER__ macro.
+ * runtime/main.c (determine_endianness): Remove function.
+ (init): Remove call to determine_endianness.
+ * runtime/minimal.c: Remove setting big_endian variable.
+
2017-11-22 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/36313
else
switch (u->flags.convert)
{
- /* big_endian is 0 for little-endian, 1 for big-endian. */
case GFC_CONVERT_NATIVE:
- p = big_endian ? "BIG_ENDIAN" : "LITTLE_ENDIAN";
+ p = __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ ? "BIG_ENDIAN" : "LITTLE_ENDIAN";
break;
case GFC_CONVERT_SWAP:
- p = big_endian ? "LITTLE_ENDIAN" : "BIG_ENDIAN";
+ p = __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ ? "LITTLE_ENDIAN" : "BIG_ENDIAN";
break;
default:
conv = compile_options.convert;
}
- /* We use big_endian, which is 0 on little-endian machines
- and 1 on big-endian machines. */
switch (conv)
{
case GFC_CONVERT_NATIVE:
break;
case GFC_CONVERT_BIG:
- conv = big_endian ? GFC_CONVERT_NATIVE : GFC_CONVERT_SWAP;
+ conv = __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ ? GFC_CONVERT_NATIVE : GFC_CONVERT_SWAP;
break;
case GFC_CONVERT_LITTLE:
- conv = big_endian ? GFC_CONVERT_SWAP : GFC_CONVERT_NATIVE;
+ conv = __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ ? GFC_CONVERT_SWAP : GFC_CONVERT_NATIVE;
break;
default:
if (conv == GFC_CONVERT_NONE)
conv = compile_options.convert;
- /* We use big_endian, which is 0 on little-endian machines
- and 1 on big-endian machines. */
switch (conv)
{
case GFC_CONVERT_NATIVE:
break;
case GFC_CONVERT_BIG:
- conv = big_endian ? GFC_CONVERT_NATIVE : GFC_CONVERT_SWAP;
+ conv = __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ ? GFC_CONVERT_NATIVE : GFC_CONVERT_SWAP;
break;
case GFC_CONVERT_LITTLE:
- conv = big_endian ? GFC_CONVERT_SWAP : GFC_CONVERT_NATIVE;
+ conv = __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ ? GFC_CONVERT_SWAP : GFC_CONVERT_NATIVE;
break;
default:
int i, j;
q = buffer;
- if (big_endian)
+ if (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
{
const char *p = s;
for (i = 0; i < len; i++)
*q = '\0';
i = k = octet = 0;
- if (big_endian)
+ if (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
{
const char *p = s + len - 1;
char c = *p;
q = buffer;
- if (big_endian)
+ if (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
{
const char *p = s;
for (i = 0; i < len; i++)
simply equal to the kind parameter itself. */
#define GFC_SIZE_OF_CHAR_KIND(kind) (kind)
-/* This will be 0 on little-endian machines and one on big-endian machines. */
-extern int big_endian;
-internal_proto(big_endian);
-
#define GFOR_POINTER_TO_L1(p, kind) \
- (big_endian * (kind - 1) + (GFC_LOGICAL_1 *)(p))
+ ((__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ ? 1: 0) * (kind - 1) + (GFC_LOGICAL_1 *)(p))
#define GFC_INTEGER_1_HUGE \
(GFC_INTEGER_1)((((GFC_UINTEGER_1)1) << 7) - 1)
return;
}
-/* This will be 0 for little-endian
- machines and 1 for big-endian machines. */
-int big_endian = 0;
-
-
-/* Figure out endianness for this machine. */
-
-static void
-determine_endianness (void)
-{
- union
- {
- GFC_LOGICAL_8 l8;
- GFC_LOGICAL_4 l4[2];
- } u;
-
- u.l8 = 1;
- if (u.l4[0])
- big_endian = 0;
- else if (u.l4[1])
- big_endian = 1;
- else
- runtime_error ("Unable to determine machine endianness");
-}
-
static int argc_save;
static char **argv_save;
static void __attribute__((constructor))
init (void)
{
- /* Figure out the machine endianness. */
- determine_endianness ();
-
/* Must be first */
init_variables ();
options_t options;
-/* This will be 0 for little-endian
- machines and 1 for big-endian machines.
-
- Currently minimal libgfortran only runs on little-endian devices
- which don't support constructors so this is just a constant. */
-int big_endian = 0;
-
static int argc_save;
static char **argv_save;