Review at https://gerrit.osmocom.org/2901
Move NUM_BYTES macro to core library It's universally useful so it make sense to have it in the shared core: * move macro from libosmocoding to libosmocore * add OSMO_ prefix * add doxygen docs Change-Id: I5386ba3e1f1cc153ba96c29dc71c9075a052aa02 --- M include/osmocom/coding/gsm0503_coding.h M include/osmocom/core/utils.h M src/coding/gsm0503_coding.c 3 files changed, 3 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/01/2901/1 diff --git a/include/osmocom/coding/gsm0503_coding.h b/include/osmocom/coding/gsm0503_coding.h index 55375bb..2f0e631 100644 --- a/include/osmocom/coding/gsm0503_coding.h +++ b/include/osmocom/coding/gsm0503_coding.h @@ -13,7 +13,6 @@ #define GSM0503_GPRS_BURSTS_NBITS (116 * 4) #define GSM0503_EGPRS_BURSTS_NBITS (348 * 4) -#define NUM_BYTES(N) ((N + 8 - 1) / 8) enum gsm0503_egprs_mcs { EGPRS_MCS0, diff --git a/include/osmocom/core/utils.h b/include/osmocom/core/utils.h index 63a73ab..9042f4b 100644 --- a/include/osmocom/core/utils.h +++ b/include/osmocom/core/utils.h @@ -19,6 +19,8 @@ #define OSMO_STRINGIFY(x) #x /*! \brief Make a value_string entry from an enum value name */ #define OSMO_VALUE_STRING(x) { x, #x } +/*! \brief Number of bytes necessary to store given number of bits */ +#define OSMO_NUM_BYTES(N) ((N + 8 - 1) / 8) #include <stdint.h> #include <stdio.h> diff --git a/src/coding/gsm0503_coding.c b/src/coding/gsm0503_coding.c index 7039863..ea9578a 100644 --- a/src/coding/gsm0503_coding.c +++ b/src/coding/gsm0503_coding.c @@ -901,7 +901,7 @@ u, 0, data_len, 1); /* Return the number of bytes required for the bit message */ - return NUM_BYTES(code->hdr_len + code->data_len); + return OSMO_NUM_BYTES(code->hdr_len + code->data_len); } /*! \brief Decode EGPRS UL message -- To view, visit https://gerrit.osmocom.org/2901 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5386ba3e1f1cc153ba96c29dc71c9075a052aa02 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Max <msur...@sysmocom.de>