Skip to content

Commit 078ce96

Browse files
brsongraydon
authored andcommitted
---
yaml --- r: 1206 b: refs/heads/master c: a9994a2 h: refs/heads/master v: v3
1 parent e8bb871 commit 078ce96

File tree

3 files changed

+39
-2
lines changed

3 files changed

+39
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 12eb60c29d8b559f7de7890917094ec95999e847
2+
refs/heads/master: a9994a29634cc8d1ce330bdbb41fb1941c41f778

trunk/src/rt/circular_buffer.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ is_power_of_two(size_t value) {
1515
circular_buffer::circular_buffer(rust_dom *dom, size_t unit_sz) :
1616
dom(dom),
1717
unit_sz(unit_sz),
18-
_buffer_sz(INITIAL_CIRCULAR_BUFFFER_SIZE_IN_UNITS * unit_sz),
18+
_buffer_sz(next_power_of_two(
19+
INITIAL_CIRCULAR_BUFFFER_SIZE_IN_UNITS * unit_sz)),
1920
_next(0),
2021
_unread(0),
2122
_buffer((uint8_t *)dom->calloc(_buffer_sz)) {
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// -*- rust -*-
2+
3+
// Regression test for circular_buffer initialization
4+
5+
use std;
6+
7+
import std.option;
8+
import std._uint;
9+
import std._vec;
10+
11+
// 12-byte unit for the channel buffer. Assuming that the default
12+
// buffer size needs to hold 8 units, then the minimum buffer size
13+
// needs to be 96. That's not a power of two so needs to be rounded up.
14+
type record = rec(i32 val1, i32 val2, i32 val3);
15+
16+
impure fn worker(chan[record] channel) {
17+
let record val = rec(val1=0i32, val2=0i32, val3=0i32);
18+
channel <| val;
19+
}
20+
21+
impure fn main() {
22+
let port[record] myport = port();
23+
auto mychan = chan(myport);
24+
25+
auto temp = spawn worker(mychan);
26+
auto val <- myport;
27+
}
28+
29+
// Local Variables:
30+
// mode: rust;
31+
// fill-column: 78;
32+
// indent-tabs-mode: nil
33+
// c-basic-offset: 4
34+
// buffer-file-coding-system: utf-8-unix
35+
// compile-command: "make -k -C .. 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
36+
// End:

0 commit comments

Comments
 (0)