aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-12-25 16:14:57 +0100
committerChristian Grothoff <christian@grothoff.org>2019-12-25 16:14:57 +0100
commit64d6551e3c6608afcd5dfd5ebdf6ad9bbac0b9f5 (patch)
tree54b7297c6a6c7ffe5b7c9fcce09c520037339ee5 /src
parentd1dea55be8b970f9ecfec06695d03b0ccfcb9c2d (diff)
downloadgnunet-64d6551e3c6608afcd5dfd5ebdf6ad9bbac0b9f5.tar.gz
gnunet-64d6551e3c6608afcd5dfd5ebdf6ad9bbac0b9f5.zip
replace expensive function call with macro for trivial calculation
Diffstat (limited to 'src')
-rw-r--r--src/include/gnunet_common.h14
-rw-r--r--src/transport/transport_api2_communication.c6
-rw-r--r--src/util/common_endian.c8
3 files changed, 27 insertions, 1 deletions
diff --git a/src/include/gnunet_common.h b/src/include/gnunet_common.h
index 3ac186e0b..36f9eee4a 100644
--- a/src/include/gnunet_common.h
+++ b/src/include/gnunet_common.h
@@ -997,6 +997,11 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind);
997 997
998/* ************************* endianess conversion ****************** */ 998/* ************************* endianess conversion ****************** */
999 999
1000#ifdef htonbe64
1001
1002#define GNUNET_htonll(n) htobe64 (n)
1003
1004#else
1000/** 1005/**
1001 * Convert unsigned 64-bit integer to network byte order. 1006 * Convert unsigned 64-bit integer to network byte order.
1002 * 1007 *
@@ -1008,7 +1013,14 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind);
1008uint64_t 1013uint64_t
1009GNUNET_htonll (uint64_t n); 1014GNUNET_htonll (uint64_t n);
1010 1015
1016#endif
1017
1011 1018
1019#ifdef be64toh
1020
1021#define GNUNET_ntohll(n) be64toh (n)
1022
1023#else
1012/** 1024/**
1013 * Convert unsigned 64-bit integer to host byte order. 1025 * Convert unsigned 64-bit integer to host byte order.
1014 * 1026 *
@@ -1020,6 +1032,8 @@ GNUNET_htonll (uint64_t n);
1020uint64_t 1032uint64_t
1021GNUNET_ntohll (uint64_t n); 1033GNUNET_ntohll (uint64_t n);
1022 1034
1035#endif
1036
1023 1037
1024/** 1038/**
1025 * Convert double to network byte order. 1039 * Convert double to network byte order.
diff --git a/src/transport/transport_api2_communication.c b/src/transport/transport_api2_communication.c
index de5b42c3f..9df9424da 100644
--- a/src/transport/transport_api2_communication.c
+++ b/src/transport/transport_api2_communication.c
@@ -872,7 +872,7 @@ GNUNET_TRANSPORT_communicator_receive (
872 { 872 {
873 GNUNET_log ( 873 GNUNET_log (
874 GNUNET_ERROR_TYPE_WARNING, 874 GNUNET_ERROR_TYPE_WARNING,
875 "Dropping message: transprot is too slow, queue length %llu exceeded\n", 875 "Dropping message: transport is too slow, queue length %llu exceeded\n",
876 ch->max_queue_length); 876 ch->max_queue_length);
877 return GNUNET_NO; 877 return GNUNET_NO;
878 } 878 }
@@ -888,6 +888,10 @@ GNUNET_TRANSPORT_communicator_receive (
888 im->expected_address_validity = 888 im->expected_address_validity =
889 GNUNET_TIME_relative_hton (expected_addr_validity); 889 GNUNET_TIME_relative_hton (expected_addr_validity);
890 im->sender = *sender; 890 im->sender = *sender;
891 // FIXME: this is expensive, would be better if we would
892 // re-design the API to allow us to create the envelope first,
893 // and then have the application fill in the body so we do
894 // not have to memcpy()
891 memcpy (&im[1], msg, msize); 895 memcpy (&im[1], msg, msize);
892 if (NULL != cb) 896 if (NULL != cb)
893 { 897 {
diff --git a/src/util/common_endian.c b/src/util/common_endian.c
index fa7d99d85..d69cc1da5 100644
--- a/src/util/common_endian.c
+++ b/src/util/common_endian.c
@@ -31,6 +31,7 @@
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
34#ifndef htonbe64
34uint64_t 35uint64_t
35GNUNET_htonll (uint64_t n) 36GNUNET_htonll (uint64_t n)
36{ 37{
@@ -44,6 +45,10 @@ GNUNET_htonll (uint64_t n)
44} 45}
45 46
46 47
48#endif
49
50
51#ifndef be64toh
47uint64_t 52uint64_t
48GNUNET_ntohll (uint64_t n) 53GNUNET_ntohll (uint64_t n)
49{ 54{
@@ -57,6 +62,9 @@ GNUNET_ntohll (uint64_t n)
57} 62}
58 63
59 64
65#endif
66
67
60/** 68/**
61 * Convert double to network-byte-order. 69 * Convert double to network-byte-order.
62 * @param d the value in network byte order 70 * @param d the value in network byte order