Skip to content

Commit

Permalink
Use uniform pattern for including config
Browse files Browse the repository at this point in the history
Previously, `common.h` would explicitly include a custom config
if present, but not explicitly include the default `config.h`
otherwise. Instead, this would be left to `params.h`, which _always_
includes the default config `config.h`, but not a custom config.

This happens to be OK if custom configs and default configs use
the same header guard, but is confusing and non-uniform nonetheless.

This commit uniformly uses the pattern

```
 #if defined(MLKEM_NATIVE_CONFIG_FILE)
 #include MLKEM_NATIVE_CONFIG_FILE
 #else
 #include "config.h"
 #endif /* MLKEM_NATIVE_CONFIG_FILE */
```

to include the configuration.

Signed-off-by: Hanno Becker <[email protected]>
  • Loading branch information
hanno-becker committed Jan 6, 2025
1 parent 7f621d2 commit 17f5276
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion mlkem/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@

#if defined(MLKEM_NATIVE_CONFIG_FILE)
#include MLKEM_NATIVE_CONFIG_FILE
#else
#include "config.h"
#endif /* MLKEM_NATIVE_CONFIG_FILE */

#include "namespacne.h"
#include "params.h"
#include "sys.h"
#include "namespace.h"

/* Include backend metadata */
#if defined(MLKEM_USE_NATIVE)
Expand Down
6 changes: 5 additions & 1 deletion mlkem/params.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
#ifndef PARAMS_H
#define PARAMS_H

#include "config.h"
#if defined(MLKEM_NATIVE_CONFIG_FILE)
#include MLKEM_NATIVE_CONFIG_FILE
#else
#includ "config.h"
#endif /* MLKEM_NATIVE_CONFIG_FILE */

#if !defined(MLKEM_K)
#error MLKEM_K is not defined
Expand Down

0 comments on commit 17f5276

Please sign in to comment.