forked from ruby/ruby
Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Write rb_mem_clear in Rust
This makefile hackery is ridiculous but whatever, it works!
- Loading branch information
Showing
4 changed files
with
44 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -30,6 +30,7 @@ | ||
| .pc | ||
| .ppack | ||
| .svn | ||
| !./Makefile | ||
| Makefile | ||
| Makefile.old | ||
| cygruby*.def | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| #![no_std] | ||
| #![feature(lang_items)] | ||
|
|
||
| #![feature(libc)] | ||
| extern crate libc; | ||
|
|
||
| pub type Value = libc::uintptr_t; | ||
|
|
||
| #[allow(non_upper_case_globals)] | ||
| static Qnil: libc::uintptr_t = 0x08 as libc::uintptr_t; | ||
|
|
||
| #[no_mangle] | ||
| pub unsafe extern fn rb_mem_clear(mut mem: *mut Value, mut size: libc::c_long) { | ||
| while size != 0 { | ||
| size -= 1; | ||
| *mem = Qnil; | ||
|
|
||
| mem = mem.offset(1); | ||
| } | ||
| } | ||
|
|
||
| use core::fmt; | ||
|
|
||
| #[lang = "eh_personality"] | ||
| #[no_mangle] | ||
| pub extern fn eh_personality() { | ||
| } | ||
|
|
||
| #[lang = "panic_fmt"] | ||
| #[no_mangle] | ||
| pub extern fn rust_begin_panic(_: fmt::Arguments, | ||
| _: &'static str, | ||
| _: u32) -> ! { | ||
| loop {} | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters