Skip to content

Commit f997924

Browse files
committed
auto merge of #8705 : brson/rust/lesscxx, r=graydon
2 parents 7b5a91f + 9cdfe1e commit f997924

25 files changed

+116
-838
lines changed

mk/rt.mk

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ endif
6363
endif
6464

6565
RUNTIME_CXXS_$(1)_$(2) := \
66-
rt/sync/timer.cpp \
6766
rt/sync/lock_and_signal.cpp \
6867
rt/sync/rust_thread.cpp \
6968
rt/rust_builtin.cpp \
@@ -72,13 +71,9 @@ RUNTIME_CXXS_$(1)_$(2) := \
7271
rt/rust_upcall.cpp \
7372
rt/rust_uv.cpp \
7473
rt/rust_crate_map.cpp \
75-
rt/rust_gc_metadata.cpp \
76-
rt/rust_util.cpp \
7774
rt/rust_log.cpp \
78-
rt/rust_exchange_alloc.cpp \
7975
rt/isaac/randport.cpp \
8076
rt/miniz.cpp \
81-
rt/rust_abi.cpp \
8277
rt/memory_region.cpp \
8378
rt/boxed_region.cpp \
8479
rt/arch/$$(HOST_$(1))/context.cpp \

src/libextra/time.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ pub struct Tm {
121121
}
122122

123123
pub fn empty_tm() -> Tm {
124+
// 64 is the max size of the timezone buffer allocated on windows
125+
// in rust_localtime. In glibc the max timezone size is supposedly 3.
126+
let zone = str::with_capacity(64);
124127
Tm {
125128
tm_sec: 0_i32,
126129
tm_min: 0_i32,
@@ -132,7 +135,7 @@ pub fn empty_tm() -> Tm {
132135
tm_yday: 0_i32,
133136
tm_isdst: 0_i32,
134137
tm_gmtoff: 0_i32,
135-
tm_zone: ~"",
138+
tm_zone: zone,
136139
tm_nsec: 0_i32,
137140
}
138141
}

src/libstd/rt/local_heap.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,10 @@ impl LocalHeap {
4040
#[fixed_stack_segment] #[inline(never)]
4141
pub fn new() -> LocalHeap {
4242
unsafe {
43-
// Don't need synchronization for the single-threaded local heap
44-
let synchronized = false as uintptr_t;
4543
// XXX: These usually come from the environment
4644
let detailed_leaks = false as uintptr_t;
4745
let poison_on_free = false as uintptr_t;
48-
let region = rust_new_memory_region(synchronized, detailed_leaks, poison_on_free);
46+
let region = rust_new_memory_region(detailed_leaks, poison_on_free);
4947
assert!(region.is_not_null());
5048
let boxed = rust_new_boxed_region(region, poison_on_free);
5149
assert!(boxed.is_not_null());
@@ -109,8 +107,7 @@ pub fn live_allocs() -> *raw::Box<()> {
109107

110108
extern {
111109
#[fast_ffi]
112-
fn rust_new_memory_region(synchronized: uintptr_t,
113-
detailed_leaks: uintptr_t,
110+
fn rust_new_memory_region(detailed_leaks: uintptr_t,
114111
poison_on_free: uintptr_t) -> *MemoryRegion;
115112
#[fast_ffi]
116113
fn rust_delete_memory_region(region: *MemoryRegion);

src/libstd/rt/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,7 @@ pub fn init(argc: int, argv: **u8, crate_map: *u8) {
224224
args::init(argc, argv);
225225
env::init();
226226
logging::init(crate_map);
227-
rust_update_gc_metadata(crate_map);
228227
}
229-
230-
externfn!(fn rust_update_gc_metadata(crate_map: *u8));
231228
}
232229

233230
/// One-time runtime cleanup.

src/libstd/rt/util.rs

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use libc;
1414
use option::{Some, None};
1515
use os;
1616
use str::StrSlice;
17+
use unstable::atomics::{AtomicInt, INIT_ATOMIC_INT, SeqCst};
1718

1819
#[cfg(target_os="macos")]
1920
use unstable::running_on_valgrind;
@@ -129,24 +130,12 @@ memory and partly incapable of presentation to others.",
129130
}
130131
}
131132

132-
pub fn set_exit_status(code: int) {
133-
#[fixed_stack_segment]; #[inline(never)];
134-
unsafe {
135-
return rust_set_exit_status_newrt(code as libc::uintptr_t);
136-
}
133+
static mut EXIT_STATUS: AtomicInt = INIT_ATOMIC_INT;
137134

138-
extern {
139-
fn rust_set_exit_status_newrt(code: libc::uintptr_t);
140-
}
135+
pub fn set_exit_status(code: int) {
136+
unsafe { EXIT_STATUS.store(code, SeqCst) }
141137
}
142138

143139
pub fn get_exit_status() -> int {
144-
#[fixed_stack_segment]; #[inline(never)];
145-
unsafe {
146-
return rust_get_exit_status_newrt() as int;
147-
}
148-
149-
extern {
150-
fn rust_get_exit_status_newrt() -> libc::uintptr_t;
151-
}
140+
unsafe { EXIT_STATUS.load(SeqCst) }
152141
}

src/rt/memory_region.cpp

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
// except according to those terms.
1010

1111

12-
#include "sync/sync.h"
1312
#include "memory_region.h"
1413

1514
#if RUSTRT_TRACK_ALLOCATIONS >= 3
@@ -42,30 +41,25 @@ inline void memory_region::maybe_print_backtrace(const alloc_header *header) con
4241
# endif
4342
}
4443

45-
memory_region::memory_region(bool synchronized,
46-
bool detailed_leaks,
44+
memory_region::memory_region(bool detailed_leaks,
4745
bool poison_on_free) :
4846
_parent(NULL), _live_allocations(0),
4947
_detailed_leaks(detailed_leaks),
50-
_poison_on_free(poison_on_free),
51-
_synchronized(synchronized) {
48+
_poison_on_free(poison_on_free) {
5249
}
5350

5451
memory_region::memory_region(memory_region *parent) :
5552
_parent(parent), _live_allocations(0),
5653
_detailed_leaks(parent->_detailed_leaks),
57-
_poison_on_free(parent->_poison_on_free),
58-
_synchronized(parent->_synchronized) {
54+
_poison_on_free(parent->_poison_on_free) {
5955
}
6056

6157
void memory_region::add_alloc() {
62-
//_live_allocations++;
63-
sync::increment(_live_allocations);
58+
_live_allocations++;
6459
}
6560

6661
void memory_region::dec_alloc() {
67-
//_live_allocations--;
68-
sync::decrement(_live_allocations);
62+
_live_allocations--;
6963
}
7064

7165
void memory_region::free(void *mem) {
@@ -112,7 +106,6 @@ memory_region::realloc(void *mem, size_t orig_size) {
112106
# endif
113107

114108
# if RUSTRT_TRACK_ALLOCATIONS >= 2
115-
if (_synchronized) { _lock.lock(); }
116109
if (_allocation_list[newMem->index] != alloc) {
117110
printf("at index %d, found %p, expected %p\n",
118111
alloc->index, _allocation_list[alloc->index], alloc);
@@ -125,7 +118,6 @@ memory_region::realloc(void *mem, size_t orig_size) {
125118
// printf("realloc: stored %p at index %d, replacing %p\n",
126119
// newMem, index, mem);
127120
}
128-
if (_synchronized) { _lock.unlock(); }
129121
# endif
130122

131123
return get_data(newMem);
@@ -160,9 +152,7 @@ memory_region::malloc(size_t size, const char *tag) {
160152
}
161153

162154
memory_region::~memory_region() {
163-
if (_synchronized) { _lock.lock(); }
164155
if (_live_allocations == 0 && !_detailed_leaks) {
165-
if (_synchronized) { _lock.unlock(); }
166156
return;
167157
}
168158
char msg[128];
@@ -193,7 +183,6 @@ memory_region::~memory_region() {
193183
fprintf(stderr, "%s\n", msg);
194184
assert(false);
195185
}
196-
if (_synchronized) { _lock.unlock(); }
197186
}
198187

199188
void
@@ -204,7 +193,6 @@ memory_region::release_alloc(void *mem) {
204193
# endif
205194

206195
# if RUSTRT_TRACK_ALLOCATIONS >= 2
207-
if (_synchronized) { _lock.lock(); }
208196
if (((size_t) alloc->index) >= _allocation_list.size()) {
209197
printf("free: ptr 0x%" PRIxPTR " (%s) index %d is beyond allocation_list of size %zu\n",
210198
(uintptr_t) get_data(alloc), alloc->tag, alloc->index, _allocation_list.size());
@@ -222,7 +210,6 @@ memory_region::release_alloc(void *mem) {
222210
_allocation_list[alloc->index] = NULL;
223211
alloc->index = -1;
224212
}
225-
if (_synchronized) { _lock.unlock(); }
226213
# endif
227214

228215
dec_alloc();
@@ -236,9 +223,7 @@ memory_region::claim_alloc(void *mem) {
236223
# endif
237224

238225
# if RUSTRT_TRACK_ALLOCATIONS >= 2
239-
if (_synchronized) { _lock.lock(); }
240226
alloc->index = _allocation_list.append(alloc);
241-
if (_synchronized) { _lock.unlock(); }
242227
# endif
243228

244229
# if RUSTRT_TRACK_ALLOCATIONS >= 3

src/rt/memory_region.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ class memory_region {
5959
array_list<alloc_header *> _allocation_list;
6060
const bool _detailed_leaks;
6161
const bool _poison_on_free;
62-
const bool _synchronized;
6362
lock_and_signal _lock;
6463

6564
void add_alloc();
@@ -77,8 +76,7 @@ class memory_region {
7776
memory_region& operator=(const memory_region& rhs);
7877

7978
public:
80-
memory_region(bool synchronized,
81-
bool detailed_leaks, bool poison_on_free);
79+
memory_region(bool detailed_leaks, bool poison_on_free);
8280
memory_region(memory_region *parent);
8381
void *malloc(size_t size, const char *tag);
8482
void *realloc(void *mem, size_t size);

src/rt/rust_abi.cpp

Lines changed: 0 additions & 88 deletions
This file was deleted.

0 commit comments

Comments
 (0)