Skip to content

Commit 7d3f653

Browse files
authored
Replace abort() with trap(). (#146)
* Replace `abort()` with `trap()`. Instead of providing an "abort" function, which might be confused with `libc::abort` which has subtly different behavior, provide a "trap" function, which just does one clear thing. * Rename "panic-handler-abort" to "panic-handler-trap". * Disable `test_trap` for now.
1 parent e2828f5 commit 7d3f653

File tree

28 files changed

+158
-60
lines changed

28 files changed

+158
-60
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# origin 0.23
2+
3+
## Changes
4+
5+
`program::abort` has been renamed to `program::trap`, and the
6+
"panic-handler-abort" feature has been renamed to "panic-handler-trap".
7+
18
# origin 0.22
29

310
## Changes

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,17 +156,17 @@ eh-personality-continue = ["unwinding?/personality-dummy"]
156156
# Provide a `#[panic_handler]` function suitable for unwinding (for no-std).
157157
#
158158
# If you know your program never panics and want smaller code size, use
159-
# "panic-handler-abort" instead.
159+
# "panic-handler-trap" instead.
160160
#
161161
# This is only needed in no-std builds, as std provides a panic handler. See
162162
# [the "panic-handler" feature of the unwinding crate] for more details.
163163
#
164164
# [the "panic-handler" feature of the unwinding crate]: https://crates.io/crates/unwinding#personality-and-other-utilities
165165
panic-handler = ["unwinding?/panic-handler"]
166166

167-
# Provide a `#[panic_handler]` function that just aborts (for no-std). Use this
167+
# Provide a `#[panic_handler]` function that just traps (for no-std). Use this
168168
# if you know your program will never panic and don't want any extra code.
169-
panic-handler-abort = ["unwinding?/panic-handler-dummy"]
169+
panic-handler-trap = ["unwinding?/panic-handler-dummy"]
170170

171171
# Enable this to define a C ABI-compatible `getauxval` function. Most Rust code
172172
# should use functions in [`rustix::param`] instead.

example-crates/external-start/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ publish = false
77
[dependencies]
88
# Origin can be depended on just like any other crate. For no_std, disable
99
# the default features, and the desired features.
10-
origin = { path = "../..", default-features = false, features = ["external-start", "program-at-exit", "thread-at-exit", "eh-personality-continue", "panic-handler-abort", "nightly"] }
10+
origin = { path = "../..", default-features = false, features = ["external-start", "program-at-exit", "thread-at-exit", "eh-personality-continue", "panic-handler-trap", "nightly"] }
1111

1212
# Ensure that libc gets linked.
1313
libc = { version = "0.2", default-features = false }

example-crates/external-start/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,5 @@ unsafe fn origin_main(_argc: usize, _argv: *mut *mut u8, _envp: *mut *mut u8) ->
7777
#[no_mangle]
7878
unsafe fn main(_argc: i32, _argv: *mut *mut u8, _envp: *mut *mut u8) -> i32 {
7979
eprintln!("Main was not supposed to be called!");
80-
program::abort();
80+
program::trap();
8181
}

example-crates/no-std/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ publish = false
77
[dependencies]
88
# Origin can be depended on just like any other crate. For no_std, disable
99
# the default features. And enable "libc" to enable the libc implementations.
10-
origin = { path = "../..", default-features = false, features = ["libc", "program-at-exit", "thread-at-exit", "eh-personality-continue", "panic-handler-abort", "nightly"] }
10+
origin = { path = "../..", default-features = false, features = ["libc", "program-at-exit", "thread-at-exit", "eh-personality-continue", "panic-handler-trap", "nightly"] }
1111

1212
# Crates to help writing no_std code.
1313
atomic-dbg = { version = "0.1.8", default-features = false }

example-crates/origin-start-dynamic-linker/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ crate-type = ["cdylib"]
1010
[dependencies]
1111
# Origin can be depended on just like any other crate. For no_std, disable
1212
# the default features, and the desired features.
13-
origin = { path = "../..", default-features = false, features = ["origin-start", "program-at-exit", "thread-at-exit", "experimental-relocate", "eh-personality-continue", "panic-handler-abort", "nightly"] }
13+
origin = { path = "../..", default-features = false, features = ["origin-start", "program-at-exit", "thread-at-exit", "experimental-relocate", "eh-personality-continue", "panic-handler-trap", "nightly"] }
1414

1515
# Crates to help writing no_std code.
1616
atomic-dbg = { version = "0.1.8", default-features = false }

example-crates/origin-start-lto/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ publish = false
77
[dependencies]
88
# Origin can be depended on just like any other crate. For no_std, disable
99
# the default features, and the desired features.
10-
origin = { path = "../..", default-features = false, features = ["origin-start", "program-at-exit", "thread-at-exit", "eh-personality-continue", "panic-handler-abort", "nightly"] }
10+
origin = { path = "../..", default-features = false, features = ["origin-start", "program-at-exit", "thread-at-exit", "eh-personality-continue", "panic-handler-trap", "nightly"] }
1111

1212
# Crates to help writing no_std code.
1313
atomic-dbg = { version = "0.1.8", default-features = false }

example-crates/origin-start-no-alloc/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ publish = false
77
[dependencies]
88
# Origin can be depended on just like any other crate. For no_std, disable
99
# the default features, and the desired features.
10-
origin = { path = "../..", default-features = false, features = ["origin-start", "eh-personality-continue", "panic-handler-abort", "nightly"] }
10+
origin = { path = "../..", default-features = false, features = ["origin-start", "eh-personality-continue", "panic-handler-trap", "nightly"] }
1111

1212
# Crates to help writing no_std code.
1313
atomic-dbg = { version = "0.1.8", default-features = false }

example-crates/origin-start-stable/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ publish = false
77
[dependencies]
88
# Origin can be depended on just like any other crate. For no_std, disable
99
# the default features, and the desired features.
10-
origin = { path = "../..", default-features = false, features = ["origin-start", "program-at-exit", "thread-at-exit", "eh-personality-continue", "panic-handler-abort"] }
10+
origin = { path = "../..", default-features = false, features = ["origin-start", "program-at-exit", "thread-at-exit", "eh-personality-continue", "panic-handler-trap"] }
1111

1212
# Crates to help writing no_std code.
1313
atomic-dbg = { version = "0.1.8", default-features = false }

example-crates/origin-start/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ publish = false
77
[dependencies]
88
# Origin can be depended on just like any other crate. For no_std, disable
99
# the default features, and the desired features.
10-
origin = { path = "../..", default-features = false, features = ["origin-start", "program-at-exit", "thread-at-exit", "eh-personality-continue", "panic-handler-abort", "nightly"] }
10+
origin = { path = "../..", default-features = false, features = ["origin-start", "program-at-exit", "thread-at-exit", "eh-personality-continue", "panic-handler-trap", "nightly"] }
1111

1212
# Crates to help writing no_std code.
1313
atomic-dbg = { version = "0.1.8", default-features = false }

0 commit comments

Comments
 (0)