Skip to content

Commit e7aee91

Browse files
committed
Document MLK_NAMESPACE and MLK_NAMESPACE_K macros
For readers trying to see through the naming indirection using MLK_NAMESPACE(...) and MLK_NAMESPACE_K(...), the previous definitions ```c #define MLK_NAMESPACE(s) \ MLK_CONCAT(MLK_CONCAT(MLK_CONFIG_NAMESPACE_PREFIX, _), s) #define MLK_NAMESPACE_K(s) \ MLK_CONCAT(MLK_CONCAT(MLK_ADD_PARAM_SET(MLK_CONFIG_NAMESPACE_PREFIX), _), s) ``` are a handful. This commit keeps the functionality as-is, but introduces internal abbreviations for the level'ed and underscore'ed prefix, so that the toplevel definitions for MLK_NAMESPACE[_K] turn into the more expectable ```c #define MLK_NAMESPACE(s) MLK_CONCAT(MLK_NAMESPACE_PREFIX, s) #define MLK_NAMESPACE_K(s) MLK_CONCAT(MLK_NAMESPACE_PREFIX_K, s) ``` Also, a comment is added with an example. Signed-off-by: Hanno Becker <beckphan@amazon.co.uk>
1 parent 05be89d commit e7aee91

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

examples/monolithic_build/mlkem_native_monobuild.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@
118118
#undef MLK_MULTILEVEL_BUILD
119119
#undef MLK_NAMESPACE
120120
#undef MLK_NAMESPACE_K
121+
#undef MLK_NAMESPACE_PREFIX
122+
#undef MLK_NAMESPACE_PREFIX_K
121123
/* mlkem/indcpa.h */
122124
#undef MLK_INDCPA_H
123125
#undef mlk_gen_matrix

mlkem/common.h

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,20 @@
4242
#define MLK_ADD_PARAM_SET(s) s
4343
#endif
4444

45-
#define MLK_NAMESPACE(s) \
46-
MLK_CONCAT(MLK_CONCAT(MLK_CONFIG_NAMESPACE_PREFIX, _), s)
47-
#define MLK_NAMESPACE_K(s) \
48-
MLK_CONCAT(MLK_CONCAT(MLK_ADD_PARAM_SET(MLK_CONFIG_NAMESPACE_PREFIX), _), s)
45+
#define MLK_NAMESPACE_PREFIX MLK_CONCAT(MLK_CONFIG_NAMESPACE_PREFIX, _)
46+
#define MLK_NAMESPACE_PREFIX_K \
47+
MLK_CONCAT(MLK_ADD_PARAM_SET(MLK_CONFIG_NAMESPACE_PREFIX), _)
48+
49+
/* Functions are prefixed by MLK_CONFIG_NAMESPACE.
50+
*
51+
* If multiple parameter sets are used, functions depending on the parameter
52+
* set are additionally prefixed with 512/768/1024. See config.h.
53+
*
54+
* Example: If MLK_CONFIG_NAMESPACE_PREFIX is mlkem, then
55+
* MLK_NAMESPACE_K(enc) becomes mlkem512_enc/mlkem768_enc/mlkem1024_enc.
56+
*/
57+
#define MLK_NAMESPACE(s) MLK_CONCAT(MLK_NAMESPACE_PREFIX, s)
58+
#define MLK_NAMESPACE_K(s) MLK_CONCAT(MLK_NAMESPACE_PREFIX_K, s)
4959

5060
/* On Apple platforms, we need to emit leading underscore
5161
* in front of assembly symbols. We thus introducee a separate

0 commit comments

Comments
 (0)