summary refs log tree commit diff
path: root/src/test/run-pass/bind-native-fn.rs
blob: ed9fb1c99a1833341878e6ecdf6170e1ec85619b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// From #1174:
// xfail-test bots are crashing on this on x86_64

use std;
import str;
import libc::*;

#[nolink]
native mod libc {
    fn write(fd: c_int, buf: *u8, nbyte: size_t);
}

fn main() {
    let s = "hello world\n";
    let b = str::bytes(s);
    let l = str::len(s);
    let b8 = unsafe { vec::unsafe::to_ptr(b) };
    libc::write(0i32, b8, l);
    let a = bind libc::write(0i32, _, _);
    a(b8, l);
}