mirror of
https://github.com/zeek/zeek.git
synced 2025-10-08 09:38:19 +00:00
GH-696: Add bytestring_to_float BIF
This commit is contained in:
parent
96a14b39fa
commit
7e56605d83
6 changed files with 101 additions and 1 deletions
|
@ -261,6 +261,15 @@ inline double htond(double d)
|
|||
return d;
|
||||
}
|
||||
|
||||
inline float ntohf(float f)
|
||||
{
|
||||
return f;
|
||||
}
|
||||
inline float htonf(float f)
|
||||
{
|
||||
return f;
|
||||
}
|
||||
|
||||
#ifndef HAVE_BYTEORDER_64
|
||||
inline uint64_t ntohll(uint64_t i)
|
||||
{
|
||||
|
@ -299,6 +308,27 @@ inline double htond(double d)
|
|||
return ntohd(d);
|
||||
}
|
||||
|
||||
inline float ntohf(float f)
|
||||
{
|
||||
assert(sizeof(f) == 4);
|
||||
|
||||
float tmp;
|
||||
char* src = (char*)&f;
|
||||
char* dst = (char*)&tmp;
|
||||
|
||||
dst[0] = src[3];
|
||||
dst[1] = src[2];
|
||||
dst[2] = src[1];
|
||||
dst[3] = src[0];
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
inline float htonf(float f)
|
||||
{
|
||||
return ntohf(f);
|
||||
}
|
||||
|
||||
#ifndef HAVE_BYTEORDER_64
|
||||
inline uint64_t ntohll(uint64_t i)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue