8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-24 06:03:02 +01:00

Move xdr_hyper to the correct place and remove duplicate definitions

This commit is contained in:
skidder 2002-11-19 15:37:55 +00:00
parent 86b4eb4e2a
commit fca1b6c9d8
4 changed files with 63 additions and 155 deletions

View File

@ -28,7 +28,7 @@
*
*/
/*
$Id: canonical.cpp,v 1.11 2002-11-16 23:57:18 hippoman Exp $
$Id: canonical.cpp,v 1.12 2002-11-19 15:37:52 skidder Exp $
*/
#include "firebird.h"
@ -71,12 +71,6 @@ static bool_t xdr_quad(register XDR*, register SLONG*);
static int xdr_init(XDR*, LSTRING*, enum xdr_op);
static bool_t xdr_slice(XDR*, LSTRING*, USHORT, UCHAR*);
#ifdef HAVE_XDR_HYPER
extern bool_t xdr_hyper(register XDR *, SINT64 *);
#else
static bool_t xdr_hyper(register XDR *, SINT64 *);
#endif
static xdr_t::xdr_ops burp_ops =
{
burp_getlong,
@ -937,73 +931,4 @@ static bool_t xdr_slice(XDR* xdrs,
}
#ifndef HAVE_XDR_HYPER
static bool_t xdr_hyper(register XDR* xdrs, SINT64* pi64)
{
/**************************************
*
* x d r _ h y p e r
*
**************************************
*
* Functional description
* Map a 64-bit Integer from external to internal representation
* (or vice versa).
*
* Enable this for all platforms except those which supply
* xdr_hyper as part of the system xdr library (initially only
* Solaris, but we expect more over time). This function (normally)
* would have been implemented in REMOTE/xdr.c. Since some system
* XDR libraries (HP-UX) do not implement this function, we have it
* in this module. At a later date, when the function is available
* on all platforms, we can start using the system-provided version.
*
* Handles "swapping" of the 2 long's to be "Endian" sensitive.
*
**************************************/
union
{
SINT64 temp_int64;
SLONG temp_long[2];
} temp;
switch (xdrs->x_op)
{
case XDR_ENCODE:
temp.temp_int64 = *pi64;
#ifndef WORDS_BIGENDIAN
if ((*xdrs->x_ops->x_putlong) (xdrs, &temp.temp_long[1]) &&
(*xdrs->x_ops->x_putlong) (xdrs, &temp.temp_long[0]))
return TRUE;
#else
if ((*xdrs->x_ops->x_putlong) (xdrs, &temp.temp_long[0]) &&
(*xdrs->x_ops->x_putlong) (xdrs, &temp.temp_long[1]))
return TRUE;
#endif
return FALSE;
case XDR_DECODE:
#ifndef WORDS_BIGENDIAN
if (!(*xdrs->x_ops->x_getlong) (xdrs, &temp.temp_long[1]) ||
!(*xdrs->x_ops->x_getlong) (xdrs, &temp.temp_long[0]))
return FALSE;
#else
if (!(*xdrs->x_ops->x_getlong) (xdrs, &temp.temp_long[0]) ||
!(*xdrs->x_ops->x_getlong) (xdrs, &temp.temp_long[1]))
return FALSE;
#endif
*pi64 = temp.temp_int64;
return TRUE;
case XDR_FREE:
return TRUE;
}
/* TMN: Now what? 'assert(0)'? 'abort()'? Anyone having a */
/* clue, feel free to fix the cludge 'return FALSE' */
return FALSE;
}
#endif /* HAVE_XDR_HYPER */
} // extern "C"

View File

@ -71,10 +71,6 @@ static bool_t xdr_cstring(XDR *, CSTRING *);
static bool_t xdr_datum(XDR *, DSC *, BLOB_PTR *);
static bool_t xdr_debug_packet(XDR *, enum xdr_op, PACKET *);
#ifndef HAVE_XDR_HYPER
static bool_t xdr_hyper(register XDR *, SINT64 *);
#endif
static bool_t xdr_longs(XDR *, CSTRING *);
static bool_t xdr_message(XDR *, REM_MSG, FMT);
static bool_t xdr_quad(register XDR *, register struct bid *);
@ -1138,70 +1134,6 @@ static bool_t xdr_debug_packet( XDR * xdrs, enum xdr_op xop, PACKET * packet)
#endif
#ifndef HAVE_XDR_HYPER
static bool_t xdr_hyper( register XDR * xdrs, SINT64 * pi64)
{
/**************************************
*
* x d r _ h y p e r ( n o n - S O L A R I S )
*
**************************************
*
* Functional description
* Map a 64-bit Integer from external to internal representation
* (or vice versa).
*
* Enable this for all platforms except Solaris (since it is
* available in the XDR library on Solaris). This function (normally)
* would have been implemented in REMOTE/xdr.c. Since some system
* XDR libraries (HP-UX) do not implement this function, we have it
* in this module. At a later date, when the function is available
* on all platforms, we can start using the system-provided version.
*
* Handles "swapping" of the 2 long's to be "Endian" sensitive.
*
**************************************/
union {
SINT64 temp_int64;
SLONG temp_long[2];
} temp;
switch (xdrs->x_op) {
case XDR_ENCODE:
temp.temp_int64 = *pi64;
#ifndef WORDS_BIGENDIAN
if ((*xdrs->x_ops->x_putlong) (xdrs, &temp.temp_long[1]) &&
(*xdrs->x_ops->x_putlong) (xdrs, &temp.temp_long[0]))
return TRUE;
#else
if ((*xdrs->x_ops->x_putlong) (xdrs, &temp.temp_long[0]) &&
(*xdrs->x_ops->x_putlong) (xdrs, &temp.temp_long[1]))
return TRUE;
#endif
return FALSE;
case XDR_DECODE:
#ifndef WORDS_BIGENDIAN
if (!(*xdrs->x_ops->x_getlong) (xdrs, &temp.temp_long[1]) ||
!(*xdrs->x_ops->x_getlong) (xdrs, &temp.temp_long[0]))
return FALSE;
#else
if (!(*xdrs->x_ops->x_getlong) (xdrs, &temp.temp_long[0]) ||
!(*xdrs->x_ops->x_getlong) (xdrs, &temp.temp_long[1]))
return FALSE;
#endif
*pi64 = temp.temp_int64;
return TRUE;
case XDR_FREE:
return TRUE;
}
// TMN: added compiler silencier return FALSE.
return FALSE;
}
#endif /* HAVE_XDR_HYPER */
static bool_t xdr_longs( XDR * xdrs, CSTRING * cstring)
{
/**************************************

View File

@ -109,6 +109,67 @@ static const XDR::xdr_ops mem_ops =
static SCHAR zeros[4] = { 0, 0, 0, 0 };
bool_t xdr_hyper( register XDR * xdrs, SINT64 * pi64)
{
/**************************************
*
* x d r _ h y p e r ( n o n - S O L A R I S )
*
**************************************
*
* Functional description
* Map a 64-bit Integer from external to internal representation
* (or vice versa).
*
* Enable this for all platforms except Solaris (since it is
* available in the XDR library on Solaris). This function (normally)
* would have been implemented in REMOTE/xdr.c. Since some system
* XDR libraries (HP-UX) do not implement this function, we have it
* in this module. At a later date, when the function is available
* on all platforms, we can start using the system-provided version.
*
* Handles "swapping" of the 2 long's to be "Endian" sensitive.
*
**************************************/
union {
SINT64 temp_int64;
SLONG temp_long[2];
} temp;
switch (xdrs->x_op) {
case XDR_ENCODE:
temp.temp_int64 = *pi64;
#ifndef WORDS_BIGENDIAN
if ((*xdrs->x_ops->x_putlong) (xdrs, &temp.temp_long[1]) &&
(*xdrs->x_ops->x_putlong) (xdrs, &temp.temp_long[0]))
return TRUE;
#else
if ((*xdrs->x_ops->x_putlong) (xdrs, &temp.temp_long[0]) &&
(*xdrs->x_ops->x_putlong) (xdrs, &temp.temp_long[1]))
return TRUE;
#endif
return FALSE;
case XDR_DECODE:
#ifndef WORDS_BIGENDIAN
if (!(*xdrs->x_ops->x_getlong) (xdrs, &temp.temp_long[1]) ||
!(*xdrs->x_ops->x_getlong) (xdrs, &temp.temp_long[0]))
return FALSE;
#else
if (!(*xdrs->x_ops->x_getlong) (xdrs, &temp.temp_long[0]) ||
!(*xdrs->x_ops->x_getlong) (xdrs, &temp.temp_long[1]))
return FALSE;
#endif
*pi64 = temp.temp_int64;
return TRUE;
case XDR_FREE:
return TRUE;
}
// TMN: added compiler silencier return FALSE.
return FALSE;
}
bool_t xdr_bool( register XDR * xdrs, register bool_t * bp)
{
/**************************************

View File

@ -48,17 +48,7 @@ extern bool_t xdr_u_long (register XDR *, register u_long *);
extern bool_t xdr_u_short (register XDR *, register u_short *);
extern int xdr_union (XDR *, enum xdr_op *, SCHAR *, struct xdr_discrim *, xdrproc_t);
extern bool_t xdr_wrapstring (register XDR *, register SCHAR **);
/* I assume all of these should be from the rpc/xdr.h file
* rather than having the definitions here, but since I don't
* want to create more trouble than I need, Im adding this
* definition here, where it is supplied by the OS. Otherwise
* a local function is defined to do the same task.
* MOD 12-Nov-2002 */
//#ifdef HAVE_XDR_HYPER
//extern bool_t xdr_hyper(register XDR *, SINT64 *);
//#endif
extern bool_t xdr_hyper(register XDR *, SINT64 *);