Skip to content

Commit 8e8c81f

Browse files
committed
---
yaml --- r: 85726 b: refs/heads/dist-snap c: 4c5f625 h: refs/heads/master v: v3
1 parent 0359af8 commit 8e8c81f

File tree

9 files changed

+193
-14
lines changed

9 files changed

+193
-14
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: 0983ebe5310d4eb6d289f636f7ed0536c08bbc0e
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: a9d28b2d9d9939b1134d48feb1d83864bae782d5
9+
refs/heads/dist-snap: 4c5f62539b51c6c8f45bd8e2e79b81fd1480906a
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/mk/rt.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ RUNTIME_CXXS_$(1)_$(2) := \
7575
rt/rust_gc_metadata.cpp \
7676
rt/rust_util.cpp \
7777
rt/rust_log.cpp \
78+
rt/rust_exchange_alloc.cpp \
7879
rt/isaac/randport.cpp \
7980
rt/miniz.cpp \
8081
rt/rust_abi.cpp \

branches/dist-snap/src/libextra/time.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,6 @@ 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);
127124
Tm {
128125
tm_sec: 0_i32,
129126
tm_min: 0_i32,
@@ -135,7 +132,7 @@ pub fn empty_tm() -> Tm {
135132
tm_yday: 0_i32,
136133
tm_isdst: 0_i32,
137134
tm_gmtoff: 0_i32,
138-
tm_zone: zone,
135+
tm_zone: ~"",
139136
tm_nsec: 0_i32,
140137
}
141138
}

branches/dist-snap/src/libstd/vec.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3154,7 +3154,6 @@ mod tests {
31543154
}
31553155
}
31563156

3157-
#[ignore] // FIXME #8698
31583157
#[test]
31593158
#[should_fail]
31603159
fn test_map_fail() {
@@ -3164,12 +3163,11 @@ mod tests {
31643163
if i == 2 {
31653164
fail!()
31663165
}
3167-
i += 0;
3166+
i += 1;
31683167
~[(~0, @0)]
31693168
};
31703169
}
31713170

3172-
#[ignore] // FIXME #8698
31733171
#[test]
31743172
#[should_fail]
31753173
fn test_flat_map_fail() {
@@ -3179,12 +3177,11 @@ mod tests {
31793177
if i == 2 {
31803178
fail!()
31813179
}
3182-
i += 0;
3180+
i += 1;
31833181
~[(~0, @0)]
31843182
};
31853183
}
31863184

3187-
#[ignore] // FIXME #8698
31883185
#[test]
31893186
#[should_fail]
31903187
fn test_rposition_fail() {
@@ -3194,12 +3191,11 @@ mod tests {
31943191
if i == 2 {
31953192
fail!()
31963193
}
3197-
i += 0;
3194+
i += 1;
31983195
false
31993196
};
32003197
}
32013198

3202-
#[ignore] // FIXME #8698
32033199
#[test]
32043200
#[should_fail]
32053201
fn test_permute_fail() {
@@ -3209,7 +3205,7 @@ mod tests {
32093205
if i == 2 {
32103206
fail!()
32113207
}
3212-
i += 0;
3208+
i += 1;
32133209
true
32143210
};
32153211
}

branches/dist-snap/src/rt/rust_builtin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ void tm_to_rust_tm(tm* in_tm, rust_tm* out_tm, int32_t gmtoff,
292292

293293
if (zone != NULL) {
294294
size_t size = strlen(zone);
295-
assert(out_tm->tm_zone->alloc >= size);
295+
reserve_vec_exact(&out_tm->tm_zone, size);
296296
memcpy(out_tm->tm_zone->data, zone, size);
297297
out_tm->tm_zone->fill = size;
298298
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#include "rust_exchange_alloc.h"
12+
#include "sync/sync.h"
13+
#include <stdlib.h>
14+
#include <assert.h>
15+
#include <string.h>
16+
#include <stdio.h>
17+
18+
void *
19+
rust_exchange_alloc::malloc(size_t size) {
20+
void *value = ::malloc(size);
21+
assert(value);
22+
return value;
23+
}
24+
25+
void *
26+
rust_exchange_alloc::realloc(void *ptr, size_t size) {
27+
void *new_ptr = ::realloc(ptr, size);
28+
assert(new_ptr);
29+
return new_ptr;
30+
}
31+
32+
void
33+
rust_exchange_alloc::free(void *ptr) {
34+
::free(ptr);
35+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#ifndef RUST_EXCHANGE_ALLOC_H
12+
#define RUST_EXCHANGE_ALLOC_H
13+
14+
#include <stddef.h>
15+
#include <stdint.h>
16+
17+
class rust_exchange_alloc {
18+
public:
19+
void *malloc(size_t size);
20+
void *realloc(void *mem, size_t size);
21+
void free(void *mem);
22+
};
23+
24+
#endif

branches/dist-snap/src/rt/rust_util.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#define RUST_UTIL_H
1313

1414
#include <limits.h>
15+
#include "rust_exchange_alloc.h"
1516
#include "rust_type.h"
1617

1718
extern struct type_desc str_body_tydesc;
@@ -56,6 +57,16 @@ vec_data(rust_vec *v) {
5657
return reinterpret_cast<T*>(v->data);
5758
}
5859

60+
inline void reserve_vec_exact(rust_vec** vpp,
61+
size_t size) {
62+
if (size > (*vpp)->alloc) {
63+
rust_exchange_alloc exchange_alloc;
64+
*vpp = (rust_vec*)exchange_alloc
65+
.realloc(*vpp, size + sizeof(rust_vec));
66+
(*vpp)->alloc = size;
67+
}
68+
}
69+
5970
typedef rust_vec rust_str;
6071

6172
inline size_t get_box_size(size_t body_size, size_t body_align) {
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#ifndef INDEXED_LIST_H
12+
#define INDEXED_LIST_H
13+
14+
#include <assert.h>
15+
#include "array_list.h"
16+
17+
class indexed_list_object {
18+
public:
19+
virtual ~indexed_list_object() {}
20+
int32_t list_index;
21+
};
22+
23+
template<typename T>
24+
class indexed_list_element : public indexed_list_object {
25+
public:
26+
T value;
27+
indexed_list_element(T value) : value(value) {
28+
}
29+
};
30+
31+
/**
32+
* An array list of objects that are aware of their position in the list.
33+
* Normally, objects in this list should derive from the base class
34+
* "indexed_list_object" however because of nasty Rust compiler dependencies
35+
* on the layout of runtime objects we cannot always derive from this
36+
* base class, so instead we just enforce the informal protocol that any
37+
* object inserted in this list must define a "int32_t list_index" member.
38+
*/
39+
template<typename T> class indexed_list {
40+
array_list<T*> list;
41+
public:
42+
int32_t append(T *value);
43+
bool pop(T **value);
44+
/**
45+
* Same as pop(), except that it returns NULL if the list is empty.
46+
*/
47+
T* pop_value();
48+
size_t length() const {
49+
return list.size();
50+
}
51+
bool is_empty() const {
52+
return list.is_empty();
53+
}
54+
int32_t remove(T* value);
55+
T * operator[](int32_t index);
56+
const T * operator[](int32_t index) const;
57+
~indexed_list() {}
58+
};
59+
60+
template<typename T> int32_t
61+
indexed_list<T>::append(T *value) {
62+
value->list_index = list.push(value);
63+
return value->list_index;
64+
}
65+
66+
/**
67+
* Swap delete the last object in the list with the specified object.
68+
*/
69+
template<typename T> int32_t
70+
indexed_list<T>::remove(T *value) {
71+
assert (value->list_index >= 0);
72+
assert (value->list_index < (int32_t)list.size());
73+
int32_t removeIndex = value->list_index;
74+
T *last = 0;
75+
list.pop(&last);
76+
if (last->list_index == removeIndex) {
77+
last->list_index = -1;
78+
return removeIndex;
79+
} else {
80+
value->list_index = -1;
81+
list[removeIndex] = last;
82+
last->list_index = removeIndex;
83+
return removeIndex;
84+
}
85+
}
86+
87+
template<typename T> bool
88+
indexed_list<T>::pop(T **value) {
89+
return list.pop(value);
90+
}
91+
92+
template<typename T> T*
93+
indexed_list<T>::pop_value() {
94+
T *value = NULL;
95+
if (list.pop(&value)) {
96+
return value;
97+
}
98+
return NULL;
99+
}
100+
101+
template <typename T> T *
102+
indexed_list<T>::operator[](int32_t index) {
103+
T *value = list[index];
104+
assert(value->list_index == index);
105+
return value;
106+
}
107+
108+
template <typename T> const T *
109+
indexed_list<T>::operator[](int32_t index) const {
110+
T *value = list[index];
111+
assert(value->list_index == index);
112+
return value;
113+
}
114+
115+
#endif /* INDEXED_LIST_H */

0 commit comments

Comments
 (0)