123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331 |
- #include "core_queu.h"
- #ifdef CORE_QUEU_CFGS_LOGS_TAG
- #define log_err(fmt, ...) \
- logs_logs_err(CORE_QUEU_CFGS_LOGS_TAG, fmt, ##__VA_ARGS__)
- #define log_war(fmt, ...) \
- logs_logs_war(CORE_QUEU_CFGS_LOGS_TAG, fmt, ##__VA_ARGS__)
- #define log_inf(fmt, ...) \
- logs_logs_inf(CORE_QUEU_CFGS_LOGS_TAG, fmt, ##__VA_ARGS__)
- #define log_ver(fmt, ...) \
- logs_logs_ver(CORE_QUEU_CFGS_LOGS_TAG, fmt, ##__VA_ARGS__)
- #define log_ent(fmt, ...) \
- logs_logs_ent(fmt, ##__VA_ARGS__)
- #define log_exi(fmt, ...) \
- logs_logs_exi(fmt, ##__VA_ARGS__)
- #else
- #define log_err(fmt, ...)
- #define log_war(fmt, ...)
- #define log_inf(fmt, ...)
- #define log_ver(fmt, ...)
- #define log_ent(fmt, ...)
- #define log_exi(fmt, ...)
- #endif
- int32
- core_sque_ini(core_sque_t* sque)
- {
- int32 rslt = FALSE;
- uint32 size = 0;
- uint32 coun = 0;
- void* blck = NULL;
- log_ent("PARA>>msgq:0x%08x", sque);
-
-
-
-
-
- if ( NULL == sque->sque_pool ) {
- goto ERR_POOL;
- }
-
- if ( TRUE != list_sque_ini(&sque->sque_dats) ) {
- goto ERR_SQUE;
- }
-
- size = sizeof ( core_qdat_t ) + sque->size_qdat;
- coun = (sque->size_pool / size);
- blck = ((uint8*) sque->sque_pool) + coun * size;
- while ( coun -- ) {
- blck = ((uint8*) blck) - size;
-
- if ( TRUE != list_snod_ini((list_snod_t*) blck, list_slst_enum_snod_cir) ) {
- goto ERR_SQUE;
- }
- if ( TRUE != list_slst_add(&sque->sque_dats.list, (list_snod_t*) blck) ) {
- goto ERR_SQUE;
- }
- }
-
- if ( TRUE != list_sque_fsh(&sque->sque_dats) ) {
- goto ERR_SQUE;
- }
- rslt = TRUE;
- goto ERR_SUCC;
- ERR_SQUE:
- ERR_POOL:
- ERR_SUCC:
- log_exi("RSLT>>rslt: %d", rslt);
- return ( rslt );
- }
- core_sque_t*
- core_sque_new(uint32 size, uint32 coun)
- {
- uint32 plsz = (size + sizeof ( core_qdat_t )) * coun;
- core_sque_t* sque = NULL;
-
- log_ent("PARA>>size:%d, cunt:%d", size, coun);
-
-
- if ( NULL == (sque = (core_sque_t*) osal_mem_alloc(sizeof ( core_sque_t ) + plsz)) ) {
- goto ERR_MMGR;
- }
-
-
- sque->sque_pool = ((uint8*) sque + sizeof ( core_sque_t ));
- sque->size_pool = plsz;
- sque->size_qdat = size;
-
- if ( TRUE != core_sque_ini(sque) ) {
- goto ERR_SQUE;
- }
-
- goto ERR_SUCC;
-
- ERR_SQUE:
- osal_mem_free(sque);
- sque = NULL;
- ERR_MMGR:
- ERR_SUCC:
- log_exi("RSLT>>sque:0x%08x", sque);
- return ( sque );
- }
- int32
- core_sque_del(core_sque_t* sque)
- {
- osal_mem_free(sque);
- return ( TRUE );
- }
- int32
- core_sque_pop(core_sque_t* sque, void* data)
- {
- int32 rslt = FALSE;
- log_ent("PARA>>sque:0x%08x, data:0x%08x", sque, data);
- if ( NULL == sque ) {
- goto ERR_SQUE;
- }
- if ( TRUE != list_sque_pop(&sque->sque_dats, data, sque->size_qdat) ) {
- goto ERR_SQUE;
- }
- rslt = TRUE;
- goto ERR_SUCC;
- ERR_SQUE:
- ERR_SUCC:
- log_exi("RSLT>>rslt: %d", rslt);
- return ( rslt );
- }
- int32
- core_sque_psh(core_sque_t* sque, const void* data)
- {
- int32 rslt = FALSE;
- log_ent("PARA>>sque:0x%08x, data:0x%08x", sque, data);
- if ( NULL == sque ) {
- goto ERR_SQUE;
- }
- if ( TRUE != list_sque_psh(&sque->sque_dats, (void*)data, sque->size_qdat) ) {
- goto ERR_SQUE;
- }
- rslt = TRUE;
- goto ERR_SUCC;
- ERR_SQUE:
- ERR_SUCC:
- log_exi("RSLT>>rslt: %d", rslt);
- return ( rslt );
- }
-
-
-
-
-
-
|