Skip to content

Commit

Permalink
Trace: remove unused META definition
Browse files Browse the repository at this point in the history
Remove unused META definition, below work is done:
1. removed META definition.
2. removed cmocka preproc module.
3. removed cmocka strcheck and debugability module.

With this change, cmocka does not have any dependency on
META programming.

Signed-off-by: Baofeng Tian <baofeng.tian@intel.com>
  • Loading branch information
btian1 authored and lgirdwood committed Jan 11, 2024
1 parent 2df16fe commit 214456d
Show file tree
Hide file tree
Showing 14 changed files with 0 additions and 937 deletions.
41 changes: 0 additions & 41 deletions src/include/sof/trace/preproc-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@
* META_RECURSE(META_REPEAT
*/

#define _META_NO_ARGS(...) 0

/* _META_IS_PROBE(...) evaluates to 0 when __VA_ARGS__ is single token
* _META_IS_PROBE(PROBE()) evaulates to 1, because it is equivalent to
* _META_GET_ARG_2(~, 1, 0)
Expand Down Expand Up @@ -134,42 +132,9 @@
*/
#define _META_EMPTY()

/* These two will expand to:
* _META_EMPTY _META_EMPTY ... _META_EMPTY
* () () ... ()
* Why '_META_EMPTY() _META_EMPTY' instead of '_META_EMPTY'?
* Using simply '_META_EMPTY' would produce
* _META_EMPTY_META_EMPTY_META_EMPTY
* and adding _META_EMPTY() introduces a " "(space) token.
*/
#define _META_EMPTY_GEN(i, rest) _META_EMPTY() _META_EMPTY
#define _META_PAREN_GEN(i, rest) ()
/* You cannot use here META_RECURSE
* and must instead use _META_REQRS_{NUMBER}.
* If META_RECURSE was used, things like
* META_RECURSE(MAP_AGGREGATE
* would break.
*/
#define _META_DEFER_N(depth) \
META_RECURSE_N(8, META_REPEAT(depth, _META_EMPTY_GEN, ~)) \
META_RECURSE_N(8, META_REPEAT(depth, _META_PAREN_GEN, ~))

/* Special, implicit defer implementation for META_REPEAT to work */
#define _META_DEFER_2(m) m _META_EMPTY _META_EMPTY () ()

/* helpers for consuming every single arg from __VA_ARGS__ */
// expand and discard
#define _META_EAT(...)
// force expansion, reverse of META_DEFER
#define _META_EXPAND(...) __VA_ARGS__
#define _META_WHEN(c) META_IF(c)(_META_EXPAND, _META_EAT)

/* while(count--!=0) do
* uses DEC so count == N can only work if all following exist
* DEC_0, DEC_1, ..., DEC_N-1, DEC_N
*/
#define _META_REPEAT_INDIRECT() META_REPEAT

/* map every group of arg_count arguments onto function m
* i.e. arg_count=2;m=ADD;args=1,2,3,4,5,6,7...
* results in ADD(1,2) ADD(3,4) ADD(5,6) and so on
Expand Down Expand Up @@ -221,12 +186,6 @@
(arg_count, m, aggr, __VA_ARGS__)\
)(aggr)

/* META_CONCAT with parametrised delimeter between concatenised tokens
* META_CONCAT_SEQ_DELIM_(A,B,C,D) tokenizes as A_B_C_D
*/
#define _META_CONCAT_DELIM(delim, x, y) META_CONCAT(META_CONCAT(x, delim),y)
#define _META_CONCAT_DELIM_(x, y) _META_CONCAT_DELIM(_, x, y)

/* UNUSED private macros */
#define _META_VOID(x) (void)(x)
#define _META_VOID2(x, y) x; _META_VOID(y)
Expand Down
77 changes: 0 additions & 77 deletions src/include/sof/trace/preproc.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,6 @@
/* concat x and y while forcing x and y expansion beforehand */
#define META_CONCAT(x, y) _META_CONCAT_BASE(x, y)

/* discard first x-1 args in vararg and return the xth arg */

#define META_GET_ARG_N(n, ...) META_CONCAT(_META_GET_ARG_, n)(__VA_ARGS__)

#define META_HAS_ARGS(...) META_BOOL(\
_META_GET_ARG_1(_META_NO_ARGS __VA_ARGS__)()\
)

/* Only META_NOT(0) evaulates to 1
* notice, that any x!=0 would also result in 0
* e.x. META_NOT(123) evaluates to 0
Expand All @@ -65,38 +57,13 @@
* default depth is 8
*/
#define META_RECURSE(...) _META_REQRS_8(__VA_ARGS__)
/* choose explicitly depth of recursion
*/
#define META_RECURSE_N(depth, ...)\
META_CONCAT(_META_REQRS_, depth)(__VA_ARGS__)

/* The only sane way I found to increment values in cpreproc */
#define META_INC(x) META_CONCAT(_META_INC_, x)

/* The only sane way I found to decrement values in cpreproc */
#define META_DEC(x) META_CONCAT(_META_DEC_, x)

/* Delay macro m expansion depth times
* by writing META_DEFER(0, m)(args) we expand it in 1st scan
* by writing META_DEFER(1, m)(args) we expand it in 2nd scan
* ...
* by writing META_DEFER(n, m)(args) we expand it in n+1nth scan
*/
#define META_DEFER(depth, m) m _META_DEFER_N(depth)

/* while(count--!=0) do
* uses DEC so count == N can only work if all following exist
* DEC_0, DEC_1, ..., DEC_N-1, DEC_N
*/
#define META_REPEAT(count, macro, ...)\
_META_WHEN(count)\
(\
_META_DEFER_2(_META_REPEAT_INDIRECT) () \
(META_DEC(count), macro, __VA_ARGS__)\
_META_DEFER_2(macro)\
(META_DEC(count), __VA_ARGS__)\
)

/* map every group of arg_count arguments onto function m
* i.e. arg_count=2;m=ADD;args=1,2,3,4,5,6,7...
* results in ADD(1,2) ADD(3,4) ADD(5,6) and so on
Expand All @@ -113,50 +80,6 @@
#define META_MAP_AGGREGATE(arg_count, m, aggr, ...)\
META_CONCAT(_META_MAP_AGGREGATE_, arg_count)(m, aggr, __VA_ARGS__)

/* META_CONCAT_SEQ is basicaly variadic version of macro META_CONCAT
* META_CONCAT_SEQ(A,B,C,D) tokenizes to ABCD
*/
#define META_CONCAT_SEQ(aggr, ...) META_RECURSE(\
META_MAP_AGGREGATE(1, META_CONCAT, aggr, __VA_ARGS__))

/* META_CONCAT with parametrised delimeter between concatenised tokens
* META_CONCAT_SEQ_DELIM_(A,B,C,D) tokenizes as A_B_C_D
*/
#define META_CONCAT_SEQ_DELIM_(aggr, ...) META_RECURSE(\
META_MAP_AGGREGATE(1, _META_CONCAT_DELIM_, aggr, __VA_ARGS__))

/* META_SEQ_FROM_0_TO(3, META_SEQ_STEP_param)
* produces , param0 , param1 , param2
*/
#define META_SEQ_FROM_0_TO(arg_count, func)\
META_RECURSE(META_REPEAT(arg_count, func, ~))

/* Macros to be used as 2nd argument of macro META_SEQ_FROM_0_TO
* for instance
* META_SEQ_FROM_0_TO(arg_count, META_SEQ_STEP)
* produces
* 0 1 2 3 4
*/
#define META_SEQ_STEP(i, _) i
#define META_SEQ_STEP_param(i, _) , META_CONCAT(param, i)
#define META_SEQ_STEP_param_uint32_t(i, _) , uint32_t META_CONCAT(param, i)
#define META_SEQ_STEP_param_uint64_t(i, _) , uint64_t META_CONCAT(param, i)
#define META_SEQ_STEP_param_int32_t( i, _) , int32_t META_CONCAT(param, i)
#define META_SEQ_STEP_param_int64_t( i, _) , int64_t META_CONCAT(param, i)

#define META_SEQ_STEP_id(i, _) , META_CONCAT(id_, i)
#define META_SEQ_STEP_id_uint32_t(i, _) , uint32_t META_CONCAT(id_, i)

/* generates function signature
* for instance with:
* prefix=foo ; postfix=__bar ; return_t=void
* args=(int x, int y)
* will produce:
* void foo_bar(int x, int y)
*/
#define META_FUNC_WITH_VARARGS(prefix, postfix, return_t, args)\
return_t META_CONCAT(prefix, postfix) (args)

/* counteract compiler warning about unused variables */
#define SOF_TRACE_UNUSED(arg1, ...) do { META_RECURSE( \
META_MAP_AGGREGATE(1, _META_VOID2, _META_VOID(arg1), __VA_ARGS__)); \
Expand Down
3 changes: 0 additions & 3 deletions test/cmocka/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# SPDX-License-Identifier: BSD-3-Clause

add_subdirectory(audio)
if(NOT BUILD_UNIT_TESTS_HOST)
add_subdirectory(debugability)
endif()
add_subdirectory(lib)
add_subdirectory(list)
add_subdirectory(math)
6 changes: 0 additions & 6 deletions test/cmocka/src/debugability/CMakeLists.txt

This file was deleted.

73 changes: 0 additions & 73 deletions test/cmocka/src/debugability/macros.c

This file was deleted.

1 change: 0 additions & 1 deletion test/cmocka/src/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@

add_subdirectory(alloc)
add_subdirectory(lib)
add_subdirectory(preproc)
5 changes: 0 additions & 5 deletions test/cmocka/src/lib/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,3 @@ cmocka_test(rstrlen
rstrlen.c
${PROJECT_SOURCE_DIR}/src/lib/lib.c
)

cmocka_test(strcheck
strcheck.c
${PROJECT_SOURCE_DIR}/src/lib/lib.c
)
Loading

0 comments on commit 214456d

Please sign in to comment.