ir: Support pointers to zsts.

Fixes #654
This commit is contained in:
Emilio Cobos Álvarez
2021-02-01 13:37:58 +01:00
parent d3cd22bc6f
commit c5c301b08a
11 changed files with 144 additions and 10 deletions
+11
View File
@@ -0,0 +1,11 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
typedef struct TraitObject {
void *data;
void *vtable;
} TraitObject;
void *root(const void *ptr, struct TraitObject t);
+19
View File
@@ -0,0 +1,19 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
typedef struct TraitObject {
void *data;
void *vtable;
} TraitObject;
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
void *root(const void *ptr, struct TraitObject t);
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
+11
View File
@@ -0,0 +1,11 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
typedef struct {
void *data;
void *vtable;
} TraitObject;
void *root(const void *ptr, TraitObject t);
+19
View File
@@ -0,0 +1,19 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
typedef struct {
void *data;
void *vtable;
} TraitObject;
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
void *root(const void *ptr, TraitObject t);
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
+16
View File
@@ -0,0 +1,16 @@
#include <cstdarg>
#include <cstdint>
#include <cstdlib>
#include <ostream>
#include <new>
struct TraitObject {
void *data;
void *vtable;
};
extern "C" {
void *root(const void *ptr, TraitObject t);
} // extern "C"
+13
View File
@@ -0,0 +1,13 @@
from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t
from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t, uintptr_t
cdef extern from *:
ctypedef bint bool
ctypedef struct va_list
cdef extern from *:
ctypedef struct TraitObject:
void *data;
void *vtable;
void *root(const void *ptr, TraitObject t);
+11
View File
@@ -0,0 +1,11 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
struct TraitObject {
void *data;
void *vtable;
};
void *root(const void *ptr, struct TraitObject t);
+19
View File
@@ -0,0 +1,19 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
struct TraitObject {
void *data;
void *vtable;
};
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
void *root(const void *ptr, struct TraitObject t);
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
+13
View File
@@ -0,0 +1,13 @@
from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t
from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t, uintptr_t
cdef extern from *:
ctypedef bint bool
ctypedef struct va_list
cdef extern from *:
cdef struct TraitObject:
void *data;
void *vtable;
void *root(const void *ptr, TraitObject t);
+10
View File
@@ -0,0 +1,10 @@
#[repr(C)]
pub struct TraitObject {
pub data: *mut (),
pub vtable: *mut (),
}
#[no_mangle]
pub extern "C" fn root(ptr: *const (), t: TraitObject) -> *mut () {
std::ptr::null_mut()
}