summaryrefslogtreecommitdiff
path: root/src/util/common_endian.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/common_endian.c')
-rw-r--r--src/util/common_endian.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/util/common_endian.c b/src/util/common_endian.c
index d7daa2d79..6ec203dd9 100644
--- a/src/util/common_endian.c
+++ b/src/util/common_endian.c
@@ -11,12 +11,12 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
18 SPDX-License-Identifier: AGPL3.0-or-later 18 SPDX-License-Identifier: AGPL3.0-or-later
19*/ 19 */
20 20
21/** 21/**
22 * @file util/common_endian.c 22 * @file util/common_endian.c
@@ -28,16 +28,16 @@
28#include "platform.h" 28#include "platform.h"
29#include "gnunet_crypto_lib.h" 29#include "gnunet_crypto_lib.h"
30 30
31#define LOG(kind,...) GNUNET_log_from (kind, "util-common-endian",__VA_ARGS__) 31#define LOG(kind, ...) GNUNET_log_from(kind, "util-common-endian", __VA_ARGS__)
32 32
33 33
34uint64_t 34uint64_t
35GNUNET_htonll (uint64_t n) 35GNUNET_htonll(uint64_t n)
36{ 36{
37#if __BYTE_ORDER == __BIG_ENDIAN 37#if __BYTE_ORDER == __BIG_ENDIAN
38 return n; 38 return n;
39#elif __BYTE_ORDER == __LITTLE_ENDIAN 39#elif __BYTE_ORDER == __LITTLE_ENDIAN
40 return (((uint64_t) htonl (n)) << 32) + htonl (n >> 32); 40 return (((uint64_t)htonl(n)) << 32) + htonl(n >> 32);
41#else 41#else
42 #error byteorder undefined 42 #error byteorder undefined
43#endif 43#endif
@@ -45,12 +45,12 @@ GNUNET_htonll (uint64_t n)
45 45
46 46
47uint64_t 47uint64_t
48GNUNET_ntohll (uint64_t n) 48GNUNET_ntohll(uint64_t n)
49{ 49{
50#if __BYTE_ORDER == __BIG_ENDIAN 50#if __BYTE_ORDER == __BIG_ENDIAN
51 return n; 51 return n;
52#elif __BYTE_ORDER == __LITTLE_ENDIAN 52#elif __BYTE_ORDER == __LITTLE_ENDIAN
53 return (((uint64_t) ntohl (n)) << 32) + ntohl (n >> 32); 53 return (((uint64_t)ntohl(n)) << 32) + ntohl(n >> 32);
54#else 54#else
55 #error byteorder undefined 55 #error byteorder undefined
56#endif 56#endif
@@ -63,11 +63,11 @@ GNUNET_ntohll (uint64_t n)
63 * @return the same value in host byte order 63 * @return the same value in host byte order
64 */ 64 */
65double 65double
66GNUNET_hton_double (double d) 66GNUNET_hton_double(double d)
67{ 67{
68 double res; 68 double res;
69 uint64_t *in = (uint64_t *) &d; 69 uint64_t *in = (uint64_t *)&d;
70 uint64_t *out = (uint64_t *) &res; 70 uint64_t *out = (uint64_t *)&res;
71 71
72 out[0] = GNUNET_htonll(in[0]); 72 out[0] = GNUNET_htonll(in[0]);
73 73
@@ -81,11 +81,11 @@ GNUNET_hton_double (double d)
81 * @return the same value in host byte order 81 * @return the same value in host byte order
82 */ 82 */
83double 83double
84GNUNET_ntoh_double (double d) 84GNUNET_ntoh_double(double d)
85{ 85{
86 double res; 86 double res;
87 uint64_t *in = (uint64_t *) &d; 87 uint64_t *in = (uint64_t *)&d;
88 uint64_t *out = (uint64_t *) &res; 88 uint64_t *out = (uint64_t *)&res;
89 89
90 out[0] = GNUNET_ntohll(in[0]); 90 out[0] = GNUNET_ntohll(in[0]);
91 91