mirror of
https://github.com/genodelabs/genode.git
synced 2025-02-20 17:52:52 +00:00
parent
42f3d2eccd
commit
aa0a98bd43
@ -86,7 +86,7 @@ class Genode::Cap_index_allocator_tpl : public Cap_index_allocator
|
||||
/* if we found a fitting hole, initialize the objects */
|
||||
if (j == cnt) {
|
||||
for (j = 0; j < cnt; j++)
|
||||
new (&_indices[i+j]) T();
|
||||
construct_at<T>(&_indices[i+j]);
|
||||
return &_indices[i];
|
||||
}
|
||||
}
|
||||
@ -102,14 +102,14 @@ class Genode::Cap_index_allocator_tpl : public Cap_index_allocator
|
||||
* construct the Cap_index pointer from the given
|
||||
* address in capability space
|
||||
*/
|
||||
T * const obj = reinterpret_cast<T*>(kcap_to_idx(addr));
|
||||
T * const obj_ptr = reinterpret_cast<T*>(kcap_to_idx(addr));
|
||||
|
||||
if (obj < &_indices[0] || obj >= &_indices[SZ]) {
|
||||
if (obj_ptr < &_indices[0] || obj_ptr >= &_indices[SZ]) {
|
||||
ASSERT(0, "cap index out of bounds");
|
||||
throw Index_out_of_bounds();
|
||||
}
|
||||
|
||||
return new (obj) T();
|
||||
return construct_at<T>(obj_ptr);
|
||||
}
|
||||
|
||||
void free(Cap_index* idx, size_t cnt) override
|
||||
|
@ -48,7 +48,6 @@ class Genode::Native_capability::Data : public Avl_node<Data>
|
||||
uint8_t dec();
|
||||
addr_t kcap() const;
|
||||
|
||||
void* operator new (__SIZE_TYPE__, Data* idx) { return idx; }
|
||||
void operator delete (void* idx) { memset(idx, 0, sizeof(Data)); }
|
||||
|
||||
|
||||
|
@ -11,6 +11,8 @@
|
||||
* under the terms of the GNU Affero General Public License version 3.
|
||||
*/
|
||||
|
||||
/* Genode includes */
|
||||
#include <util/construct_at.h>
|
||||
#include <base/component.h>
|
||||
|
||||
/* core includes */
|
||||
@ -22,10 +24,10 @@
|
||||
|
||||
using Genode::size_t;
|
||||
using Genode::addr_t;
|
||||
using Genode::construct_at;
|
||||
using Kernel::Cpu_share;
|
||||
using Kernel::Cpu_scheduler;
|
||||
|
||||
void * operator new(__SIZE_TYPE__, void * p) { return p; }
|
||||
|
||||
struct Data
|
||||
{
|
||||
@ -73,15 +75,15 @@ void create(unsigned const id)
|
||||
Cpu_share * const s = share(id);
|
||||
void * const p = (void *)s;
|
||||
switch (id) {
|
||||
case 1: new (p) Cpu_share(2, 230); break;
|
||||
case 2: new (p) Cpu_share(0, 170); break;
|
||||
case 3: new (p) Cpu_share(3, 110); break;
|
||||
case 4: new (p) Cpu_share(1, 90); break;
|
||||
case 5: new (p) Cpu_share(3, 120); break;
|
||||
case 6: new (p) Cpu_share(3, 0); break;
|
||||
case 7: new (p) Cpu_share(2, 180); break;
|
||||
case 8: new (p) Cpu_share(2, 100); break;
|
||||
case 9: new (p) Cpu_share(2, 0); break;
|
||||
case 1: construct_at<Cpu_share>(p, 2, 230); break;
|
||||
case 2: construct_at<Cpu_share>(p, 0, 170); break;
|
||||
case 3: construct_at<Cpu_share>(p, 3, 110); break;
|
||||
case 4: construct_at<Cpu_share>(p, 1, 90); break;
|
||||
case 5: construct_at<Cpu_share>(p, 3, 120); break;
|
||||
case 6: construct_at<Cpu_share>(p, 3, 0); break;
|
||||
case 7: construct_at<Cpu_share>(p, 2, 180); break;
|
||||
case 8: construct_at<Cpu_share>(p, 2, 100); break;
|
||||
case 9: construct_at<Cpu_share>(p, 2, 0); break;
|
||||
default: return;
|
||||
}
|
||||
data()->scheduler.insert(*s);
|
||||
|
@ -12,6 +12,7 @@
|
||||
*/
|
||||
|
||||
/* base includes */
|
||||
#include <util/construct_at.h>
|
||||
#include <base/component.h>
|
||||
#include <base/log.h>
|
||||
|
||||
@ -27,8 +28,6 @@ using Genode::size_t;
|
||||
using Kernel::Double_list;
|
||||
using Kernel::Double_list_item;
|
||||
|
||||
void * operator new(__SIZE_TYPE__, void * p) { return p; }
|
||||
|
||||
|
||||
struct Item_load { char volatile x = 0, y = 0, z = 0; };
|
||||
|
||||
@ -53,7 +52,7 @@ struct Data
|
||||
Data()
|
||||
{
|
||||
for (unsigned i = 0; i < nr_of_items; i++) {
|
||||
new (&items[i]) Item(i + 1); }
|
||||
Genode::construct_at<Item>(&items[i], i + 1); }
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user