Skip to content

Commit

Permalink
librustc: Disallow "unsafe" for external functions
Browse files Browse the repository at this point in the history
  • Loading branch information
pcwalton committed Aug 3, 2013
1 parent 887c656 commit 9457ebe
Show file tree
Hide file tree
Showing 36 changed files with 1,705 additions and 1,825 deletions.
20 changes: 10 additions & 10 deletions src/libextra/flate.rs
Expand Up @@ -25,17 +25,17 @@ pub mod rustrt {

#[link_name = "rustrt"]
extern {
pub unsafe fn tdefl_compress_mem_to_heap(psrc_buf: *const c_void,
src_buf_len: size_t,
pout_len: *mut size_t,
flags: c_int)
-> *c_void;
pub fn tdefl_compress_mem_to_heap(psrc_buf: *const c_void,
src_buf_len: size_t,
pout_len: *mut size_t,
flags: c_int)
-> *c_void;

pub unsafe fn tinfl_decompress_mem_to_heap(psrc_buf: *const c_void,
src_buf_len: size_t,
pout_len: *mut size_t,
flags: c_int)
-> *c_void;
pub fn tinfl_decompress_mem_to_heap(psrc_buf: *const c_void,
src_buf_len: size_t,
pout_len: *mut size_t,
flags: c_int)
-> *c_void;
}
}

Expand Down
14 changes: 7 additions & 7 deletions src/libextra/rl.rs
Expand Up @@ -20,13 +20,13 @@ pub mod rustrt {
use std::libc::{c_char, c_int};

extern {
pub unsafe fn linenoise(prompt: *c_char) -> *c_char;
pub unsafe fn linenoiseHistoryAdd(line: *c_char) -> c_int;
pub unsafe fn linenoiseHistorySetMaxLen(len: c_int) -> c_int;
pub unsafe fn linenoiseHistorySave(file: *c_char) -> c_int;
pub unsafe fn linenoiseHistoryLoad(file: *c_char) -> c_int;
pub unsafe fn linenoiseSetCompletionCallback(callback: *u8);
pub unsafe fn linenoiseAddCompletion(completions: *(), line: *c_char);
pub fn linenoise(prompt: *c_char) -> *c_char;
pub fn linenoiseHistoryAdd(line: *c_char) -> c_int;
pub fn linenoiseHistorySetMaxLen(len: c_int) -> c_int;
pub fn linenoiseHistorySave(file: *c_char) -> c_int;
pub fn linenoiseHistoryLoad(file: *c_char) -> c_int;
pub fn linenoiseSetCompletionCallback(callback: *u8);
pub fn linenoiseAddCompletion(completions: *(), line: *c_char);
}
}

Expand Down
17 changes: 7 additions & 10 deletions src/libextra/time.rs
Expand Up @@ -23,16 +23,13 @@ pub mod rustrt {

#[abi = "cdecl"]
extern {
pub unsafe fn get_time(sec: &mut i64, nsec: &mut i32);

pub unsafe fn precise_time_ns(ns: &mut u64);

pub unsafe fn rust_tzset();

pub unsafe fn rust_gmtime(sec: i64, nsec: i32, result: &mut Tm);
pub unsafe fn rust_localtime(sec: i64, nsec: i32, result: &mut Tm);
pub unsafe fn rust_timegm(tm: &Tm) -> i64;
pub unsafe fn rust_mktime(tm: &Tm) -> i64;
pub fn get_time(sec: &mut i64, nsec: &mut i32);
pub fn precise_time_ns(ns: &mut u64);
pub fn rust_tzset();
pub fn rust_gmtime(sec: i64, nsec: i32, result: &mut Tm);
pub fn rust_localtime(sec: i64, nsec: i32, result: &mut Tm);
pub fn rust_timegm(tm: &Tm) -> i64;
pub fn rust_mktime(tm: &Tm) -> i64;
}
}

Expand Down
15 changes: 7 additions & 8 deletions src/libextra/unicode.rs
Expand Up @@ -162,14 +162,13 @@ pub mod icu {
#[link_name = "icuuc"]
#[abi = "cdecl"]
extern {
pub unsafe fn u_hasBinaryProperty(c: UChar32, which: UProperty)
-> UBool;
pub unsafe fn u_isdigit(c: UChar32) -> UBool;
pub unsafe fn u_islower(c: UChar32) -> UBool;
pub unsafe fn u_isspace(c: UChar32) -> UBool;
pub unsafe fn u_isupper(c: UChar32) -> UBool;
pub unsafe fn u_tolower(c: UChar32) -> UChar32;
pub unsafe fn u_toupper(c: UChar32) -> UChar32;
pub fn u_hasBinaryProperty(c: UChar32, which: UProperty) -> UBool;
pub fn u_isdigit(c: UChar32) -> UBool;
pub fn u_islower(c: UChar32) -> UBool;
pub fn u_isspace(c: UChar32) -> UBool;
pub fn u_isupper(c: UChar32) -> UBool;
pub fn u_tolower(c: UChar32) -> UChar32;
pub fn u_toupper(c: UChar32) -> UChar32;
}
}
}
Expand Down

5 comments on commit 9457ebe

@bors
Copy link
Contributor

@bors bors commented on 9457ebe Aug 3, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from pcwalton
at pcwalton@9457ebe

@bors
Copy link
Contributor

@bors bors commented on 9457ebe Aug 3, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging pcwalton/rust/unsafe-extern-fns = 9457ebe into auto

@bors
Copy link
Contributor

@bors bors commented on 9457ebe Aug 3, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pcwalton/rust/unsafe-extern-fns = 9457ebe merged ok, testing candidate = 2a7be1c

@bors
Copy link
Contributor

@bors bors commented on 9457ebe Aug 3, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 2a7be1c

Please sign in to comment.