#include "db_config.h"
#include "db_int.h"
int
__db_isbigendian()
{
union {
long l;
char c[sizeof(long)];
} u;
u.l = 1;
return (u.c[sizeof(long) - 1] == 1);
}
int
__db_byteorder(env, lorder)
ENV *env;
int lorder;
{
switch (lorder) {
case 0:
break;
case 1234:
if (!F_ISSET(env, ENV_LITTLEENDIAN))
return (DB_SWAPBYTES);
break;
case 4321:
if (F_ISSET(env, ENV_LITTLEENDIAN))
return (DB_SWAPBYTES);
break;
default:
__db_errx(env, DB_STR("0041",
"unsupported byte order, only big and little-endian supported"));
return (EINVAL);
}
return (0);
}