diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp index b8e808863c0..90042491d1d 100644 --- a/src/rt/rust_builtin.cpp +++ b/src/rt/rust_builtin.cpp @@ -10,7 +10,6 @@ /* Foreign builtins. */ -#include "rust_util.h" #include "sync/lock_and_signal.h" #include "vg/valgrind.h" @@ -234,6 +233,16 @@ precise_time_ns(uint64_t *ns) { #endif } +struct +rust_vec +{ + size_t fill; // in bytes; if zero, heapified + size_t alloc; // in bytes + uint8_t data[0]; +}; + +typedef rust_vec rust_str; + struct rust_tm { int32_t tm_sec; int32_t tm_min; diff --git a/src/rt/rust_test_helpers.cpp b/src/rt/rust_test_helpers.cpp index 3c6e2d68c2f..631745e656a 100644 --- a/src/rt/rust_test_helpers.cpp +++ b/src/rt/rust_test_helpers.cpp @@ -10,7 +10,6 @@ // Helper functions used only in tests -#include "rust_util.h" #include "sync/lock_and_signal.h" // These functions are used in the unit tests for C ABI calls. diff --git a/src/rt/rust_type.h b/src/rt/rust_type.h deleted file mode 100644 index fe3c946a40b..00000000000 --- a/src/rt/rust_type.h +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -#ifndef RUST_TYPE_H -#define RUST_TYPE_H - -#include "rust_globals.h" - -struct rust_opaque_box; - -// The type of functions that we spawn, which fall into two categories: -// - the main function: has a NULL environment, but uses the void* arg -// - unique closures of type fn~(): have a non-NULL environment, but -// no arguments (and hence the final void*) is harmless -typedef void (*CDECL spawn_fn)(rust_opaque_box*, void *); - -struct type_desc; - -typedef void CDECL (glue_fn)(void *, - void *); - -typedef unsigned long ref_cnt_t; - -// Corresponds to the boxed data in the @ region. The body follows the -// header; you can obtain a ptr via box_body() below. -struct rust_opaque_box { - ref_cnt_t ref_count; - type_desc *td; - rust_opaque_box *prev; - rust_opaque_box *next; -}; - -// corresponds to the layout of a &fn(), @fn(), ~fn() etc -struct fn_env_pair { - spawn_fn f; - rust_opaque_box *env; -}; - -static inline void *box_body(rust_opaque_box *box) { - // Here we take advantage of the fact that the size of a box in 32 - // (resp. 64) bit is 16 (resp. 32) bytes, and thus always 16-byte aligned. - // If this were to change, we would have to update the method - // rustc::middle::trans::base::opaque_box_body() as well. - return (void*)(box + 1); -} - -struct slice { - void *data; - size_t length; -}; - -struct type_desc { - size_t size; - size_t align; - glue_fn *take_glue; - glue_fn *drop_glue; - glue_fn *free_glue; - glue_fn *visit_glue; - size_t borrow_offset; - slice name; -}; - -#endif - -// -// Local Variables: -// mode: C++ -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// diff --git a/src/rt/rust_upcall.cpp b/src/rt/rust_upcall.cpp index e7648a081be..95f4bec02e9 100644 --- a/src/rt/rust_upcall.cpp +++ b/src/rt/rust_upcall.cpp @@ -17,7 +17,6 @@ */ #include "rust_globals.h" -#include "rust_util.h" //Unwinding ABI declarations. typedef int _Unwind_Reason_Code; diff --git a/src/rt/rust_util.h b/src/rt/rust_util.h deleted file mode 100644 index bd3258c24f9..00000000000 --- a/src/rt/rust_util.h +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#ifndef RUST_UTIL_H -#define RUST_UTIL_H - -#include -#include "rust_type.h" - -// Inline fn used regularly elsewhere. - -// Rounds |size| to the nearest |alignment|. Invariant: |alignment| is a power -// of two. -template -static inline T -align_to(T size, size_t alignment) { - assert(alignment); - T x = (T)(((uintptr_t)size + alignment - 1) & ~(alignment - 1)); - return x; -} - -// Interior vectors (rust-user-code level). - -struct -rust_vec -{ - size_t fill; // in bytes; if zero, heapified - size_t alloc; // in bytes - uint8_t data[0]; -}; - -typedef rust_vec rust_str; - -inline size_t get_box_size(size_t body_size, size_t body_align) { - size_t header_size = sizeof(rust_opaque_box); - size_t total_size = align_to(header_size, body_align) + body_size; - return total_size; -} - -// -// Local Variables: -// mode: C++ -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// - -#endif