kirr has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmocom-bb/+/40061?usp=email )
Change subject: trx_toolkit/_clck_gen: Switch CLCKGen to cdef class ......................................................................
trx_toolkit/_clck_gen: Switch CLCKGen to cdef class
- Put fields into the object struct; fields are now accessed directly via that C-level struct instead of via __dict__ lookup - cimport instead of import CLCKGen at the users - switch to invoke CLCKGen.send_clck_ind via C-level as that function is used only by CLCKGen internally - switch globals to be also typed and looked up statically instead of from module __dict__.
Change-Id: I2fb0219776b973c217348e34dab269aa804b2a04 --- A src/target/trx_toolkit/_clck_gen.pxd M src/target/trx_toolkit/_clck_gen.pyx M src/target/trx_toolkit/_fake_trx.pyx 3 files changed, 34 insertions(+), 7 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/61/40061/1
diff --git a/src/target/trx_toolkit/_clck_gen.pxd b/src/target/trx_toolkit/_clck_gen.pxd new file mode 100644 index 0000000..f4de595 --- /dev/null +++ b/src/target/trx_toolkit/_clck_gen.pxd @@ -0,0 +1,22 @@ +# cython: language_level=3 + +from libc.stdint cimport int64_t +from udp_link cimport UDPLink + + +cdef class CLCKGen: + cdef public: + list[UDPLink] clck_links + int64_t clck_start + int64_t ind_period + + double ctr_interval + int64_t clck_src + + object clck_handler + + cdef int _timerfd + cdef int _t_tick + + + cdef send_clck_ind(self) diff --git a/src/target/trx_toolkit/_clck_gen.pyx b/src/target/trx_toolkit/_clck_gen.pyx index 6eb5717..46e28c1 100644 --- a/src/target/trx_toolkit/_clck_gen.pyx +++ b/src/target/trx_toolkit/_clck_gen.pyx @@ -22,15 +22,19 @@ import os import sys
-from udp_link cimport UDPLink -from gsm_shared import * +from cython cimport final
-ns = 1e-9 -us = 1e-6 +import gsm_shared +cdef int GSM_HYPERFRAME = gsm_shared.GSM_HYPERFRAME
-class CLCKGen: +cdef double ns = 1e-9 +cdef double us = 1e-6 + + +@final +cdef class CLCKGen: # GSM TDMA definitions SEC_DELAY_US = 1000 * 1000 GSM_FRAME_US = 4615.0 @@ -94,7 +98,7 @@
self.send_clck_ind()
- def send_clck_ind(self): + cdef send_clck_ind(self): cdef UDPLink link
# We don't need to send so often diff --git a/src/target/trx_toolkit/_fake_trx.pyx b/src/target/trx_toolkit/_fake_trx.pyx index c17c16d..8803b24 100644 --- a/src/target/trx_toolkit/_fake_trx.pyx +++ b/src/target/trx_toolkit/_fake_trx.pyx @@ -22,6 +22,7 @@ import select
from burst_fwd import BurstForwarder +from _clck_gen cimport CLCKGen from transceiver import Transceiver from data_msg import Modulation from gsm_shared import * @@ -374,7 +375,7 @@
# Runner organizes execution of several FakeTRX instances with common clock. cdef class Runner: - cdef object clck_gen # CLCKGen + cdef CLCKGen clck_gen cdef object burst_fwd # BurstForwarder cdef list[Transceiver] trx_list