Skip to content

Commit 87bf35e

Browse files
committed
ALWAYS_INLINE -> NOINLINE
Signed-off-by: Matthias J. Kannwischer <matthias@zerorisc.com>
1 parent 81fd4c0 commit 87bf35e

4 files changed

Lines changed: 20 additions & 2 deletions

File tree

mlkem/mlkem_native.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@
377377
#undef MLK_HAVE_INLINE_ASM
378378
#undef MLK_INLINE
379379
#undef MLK_MUST_CHECK_RETURN_VALUE
380+
#undef MLK_NOINLINE
380381
#undef MLK_RESTRICT
381382
#undef MLK_STATIC_TESTABLE
382383
#undef MLK_SYS_AARCH64

mlkem/mlkem_native_asm.S

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@
398398
#undef MLK_HAVE_INLINE_ASM
399399
#undef MLK_INLINE
400400
#undef MLK_MUST_CHECK_RETURN_VALUE
401+
#undef MLK_NOINLINE
401402
#undef MLK_RESTRICT
402403
#undef MLK_STATIC_TESTABLE
403404
#undef MLK_SYS_AARCH64

mlkem/src/indcpa.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ int mlk_indcpa_keypair_derand(uint8_t pk[MLKEM_INDCPA_PUBLICKEYBYTES],
468468
#if defined(MLK_CONFIG_ENABLE_MLKEM_BRAID)
469469
MLK_INTERNAL_API
470470
#else
471-
static MLK_ALWAYS_INLINE
471+
static MLK_NOINLINE
472472
#endif
473473
int mlk_indcpa_enc_u(uint8_t ct_u[MLKEM_POLYVECCOMPRESSEDBYTES_DU],
474474
mlk_polyvec *sp, mlk_poly *epp,
@@ -544,7 +544,7 @@ int mlk_indcpa_enc_u(uint8_t ct_u[MLKEM_POLYVECCOMPRESSEDBYTES_DU],
544544
#if defined(MLK_CONFIG_ENABLE_MLKEM_BRAID)
545545
MLK_INTERNAL_API
546546
#else
547-
static MLK_ALWAYS_INLINE
547+
static MLK_NOINLINE
548548
#endif
549549
int mlk_indcpa_enc_v(uint8_t ct_v[MLKEM_POLYCOMPRESSEDBYTES_DV],
550550
const mlk_polyvec *sp, const mlk_poly *epp,

mlkem/src/sys.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,22 @@
146146
#endif
147147
#endif /* !MLK_ALWAYS_INLINE */
148148

149+
/*
150+
* MLK_NOINLINE: Prevent inlining.
151+
* - GCC/Clang: __attribute__((noinline))
152+
* - MSVC: __declspec(noinline)
153+
* - Other: (no annotation)
154+
*/
155+
#if !defined(MLK_NOINLINE)
156+
#if defined(_MSC_VER)
157+
#define MLK_NOINLINE __declspec(noinline)
158+
#elif defined(__GNUC__) || defined(__clang__)
159+
#define MLK_NOINLINE __attribute__((noinline))
160+
#else
161+
#define MLK_NOINLINE
162+
#endif
163+
#endif /* !MLK_NOINLINE */
164+
149165
#ifndef MLK_STATIC_TESTABLE
150166
#define MLK_STATIC_TESTABLE static
151167
#endif

0 commit comments

Comments
 (0)