fixeria has submitted this change. ( https://gerrit.osmocom.org/c/osmo-pcu/+/34521?usp=email )
Change subject: pdch_ul_controller: migrate from fn_cmp() to gsm0502_fncmp() ......................................................................
pdch_ul_controller: migrate from fn_cmp() to gsm0502_fncmp()
This function is also needed in osmocom-bb.git, so it becomes a library function (part of libosmogsm).
Change-Id: I6a8502c2b2015ca7d0452ab9f5da0484a03ce91e Depends: libosmocore.git I9590f2e836fc48650decf1564b6ab46306c4fe2d Depends: libosmocore.git Ie8bb9c49c6f81b8f4a1766547d6943f9880d1186 --- M TODO-RELEASE M src/pdch_ul_controller.c 2 files changed, 21 insertions(+), 18 deletions(-)
Approvals: Jenkins Builder: Verified pespin: Looks good to me, approved
diff --git a/TODO-RELEASE b/TODO-RELEASE index cbfda24..73ad83b 100644 --- a/TODO-RELEASE +++ b/TODO-RELEASE @@ -7,3 +7,4 @@ # If any interfaces have been added since the last public release: c:r:a + 1. # If any interfaces have been removed or changed since the last public release: c:r:0. #library what description / commit summary line +libosmocore > 1.9.0 added gsm0502_fncmp() diff --git a/src/pdch_ul_controller.c b/src/pdch_ul_controller.c index c0e26de..661957b 100644 --- a/src/pdch_ul_controller.c +++ b/src/pdch_ul_controller.c @@ -17,6 +17,8 @@ #include <unistd.h> #include <talloc.h>
+#include <osmocom/gsm/gsm0502.h> + #include "pdch_ul_controller.h" #include "bts.h" #include "sba.h" @@ -43,20 +45,6 @@ { 0, NULL } };
-#define GSM_MAX_FN_THRESH (GSM_MAX_FN >> 1) -/* 0: equal, -1: fn1 BEFORE fn2, 1: fn1 AFTER fn2 */ -static inline int fn_cmp(uint32_t fn1, uint32_t fn2) -{ - if (fn1 == fn2) - return 0; - /* FN1 goes before FN2: */ - if ((fn1 < fn2 && (fn2 - fn1) < GSM_MAX_FN_THRESH) || - (fn1 > fn2 && (fn1 - fn2) > GSM_MAX_FN_THRESH)) - return -1; - /* FN1 goes after FN2: */ - return 1; -} - struct pdch_ulc *pdch_ulc_alloc(struct gprs_rlcmac_pdch *pdch, void *ctx) { struct pdch_ulc* ulc; @@ -78,7 +66,7 @@
while (node) { it = rb_entry(node, struct pdch_ulc_node, node); - res = fn_cmp(it->fn, fn); + res = gsm0502_fncmp(it->fn, fn); if (res > 0) /* it->fn AFTER fn */ node = node->rb_left; else if (res < 0) /* it->fn BEFORE fn */ @@ -167,7 +155,7 @@
for (node = rb_first(&ulc->tree_root); node; node = rb_next(node)) { it = container_of(node, struct pdch_ulc_node, node); - res = fn_cmp(it->fn, check_fn); + res = gsm0502_fncmp(it->fn, check_fn); if (res > 0) { /* it->fn AFTER check_fn */ /* Next reserved FN is passed check_fn, hence it means check_fn is free */ return check_fn; @@ -203,7 +191,7 @@ it = container_of(*n, struct pdch_ulc_node, node);
parent = *n; - res = fn_cmp(item->fn, it->fn); + res = gsm0502_fncmp(item->fn, it->fn); if (res < 0) { /* item->fn "BEFORE" it->fn */ n = &((*n)->rb_left); } else if (res > 0) { /* item->fn "AFTER" it->fn */ @@ -305,7 +293,7 @@ struct rb_node *first; while ((first = rb_first(&ulc->tree_root))) { item = container_of(first, struct pdch_ulc_node, node); - res = fn_cmp(item->fn, fn); + res = gsm0502_fncmp(item->fn, fn); if (res > 0) /* item->fn AFTER fn */ break; if (res < 0) { /* item->fn BEFORE fn */