38
38
39
39
#if OSAL_MUTEX_REQUIRED
40
40
41
- static inline void _ff_lock (osal_mutex_t mutex )
41
+ TU_ATTR_ALWAYS_INLINE static inline void _ff_lock (osal_mutex_t mutex )
42
42
{
43
43
if (mutex ) osal_mutex_lock (mutex , OSAL_TIMEOUT_WAIT_FOREVER );
44
44
}
45
45
46
- static inline void _ff_unlock (osal_mutex_t mutex )
46
+ TU_ATTR_ALWAYS_INLINE static inline void _ff_unlock (osal_mutex_t mutex )
47
47
{
48
48
if (mutex ) osal_mutex_unlock (mutex );
49
49
}
@@ -361,30 +361,14 @@ static inline uint16_t idx2ptr(uint16_t idx, uint16_t depth)
361
361
// Works on local copies of w and r - return only the difference and as such can be used to determine an overflow
362
362
static inline uint16_t _tu_fifo_count (tu_fifo_t * f , uint16_t wr_idx , uint16_t rd_idx )
363
363
{
364
- uint16_t cnt ;
365
-
366
364
// In case we have non-power of two depth we need a further modification
367
365
if (wr_idx >= rd_idx )
368
366
{
369
- cnt = (uint16_t ) (wr_idx - rd_idx );
367
+ return (uint16_t ) (wr_idx - rd_idx );
370
368
} else
371
369
{
372
- cnt = (uint16_t ) (2 * f -> depth - (rd_idx - wr_idx ));
370
+ return (uint16_t ) (2 * f -> depth - (rd_idx - wr_idx ));
373
371
}
374
-
375
- return cnt ;
376
- }
377
-
378
- // Works on local copies of w and r
379
- static inline bool _tu_fifo_empty (uint16_t wr_idx , uint16_t rd_idx )
380
- {
381
- return wr_idx == rd_idx ;
382
- }
383
-
384
- // Works on local copies of w and r
385
- static inline bool _tu_fifo_full (tu_fifo_t * f , uint16_t wAbs , uint16_t rAbs )
386
- {
387
- return _tu_fifo_count (f , wAbs , rAbs ) == f -> depth ;
388
372
}
389
373
390
374
// Works on local copies of w and r
@@ -601,7 +585,7 @@ uint16_t tu_fifo_count(tu_fifo_t* f)
601
585
/******************************************************************************/
602
586
bool tu_fifo_empty (tu_fifo_t * f )
603
587
{
604
- return _tu_fifo_empty ( f -> wr_idx , f -> rd_idx ) ;
588
+ return f -> wr_idx == f -> rd_idx ;
605
589
}
606
590
607
591
/******************************************************************************/
@@ -619,7 +603,7 @@ bool tu_fifo_empty(tu_fifo_t* f)
619
603
/******************************************************************************/
620
604
bool tu_fifo_full (tu_fifo_t * f )
621
605
{
622
- return _tu_fifo_full (f , f -> wr_idx , f -> rd_idx );
606
+ return _tu_fifo_count (f , f -> wr_idx , f -> rd_idx ) >= f -> depth ;
623
607
}
624
608
625
609
/******************************************************************************/
@@ -798,7 +782,7 @@ bool tu_fifo_write(tu_fifo_t* f, const void * data)
798
782
bool ret ;
799
783
uint16_t const wr_idx = f -> wr_idx ;
800
784
801
- if ( _tu_fifo_full ( f , wr_idx , f -> rd_idx ) && !f -> overwritable )
785
+ if ( tu_fifo_full ( f ) && !f -> overwritable )
802
786
{
803
787
ret = false;
804
788
}else
0 commit comments