translate-c: fix __builtin_object_size

Previous code assumed `c_long` and `usize` were the same size.
Use `isize` instead.
This commit is contained in:
Evan Haas 2021-03-09 07:34:21 -08:00 committed by Veikka Tuominen
parent 715370a10a
commit f76bd56588

View File

@ -140,7 +140,7 @@ pub fn __builtin_object_size(ptr: ?*const c_void, ty: c_int) callconv(.Inline) u
// If it is not possible to determine which objects ptr points to at compile time, // If it is not possible to determine which objects ptr points to at compile time,
// __builtin_object_size should return (size_t) -1 for type 0 or 1 and (size_t) 0 // __builtin_object_size should return (size_t) -1 for type 0 or 1 and (size_t) 0
// for type 2 or 3. // for type 2 or 3.
if (ty == 0 or ty == 1) return @bitCast(usize, -@as(c_long, 1)); if (ty == 0 or ty == 1) return @bitCast(usize, -@as(isize, 1));
if (ty == 2 or ty == 3) return 0; if (ty == 2 or ty == 3) return 0;
unreachable; unreachable;
} }