Skip to contentSkip to conversation

rust: macros: document emit_base in ModInfoBuilder

PATCH Superseded Ivan Tverdohleb 1 participant 6 messages Oct 28 – Nov 13 1 message not in the archive

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rust: macros: document emit_base in ModInfoBuilder

Add documentation for the emit_base method within the ModInfoBuilder struct. Explain its role in formatting metadata strings, handling the differentiation between built-in and loadable modules, and managing linker sections and conditional compilation.

---
 rust/macros/module.rs | 10 ++++++++++
 1 file changed, 10 insertions(+)
rust/macros/module.rs +10 -0
index 0a7b9e24c..6f361013f 100644
@@ -49,6 +49,16 @@ fn new(module: &'a str) -> Self {
         }
     }
 
+    /// Emits a single metadata entry into the module information table.
+    ///
+    /// This method formats a `field=content\0` byte string and places it into the
+    /// `.modinfo` linker section. For built-in modules (`builtin == true`), the string
+    /// is prefixed with the module name (`module.field=content\0`) to avoid naming
+    /// collisions in the final monolithic kernel binary.
+    ///
+    /// It automatically generates a unique static identifier using an internal counter
+    /// and applies appropriate conditional compilation attributes (`#[cfg(MODULE)]` or
+    /// `#[cfg(not(MODULE))]`) based on the target type.
     fn emit_base(&mut self, field: &str, content: &str, builtin: bool, param: bool) {
         let string = if builtin {
             // Built-in modules prefix their modinfo strings by `module.`.
Signature · 1 line
2.56.0

A message that is not in the archive (sent off-list or not yet received): CA+YDrKA1hTM-Yh+qsCz7Q_O9f4m_JWqyxkm4izaz4uAao_Jz5Q@mail.gmail.com

author
#2 lore raw

ср, 28 окт. 2026 г. в 21:57, MBKCHEL <[email protected]>:

Quoted 44 lines

Hi,
Please note that I made a typo in my last name in the "From" and "Signed-off-by" lines. My correct name is "Ivan Tverdokhleb". If the patch is accepted, could you please apply it with the corrected name?
Thanks,
Ivan

ср, 28 окт. 2026 г. в 17:50, Ivan Tverdohleb <[email protected]>:

Quoted 35 lines

Add documentation for the emit_base method within the ModInfoBuilder struct. Explain its role in formatting metadata strings, handling the differentiation between built-in and loadable modules, and managing linker sections and conditional compilation.

---
 rust/macros/module.rs | 10 ++++++++++
 1 file changed, 10 insertions(+)
rust/macros/module.rs +10 -1
index 0a7b9e24c..6f361013f 100644
@@ -49,6 +49,16 @@ fn new(module: &'a str) -> Self {
         }
     }
 
+    /// Emits a single metadata entry into the module information table.
+    ///
+    /// This method formats a `field=content\0` byte string and places it into the
+    /// `.modinfo` linker section. For built-in modules (`builtin == true`), the string
+    /// is prefixed with the module name (`module.field=content\0`) to avoid naming
+    /// collisions in the final monolithic kernel binary.
+    ///
+    /// It automatically generates a unique static identifier using an internal counter
+    /// and applies appropriate conditional compilation attributes (`#[cfg(MODULE)]` or
+    /// `#[cfg(not(MODULE))]`) based on the target type.
     fn emit_base(&mut self, field: &str, content: &str, builtin: bool, param: bool) {
         let string = if builtin {
             // Built-in modules prefix their modinfo strings by `module.`.
--

2.56.0

author
#3 lore raw
In reply to a message not in the archive

Hi,

Please note that I made a typo in my last name in the "From" and "Signed-off-by" lines. My correct name is "Ivan Tverdokhleb".

If the patch is accepted, could you please apply it with the corrected name?

Thanks,
Ivan

ср, 28 окт. 2026 г. в 21:57, MBKCHEL <[email protected]>:

Quoted 44 lines

Hi,
Please note that I made a typo in my last name in the "From" and "Signed-off-by" lines. My correct name is "Ivan Tverdokhleb". If the patch is accepted, could you please apply it with the corrected name?
Thanks,
Ivan

ср, 28 окт. 2026 г. в 17:50, Ivan Tverdohleb <[email protected]>:

Quoted 35 lines

Add documentation for the emit_base method within the ModInfoBuilder struct. Explain its role in formatting metadata strings, handling the differentiation between built-in and loadable modules, and managing linker sections and conditional compilation.

---
 rust/macros/module.rs | 10 ++++++++++
 1 file changed, 10 insertions(+)
rust/macros/module.rs +10 -1
index 0a7b9e24c..6f361013f 100644
@@ -49,6 +49,16 @@ fn new(module: &'a str) -> Self {
         }
     }
 
+    /// Emits a single metadata entry into the module information table.
+    ///
+    /// This method formats a `field=content\0` byte string and places it into the
+    /// `.modinfo` linker section. For built-in modules (`builtin == true`), the string
+    /// is prefixed with the module name (`module.field=content\0`) to avoid naming
+    /// collisions in the final monolithic kernel binary.
+    ///
+    /// It automatically generates a unique static identifier using an internal counter
+    /// and applies appropriate conditional compilation attributes (`#[cfg(MODULE)]` or
+    /// `#[cfg(not(MODULE))]`) based on the target type.
     fn emit_base(&mut self, field: &str, content: &str, builtin: bool, param: bool) {
         let string = if builtin {
             // Built-in modules prefix their modinfo strings by `module.`.
--

2.56.0

author
#4 lore raw
In reply to Ivan Tverdohleb

Hi,

Please note that I made a typo in my last name in the "From" and "Signed-off-by" lines. My correct name is "Ivan Tverdokhleb".

If the patch is accepted, could you please apply it with the corrected name?

Thanks,
Ivan

ср, 28 окт. 2026 г. в 17:50, Ivan Tverdohleb <[email protected]>:

Quoted 35 lines

Add documentation for the emit_base method within the ModInfoBuilder struct. Explain its role in formatting metadata strings, handling the differentiation between built-in and loadable modules, and managing linker sections and conditional compilation.

---
 rust/macros/module.rs | 10 ++++++++++
 1 file changed, 10 insertions(+)
rust/macros/module.rs +10 -1
index 0a7b9e24c..6f361013f 100644
@@ -49,6 +49,16 @@ fn new(module: &'a str) -> Self {
         }
     }
 
+    /// Emits a single metadata entry into the module information table.
+    ///
+    /// This method formats a `field=content\0` byte string and places it into the
+    /// `.modinfo` linker section. For built-in modules (`builtin == true`), the string
+    /// is prefixed with the module name (`module.field=content\0`) to avoid naming
+    /// collisions in the final monolithic kernel binary.
+    ///
+    /// It automatically generates a unique static identifier using an internal counter
+    /// and applies appropriate conditional compilation attributes (`#[cfg(MODULE)]` or
+    /// `#[cfg(not(MODULE))]`) based on the target type.
     fn emit_base(&mut self, field: &str, content: &str, builtin: bool, param: bool) {
         let string = if builtin {
             // Built-in modules prefix their modinfo strings by `module.`.
--

2.56.0

author
#5 lore raw
In reply to Ivan Tverdohleb

Hi,

Please note that I made a typo in my last name in the "From" and "Signed-off-by" lines. My correct name is "Ivan Tverdokhleb".

If the patch is accepted, could you please apply it with the corrected name?

Thanks,
Ivan

ср, 28 окт. 2026 г. в 17:50, Ivan Tverdohleb <[email protected]>:

Quoted 35 lines

Add documentation for the emit_base method within the ModInfoBuilder struct. Explain its role in formatting metadata strings, handling the differentiation between built-in and loadable modules, and managing linker sections and conditional compilation.

---
 rust/macros/module.rs | 10 ++++++++++
 1 file changed, 10 insertions(+)
rust/macros/module.rs +10 -1
index 0a7b9e24c..6f361013f 100644
@@ -49,6 +49,16 @@ fn new(module: &'a str) -> Self {
         }
     }
 
+    /// Emits a single metadata entry into the module information table.
+    ///
+    /// This method formats a `field=content\0` byte string and places it into the
+    /// `.modinfo` linker section. For built-in modules (`builtin == true`), the string
+    /// is prefixed with the module name (`module.field=content\0`) to avoid naming
+    /// collisions in the final monolithic kernel binary.
+    ///
+    /// It automatically generates a unique static identifier using an internal counter
+    /// and applies appropriate conditional compilation attributes (`#[cfg(MODULE)]` or
+    /// `#[cfg(not(MODULE))]`) based on the target type.
     fn emit_base(&mut self, field: &str, content: &str, builtin: bool, param: bool) {
         let string = if builtin {
             // Built-in modules prefix their modinfo strings by `module.`.
--

2.56.0

author
#6 lore raw

Hi,

Friendly ping on this patch.

Thanks,
Ivan

чт, 29 окт. 2026 г. в 15:33, MBKCHEL <[email protected]>:

Quoted 47 lines

Hi,

Please note that I made a typo in my last name in the "From" and "Signed-off-by" lines. My correct name is "Ivan Tverdokhleb".

If the patch is accepted, could you please apply it with the corrected name?

Thanks,
Ivan

ср, 28 окт. 2026 г. в 17:50, Ivan Tverdohleb <[email protected]>:

Quoted 35 lines

Add documentation for the emit_base method within the ModInfoBuilder struct. Explain its role in formatting metadata strings, handling the differentiation between built-in and loadable modules, and managing linker sections and conditional compilation.

---
 rust/macros/module.rs | 10 ++++++++++
 1 file changed, 10 insertions(+)
rust/macros/module.rs +10 -1
index 0a7b9e24c..6f361013f 100644
@@ -49,6 +49,16 @@ fn new(module: &'a str) -> Self {
         }
     }
 
+    /// Emits a single metadata entry into the module information table.
+    ///
+    /// This method formats a `field=content\0` byte string and places it into the
+    /// `.modinfo` linker section. For built-in modules (`builtin == true`), the string
+    /// is prefixed with the module name (`module.field=content\0`) to avoid naming
+    /// collisions in the final monolithic kernel binary.
+    ///
+    /// It automatically generates a unique static identifier using an internal counter
+    /// and applies appropriate conditional compilation attributes (`#[cfg(MODULE)]` or
+    /// `#[cfg(not(MODULE))]`) based on the target type.
     fn emit_base(&mut self, field: &str, content: &str, builtin: bool, param: bool) {
         let string = if builtin {
             // Built-in modules prefix their modinfo strings by `module.`.
--

2.56.0