Import BSDDB 4.7.25 (as of svn r89086)

This commit is contained in:
Zachary Ware
2017-09-04 13:40:25 -05:00
parent 4b29e0458f
commit 8f590873d0
4781 changed files with 2241032 additions and 6 deletions

63
common/db_byteorder.c Normal file
View File

@@ -0,0 +1,63 @@
/*-
* See the file LICENSE for redistribution information.
*
* Copyright (c) 1996,2008 Oracle. All rights reserved.
*
* $Id: db_byteorder.c 63573 2008-05-23 21:43:21Z trent.nelson $
*/
#include "db_config.h"
#include "db_int.h"
/*
* __db_isbigendian --
* Return 1 if big-endian (Motorola and Sparc), not little-endian
* (Intel and Vax). We do this work at run-time, rather than at
* configuration time so cross-compilation and general embedded
* system support is simpler.
*
* PUBLIC: int __db_isbigendian __P((void));
*/
int
__db_isbigendian()
{
union { /* From Harbison & Steele. */
long l;
char c[sizeof(long)];
} u;
u.l = 1;
return (u.c[sizeof(long) - 1] == 1);
}
/*
* __db_byteorder --
* Return if we need to do byte swapping, checking for illegal
* values.
*
* PUBLIC: int __db_byteorder __P((ENV *, int));
*/
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,
"unsupported byte order, only big and little-endian supported");
return (EINVAL);
}
return (0);
}