forked from osmocom/wireshark
Use "gfloat" and "gdouble", rather than "float" and "double", as the
return types of the tvbuff accessors for floating-point types, to more closely match the tvbuff accessors for integral types. Fix an error in the code for fetching doubles on VAXes, and get rid of unused union members on VAXes. svn path=/trunk/; revision=5245
This commit is contained in:
parent
1be3f38a96
commit
ed02576048
|
@ -9,7 +9,7 @@
|
|||
* the data of a backing tvbuff, or can be a composite of
|
||||
* other tvbuffs.
|
||||
*
|
||||
* $Id: tvbuff.c,v 1.33 2002/04/24 21:19:38 guy Exp $
|
||||
* $Id: tvbuff.c,v 1.34 2002/04/24 21:53:05 guy Exp $
|
||||
*
|
||||
* Copyright (c) 2000 by Gilbert Ramirez <gram@alumni.rice.edu>
|
||||
*
|
||||
|
@ -1055,7 +1055,7 @@ ieee_float_is_zero(guint32 w)
|
|||
return ((w & ~IEEE_SP_SIGN_MASK) == 0);
|
||||
}
|
||||
|
||||
static float
|
||||
static gfloat
|
||||
get_ieee_float(guint32 w)
|
||||
{
|
||||
long sign;
|
||||
|
@ -1116,7 +1116,7 @@ ieee_double_is_zero(guint64 w)
|
|||
return ((w & ~IEEE_SP_SIGN_MASK) == 0);
|
||||
}
|
||||
|
||||
static double
|
||||
static gdouble
|
||||
get_ieee_double(guint64 w)
|
||||
{
|
||||
gint64 sign;
|
||||
|
@ -1162,14 +1162,14 @@ get_ieee_double(guint64 w)
|
|||
* precision numbers that won't fit in some platform's native
|
||||
* "float" format?
|
||||
*/
|
||||
float
|
||||
gfloat
|
||||
tvb_get_ntohieee_float(tvbuff_t *tvb, int offset)
|
||||
{
|
||||
#if defined(vax)
|
||||
return get_ieee_float(tvb_get_ntohl(tvb, offset));
|
||||
#else
|
||||
union {
|
||||
float f;
|
||||
gfloat f;
|
||||
guint32 w;
|
||||
} ieee_fp_union;
|
||||
|
||||
|
@ -1182,18 +1182,17 @@ tvb_get_ntohieee_float(tvbuff_t *tvb, int offset)
|
|||
* Fetches an IEEE double-precision floating-point number, in
|
||||
* big-endian form, and returns a "double".
|
||||
*/
|
||||
double
|
||||
gdouble
|
||||
tvb_get_ntohieee_double(tvbuff_t *tvb, int offset)
|
||||
{
|
||||
#if defined(vax)
|
||||
union {
|
||||
double d;
|
||||
guint32 w[2];
|
||||
guint64 dw;
|
||||
} ieee_fp_union;
|
||||
#else
|
||||
union {
|
||||
double d;
|
||||
gdouble d;
|
||||
guint32 w[2];
|
||||
} ieee_fp_union;
|
||||
#endif
|
||||
|
@ -1206,7 +1205,7 @@ tvb_get_ntohieee_double(tvbuff_t *tvb, int offset)
|
|||
ieee_fp_union.w[1] = tvb_get_ntohl(tvb, offset);
|
||||
#endif
|
||||
#if defined(vax)
|
||||
return get_ieee_double(dw);
|
||||
return get_ieee_double(ieee_fp_union.dw);
|
||||
#else
|
||||
return ieee_fp_union.d;
|
||||
#endif
|
||||
|
@ -1247,14 +1246,14 @@ tvb_get_letohl(tvbuff_t *tvb, gint offset)
|
|||
* precision numbers that won't fit in some platform's native
|
||||
* "float" format?
|
||||
*/
|
||||
float
|
||||
gfloat
|
||||
tvb_get_letohieee_float(tvbuff_t *tvb, int offset)
|
||||
{
|
||||
#if defined(vax)
|
||||
return get_ieee_float(tvb_get_letohl(tvb, offset));
|
||||
#else
|
||||
union {
|
||||
float f;
|
||||
gfloat f;
|
||||
guint32 w;
|
||||
} ieee_fp_union;
|
||||
|
||||
|
@ -1267,18 +1266,17 @@ tvb_get_letohieee_float(tvbuff_t *tvb, int offset)
|
|||
* Fetches an IEEE double-precision floating-point number, in
|
||||
* little-endian form, and returns a "double".
|
||||
*/
|
||||
double
|
||||
gdouble
|
||||
tvb_get_letohieee_double(tvbuff_t *tvb, int offset)
|
||||
{
|
||||
#if defined(vax)
|
||||
union {
|
||||
double d;
|
||||
guint32 w[2];
|
||||
guint64 dw;
|
||||
} ieee_fp_union;
|
||||
#else
|
||||
union {
|
||||
double d;
|
||||
gdouble d;
|
||||
guint32 w[2];
|
||||
} ieee_fp_union;
|
||||
#endif
|
||||
|
@ -1291,7 +1289,7 @@ tvb_get_letohieee_double(tvbuff_t *tvb, int offset)
|
|||
ieee_fp_union.w[1] = tvb_get_letohl(tvb, offset+4);
|
||||
#endif
|
||||
#if defined(vax)
|
||||
return get_ieee_double(dw);
|
||||
return get_ieee_double(ieee_fp_union.dw);
|
||||
#else
|
||||
return ieee_fp_union.d;
|
||||
#endif
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
* the data of a backing tvbuff, or can be a composite of
|
||||
* other tvbuffs.
|
||||
*
|
||||
* $Id: tvbuff.h,v 1.24 2002/04/12 23:25:24 guy Exp $
|
||||
* $Id: tvbuff.h,v 1.25 2002/04/24 21:53:05 guy Exp $
|
||||
*
|
||||
* Copyright (c) 2000 by Gilbert Ramirez <gram@alumni.rice.edu>
|
||||
*
|
||||
|
@ -230,14 +230,14 @@ extern guint8 tvb_get_guint8(tvbuff_t*, gint offset);
|
|||
extern guint16 tvb_get_ntohs(tvbuff_t*, gint offset);
|
||||
extern guint32 tvb_get_ntoh24(tvbuff_t*, gint offset);
|
||||
extern guint32 tvb_get_ntohl(tvbuff_t*, gint offset);
|
||||
extern float tvb_get_ntohieee_float(tvbuff_t*, gint offset);
|
||||
extern double tvb_get_ntohieee_double(tvbuff_t*, gint offset);
|
||||
extern gfloat tvb_get_ntohieee_float(tvbuff_t*, gint offset);
|
||||
extern gdouble tvb_get_ntohieee_double(tvbuff_t*, gint offset);
|
||||
|
||||
extern guint16 tvb_get_letohs(tvbuff_t*, gint offset);
|
||||
extern guint32 tvb_get_letoh24(tvbuff_t*, gint offset);
|
||||
extern guint32 tvb_get_letohl(tvbuff_t*, gint offset);
|
||||
extern float tvb_get_letohieee_float(tvbuff_t*, gint offset);
|
||||
extern double tvb_get_letohieee_double(tvbuff_t*, gint offset);
|
||||
extern gfloat tvb_get_letohieee_float(tvbuff_t*, gint offset);
|
||||
extern gdouble tvb_get_letohieee_double(tvbuff_t*, gint offset);
|
||||
|
||||
/* Returns target for convenience. Does not suffer from possible
|
||||
* expense of tvb_get_ptr(), since this routine is smart enough
|
||||
|
|
Loading…
Reference in New Issue