Skip to content

Commit ea924a7

Browse files
authored
Merge pull request #638 from ojeda/helpers-comment
rust: helpers: explain file with a top-level comment
2 parents a50107e + 5991c70 commit ea924a7

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

rust/exports.c

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
// This requires the Rust's new/future `v0` mangling scheme because the default
77
// one ("legacy") uses invalid characters for C identifiers (thus we cannot use
88
// the `EXPORT_SYMBOL_*` macros).
9+
//
10+
// All symbols are exported as GPL-only to guarantee no GPL-only feature is
11+
// accidentally exposed.
912

1013
#include <linux/module.h>
1114

rust/helpers.c

+17
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,21 @@
11
// SPDX-License-Identifier: GPL-2.0
2+
//
3+
// Non-trivial C macros cannot be used in Rust. Similarly, inlined C functions
4+
// cannot be called either. This file explicitly creates functions ("helpers")
5+
// that wrap those so that they can be called from Rust.
6+
//
7+
// Even though Rust kernel modules should never use directly the bindings, some
8+
// of these helpers need to be exported because Rust generics and inlined
9+
// functions may not get their code generated in the crate where they are
10+
// defined. Other helpers, called from non-inline functions, may not be
11+
// exported, in principle. However, in general, the Rust compiler does not
12+
// guarantee codegen will be performed for a non-inline function either.
13+
// Therefore, this file exports all the helpers. In the future, this may be
14+
// revisited to reduce the number of exports after the compiler is informed
15+
// about the places codegen is required.
16+
//
17+
// All symbols are exported as GPL-only to guarantee no GPL-only feature is
18+
// accidentally exposed.
219

320
#include <linux/bug.h>
421
#include <linux/build_bug.h>

0 commit comments

Comments
 (0)