Skip to content

Commit 2006782

Browse files
committed
Swap size and value args in roundtrip tests
If there is a disagreement on the size of the value, this can cause issues on archs that pass parameters on the stack (such as x86) leading to non-sensical errors like this: > size of struct sched_param is 28 in C and -134597808 in Rust
1 parent 8ef9712 commit 2006782

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ctest/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1913,7 +1913,7 @@ impl<'a> Generator<'a> {
19131913
# pragma warning(disable:4365)
19141914
#endif
19151915
{linkage} {cty} __test_roundtrip_{ty}(
1916-
{cty} value, int32_t rust_size, int* error, unsigned char* pad
1916+
int32_t rust_size, {cty} value, int* error, unsigned char* pad
19171917
) {{
19181918
volatile unsigned char* p = (volatile unsigned char*)&value;
19191919
int size = (int)sizeof({cty});
@@ -1967,7 +1967,7 @@ impl<'a> Generator<'a> {
19671967
extern {{
19681968
#[allow(non_snake_case)]
19691969
fn __test_roundtrip_{ty}(
1970-
x: U, size: i32, e: *mut c_int, pad: *const u8
1970+
size: i32, x: U, e: *mut c_int, pad: *const u8
19711971
) -> U;
19721972
}}
19731973
let pad = roundtrip_padding_{ty}();
@@ -1987,7 +1987,7 @@ impl<'a> Generator<'a> {
19871987
x_ptr.add(i).write_volatile(c);
19881988
y_ptr.add(i).write_volatile(d);
19891989
}}
1990-
let r: U = __test_roundtrip_{ty}(x.assume_init(), sz as i32, &mut error, pad.as_ptr());
1990+
let r: U = __test_roundtrip_{ty}(sz as i32, x.assume_init(), &mut error, pad.as_ptr());
19911991
if error == 1 {{
19921992
FAILED.store(true, Ordering::SeqCst);
19931993
return;

0 commit comments

Comments
 (0)