Skip to content

Commit

Permalink
Deploying to gh-pages from @ 69edaaa 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
Azure-stars committed Nov 20, 2024
0 parents commit d12e395
Show file tree
Hide file tree
Showing 48 changed files with 1,164 additions and 0 deletions.
Empty file added .lock
Empty file.
2 changes: 2 additions & 0 deletions crates.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
window.ALL_CRATES = ["ctor_bare","ctor_bare_macros"];
//{"start":21,"fragment_lengths":[11,19]}
1 change: 1 addition & 0 deletions ctor_bare/all.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="List of all items in this crate"><title>List of all items in this crate</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="ctor_bare" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.0-nightly (ee612c45f 2024-11-19)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc mod sys"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../ctor_bare/index.html">ctor_<wbr>bare</a><span class="version">0.1.1</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h3><a href="#functions">Crate Items</a></h3><ul class="block"><li><a href="#functions" title="Functions">Functions</a></li><li><a href="#attributes" title="Attribute Macros">Attribute Macros</a></li></ul></section><div id="rustdoc-modnav"></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><h1>List of all items</h1><h3 id="attributes">Attribute Macros</h3><ul class="all-items"><li><a href="attr.register_ctor.html">register_ctor</a></li></ul><h3 id="functions">Functions</h3><ul class="all-items"><li><a href="fn.call_ctors.html">call_ctors</a></li></ul></section></div></main></body></html>
4 changes: 4 additions & 0 deletions ctor_bare/attr.register_ctor.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Register a constructor function to be called before `main`."><title>register_ctor in ctor_bare - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="ctor_bare" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.0-nightly (ee612c45f 2024-11-19)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc attr"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../ctor_bare/index.html">ctor_<wbr>bare</a><span class="version">0.1.1</span></h2></div><div class="sidebar-elems"><div id="rustdoc-modnav"></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="index.html">ctor_bare</a></span><h1>Attribute Macro <span class="attr">register_ctor</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/ctor_bare_macros/lib.rs.html#22">Source</a> </span></div><pre class="rust item-decl"><code>#[register_ctor]</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Register a constructor function to be called before <code>main</code>.</p>
<p>The function should have no input arguments and return nothing.</p>
<p>See the documentation of the <a href="https://docs.rs/ctor_bare">ctor_bare</a> crate for more details.</p>
</div></details></section></div></main></body></html>
4 changes: 4 additions & 0 deletions ctor_bare/fn.call_ctors.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Invoke all constructor functions registered by the `register_ctor` attribute."><title>call_ctors in ctor_bare - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="ctor_bare" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.0-nightly (ee612c45f 2024-11-19)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../ctor_bare/index.html">ctor_<wbr>bare</a><span class="version">0.1.1</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">call_<wbr>ctors</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#notes" title="Notes">Notes</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate ctor_<wbr>bare</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="index.html">ctor_bare</a></span><h1>Function <span class="fn">call_ctors</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/ctor_bare/lib.rs.html#21-31">Source</a> </span></div><pre class="rust item-decl"><code>pub fn call_ctors()</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Invoke all constructor functions registered by the <code>register_ctor</code> attribute.</p>
<h2 id="notes"><a class="doc-anchor" href="#notes">§</a>Notes</h2>
<p>Caller should ensure that the <code>.init_array</code> section will not be disturbed by other sections.</p>
</div></details></section></div></main></body></html>
39 changes: 39 additions & 0 deletions ctor_bare/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="ctor_bare"><title>ctor_bare - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="ctor_bare" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.0-nightly (ee612c45f 2024-11-19)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="../crates.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc mod crate"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../ctor_bare/index.html">ctor_<wbr>bare</a><span class="version">0.1.1</span></h2></div><div class="sidebar-elems"><ul class="block"><li><a id="all-types" href="all.html">All Items</a></li></ul><section id="rustdoc-toc"><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#ctor_bare" title="ctor_bare">ctor_bare</a><ul><li><a href="#usage" title="Usage">Usage</a></li><li><a href="#notes" title="Notes">Notes</a></li></ul></li></ul><h3><a href="#functions">Crate Items</a></h3><ul class="block"><li><a href="#functions" title="Functions">Functions</a></li><li><a href="#attributes" title="Attribute Macros">Attribute Macros</a></li></ul></section><div id="rustdoc-modnav"></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><h1>Crate <span>ctor_bare</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/ctor_bare/lib.rs.html#1-31">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><h2 id="ctor_bare"><a class="doc-anchor" href="#ctor_bare">§</a>ctor_bare</h2>
<p><a href="https://crates.io/crates/ctor_bare"><img src="https://img.shields.io/crates/v/ctor_bare" alt="Crates.io" /></a>
<a href="https://docs.rs/ctor_bare"><img src="https://docs.rs/ctor_bare/badge.svg" alt="Docs.rs" /></a>
<a href="https://github.com/arceos-org/ctor_bare/actions/workflows/ci.yml"><img src="https://github.com/arceos-org/ctor_bare/actions/workflows/ci.yml/badge.svg?branch=main" alt="CI" /></a></p>
<p>Module initialization functions for Rust (like <strong>attribute</strong>((constructor)) in C/C++) under no_std.</p>
<p>After registering a constructor function, a function pointer pointing to it will be stored in the <code>.init_array</code> section.</p>
<p>It can support Linux, MacOS and other systems, and can be also used in <code>no_std</code> environments when developing your own kernel.</p>
<p>In Linux, Windows, MacOS and other systems, the <code>.init_array</code> section is a default section to store initialization functions. When the program starts, the system will call all functions in the <code>.init_array</code> section in order.</p>
<p>When you are running your own operating system, you can call <code>ctor_bare::call_ctors</code> to invoke all registered constructor functions.</p>
<h3 id="usage"><a class="doc-anchor" href="#usage">§</a>Usage</h3>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>ctor_bare::register_ctor;
<span class="attr">#[register_ctor]
</span><span class="kw">fn </span>hello_world() {
<span class="macro">println!</span>(<span class="string">"Hello, world!"</span>);
}

<span class="kw">static </span>MAX_NUM: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(<span class="number">0</span>);

<span class="attr">#[register_ctor]
</span><span class="kw">fn </span>set_max_num() {
MAX_NUM.store(<span class="number">20</span>, std::sync::atomic::Ordering::Relaxed);
}

<span class="kw">fn </span>main() {
<span class="macro">assert_eq!</span>(MAX_NUM.load(std::sync::atomic::Ordering::Relaxed), <span class="number">20</span>);
}</code></pre></div>
<p>Because the <code>.init_array</code> section is a default section to store initialization functions in Linux and some other systems, it will be included in the linker script of compilers like GCC and Clang.</p>
<p><strong>However</strong>, if you are using a custom linker script, you need to <strong>add the <code>.init_array</code> section and map them in the page table manually</strong>, so that these functions can be executed correctly. You can add the following line to your linker script as a reference:</p>
<div class="example-wrap"><pre class="language-test"><code>.init_array : ALIGN(4K) {
PROVIDE_HIDDEN (__init_array_start = .);
*(.init_array .init_array.*)
PROVIDE_HIDDEN (__init_array_end = .);
. = ALIGN(4K);
}</code></pre></div><h3 id="notes"><a class="doc-anchor" href="#notes">§</a>Notes</h3>
<p>To avoid section-related symbols being optimized by the compiler, you need to add “-z nostart-stop-gc” to the compile flags (see <a href="https://lld.llvm.org/ELF/start-stop-gc">https://lld.llvm.org/ELF/start-stop-gc</a>).</p>
<p>For example, in <code>.cargo/config.toml</code>:</p>
<div class="example-wrap"><pre class="language-toml"><code>[build]
rustflags = [&quot;-C&quot;, &quot;link-arg=-z&quot;, &quot;link-arg=nostart-stop-gc&quot;]
rustdocflags = [&quot;-C&quot;, &quot;link-arg=-z&quot;, &quot;-C&quot;, &quot;link-arg=nostart-stop-gc&quot;]</code></pre></div></div></details><h2 id="functions" class="section-header">Functions<a href="#functions" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="fn" href="fn.call_ctors.html" title="fn ctor_bare::call_ctors">call_<wbr>ctors</a></div><div class="desc docblock-short">Invoke all constructor functions registered by the <code>register_ctor</code> attribute.</div></li></ul><h2 id="attributes" class="section-header">Attribute Macros<a href="#attributes" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="attr" href="attr.register_ctor.html" title="attr ctor_bare::register_ctor">register_<wbr>ctor</a></div><div class="desc docblock-short">Register a constructor function to be called before <code>main</code>.</div></li></ul></section></div></main></body></html>
1 change: 1 addition & 0 deletions ctor_bare/sidebar-items.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
window.SIDEBAR_ITEMS = {"attr":["register_ctor"],"fn":["call_ctors"]};
1 change: 1 addition & 0 deletions ctor_bare_macros/all.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="List of all items in this crate"><title>List of all items in this crate</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="ctor_bare_macros" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.0-nightly (ee612c45f 2024-11-19)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc mod sys"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../ctor_bare_macros/index.html">ctor_<wbr>bare_<wbr>macros</a><span class="version">0.1.1</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h3><a href="#attributes">Crate Items</a></h3><ul class="block"><li><a href="#attributes" title="Attribute Macros">Attribute Macros</a></li></ul></section><div id="rustdoc-modnav"></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><h1>List of all items</h1><h3 id="attributes">Attribute Macros</h3><ul class="all-items"><li><a href="attr.register_ctor.html">register_ctor</a></li></ul></section></div></main></body></html>
Loading

0 comments on commit d12e395

Please sign in to comment.