Skip to content

rust: helpers: explain file with a top-level comment #638

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions rust/exports.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
// This requires the Rust's new/future `v0` mangling scheme because the default
// one ("legacy") uses invalid characters for C identifiers (thus we cannot use
// the `EXPORT_SYMBOL_*` macros).
//
// All symbols are exported as GPL-only to guarantee no GPL-only feature is
// accidentally exposed.

#include <linux/module.h>

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

#include <linux/bug.h>
#include <linux/build_bug.h>
Expand Down