1 // Copyright 2013 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.
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.
12 * C-like enums have to be represented as LLVM ints, not wrapped in a
13 * struct, because it's important for the FFI that they interoperate
14 * with C integers/enums, and the ABI can treat structs differently.
15 * For example, on i686-linux-gnu, a struct return value is passed by
16 * storing to a hidden out parameter, whereas an integer would be
17 * returned in a register.
19 * This test just checks that the ABIs for the enum and the plain
20 * integer are compatible, rather than actually calling C code.
21 * The unused parameter to `foo` is to increase the likelihood of
22 * crashing if something goes wrong here.
32 extern "C" fn foo(_x: uint) -> Foo { Foo::B }
36 let f: extern "C" fn(uint) -> u32 = ::std::mem::transmute(foo);
37 assert_eq!(f(0xDEADBEEF), Foo::B as u32);