aboutsummaryrefslogtreecommitdiffstats
path: root/src/l1
diff options
context:
space:
mode:
authorSylvain Munaut <tnt@246tNt.com>2011-11-19 19:46:11 +0100
committerSylvain Munaut <tnt@246tNt.com>2011-11-19 21:30:20 +0100
commitdc50d50bb70256e4b71e9c3926d27454065ce538 (patch)
tree081655bd07caf5225351ff10ca65a1f9ed31ebe6 /src/l1
parent9cfb493b81f28ff62a534fd099b3b1a6df2b8849 (diff)
l1: Use constructor attribute to init the channel coders
Much more elegant than doing a manual check ... Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Diffstat (limited to 'src/l1')
-rw-r--r--src/l1/bcch.c12
-rw-r--r--src/l1/ccch.c12
2 files changed, 2 insertions, 22 deletions
diff --git a/src/l1/bcch.c b/src/l1/bcch.c
index 2ab1402..16dc2fb 100644
--- a/src/l1/bcch.c
+++ b/src/l1/bcch.c
@@ -36,21 +36,15 @@
static struct osmo_conv_code gmr1_conv_bcch;
-static int bcch_init_done = 0;
-static void
+static void __attribute__ ((constructor))
gmr1_bcch_init(void)
{
/* Init convolutional coder */
memcpy(&gmr1_conv_bcch, &gmr1_conv_12, sizeof(struct osmo_conv_code));
gmr1_conv_bcch.len = 208;
-
- /* Init done */
- bcch_init_done = 1;
}
-#define GMR1_BCCH_CHECK_INIT if (!bcch_init_done) gmr1_bcch_init()
-
/*! \brief Stateless GMR-1 BCCH channel coder
* \param[out] bits_e Data bits of a burst
@@ -66,8 +60,6 @@ gmr1_bcch_encode(ubit_t *bits_e, const uint8_t *l2)
ubit_t bits_c[424];
ubit_t bits_ep[424];
- GMR1_BCCH_CHECK_INIT;
-
osmo_pbit2ubit_ext(bits_u, 0, l2, 0, 192, 1);
osmo_crc16gen_set_bits(&gmr1_crc16, bits_u, 192, bits_u+192);
osmo_conv_encode(&gmr1_conv_bcch, bits_u, bits_c);
@@ -90,8 +82,6 @@ gmr1_bcch_decode(uint8_t *l2, const sbit_t *bits_e, int *conv_rv)
ubit_t bits_u[208];
int rv;
- GMR1_BCCH_CHECK_INIT;
-
gmr1_scramble_sbit(bits_ep, bits_e, 424);
gmr1_deinterleave_intra(bits_c, bits_ep, 53);
diff --git a/src/l1/ccch.c b/src/l1/ccch.c
index 628e849..3401c3d 100644
--- a/src/l1/ccch.c
+++ b/src/l1/ccch.c
@@ -36,21 +36,15 @@
static struct osmo_conv_code gmr1_conv_ccch;
-static int ccch_init_done = 0;
-static void
+static void __attribute__ ((constructor))
gmr1_ccch_init(void)
{
/* Init convolutional coder */
memcpy(&gmr1_conv_ccch, &gmr1_conv_12, sizeof(struct osmo_conv_code));
gmr1_conv_ccch.len = 208;
-
- /* Init done */
- ccch_init_done = 1;
}
-#define GMR1_CCCH_CHECK_INIT if (!ccch_init_done) gmr1_ccch_init()
-
/*! \brief Stateless GMR-1 CCCH channel coder
* \param[out] bits_e Data bits of a burst
@@ -67,8 +61,6 @@ gmr1_ccch_encode(ubit_t *bits_e, uint8_t *l2)
ubit_t bits_ep[432];
int i;
- GMR1_CCCH_CHECK_INIT;
-
for (i=0; i<4; i++)
bits_ep[i] = bits_ep[431-i] = 0;
@@ -94,8 +86,6 @@ gmr1_ccch_decode(uint8_t *l2, sbit_t *bits_e, int *conv_rv)
ubit_t bits_u[208];
int rv;
- GMR1_CCCH_CHECK_INIT;
-
gmr1_scramble_sbit(bits_ep, bits_e, 432);
gmr1_deinterleave_intra(bits_c, &bits_ep[4], 53);