File tree Expand file tree Collapse file tree 3 files changed +39
-2
lines changed Expand file tree Collapse file tree 3 files changed +39
-2
lines changed Original file line number Diff line number Diff line change 1
1
---
2
- refs/heads/master: 12eb60c29d8b559f7de7890917094ec95999e847
2
+ refs/heads/master: a9994a29634cc8d1ce330bdbb41fb1941c41f778
Original file line number Diff line number Diff line change @@ -15,7 +15,8 @@ is_power_of_two(size_t value) {
15
15
circular_buffer::circular_buffer (rust_dom *dom, size_t unit_sz) :
16
16
dom(dom),
17
17
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)),
19
20
_next(0 ),
20
21
_unread(0 ),
21
22
_buffer((uint8_t *)dom->calloc(_buffer_sz)) {
Original file line number Diff line number Diff line change
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:
You can’t perform that action at this time.
0 commit comments