aboutsummaryrefslogtreecommitdiff
path: root/src/util/common_endian.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-01-05 15:10:46 +0000
committerChristian Grothoff <christian@grothoff.org>2012-01-05 15:10:46 +0000
commitaa79ba473f5351a046f870601524ba628aaa11b5 (patch)
tree7ac26e4d39a3785c59c36fbf4804bbd48754a1c5 /src/util/common_endian.c
parent08122e992e162831cc62fe7177030fec22712e71 (diff)
downloadgnunet-aa79ba473f5351a046f870601524ba628aaa11b5.tar.gz
gnunet-aa79ba473f5351a046f870601524ba628aaa11b5.zip
-try converting doubles to network byte order
Diffstat (limited to 'src/util/common_endian.c')
-rw-r--r--src/util/common_endian.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/util/common_endian.c b/src/util/common_endian.c
index 34a1dbf54..3a1321463 100644
--- a/src/util/common_endian.c
+++ b/src/util/common_endian.c
@@ -50,5 +50,33 @@ GNUNET_htonll (uint64_t n)
50} 50}
51 51
52 52
53double
54GNUNET_hton_double (double d)
55{
56 double res;
57 unsigned int *in = (unsigned int *) &d;
58 unsigned int *out = (unsigned int *) &res;
59
60 out[0] = htonl(in[0]);
61 out[1] = htonl(in[1]);
62
63 return res;
64}
65
66
67double
68GNUNET_ntoh_double (double d)
69{
70 double res;
71 unsigned int *in = (unsigned int *) &d;
72 unsigned int *out = (unsigned int *) &res;
73
74 out[0] = ntohl(in[0]);
75 out[1] = ntohl(in[1]);
76
77 return res;
78}
79
80
53 81
54/* end of common_endian.c */ 82/* end of common_endian.c */