]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/auxiliary/allocator-dummy.rs
libsyntax/parse: improve associated item error reporting
[rust.git] / src / test / run-pass / auxiliary / allocator-dummy.rs
1 // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // no-prefer-dynamic
12
13 #![feature(allocator, core_intrinsics, libc)]
14 #![allocator]
15 #![crate_type = "rlib"]
16 #![no_std]
17
18 extern crate libc;
19
20 pub static mut HITS: usize = 0;
21
22 #[no_mangle]
23 pub extern fn __rust_allocate(size: usize, align: usize) -> *mut u8 {
24     unsafe {
25         HITS += 1;
26         libc::malloc(size as libc::size_t) as *mut u8
27     }
28 }
29
30 #[no_mangle]
31 pub extern fn __rust_deallocate(ptr: *mut u8, old_size: usize, align: usize) {
32     unsafe {
33         HITS += 1;
34         libc::free(ptr as *mut _)
35     }
36 }
37
38 #[no_mangle]
39 pub extern fn __rust_reallocate(ptr: *mut u8, old_size: usize, size: usize,
40                                 align: usize) -> *mut u8 {
41     unsafe {
42         libc::realloc(ptr as *mut _, size as libc::size_t) as *mut u8
43     }
44 }
45
46 #[no_mangle]
47 pub extern fn __rust_reallocate_inplace(ptr: *mut u8, old_size: usize,
48                                         size: usize, align: usize) -> usize {
49     unsafe { core::intrinsics::abort() }
50 }
51
52 #[no_mangle]
53 pub extern fn __rust_usable_size(size: usize, align: usize) -> usize {
54     unsafe { core::intrinsics::abort() }
55 }