liblibc: don't use int/uint for intptr_t/uintptr_t
int/uint aren't considered FFI safe, replace them with the actual type they represent (i64/u64 or i32/u32). This is a breaking change, but at most a cast to `uint` or `int` needs to be added. [breaking-change]
This commit is contained in:
parent
0cffa32c21
commit
2dc2ac1e6b
|
@ -507,8 +507,8 @@ pub mod types {
|
|||
pub mod c99 {
|
||||
pub type c_longlong = i64;
|
||||
pub type c_ulonglong = u64;
|
||||
pub type intptr_t = int;
|
||||
pub type uintptr_t = uint;
|
||||
pub type intptr_t = i32;
|
||||
pub type uintptr_t = u32;
|
||||
}
|
||||
#[cfg(target_arch = "x86")]
|
||||
#[cfg(target_arch = "mips")]
|
||||
|
@ -702,8 +702,8 @@ pub mod types {
|
|||
pub mod c99 {
|
||||
pub type c_longlong = i64;
|
||||
pub type c_ulonglong = u64;
|
||||
pub type intptr_t = int;
|
||||
pub type uintptr_t = uint;
|
||||
pub type intptr_t = i64;
|
||||
pub type uintptr_t = u64;
|
||||
}
|
||||
pub mod posix88 {
|
||||
pub type off_t = i64;
|
||||
|
@ -911,8 +911,8 @@ pub mod types {
|
|||
pub mod c99 {
|
||||
pub type c_longlong = i64;
|
||||
pub type c_ulonglong = u64;
|
||||
pub type intptr_t = int;
|
||||
pub type uintptr_t = uint;
|
||||
pub type intptr_t = i64;
|
||||
pub type uintptr_t = u64;
|
||||
}
|
||||
pub mod posix88 {
|
||||
pub type off_t = i64;
|
||||
|
@ -1124,8 +1124,8 @@ pub mod types {
|
|||
pub mod c99 {
|
||||
pub type c_longlong = i64;
|
||||
pub type c_ulonglong = u64;
|
||||
pub type intptr_t = int;
|
||||
pub type uintptr_t = uint;
|
||||
pub type intptr_t = i64;
|
||||
pub type uintptr_t = u64;
|
||||
}
|
||||
pub mod posix88 {
|
||||
pub type off_t = i64;
|
||||
|
@ -1243,9 +1243,10 @@ pub mod types {
|
|||
}
|
||||
|
||||
pub mod bsd44 {
|
||||
use types::os::arch::c95::{c_char, c_int, c_uint, size_t, uintptr_t};
|
||||
use types::os::arch::c95::{c_char, c_int, c_uint, size_t};
|
||||
use types::os::arch::c99::uintptr_t;
|
||||
|
||||
pub type SOCKET = uint;
|
||||
pub type SOCKET = uintptr_t;
|
||||
pub type socklen_t = c_int;
|
||||
pub type sa_family_t = u16;
|
||||
pub type in_port_t = u16;
|
||||
|
@ -1356,8 +1357,8 @@ pub mod types {
|
|||
pub mod c99 {
|
||||
pub type c_longlong = i64;
|
||||
pub type c_ulonglong = u64;
|
||||
pub type intptr_t = int;
|
||||
pub type uintptr_t = uint;
|
||||
pub type intptr_t = i32;
|
||||
pub type uintptr_t = u32;
|
||||
}
|
||||
|
||||
pub mod posix88 {
|
||||
|
@ -1486,7 +1487,7 @@ pub mod types {
|
|||
pub dwPageSize: DWORD,
|
||||
pub lpMinimumApplicationAddress: LPVOID,
|
||||
pub lpMaximumApplicationAddress: LPVOID,
|
||||
pub dwActiveProcessorMask: uint,
|
||||
pub dwActiveProcessorMask: uintptr_t,
|
||||
pub dwNumberOfProcessors: DWORD,
|
||||
pub dwProcessorType: DWORD,
|
||||
pub dwAllocationGranularity: DWORD,
|
||||
|
@ -1720,8 +1721,8 @@ pub mod types {
|
|||
pub mod c99 {
|
||||
pub type c_longlong = i64;
|
||||
pub type c_ulonglong = u64;
|
||||
pub type intptr_t = int;
|
||||
pub type uintptr_t = uint;
|
||||
pub type intptr_t = i32;
|
||||
pub type uintptr_t = u32;
|
||||
}
|
||||
pub mod posix88 {
|
||||
pub type off_t = i64;
|
||||
|
@ -1821,8 +1822,8 @@ pub mod types {
|
|||
pub mod c99 {
|
||||
pub type c_longlong = i64;
|
||||
pub type c_ulonglong = u64;
|
||||
pub type intptr_t = int;
|
||||
pub type uintptr_t = uint;
|
||||
pub type intptr_t = i64;
|
||||
pub type uintptr_t = u64;
|
||||
}
|
||||
pub mod posix88 {
|
||||
pub type off_t = i64;
|
||||
|
@ -4401,7 +4402,7 @@ pub mod funcs {
|
|||
pub fn glob(pattern: *const c_char,
|
||||
flags: c_int,
|
||||
errfunc: ::Nullable<extern "C" fn(epath: *const c_char,
|
||||
errno: int) -> int>,
|
||||
errno: c_int) -> int>,
|
||||
pglob: *mut glob_t);
|
||||
pub fn globfree(pglob: *mut glob_t);
|
||||
}
|
||||
|
|
|
@ -235,6 +235,7 @@ mod signal {
|
|||
pub type sigset_t = u32;
|
||||
#[cfg(target_os = "freebsd")]
|
||||
#[cfg(target_os = "dragonfly")]
|
||||
#[repr(C)]
|
||||
pub struct sigset_t {
|
||||
bits: [u32, ..4],
|
||||
}
|
||||
|
|
|
@ -369,9 +369,9 @@ impl LintPass for CTypes {
|
|||
|
||||
if !ty::is_ffi_safe(cx.tcx, tty) {
|
||||
cx.span_lint(CTYPES, ty.span,
|
||||
"found enum type without foreign-function-safe
|
||||
"found type without foreign-function-safe
|
||||
representation annotation in foreign module, consider \
|
||||
adding a #[repr(...)] attribute to the enumeration");
|
||||
adding a #[repr(...)] attribute to the type");
|
||||
}
|
||||
}
|
||||
_ => ()
|
||||
|
|
|
@ -378,14 +378,14 @@ pub unsafe fn free_req(v: *mut c_void) {
|
|||
#[test]
|
||||
fn handle_sanity_check() {
|
||||
unsafe {
|
||||
assert_eq!(UV_HANDLE_TYPE_MAX as uint, rust_uv_handle_type_max());
|
||||
assert_eq!(UV_HANDLE_TYPE_MAX as libc::uintptr_t, rust_uv_handle_type_max());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn request_sanity_check() {
|
||||
unsafe {
|
||||
assert_eq!(UV_REQ_TYPE_MAX as uint, rust_uv_req_type_max());
|
||||
assert_eq!(UV_REQ_TYPE_MAX as libc::uintptr_t, rust_uv_req_type_max());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ use libc::c_char;
|
|||
/// Get the number of cores available
|
||||
pub fn num_cpus() -> uint {
|
||||
unsafe {
|
||||
return rust_get_num_cpus();
|
||||
return rust_get_num_cpus() as uint;
|
||||
}
|
||||
|
||||
extern {
|
||||
|
|
|
@ -24,7 +24,7 @@ pub mod rustrt {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn fact(n: uint) -> uint {
|
||||
pub fn fact(n: libc::uintptr_t) -> libc::uintptr_t {
|
||||
unsafe {
|
||||
println!("n = {}", n);
|
||||
rustrt::rust_dbg_call(cb, n)
|
||||
|
@ -32,9 +32,9 @@ pub fn fact(n: uint) -> uint {
|
|||
}
|
||||
|
||||
pub extern fn cb(data: libc::uintptr_t) -> libc::uintptr_t {
|
||||
if data == 1u {
|
||||
if data == 1 {
|
||||
data
|
||||
} else {
|
||||
fact(data - 1u) * data
|
||||
fact(data - 1) * data
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,19 +11,19 @@
|
|||
#![deny(ctypes)]
|
||||
#![allow(dead_code)]
|
||||
|
||||
struct A { //~ NOTE consider adding `#[repr(C)]` to this type
|
||||
x: int
|
||||
struct A {
|
||||
x: i32
|
||||
}
|
||||
|
||||
#[repr(C, packed)]
|
||||
struct B {
|
||||
x: int,
|
||||
x: i32,
|
||||
y: A
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
struct C {
|
||||
x: int
|
||||
x: i32
|
||||
}
|
||||
|
||||
type A2 = A;
|
||||
|
@ -37,13 +37,13 @@ struct D {
|
|||
}
|
||||
|
||||
extern "C" {
|
||||
fn foo(x: A); //~ ERROR found struct without FFI-safe representation used in FFI
|
||||
fn bar(x: B); //~ ERROR FFI-safe
|
||||
fn foo(x: A); //~ ERROR found type without foreign-function-safe
|
||||
fn bar(x: B); //~ ERROR foreign-function-safe
|
||||
fn baz(x: C);
|
||||
fn qux(x: A2); //~ ERROR FFI-safe
|
||||
fn quux(x: B2); //~ ERROR FFI-safe
|
||||
fn qux(x: A2); //~ ERROR foreign-function-safe
|
||||
fn quux(x: B2); //~ ERROR foreign-function-safe
|
||||
fn corge(x: C2);
|
||||
fn fred(x: D); //~ ERROR FFI-safe
|
||||
fn fred(x: D); //~ ERROR foreign-function-safe
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
|
|
|
@ -18,9 +18,9 @@ enum T { E, F, G }
|
|||
|
||||
extern {
|
||||
fn zf(x: Z);
|
||||
fn uf(x: U);
|
||||
fn bf(x: B); //~ ERROR found enum without FFI-safe
|
||||
fn tf(x: T); //~ ERROR found enum without FFI-safe
|
||||
fn uf(x: U); //~ ERROR found type without foreign-function-safe
|
||||
fn bf(x: B); //~ ERROR found type without foreign-function-safe
|
||||
fn tf(x: T); //~ ERROR found type without foreign-function-safe
|
||||
}
|
||||
|
||||
pub fn main() { }
|
||||
|
|
|
@ -22,14 +22,14 @@ mod rustrt {
|
|||
}
|
||||
|
||||
extern fn cb(data: libc::uintptr_t) -> libc::uintptr_t {
|
||||
if data == 1u {
|
||||
if data == 1 {
|
||||
data
|
||||
} else {
|
||||
count(data - 1u) + 1u
|
||||
count(data - 1) + 1
|
||||
}
|
||||
}
|
||||
|
||||
fn count(n: uint) -> uint {
|
||||
fn count(n: libc::uintptr_t) -> libc::uintptr_t {
|
||||
unsafe {
|
||||
println!("n = {}", n);
|
||||
rustrt::rust_dbg_call(cb, n)
|
||||
|
@ -37,7 +37,7 @@ fn count(n: uint) -> uint {
|
|||
}
|
||||
|
||||
pub fn main() {
|
||||
let result = count(1000u);
|
||||
let result = count(1000);
|
||||
println!("result = {}", result);
|
||||
assert_eq!(result, 1000u);
|
||||
assert_eq!(result, 1000);
|
||||
}
|
||||
|
|
|
@ -23,14 +23,14 @@ mod rustrt {
|
|||
}
|
||||
|
||||
extern fn cb(data: libc::uintptr_t) -> libc::uintptr_t {
|
||||
if data == 1u {
|
||||
if data == 1 {
|
||||
data
|
||||
} else {
|
||||
count(data - 1u) + 1u
|
||||
count(data - 1) + 1
|
||||
}
|
||||
}
|
||||
|
||||
fn count(n: uint) -> uint {
|
||||
fn count(n: libc::uintptr_t) -> libc::uintptr_t {
|
||||
unsafe {
|
||||
println!("n = {}", n);
|
||||
rustrt::rust_dbg_call(cb, n)
|
||||
|
@ -41,8 +41,8 @@ pub fn main() {
|
|||
// Make sure we're on a task with small Rust stacks (main currently
|
||||
// has a large stack)
|
||||
task::spawn(proc() {
|
||||
let result = count(1000u);
|
||||
let result = count(1000);
|
||||
println!("result = {}", result);
|
||||
assert_eq!(result, 1000u);
|
||||
assert_eq!(result, 1000);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -22,14 +22,14 @@ mod rustrt {
|
|||
}
|
||||
|
||||
extern fn cb(data: libc::uintptr_t) -> libc::uintptr_t {
|
||||
if data == 1u {
|
||||
if data == 1 {
|
||||
data
|
||||
} else {
|
||||
fact(data - 1u) * data
|
||||
fact(data - 1) * data
|
||||
}
|
||||
}
|
||||
|
||||
fn fact(n: uint) -> uint {
|
||||
fn fact(n: libc::uintptr_t) -> libc::uintptr_t {
|
||||
unsafe {
|
||||
println!("n = {}", n);
|
||||
rustrt::rust_dbg_call(cb, n)
|
||||
|
@ -37,7 +37,7 @@ fn fact(n: uint) -> uint {
|
|||
}
|
||||
|
||||
pub fn main() {
|
||||
let result = fact(10u);
|
||||
let result = fact(10);
|
||||
println!("result = {}", result);
|
||||
assert_eq!(result, 3628800u);
|
||||
assert_eq!(result, 3628800);
|
||||
}
|
||||
|
|
|
@ -27,14 +27,14 @@ mod rustrt {
|
|||
}
|
||||
|
||||
extern fn cb(data: libc::uintptr_t) -> libc::uintptr_t {
|
||||
if data == 1u {
|
||||
if data == 1 {
|
||||
data
|
||||
} else {
|
||||
count(data - 1u) + count(data - 1u)
|
||||
count(data - 1) + count(data - 1)
|
||||
}
|
||||
}
|
||||
|
||||
fn count(n: uint) -> uint {
|
||||
fn count(n: libc::uintptr_t) -> libc::uintptr_t {
|
||||
unsafe {
|
||||
println!("n = {}", n);
|
||||
rustrt::rust_dbg_call(cb, n)
|
||||
|
@ -45,8 +45,8 @@ pub fn main() {
|
|||
// Make sure we're on a task with small Rust stacks (main currently
|
||||
// has a large stack)
|
||||
task::spawn(proc() {
|
||||
let result = count(12u);
|
||||
let result = count(12);
|
||||
println!("result = {}", result);
|
||||
assert_eq!(result, 2048u);
|
||||
assert_eq!(result, 2048);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -11,8 +11,9 @@
|
|||
//aux-build:extern-crosscrate-source.rs
|
||||
|
||||
extern crate externcallback;
|
||||
extern crate libc;
|
||||
|
||||
fn fact(n: uint) -> uint {
|
||||
fn fact(n: libc::uintptr_t) -> libc::uintptr_t {
|
||||
unsafe {
|
||||
println!("n = {}", n);
|
||||
externcallback::rustrt::rust_dbg_call(externcallback::cb, n)
|
||||
|
@ -20,7 +21,7 @@ fn fact(n: uint) -> uint {
|
|||
}
|
||||
|
||||
pub fn main() {
|
||||
let result = fact(10u);
|
||||
let result = fact(10);
|
||||
println!("result = {}", result);
|
||||
assert_eq!(result, 3628800u);
|
||||
assert_eq!(result, 3628800);
|
||||
}
|
||||
|
|
|
@ -26,24 +26,24 @@ mod rustrt {
|
|||
}
|
||||
|
||||
extern fn cb(data: libc::uintptr_t) -> libc::uintptr_t {
|
||||
if data == 1u {
|
||||
if data == 1 {
|
||||
data
|
||||
} else {
|
||||
task::deschedule();
|
||||
count(data - 1u) + count(data - 1u)
|
||||
count(data - 1) + count(data - 1)
|
||||
}
|
||||
}
|
||||
|
||||
fn count(n: uint) -> uint {
|
||||
fn count(n: libc::uintptr_t) -> libc::uintptr_t {
|
||||
unsafe {
|
||||
rustrt::rust_dbg_call(cb, n)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
for _ in range(0, 100u) {
|
||||
for _ in range(0u, 100) {
|
||||
task::spawn(proc() {
|
||||
assert_eq!(count(5u), 16u);
|
||||
assert_eq!(count(5), 16);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,14 +23,14 @@ mod rustrt {
|
|||
}
|
||||
|
||||
extern fn cb(data: libc::uintptr_t) -> libc::uintptr_t {
|
||||
if data == 1u {
|
||||
if data == 1 {
|
||||
data
|
||||
} else {
|
||||
count(data - 1u) + count(data - 1u)
|
||||
count(data - 1) + count(data - 1)
|
||||
}
|
||||
}
|
||||
|
||||
fn count(n: uint) -> uint {
|
||||
fn count(n: libc::uintptr_t) -> libc::uintptr_t {
|
||||
unsafe {
|
||||
task::deschedule();
|
||||
rustrt::rust_dbg_call(cb, n)
|
||||
|
@ -40,9 +40,9 @@ fn count(n: uint) -> uint {
|
|||
pub fn main() {
|
||||
for _ in range(0, 10u) {
|
||||
task::spawn(proc() {
|
||||
let result = count(5u);
|
||||
let result = count(5);
|
||||
println!("result = {}", result);
|
||||
assert_eq!(result, 16u);
|
||||
assert_eq!(result, 16);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue