Skip to content

Commit 40a4b23

Browse files
committed
Document origin_main.
1 parent f7daf5b commit 40a4b23

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/program.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,27 @@
11
//! Program startup and shutdown.
2+
//!
3+
//! To use origin's program startup, define a function named `origin_main` like
4+
//! this:
5+
//!
6+
//! ```no_run
7+
//! #[no_mangle]
8+
//! fn origin_main(argc: usize, argv: *mut *mut u8, envp: *mut *mut u8) -> i32 {
9+
//! todo!("Run the program and return the program exit status.")
10+
//! }
11+
//! ```
12+
//!
13+
//! Origin will call this function after starting up the program and running
14+
//! the constructors. `argc` is the number of command-line arguments with a
15+
//! value of at most `c_int::MAX`, and `argv` is a pointer to a NULL-terminated
16+
//! array of pointers to NUL-terminated C strings. `argc` and `argv` describe
17+
//! the command-line arguments. `envp` is a pointer to a NULL-terminated array
18+
//! of pointers to NUL-terminated C strings containing a key followed by `b'='`
19+
//! followed by a value. It describes the environment variables. The function
20+
//! should return a value for the program exit status.
21+
//!
22+
//! This is a low-level and somewhat C-flavored interface, which is in tension
23+
//! with origin's goal of providing Rust-idiomatic interfaces, however it does
24+
//! mean that origin can avoid doing any work that users might not need.
225
326
#[cfg(feature = "origin-thread")]
427
use crate::thread::initialize_main_thread;

0 commit comments

Comments
 (0)