Revamp foreign code not to consider the Rust modes. This requires
adjusting a few foreign functions that were declared with by-ref mode. This also allows us to remove by-val mode in the near future. With copy mode, though, we have to be careful because Rust will implicitly pass somethings by pointer but this may not be the C ABI rules. For example, rust will pass a struct Foo as a Foo*. So I added some code into the adapters to fix this (though the C ABI rules may put the pointer back, oh well). This patch also includes a lint mode for the use of by-ref mode in foreign functions as the semantics of this have changed.
This commit is contained in:
@@ -434,18 +434,18 @@ rust_tzset() {
|
||||
}
|
||||
|
||||
extern "C" CDECL void
|
||||
rust_gmtime(int64_t *sec, int32_t *nsec, rust_tm *timeptr) {
|
||||
rust_gmtime(int64_t sec, int32_t nsec, rust_tm *timeptr) {
|
||||
tm tm;
|
||||
time_t s = *sec;
|
||||
time_t s = sec;
|
||||
GMTIME(&s, &tm);
|
||||
|
||||
tm_to_rust_tm(&tm, timeptr, 0, "UTC", *nsec);
|
||||
tm_to_rust_tm(&tm, timeptr, 0, "UTC", nsec);
|
||||
}
|
||||
|
||||
extern "C" CDECL void
|
||||
rust_localtime(int64_t *sec, int32_t *nsec, rust_tm *timeptr) {
|
||||
rust_localtime(int64_t sec, int32_t nsec, rust_tm *timeptr) {
|
||||
tm tm;
|
||||
time_t s = *sec;
|
||||
time_t s = sec;
|
||||
LOCALTIME(&s, &tm);
|
||||
|
||||
#if defined(__WIN32__)
|
||||
@@ -457,7 +457,7 @@ rust_localtime(int64_t *sec, int32_t *nsec, rust_tm *timeptr) {
|
||||
const char *zone = tm.tm_zone;
|
||||
#endif
|
||||
|
||||
tm_to_rust_tm(&tm, timeptr, gmtoff, zone, *nsec);
|
||||
tm_to_rust_tm(&tm, timeptr, gmtoff, zone, nsec);
|
||||
}
|
||||
|
||||
extern "C" CDECL void
|
||||
@@ -844,6 +844,38 @@ rust_readdir() {
|
||||
|
||||
#endif
|
||||
|
||||
// These functions are used in the unit tests for C ABI calls.
|
||||
|
||||
extern "C" CDECL uint32_t
|
||||
rust_dbg_extern_identity_u32(uint32_t u) {
|
||||
return u;
|
||||
}
|
||||
|
||||
extern "C" CDECL uint64_t
|
||||
rust_dbg_extern_identity_u64(uint64_t u) {
|
||||
return u;
|
||||
}
|
||||
|
||||
struct TwoU64s {
|
||||
uint64_t one;
|
||||
uint64_t two;
|
||||
};
|
||||
|
||||
extern "C" CDECL TwoU64s
|
||||
rust_dbg_extern_identity_TwoU64s(TwoU64s u) {
|
||||
return u;
|
||||
}
|
||||
|
||||
extern "C" CDECL double
|
||||
rust_dbg_extern_identity_double(double u) {
|
||||
return u;
|
||||
}
|
||||
|
||||
extern "C" CDECL char
|
||||
rust_dbg_extern_identity_u8(char u) {
|
||||
return u;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Local Variables:
|
||||
|
||||
Reference in New Issue
Block a user