* logging.
*/
-native "rust" mod rustrt {
- fn debug_tydesc<T>();
- fn debug_opaque<T>(x: T);
- fn debug_box<T>(x: @T);
- fn debug_tag<T>(x: T);
- fn debug_obj<T>(x: T, nmethods: uint, nbytes: uint);
- fn debug_fn<T>(x: T);
- fn debug_ptrcast<T, U>(x: @T) -> @U;
+native "c-stack-cdecl" mod rustrt {
+ fn debug_tydesc(td: *sys::type_desc);
+ fn debug_opaque<T>(td: *sys::type_desc, x: T);
+ fn debug_box<T>(td: *sys::type_desc, x: @T);
+ fn debug_tag<T>(td: *sys::type_desc, x: T);
+ fn debug_obj<T>(td: *sys::type_desc, x: T, nmethods: uint, nbytes: uint);
+ fn debug_fn<T>(td: *sys::type_desc, x: T);
+ fn debug_ptrcast<T, U>(td: *sys::type_desc, x: @T) -> @U;
}
-fn debug_tydesc<T>() { rustrt::debug_tydesc::<T>(); }
+fn debug_tydesc<T>() {
+ rustrt::debug_tydesc(sys::get_type_desc::<T>());
+}
-fn debug_opaque<T>(x: T) { rustrt::debug_opaque::<T>(x); }
+fn debug_opaque<T>(x: T) {
+ rustrt::debug_opaque::<T>(sys::get_type_desc::<T>(), x);
+}
-fn debug_box<T>(x: @T) { rustrt::debug_box::<T>(x); }
+fn debug_box<T>(x: @T) {
+ rustrt::debug_box::<T>(sys::get_type_desc::<T>(), x);
+}
-fn debug_tag<T>(x: T) { rustrt::debug_tag::<T>(x); }
+fn debug_tag<T>(x: T) {
+ rustrt::debug_tag::<T>(sys::get_type_desc::<T>(), x);
+}
/**
* the front of any obj's data tuple.x
*/
fn debug_obj<T>(x: T, nmethods: uint, nbytes: uint) {
- rustrt::debug_obj::<T>(x, nmethods, nbytes);
+ rustrt::debug_obj::<T>(sys::get_type_desc::<T>(), x, nmethods, nbytes);
}
-fn debug_fn<T>(x: T) { rustrt::debug_fn::<T>(x); }
+fn debug_fn<T>(x: T) {
+ rustrt::debug_fn::<T>(sys::get_type_desc::<T>(), x);
+}
unsafe fn ptr_cast<T, U>(x: @T) -> @U {
- ret rustrt::debug_ptrcast::<T, U>(x);
+ ret rustrt::debug_ptrcast::<T, U>(sys::get_type_desc::<T>(), x);
}
fn refcount<T>(a: @T) -> uint unsafe {
}
extern "C" CDECL size_t
-<<<<<<< HEAD
rand_next(randctx *rctx) {
-=======
-rand_next(randctx *rctx)
-{
->>>>>>> move rand functions into c-stack-cdecl mode
return isaac_rand(rctx);
}
extern "C" CDECL void
-<<<<<<< HEAD
rand_free(randctx *rctx) {
-=======
-rand_free(randctx *rctx)
-{
->>>>>>> move rand functions into c-stack-cdecl mode
rust_task *task = rust_scheduler::get_task();
task->free(rctx);
}
/* Debug builtins for std::dbg. */
static void
-debug_tydesc_helper(rust_task* task, type_desc *t) {
+debug_tydesc_helper(type_desc *t)
+{
+ rust_task *task = rust_scheduler::get_task();
LOG(task, stdlib, " size %" PRIdPTR ", align %" PRIdPTR
", first_param 0x%" PRIxPTR,
t->size, t->align, t->first_param);
debug_tydesc(type_desc *t) {
rust_task *task = rust_scheduler::get_task();
LOG(task, stdlib, "debug_tydesc");
- debug_tydesc_helper(task, t);
+ debug_tydesc_helper(t);
}
extern "C" CDECL void
debug_opaque(type_desc *t, uint8_t *front) {
rust_task *task = rust_scheduler::get_task();
LOG(task, stdlib, "debug_opaque");
- debug_tydesc_helper(task, t);
+ debug_tydesc_helper(t);
// FIXME may want to actually account for alignment. `front` may not
// indeed be the front byte of the passed-in argument.
for (uintptr_t i = 0; i < t->size; ++front, ++i) {
debug_box(type_desc *t, rust_box *box) {
rust_task *task = rust_scheduler::get_task();
LOG(task, stdlib, "debug_box(0x%" PRIxPTR ")", box);
- debug_tydesc_helper(task, t);
+ debug_tydesc_helper(t);
LOG(task, stdlib, " refcount %" PRIdPTR,
box->ref_count - 1); // -1 because we ref'ed for this call
for (uintptr_t i = 0; i < t->size; ++i) {
rust_task *task = rust_scheduler::get_task();
LOG(task, stdlib, "debug_tag");
- debug_tydesc_helper(task, t);
+ debug_tydesc_helper(t);
LOG(task, stdlib, " discriminant %" PRIdPTR, tag->discriminant);
for (uintptr_t i = 0; i < t->size - sizeof(tag->discriminant); ++i)
rust_task *task = rust_scheduler::get_task();
LOG(task, stdlib, "debug_obj with %" PRIdPTR " methods", nmethods);
- debug_tydesc_helper(task, t);
+ debug_tydesc_helper(t);
LOG(task, stdlib, " vtbl at 0x%" PRIxPTR, obj->vtbl);
LOG(task, stdlib, " body at 0x%" PRIxPTR, obj->body);
debug_fn(type_desc *t, rust_fn *fn) {
rust_task *task = rust_scheduler::get_task();
LOG(task, stdlib, "debug_fn");
- debug_tydesc_helper(task, t);
+ debug_tydesc_helper(t);
LOG(task, stdlib, " thunk at 0x%" PRIxPTR, fn->thunk);
LOG(task, stdlib, " closure at 0x%" PRIxPTR, fn->closure);
if (fn->closure) {
void *ptr) {
rust_task *task = rust_scheduler::get_task();
LOG(task, stdlib, "debug_ptrcast from");
- debug_tydesc_helper(task, from_ty);
+ debug_tydesc_helper(from_ty);
LOG(task, stdlib, "to");
- debug_tydesc_helper(task, to_ty);
+ debug_tydesc_helper(to_ty);
return ptr;
}