bts: Introduce a singleton for the BTS and use it in the code

Compared to the previous code there will be a branch to get the
global pointer so the code will be slightly slower than the previous
version but it allows us to start creating objects but still use
the code from C. It is best approach I have found so far.

One downside of C++ is that by default talloc will not be used
(unless we override the new operator to use talloc. Right now
we need to memset the C data structure by hand. The benefit of
enforcing a better structure should is more important though.
diff --git a/src/pcu_l1_if.cpp b/src/pcu_l1_if.cpp
index e70de55..8239247 100644
--- a/src/pcu_l1_if.cpp
+++ b/src/pcu_l1_if.cpp
@@ -138,7 +138,7 @@
 	uint32_t fn, uint8_t block_nr)
 {
 #ifdef ENABLE_SYSMODSP
-	struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
+	struct gprs_rlcmac_bts *bts = bts_main_data();
 
 	if (bts->trx[trx].fl1h)
 		l1if_pdch_req(bts->trx[trx].fl1h, ts, 0, fn, arfcn, block_nr,
@@ -154,7 +154,7 @@
 	uint32_t fn, uint8_t block_nr)
 {
 #ifdef ENABLE_SYSMODSP
-	struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
+	struct gprs_rlcmac_bts *bts = bts_main_data();
 
 	if (bts->trx[trx].fl1h)
 		l1if_pdch_req(bts->trx[trx].fl1h, ts, 1, fn, arfcn, block_nr,
@@ -196,7 +196,8 @@
 extern "C" int pcu_rx_data_ind_pdtch(uint8_t trx, uint8_t ts, uint8_t *data,
 	uint8_t len, uint32_t fn, int8_t rssi)
 {
-	return gprs_rlcmac_rcv_block(gprs_rlcmac_bts, trx, ts, data, len, fn, rssi);
+	return gprs_rlcmac_rcv_block(bts_main_data(),
+					trx, ts, data, len, fn, rssi);
 }
 
 static int pcu_rx_data_ind(struct gsm_pcu_if_data *data_ind)
@@ -249,7 +250,8 @@
 extern "C" int pcu_rx_rts_req_pdtch(uint8_t trx, uint8_t ts, uint16_t arfcn,
 	uint32_t fn, uint8_t block_nr)
 {
-	return gprs_rlcmac_rcv_rts_block(gprs_rlcmac_bts, trx, ts, arfcn, fn, block_nr);
+	return gprs_rlcmac_rcv_rts_block(bts_main_data(),
+					trx, ts, arfcn, fn, block_nr);
 }
 
 static int pcu_rx_rts_req(struct gsm_pcu_if_rts_req *rts_req)
@@ -293,7 +295,7 @@
 
 	switch (rach_ind->sapi) {
 	case PCU_IF_SAPI_RACH:
-		rc = gprs_rlcmac_rcv_rach(gprs_rlcmac_bts,
+		rc = gprs_rlcmac_rcv_rach(bts_main_data(),
 			rach_ind->ra, rach_ind->fn,
 			rach_ind->qta);
 		break;
@@ -330,7 +332,7 @@
 
 static int pcu_rx_info_ind(struct gsm_pcu_if_info_ind *info_ind)
 {
-	struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
+	struct gprs_rlcmac_bts *bts = bts_main_data();
 	struct gprs_bssgp_pcu *pcu;
 	struct gprs_rlcmac_pdch *pdch;
 	struct in_addr ia;
@@ -505,6 +507,7 @@
 
 static int pcu_rx_time_ind(struct gsm_pcu_if_time_ind *time_ind)
 {
+	struct gprs_rlcmac_bts *bts = bts_main_data();
 	struct gprs_rlcmac_tbf *tbf;
 	struct gprs_rlcmac_sba *sba, *sba2;
 	uint32_t elapsed;
@@ -525,7 +528,7 @@
 			elapsed = (frame_number + 2715648 - tbf->poll_fn)
 								% 2715648;
 			if (elapsed >= 20 && elapsed < 2715400)
-				gprs_rlcmac_poll_timeout(gprs_rlcmac_bts, tbf);
+				gprs_rlcmac_poll_timeout(bts, tbf);
 		}
 	}
 	llist_for_each_entry(tbf, &gprs_rlcmac_dl_tbfs, list) {
@@ -533,7 +536,7 @@
 			elapsed = (frame_number + 2715648 - tbf->poll_fn)
 								% 2715648;
 			if (elapsed >= 20 && elapsed < 2715400)
-				gprs_rlcmac_poll_timeout(gprs_rlcmac_bts, tbf);
+				gprs_rlcmac_poll_timeout(bts, tbf);
 		}
 	}
 	llist_for_each_entry_safe(sba, sba2, &gprs_rlcmac_sbas, list) {
@@ -552,7 +555,7 @@
 	LOGP(DL1IF, LOGL_DEBUG, "Paging request received: chan_needed=%d "
 		"length=%d\n", pag_req->chan_needed, pag_req->identity_lv[0]);
 
-	return gprs_rlcmac_add_paging(gprs_rlcmac_bts, pag_req->chan_needed,
+	return gprs_rlcmac_add_paging(bts_main_data(), pag_req->chan_needed,
 						pag_req->identity_lv);
 }