1N/A/*-
1N/A * See the file LICENSE for redistribution information.
1N/A *
1N/A * Copyright (c) 1996, 1997
1N/A * Sleepycat Software. All rights reserved.
1N/A */
1N/A/*
1N/A * Copyright (c) 1998 by Sun Microsystems, Inc.
1N/A * All rights reserved.
1N/A */
1N/A
1N/A#include "config.h"
1N/A
1N/A#pragma ident "%Z%%M% %I% %E% SMI"
1N/A
1N/A#ifndef lint
1N/Astatic const char sccsid[] = "@(#)db_byteorder.c 10.4 (Sleepycat) 9/4/97";
1N/Astatic const char sccsi2[] = "%W% (Sun) %G%";
1N/A#endif /* not lint */
1N/A
1N/A#ifndef NO_SYSTEM_INCLUDES
1N/A#include <sys/types.h>
1N/A
1N/A#ifdef HAVE_ENDIAN_H
1N/A#include <endian.h>
1N/A#if BYTE_ORDER == BIG_ENDIAN
1N/A#define WORDS_BIGENDIAN 1
1N/A#endif
1N/A#endif
1N/A
1N/A#include <errno.h>
1N/A#endif
1N/A
1N/A#include "db_int.h"
1N/A#include "common_ext.h"
1N/A
1N/A/*
1N/A * __db_byteorder --
1N/A * Return if we need to do byte swapping, checking for illegal
1N/A * values.
1N/A *
1N/A * PUBLIC: int __db_byteorder __P((DB_ENV *, int));
1N/A */
1N/Aint
1N/A__db_byteorder(dbenv, lorder)
1N/A DB_ENV *dbenv;
1N/A int lorder;
1N/A{
1N/A switch (lorder) {
1N/A case 0:
1N/A break;
1N/A case 1234:
1N/A#if defined(WORDS_BIGENDIAN)
1N/A return (DB_SWAPBYTES);
1N/A#else
1N/A break;
1N/A#endif
1N/A case 4321:
1N/A#if defined(WORDS_BIGENDIAN)
1N/A break;
1N/A#else
1N/A return (DB_SWAPBYTES);
1N/A#endif
1N/A default:
1N/A __db_err(dbenv,
1N/A "illegal byte order, only big and little-endian supported");
1N/A return (EINVAL);
1N/A }
1N/A return (0);
1N/A}