equal
deleted
inserted
replaced
76 size_t elements = left / sizeof(T); |
76 size_t elements = left / sizeof(T); |
77 assert(elements <= (size_t)INT_MAX, "number of elements " SIZE_FORMAT "doesn't fit into an int.", elements); |
77 assert(elements <= (size_t)INT_MAX, "number of elements " SIZE_FORMAT "doesn't fit into an int.", elements); |
78 |
78 |
79 int length = (int)elements; |
79 int length = (int)elements; |
80 |
80 |
81 assert((size_t)size(length) * BytesPerWord == bytes, |
81 assert((size_t)size(length) * BytesPerWord == (size_t)bytes, |
82 "Expected: " SIZE_FORMAT " got: " SIZE_FORMAT, |
82 "Expected: " SIZE_FORMAT " got: " SIZE_FORMAT, |
83 bytes, (size_t)size(length) * BytesPerWord); |
83 bytes, (size_t)size(length) * BytesPerWord); |
84 |
84 |
85 return length; |
85 return length; |
86 } |
86 } |
120 |
120 |
121 T at_acquire(const int which) { return OrderAccess::load_acquire(adr_at(which)); } |
121 T at_acquire(const int which) { return OrderAccess::load_acquire(adr_at(which)); } |
122 void release_at_put(int which, T contents) { OrderAccess::release_store(adr_at(which), contents); } |
122 void release_at_put(int which, T contents) { OrderAccess::release_store(adr_at(which), contents); } |
123 |
123 |
124 static int size(int length) { |
124 static int size(int length) { |
125 return align_size_up(byte_sizeof(length), BytesPerWord) / BytesPerWord; |
125 size_t bytes = align_size_up(byte_sizeof(length), BytesPerWord); |
|
126 size_t words = bytes / BytesPerWord; |
|
127 |
|
128 assert(words <= INT_MAX, "Overflow: " SIZE_FORMAT, words); |
|
129 |
|
130 return (int)words; |
126 } |
131 } |
127 |
132 |
128 int size() { |
133 int size() { |
129 return size(_length); |
134 return size(_length); |
130 } |
135 } |