diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2013-08-02 14:30:00 -0700 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2013-08-02 21:57:59 -0700 |
| commit | 9457ebee550d8f77ffc9b895acddae8946ee631e (patch) | |
| tree | b7612d4ec3135ab61b5a02f68259943e88b87936 /src/libstd/os.rs | |
| parent | 887c65697056b23be69b9b11f41637d07327626e (diff) | |
| download | rust-9457ebee550d8f77ffc9b895acddae8946ee631e.tar.gz rust-9457ebee550d8f77ffc9b895acddae8946ee631e.zip | |
librustc: Disallow "unsafe" for external functions
Diffstat (limited to 'src/libstd/os.rs')
| -rw-r--r-- | src/libstd/os.rs | 50 |
1 files changed, 28 insertions, 22 deletions
diff --git a/src/libstd/os.rs b/src/libstd/os.rs index 8a1964783ae..f78f5812863 100644 --- a/src/libstd/os.rs +++ b/src/libstd/os.rs @@ -61,11 +61,11 @@ pub mod rustrt { use libc; extern { - pub unsafe fn rust_get_argc() -> c_int; - pub unsafe fn rust_get_argv() -> **c_char; - pub unsafe fn rust_path_is_dir(path: *libc::c_char) -> c_int; - pub unsafe fn rust_path_exists(path: *libc::c_char) -> c_int; - pub unsafe fn rust_set_exit_status(code: libc::intptr_t); + pub fn rust_get_argc() -> c_int; + pub fn rust_get_argv() -> **c_char; + pub fn rust_path_is_dir(path: *libc::c_char) -> c_int; + pub fn rust_path_exists(path: *libc::c_char) -> c_int; + pub fn rust_set_exit_status(code: libc::intptr_t); } } @@ -201,7 +201,7 @@ pub fn env() -> ~[(~str,~str)] { #[cfg(unix)] unsafe fn get_env_pairs() -> ~[~str] { extern { - unsafe fn rust_env_pairs() -> **libc::c_char; + fn rust_env_pairs() -> **libc::c_char; } let environ = rust_env_pairs(); if (environ as uint == 0) { @@ -694,7 +694,7 @@ pub fn list_dir(p: &Path) -> ~[~str] { use libc::{dirent_t}; use libc::{opendir, readdir, closedir}; extern { - unsafe fn rust_list_dir_val(ptr: *dirent_t) -> *libc::c_char; + fn rust_list_dir_val(ptr: *dirent_t) -> *libc::c_char; } let input = p.to_str(); let mut strings = ~[]; @@ -735,9 +735,8 @@ pub fn list_dir(p: &Path) -> ~[~str] { #[nolink] extern { - unsafe fn rust_list_dir_wfd_size() -> libc::size_t; - unsafe fn rust_list_dir_wfd_fp_buf(wfd: *libc::c_void) - -> *u16; + fn rust_list_dir_wfd_size() -> libc::size_t; + fn rust_list_dir_wfd_fp_buf(wfd: *libc::c_void) -> *u16; } fn star(p: &Path) -> Path { p.push("*") } do as_utf16_p(star(p).to_str()) |path_ptr| { @@ -964,7 +963,7 @@ pub fn errno() -> int { fn errno_location() -> *c_int { #[nolink] extern { - unsafe fn __error() -> *c_int; + fn __error() -> *c_int; } unsafe { __error() @@ -976,7 +975,7 @@ pub fn errno() -> int { fn errno_location() -> *c_int { #[nolink] extern { - unsafe fn __errno_location() -> *c_int; + fn __errno_location() -> *c_int; } unsafe { __errno_location() @@ -996,7 +995,7 @@ pub fn errno() -> uint { #[link_name = "kernel32"] #[abi = "stdcall"] extern "stdcall" { - unsafe fn GetLastError() -> DWORD; + fn GetLastError() -> DWORD; } unsafe { @@ -1011,11 +1010,12 @@ pub fn last_os_error() -> ~str { #[cfg(target_os = "macos")] #[cfg(target_os = "android")] #[cfg(target_os = "freebsd")] - fn strerror_r(errnum: c_int, buf: *mut c_char, buflen: size_t) -> c_int { + fn strerror_r(errnum: c_int, buf: *mut c_char, buflen: size_t) + -> c_int { #[nolink] extern { - unsafe fn strerror_r(errnum: c_int, buf: *mut c_char, - buflen: size_t) -> c_int; + fn strerror_r(errnum: c_int, buf: *mut c_char, buflen: size_t) + -> c_int; } unsafe { strerror_r(errnum, buf, buflen) @@ -1029,8 +1029,10 @@ pub fn last_os_error() -> ~str { fn strerror_r(errnum: c_int, buf: *mut c_char, buflen: size_t) -> c_int { #[nolink] extern { - unsafe fn __xpg_strerror_r(errnum: c_int, buf: *mut c_char, - buflen: size_t) -> c_int; + fn __xpg_strerror_r(errnum: c_int, + buf: *mut c_char, + buflen: size_t) + -> c_int; } unsafe { __xpg_strerror_r(errnum, buf, buflen) @@ -1058,10 +1060,14 @@ pub fn last_os_error() -> ~str { #[link_name = "kernel32"] #[abi = "stdcall"] extern "stdcall" { - unsafe fn FormatMessageA(flags: DWORD, lpSrc: LPVOID, - msgId: DWORD, langId: DWORD, - buf: LPSTR, nsize: DWORD, - args: *c_void) -> DWORD; + fn FormatMessageA(flags: DWORD, + lpSrc: LPVOID, + msgId: DWORD, + langId: DWORD, + buf: LPSTR, + nsize: DWORD, + args: *c_void) + -> DWORD; } static FORMAT_MESSAGE_FROM_SYSTEM: DWORD = 0x00001000; |
