auto merge of #13315 : alexcrichton/rust/libc, r=alexcrichton,me

Rebasing of #12526 with a very obscure bug fixed on windows.
This commit is contained in:
bors 2014-04-06 02:56:39 -07:00
commit f1f50565a1
124 changed files with 612 additions and 511 deletions

View file

@ -10,7 +10,7 @@
#[crate_id="anonexternmod#0.1"];
use std::libc;
extern crate libc;
#[link(name="rustrt")]
extern {

View file

@ -11,10 +11,10 @@
#[crate_id="externcallback#0.1"];
#[crate_type = "lib"];
use std::libc;
extern crate libc;
pub mod rustrt {
use std::libc;
extern crate libc;
#[link(name = "rustrt")]
extern {

View file

@ -11,7 +11,7 @@
#[crate_id="foreign_lib"];
pub mod rustrt {
use std::libc;
extern crate libc;
#[link(name = "rustrt")]
extern {

View file

@ -12,7 +12,7 @@
#[crate_type = "lib"];
pub mod socket {
use std::libc;
extern crate libc;
pub struct socket_handle {
sockfd: libc::c_int,

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::libc;
extern crate libc;
extern "C" {
pub fn rand() -> libc::c_int;

View file

@ -12,7 +12,7 @@
// statics cannot. This ensures that there's some form of error if this is
// attempted.
use std::libc;
extern crate libc;
extern {
static mut rust_dbg_static_mut: libc::c_int;

View file

@ -10,7 +10,7 @@
#![deny(ctypes)]
use std::libc;
extern crate libc;
extern {
pub fn bare_type1(size: int); //~ ERROR: found rust type

View file

@ -14,6 +14,8 @@
#![crate_type="lib"]
extern crate libc;
struct Foo; //~ ERROR: code is never used
impl Foo {
fn foo(&self) { //~ ERROR: code is never used
@ -46,7 +48,7 @@ pub fn pub_fn() {
}
mod blah {
use std::libc::size_t;
use libc::size_t;
// not warned because it's used in the parameter of `free` and return of
// `malloc` below, which are also used.
enum c_void {}

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::libc;
extern crate libc;
fn main() {
let x : *Vec<int> = &vec!(1,2,3);

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::libc;
extern crate libc;
extern {
static mut a: libc::c_int;

View file

@ -10,7 +10,7 @@
// error-pattern:unsupported cast
use std::libc;
extern crate libc;
fn main() {
println!("{:?}", 1.0 as *libc::FILE); // Can't cast float to foreign.

View file

@ -13,11 +13,11 @@
// Testing that runtime failure doesn't cause callbacks to abort abnormally.
// Instead the failure will be delivered after the callbacks return.
use std::libc;
extern crate libc;
use std::task;
mod rustrt {
use std::libc;
extern crate libc;
extern {
pub fn rust_dbg_call(cb: *u8, data: libc::uintptr_t)

View file

@ -16,11 +16,11 @@
// See the hack in upcall_call_shim_on_c_stack where it messes
// with the stack limit.
use std::libc;
extern crate libc;
use std::task;
mod rustrt {
use std::libc;
extern crate libc;
extern {
pub fn rust_get_argc() -> libc::c_int;

View file

@ -4,6 +4,9 @@ ifneq ($(shell uname),Darwin)
EXTRAFLAGS := -lm -lrt -ldl -lpthread
endif
# Apparently older versions of GCC segfault if -g is passed...
CC := $(CC:-g=)
all:
$(RUSTC) foo.rs -Z lto
ln -s $(call STATICLIB,foo-*) $(call STATICLIB,foo)

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[crate_type = "staticlib"];
#![crate_type = "staticlib"]
#[no_mangle]
pub extern "C" fn foo() {}

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::libc;
extern crate libc;
#[link(name = "rustrt")]
extern {

View file

@ -9,7 +9,7 @@
// except according to those terms.
mod rustrt {
use std::libc;
extern crate libc;
#[link(name = "rustrt")]
extern {

View file

@ -8,8 +8,12 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
mod libc {
use std::libc::{c_char, c_long, c_longlong};
// ignore-fast doesn't like extern crate
extern crate libc;
mod mlibc {
use libc::{c_char, c_long, c_longlong};
extern {
pub fn atol(x: *c_char) -> c_long;
@ -18,11 +22,11 @@ mod libc {
}
fn atol(s: ~str) -> int {
s.with_c_str(|x| unsafe { libc::atol(x) as int })
s.with_c_str(|x| unsafe { mlibc::atol(x) as int })
}
fn atoll(s: ~str) -> i64 {
s.with_c_str(|x| unsafe { libc::atoll(x) as i64 })
s.with_c_str(|x| unsafe { mlibc::atoll(x) as i64 })
}
pub fn main() {

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::libc;
extern crate libc;
extern fn foo() {}

View file

@ -17,6 +17,7 @@
// instead of in std.
#[feature(macro_rules)];
extern crate libc;
extern crate native;
extern crate green;
@ -34,7 +35,7 @@ macro_rules! iotest (
#[allow(unused_imports)];
use std::io::timer;
use std::libc;
use libc;
use std::str;
use std::io::process::{Process, ProcessOutput};
use native;
@ -87,7 +88,7 @@ iotest!(fn test_destroy_twice() {
pub fn test_destroy_actually_kills(force: bool) {
use std::io::process::{Process, ProcessOutput, ExitStatus, ExitSignal};
use std::io::timer;
use std::libc;
use libc;
use std::str;
#[cfg(unix,not(target_os="android"))]

View file

@ -8,10 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::libc;
extern crate libc;
mod rustrt {
use std::libc;
extern crate libc;
#[link(name = "rustrt")]
extern {

View file

@ -8,11 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::libc;
extern crate libc;
use std::task;
mod rustrt {
use std::libc;
extern crate libc;
#[link(name = "rustrt")]
extern {

View file

@ -8,10 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::libc;
extern crate libc;
mod rustrt {
use std::libc;
extern crate libc;
#[link(name = "rustrt")]
extern {

View file

@ -12,11 +12,11 @@
// make sure the stack pointers are maintained properly in both
// directions
use std::libc;
extern crate libc;
use std::task;
mod rustrt {
use std::libc;
extern crate libc;
#[link(name = "rustrt")]
extern {

View file

@ -11,11 +11,11 @@
// This creates a bunch of descheduling tasks that run concurrently
// while holding onto C stacks
use std::libc;
extern crate libc;
use std::task;
mod rustrt {
use std::libc;
extern crate libc;
#[link(name = "rustrt")]
extern {

View file

@ -8,11 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::libc;
extern crate libc;
use std::task;
mod rustrt {
use std::libc;
extern crate libc;
#[link(name = "rustrt")]
extern {

View file

@ -8,8 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
extern crate libc;
use std::cast;
use std::libc;
use std::unstable::run_in_bare_thread;
#[link(name = "rustrt")]

View file

@ -12,7 +12,7 @@
// calling pin_task and that's having wierd side-effects.
mod rustrt1 {
use std::libc;
extern crate libc;
#[link(name = "rustrt")]
extern {
@ -21,7 +21,7 @@ mod rustrt1 {
}
mod rustrt2 {
use std::libc;
extern crate libc;
#[link(name = "rustrt")]
extern {

View file

@ -8,8 +8,13 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
mod libc {
use std::libc::{c_char, size_t};
// ignore-fast doesn't like extern crate
extern crate libc;
mod mlibc {
extern crate libc;
use self::libc::{c_char, size_t};
extern {
#[link_name = "strlen"]
@ -21,7 +26,7 @@ fn strlen(str: ~str) -> uint {
// C string is terminated with a zero
str.with_c_str(|buf| {
unsafe {
libc::my_strlen(buf) as uint
mlibc::my_strlen(buf) as uint
}
})
}

View file

@ -8,8 +8,12 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// ignore-fast doesn't like extern crate
extern crate libc;
mod foo {
use std::libc::c_int;
use libc::c_int;
extern {
pub static errno: c_int;

View file

@ -11,7 +11,7 @@
// ABI is cdecl by default
mod rustrt {
use std::libc;
extern crate libc;
#[link(name = "rustrt")]
extern {

View file

@ -8,6 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// ignore-fast doesn't like extern crate
extern crate libc;
mod bar {
extern {}
}
@ -16,8 +20,8 @@ mod zed {
extern {}
}
mod libc {
use std::libc::{c_int, c_void, size_t, ssize_t};
mod mlibc {
use libc::{c_int, c_void, size_t, ssize_t};
extern {
pub fn write(fd: c_int, buf: *c_void, count: size_t) -> ssize_t;

View file

@ -11,7 +11,7 @@
#[crate_id="rust_get_test_int"];
mod rustrt {
use std::libc;
extern crate libc;
extern {
pub fn rust_get_test_int() -> libc::intptr_t;

View file

@ -10,8 +10,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
extern crate libc;
use std::cast;
use std::libc::{c_double, c_int};
use libc::{c_double, c_int};
fn to_c_int(v: &mut int) -> &mut c_int {
unsafe {
@ -26,7 +28,7 @@ fn lgamma(n: c_double, value: &mut int) -> c_double {
}
mod m {
use std::libc::{c_double, c_int};
use libc::{c_double, c_int};
#[link_name = "m"]
extern {

View file

@ -14,9 +14,9 @@
#[feature(managed_boxes)];
extern crate socketlib;
extern crate libc;
use socketlib::socket;
use std::libc;
pub fn main() {
let fd: libc::c_int = 1 as libc::c_int;

View file

@ -13,7 +13,8 @@
// Incorrect struct size computation in the FFI, because of not taking
// the alignment of elements into account.
use std::libc::{c_uint, uint32_t, c_void};
extern crate libc;
use libc::{c_uint, uint32_t, c_void};
struct KEYGEN {
hash_algorithm: [c_uint, ..2],

View file

@ -8,9 +8,12 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// ignore-fast doesn't like extern crate
extern crate libc;
use std::cast::transmute;
use std::libc::c_void;
use libc::c_void;
struct NonCopyable(*c_void);

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::libc;
extern crate libc;
extern {
#[link_name = "malloc"]

View file

@ -157,7 +157,7 @@ mod test_other_forms {
mod test_foreign_items {
pub mod rustrt {
use std::libc;
extern crate libc;
extern {
#![attr]

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::libc;
extern crate libc;
extern {
fn rust_get_test_int() -> libc::intptr_t;

View file

@ -18,7 +18,7 @@ extern crate rand;
use std::task;
mod rustrt {
use std::libc;
extern crate libc;
extern {
pub fn debug_get_stk_seg() -> *u8;

View file

@ -8,8 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::libc::c_int;
use std::libc;
// ignore-fast doesn't like extern crate
extern crate libc;
use libc::c_int;
pub struct Fd(c_int);

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::libc;
extern crate libc;
#[cfg(target_os = "macos")]
#[link(name = "CoreFoundation", kind = "framework")]

View file

@ -22,8 +22,8 @@
extern crate green;
extern crate rustuv;
extern crate libc;
use std::libc;
use std::io::process;
use std::io::signal::{Listener, Interrupt};

View file

@ -18,11 +18,11 @@
extern crate arena;
extern crate collections;
extern crate libc;
use arena::Arena;
use collections::HashMap;
use std::cast;
use std::libc;
use std::mem;
type Type<'tcx> = &'tcx TypeStructure<'tcx>;

View file

@ -8,8 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
extern crate libc;
use std::cast;
use std::libc;
use std::mem;
struct arena(());

View file

@ -13,9 +13,10 @@
// ignore-fast
extern crate libc;
use std::io::TempDir;
use std::os;
use std::libc;
use std::io;
use std::io::fs;

View file

@ -12,7 +12,7 @@
// statics cannot. This ensures that there's some form of error if this is
// attempted.
use std::libc;
extern crate libc;
#[link(name = "rustrt")]
extern {

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::libc;
extern crate libc;
pub fn main() {
let f = 1 as *libc::FILE;

View file

@ -16,8 +16,8 @@
#![feature(phase)]
#[phase(syntax, link)]
extern crate log;
extern crate libc;
use std::libc;
use std::io::net::ip::{Ipv4Addr, SocketAddr};
use std::io::net::tcp::{TcpListener, TcpStream};
use std::io::{Acceptor, Listener};

View file

@ -8,8 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
extern crate libc;
use std::c_str::CString;
use std::libc::{c_char, c_int};
use libc::{c_char, c_int};
// ignore-fast doesn't like extern crate
extern {
fn sprintf(s: *mut c_char, format: *c_char, ...) -> c_int;