From cc1bee96fd874ff2c85c765f81ec2f4ba4584b9d Mon Sep 17 00:00:00 2001 From: Scott Wood Date: Sun, 9 Dec 2007 22:06:38 -0600 Subject: [PATCH] Move arrays to Util namespace, add parametric allocator. --- idlcomp/languages/c++/main.cc | 4 +- idlcomp/languages/c++/marshall.cc | 10 +- idlcomp/tests/cpp-server.cc | 14 +- idlcomp/vtable-sample.h | 8 +- include/c++/orb.h | 332 ++---------------------------- include/c++/util/array.h | 305 +++++++++++++++++++++++++++ kernel/core/irq.cc | 2 +- kernel/include/kern/console.h | 2 +- kernel/include/kern/kernel.h | 2 +- kernel/include/kern/mem.h | 2 - kernel/io/console/misc.cc | 2 +- kernel/mem/addrspace.cc | 14 +- kernel/mem/orbmm.cc | 5 - kernel/orb/invoke.cc | 12 +- lib/c++/orb.cc | 4 +- 15 files changed, 364 insertions(+), 354 deletions(-) create mode 100644 include/c++/util/array.h diff --git a/idlcomp/languages/c++/main.cc b/idlcomp/languages/c++/main.cc index 57f9455..ab4289c 100644 --- a/idlcomp/languages/c++/main.cc +++ b/idlcomp/languages/c++/main.cc @@ -259,7 +259,7 @@ void cpp_output_type(ostream &file, Type *t, bool array, bool is_mutable) cpp_output_name(file, t); if (array) - file << ">"; + file << ", ::System::RunTime::ORBMM>"; file << ' '; } @@ -293,7 +293,7 @@ void cpp_output_type(ostream &file, CompiledBasicType &t, bool is_mutable) } if (is_array(t)) - file << '>'; + file << ", ::System::RunTime::ORBMM>"; file << ' '; } diff --git a/idlcomp/languages/c++/marshall.cc b/idlcomp/languages/c++/marshall.cc index 6deb115..bd1f428 100644 --- a/idlcomp/languages/c++/marshall.cc +++ b/idlcomp/languages/c++/marshall.cc @@ -39,14 +39,14 @@ void CPPFile::output_marshall(Struct *sym, int pass) case trav_nsdecl: extra_newline(); - file << indent << "int _marshall(::System::RunTime::GrowableArray &buf,\n" - << indent << " ::System::RunTime::GrowableArray< ::System::RunTime::ID> &objlist,\n" - << indent << " ::System::RunTime::GrowableArray< ::System::RunTime::NewObject> &newobjlist,\n" + file << indent << "int _marshall(::System::RunTime::GrowableArray &buf,\n" + << indent << " ::System::RunTime::GrowableArray< ::System::RunTime::ID, ::System::RunTime::ORBMM> &objlist,\n" + << indent << " ::System::RunTime::GrowableArray< ::System::RunTime::NewObject, ::System::RunTime::ORBMM> &newobjlist,\n" << indent << " ::System::RunTime::ParamInfoBlock::Segment *segs,\n" << indent << " int nsegs);\n"; - file << indent << "void _unmarshall(::System::RunTime::Array buf,\n" - << indent << " ::System::RunTime::Array< ::System::_i_Object *> objlist,\n" + file << indent << "void _unmarshall(::System::RunTime::Array buf,\n" + << indent << " ::System::RunTime::Array< ::System::_i_Object *, ::System::RunTime::ORBMM> objlist,\n" << indent << " ::System::RunTime::ParamInfoBlock::Segment *segs,\n" << indent << " int nsegs);\n"; diff --git a/idlcomp/tests/cpp-server.cc b/idlcomp/tests/cpp-server.cc index 528ee1e..02d4924 100644 --- a/idlcomp/tests/cpp-server.cc +++ b/idlcomp/tests/cpp-server.cc @@ -5,7 +5,7 @@ using System::IO::File; using namespace System::IO::FileStream_ns; using System::RunTime::Array; using System::RunTime::MutableArray; - +using System::RunTime::ORBMM; namespace Stuff { using System::Notifiers::Notifier; @@ -79,7 +79,7 @@ public: f.size(size); } - void read(Array *buf, uint64_t *len) + void read(Array *buf, uint64_t *len) { if (!f) { // throw exc @@ -90,7 +90,7 @@ public: pos += *len; } - void read_foo(MutableArray buf, uint64_t len, Notifier n) + void read_foo(MutableArray buf, uint64_t len, Notifier n) { if (!f) { // throw exc @@ -101,7 +101,7 @@ public: pos += len; } - void write(Array buf, uint64_t *len) + void write(Array buf, uint64_t *len) { if (!f) { // throw exc @@ -112,7 +112,7 @@ public: pos += *len; } - void write_foo(Array buf, uint64_t len, Notifier n) + void write_foo(Array buf, uint64_t len, Notifier n) { printf("write_foo, this %p\n", this); @@ -155,11 +155,11 @@ int main() } printf("fs is %p\n", (void *)fs); - fs.write_async(Array(NULL, 0), 0, NULL); + fs.write_async(nullarray, 0, NULL); printf("fs is %p\n", (void *)fs); System::IO::OStream ostr = fs; printf("ostr is %p\n", (void *)ostr); - ostr.write_async(Array(NULL, 0), 0, NULL); + ostr.write_async(nullarray, 0, NULL); System::Object obj = fs; System::IO::FileStream fs2 = System::IO::FileStream::downcast(obj); System::IO::OStream os2 = System::IO::OStream::downcast(obj); diff --git a/idlcomp/vtable-sample.h b/idlcomp/vtable-sample.h index bffd75f..eff0f4c 100644 --- a/idlcomp/vtable-sample.h +++ b/idlcomp/vtable-sample.h @@ -187,10 +187,10 @@ namespace IO { struct methods { void (*read)(::System::IO::_i_IStream *_this, - Array *buf, uint64_t *len); + Array *buf, uint64_t *len); void (*read_async)(::System::IO::_i_IStream *_this, - Array *buf, + Array *buf, ::System::Notifier *notifier); } methods; } info; @@ -322,10 +322,10 @@ namespace IO { struct methods { void (*read)(::System::IO::_i_IStream *_this, - Array *buf, uint64_t *len); + Array *buf, uint64_t *len); void (*read_async)(::System::IO::_i_IStream *_this, - Array *buf, + Array *buf, ::System::Notifier *notifier); void (*write)(::System::IO::_i_OStream *_this, unsigned char *buf, diff --git a/include/c++/orb.h b/include/c++/orb.h index 1f1a3e6..a2ead4d 100644 --- a/include/c++/orb.h +++ b/include/c++/orb.h @@ -9,6 +9,8 @@ #include #include +#include + namespace System { struct _i_Object; @@ -17,296 +19,19 @@ namespace System { } namespace RunTime { + using namespace ::Util::Arrays; + class ORBMM { - void *priv; + static void *priv; public: - class AllocGroup { - friend class ORBMM; - }; - typedef ::System::Mem::Region Region; - ORBMM(); - - void *alloc(size_t size, int refs = 1); - void retain(void *ptr, int refs = 1); - void release(void *ptr, int refs = 1); - void add_region(Region region, bool unmap_orig, int refs = 1); - }; - - extern ORBMM *orbmm; - - // FIXME: should be an IDL exception - struct ArrayException - { - }; - - class NullArray { - }; - - static const NullArray nullarray = {}; - - template struct MutableArray { - T *ptr; - size_t count; - - bool valid_index(size_t index) - { - return index >= 0 && index < count; - } - - T &operator[](size_t index) - { -#ifndef POLINTOS_NO_ARRAY_BOUNDS_CHECK - if (!valid_index(index)) - throw ArrayException(); -#endif - - return ptr[index]; - } - - MutableArray() - { - ptr = NULL; - count = 0; - } - - MutableArray(NullArray na) - { - ptr = NULL; - count = 0; - } - - MutableArray(T *PTR, size_t COUNT) - { - ptr = PTR; - count = COUNT; - } - - MutableArray &slice_nocheck(size_t first, size_t newcount) - { - MutableArray ret; - ret.ptr = ptr + first; - ret.count = newcount; - return ret; - } - - MutableArray &slice_nocheck(size_t first) - { - MutableArray ret; - ret.ptr = ptr + first; - ret.count = count - first; - return ret; - } - - MutableArray &slice(size_t first, size_t count) - { -#ifndef POLINTOS_NO_ARRAY_BOUNDS_CHECK - if (!valid_index(first) || !valid_index(first + count - 1)) - throw ArrayException(); -#endif - - return slice_nocheck(first, count); - } - - MutableArray &slice(size_t first) - { -#ifndef POLINTOS_NO_ARRAY_BOUNDS_CHECK - if (!valid_index(first)) - throw ArrayException(); -#endif - - return slice_nocheck(first); - } - - MutableArray copy() - { - MutableArray new_arr; - new_arr.ptr = new(orbmm) T[count]; - new_arr.count = count; - memcpy(new_arr.ptr, ptr, count); - return new_arr; - } - }; - - template - struct GrowableArray : public MutableArray { - using MutableArray::ptr; - using MutableArray::count; - size_t bufsize; - - GrowableArray() - { - bufsize = 0; - } - - GrowableArray(NullArray na) : MutableArray(na) - { - bufsize = 0; - } - - GrowableArray(T *PTR, size_t COUNT) : MutableArray(PTR, COUNT) - { - bufsize = COUNT; - } - - GrowableArray(T *PTR, size_t COUNT, size_t BUFSIZE) : - MutableArray(PTR, COUNT) - { - bufsize = BUFSIZE; - } - - GrowableArray(MutableArray &ma) : MutableArray(ma) - { - bufsize = count; - } - - void grow(size_t newsize) - { - if (newsize <= bufsize) - return; - - T *oldptr = ptr; - T *newptr = new(orbmm) T[newsize]; - memcpy(newptr, ptr, count * sizeof(T)); - ptr = newptr; - ll_smp_membar_store_after_store(); - bufsize = newsize; - // FIXME: Should release imply membar? - ll_smp_membar_any_after_store(); - orbmm->release(oldptr); - } - - // Caller must sync against all writers. - void append(T *newptr, size_t len, size_t max = ULONG_MAX) - { - if (count + len < count) - throw ArrayException(); - - if (count + len > max) - throw ArrayException(); - - if (count + len > bufsize) - grow(ll_get_order_round_up(count + len)); - - memcpy(ptr + count, newptr, len * sizeof(T)); - count += len; - } + static void *alloc(size_t size, int refs = 1); + static void retain(void *ptr, int refs = 1); + static void release(void *ptr, int refs = 1); + static void add_region(Region region, bool unmap_orig, int refs = 1); }; - - template struct Array { - const T *ptr; - size_t count; - - bool valid_index(size_t index) - { - return index >= 0 && index < count; - } - - const T &operator[](size_t index) - { -#ifndef POLINTOS_NO_ARRAY_BOUNDS_CHECK - if (!valid_index(index)) - throw ArrayException(); -#endif - - return ptr[index]; - } - - Array() - { - ptr = NULL; - count = 0; - } - - Array(NullArray na) - { - ptr = NULL; - count = 0; - } - - Array(const T *PTR, size_t COUNT) - { - ptr = PTR; - count = COUNT; - } - - Array(MutableArray ma) - { - ptr = ma.ptr; - count = ma.count; - } - - MutableArray constcast() - { - MutableArray ma; - ma.ptr = const_cast(ptr); - ma.count = count; - return ma; - } - - Array &slice_nocheck(size_t first, size_t newcount) - { - Array ret; - ret.ptr = ptr + first; - ret.count = newcount; - return ret; - } - - Array &slice_nocheck(size_t first) - { - Array ret; - ret.ptr = ptr + first; - ret.count = count - first; - return ret; - } - - Array &slice(size_t first, size_t count) - { -#ifndef POLINTOS_NO_ARRAY_BOUNDS_CHECK - if (!valid_index(first) || !valid_index(first + count - 1)) - throw ArrayException(); -#endif - - return slice_nocheck(first, count); - } - - Array &slice(size_t first) - { -#ifndef POLINTOS_NO_ARRAY_BOUNDS_CHECK - if (!valid_index(first)) - throw ArrayException(); -#endif - - return slice_nocheck(first); - } - - MutableArray copy() - { - MutableArray new_arr; - new_arr.ptr = new(orbmm) T[count]; - new_arr.count = count; - memcpy(new_arr.ptr, ptr, count); - return new_arr; - } - }; - - static inline Array countarray(const char *ptr) - { - Array ret; - ret.ptr = reinterpret_cast(ptr); - ret.count = strlen(ptr); - return ret; - } - - static inline MutableArray countarray(char *ptr) - { - MutableArray ret; - ret.ptr = reinterpret_cast(ptr); - ret.count = strlen(ptr); - return ret; - } struct IFaceInfo; typedef uint32_t ID; @@ -386,7 +111,7 @@ namespace System { struct IFaceInfo { const GUID *guid; - void (*invoke)(Array objlist, + void (*invoke)(Array objlist, ParamInfoBlock::Segment *segs, int nsegs); ::System::_i_Object *(*wrapper)(ID id); @@ -409,13 +134,13 @@ namespace System { const int chainlen; - int (*marshall)(GrowableArray &buf, - GrowableArray &objlist, - GrowableArray &newobjlist, + int (*marshall)(GrowableArray &buf, + GrowableArray &objlist, + GrowableArray &newobjlist, ParamInfoBlock::Segment *segs, int nsegs); - void (*unmarshall)(Array buf, - Array< ::System::_i_Object *> objlist, + void (*unmarshall)(Array buf, + Array< ::System::_i_Object *, ORBMM> objlist, ParamInfoBlock::Segment *segs, int nsegs); }; @@ -440,29 +165,16 @@ namespace System { }; } -inline void *operator new(size_t len, ::System::RunTime::ORBMM *orbmm, +inline void *operator new(size_t len, ::System::RunTime::ORBMM orbmm, int refs = 1) { - return orbmm->alloc(len, refs); -} - -inline void *operator new[](size_t len, ::System::RunTime::ORBMM *orbmm, - int refs = 1) -{ - return orbmm->alloc(len, refs); + return ::System::RunTime::ORBMM::alloc(len, refs); } -// FIXME: This isn't safe on anything with a descructor. -inline void operator delete(void *ptr, ::System::RunTime::ORBMM *orbmm, +inline void *operator new[](size_t len, ::System::RunTime::ORBMM orbmm, int refs = 1) { - orbmm->release(ptr, refs); -} - -inline void operator delete[](void *ptr, ::System::RunTime::ORBMM *orbmm, - int refs = 1) -{ - orbmm->release(ptr, refs); + return ::System::RunTime::ORBMM::alloc(len, refs); } // This is a macro rather than an inline template function so that the @@ -476,15 +188,15 @@ inline void operator delete[](void *ptr, ::System::RunTime::ORBMM *orbmm, #ifndef POLINTOS_NO_THROW_IDL #define throw_idl(T, args...) do { \ throw T(NULL, NULL, \ - new(::System::RunTime::orbmm) \ + new(::System::RunTime::ORBMM()) \ ::System::Exceptions::NativeCodeExceptionOriginInfo \ (::System::RunTime::Priv::get_pc()), \ ::System::RunTime::Priv::in_kernel(), ##args); \ } while (0) #define rethrow_idl(oldex, T, args...) do { \ - throw T(new(::System::RunTime::orbmm) typeof(oldex)(oldex), NULL, \ - new(::System::RunTime::orbmm) \ + throw T(new(::System::RunTime::ORBMM()) typeof(oldex)(oldex), NULL, \ + new(::System::RunTime::ORBMM()) \ ::System::Exceptions::NativeCodeExceptionOriginInfo \ (::System::RunTime::Priv::get_pc()), \ ::System::RunTime::Priv::in_kernel(), ##args); \ diff --git a/include/c++/util/array.h b/include/c++/util/array.h new file mode 100644 index 0000000..80ba1c7 --- /dev/null +++ b/include/c++/util/array.h @@ -0,0 +1,305 @@ +// util/array.h -- Dynamically sized arrays +// +// This software is copyright (c) 2007 Scott Wood . +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors or contributors be held liable for any damages +// arising from the use of this software. +// +// Permission is hereby granted to everyone, free of charge, to use, copy, +// modify, prepare derivative works of, publish, distribute, perform, +// sublicense, and/or sell copies of the Software, provided that the above +// copyright notice and disclaimer of warranty be included in all copies or +// substantial portions of this software. + +#ifndef _UTIL_ARRAY_H +#define _UTIL_ARRAY_H + +namespace System { +namespace RunTime { + class ORBMM; +}} + +namespace Util { + namespace Arrays { + struct ArrayException + { + }; + + class NullArray { + }; + + static const NullArray nullarray = {}; + + template struct MutableArray { + T *ptr; + size_t count; + + bool valid_index(size_t index) + { + return index >= 0 && index < count; + } + + T &operator[](size_t index) + { +#ifndef POLINTOS_NO_ARRAY_BOUNDS_CHECK + if (!valid_index(index)) + throw ArrayException(); +#endif + + return ptr[index]; + } + + MutableArray() + { + ptr = NULL; + count = 0; + } + + MutableArray(NullArray na) + { + ptr = NULL; + count = 0; + } + + MutableArray(T *PTR, size_t COUNT) + { + ptr = PTR; + count = COUNT; + } + + MutableArray &slice_nocheck(size_t first, size_t newcount) + { + MutableArray ret; + ret.ptr = ptr + first; + ret.count = newcount; + return ret; + } + + MutableArray &slice_nocheck(size_t first) + { + MutableArray ret; + ret.ptr = ptr + first; + ret.count = count - first; + return ret; + } + + MutableArray &slice(size_t first, size_t count) + { +#ifndef POLINTOS_NO_ARRAY_BOUNDS_CHECK + if (!valid_index(first) || !valid_index(first + count - 1)) + throw ArrayException(); +#endif + + return slice_nocheck(first, count); + } + + MutableArray &slice(size_t first) + { +#ifndef POLINTOS_NO_ARRAY_BOUNDS_CHECK + if (!valid_index(first)) + throw ArrayException(); +#endif + + return slice_nocheck(first); + } + + MutableArray copy() + { + MutableArray new_arr; + new_arr.ptr = new(Alloc()) T[count]; + new_arr.count = count; + memcpy(new_arr.ptr, ptr, count); + return new_arr; + } + }; + + template + struct GrowableArray : public MutableArray { + using MutableArray::ptr; + using MutableArray::count; + size_t bufsize; + + GrowableArray() + { + bufsize = 0; + } + + GrowableArray(NullArray na) : MutableArray(na) + { + bufsize = 0; + } + + GrowableArray(T *PTR, size_t COUNT) : MutableArray(PTR, COUNT) + { + bufsize = COUNT; + } + + GrowableArray(T *PTR, size_t COUNT, size_t BUFSIZE) : + MutableArray(PTR, COUNT) + { + bufsize = BUFSIZE; + } + + GrowableArray(MutableArray &ma) : MutableArray(ma) + { + bufsize = count; + } + + void grow(size_t newsize) + { + if (newsize <= bufsize) + return; + + T *oldptr = ptr; + T *newptr = new(Alloc()) T[newsize]; + + memcpy(newptr, ptr, count * sizeof(T)); + + ptr = newptr; + ll_smp_membar_store_after_store(); + bufsize = newsize; + ll_smp_membar_any_after_store(); + + Alloc::release(oldptr); + } + + // Caller must sync against all writers. + void append(T *newptr, size_t len, size_t max = ULONG_MAX) + { + if (count + len < count) + throw ArrayException(); + + if (count + len > max) + throw ArrayException(); + + if (count + len > bufsize) + grow(ll_get_order_round_up(count + len)); + + memcpy(ptr + count, newptr, len * sizeof(T)); + count += len; + } + }; + + template struct Array { + const T *ptr; + size_t count; + + bool valid_index(size_t index) + { + return index >= 0 && index < count; + } + + const T &operator[](size_t index) + { +#ifndef POLINTOS_NO_ARRAY_BOUNDS_CHECK + if (!valid_index(index)) + throw ArrayException(); +#endif + + return ptr[index]; + } + + Array() + { + ptr = NULL; + count = 0; + } + + Array(NullArray na) + { + ptr = NULL; + count = 0; + } + + Array(const T *PTR, size_t COUNT) + { + ptr = PTR; + count = COUNT; + } + + Array(MutableArray ma) + { + ptr = ma.ptr; + count = ma.count; + } + + MutableArray constcast() + { + MutableArray ma; + ma.ptr = const_cast(ptr); + ma.count = count; + return ma; + } + + Array &slice_nocheck(size_t first, size_t newcount) + { + Array ret; + ret.ptr = ptr + first; + ret.count = newcount; + return ret; + } + + Array &slice_nocheck(size_t first) + { + Array ret; + ret.ptr = ptr + first; + ret.count = count - first; + return ret; + } + + Array &slice(size_t first, size_t count) + { +#ifndef POLINTOS_NO_ARRAY_BOUNDS_CHECK + if (!valid_index(first) || !valid_index(first + count - 1)) + throw ArrayException(); +#endif + + return slice_nocheck(first, count); + } + + Array &slice(size_t first) + { +#ifndef POLINTOS_NO_ARRAY_BOUNDS_CHECK + if (!valid_index(first)) + throw ArrayException(); +#endif + + return slice_nocheck(first); + } + + MutableArray copy() + { + MutableArray new_arr; + new_arr.ptr = new(Alloc()) T[count]; + new_arr.count = count; + memcpy(new_arr.ptr, ptr, count); + return new_arr; + } + }; + + template + static inline Array + countarray(const char *ptr) + { + Array ret; + ret.ptr = reinterpret_cast(ptr); + ret.count = strlen(ptr); + return ret; + } + + template + static inline MutableArray + countarray(char *ptr) + { + MutableArray ret; + ret.ptr = reinterpret_cast(ptr); + ret.count = strlen(ptr); + return ret; + } + } + + using namespace Arrays; +} + +#endif diff --git a/kernel/core/irq.cc b/kernel/core/irq.cc index 577f63b..b9e84e6 100644 --- a/kernel/core/irq.cc +++ b/kernel/core/irq.cc @@ -27,7 +27,7 @@ namespace IRQ { while (list) { if (list == irq) - throw_idl(ResourceBusy, -1, countarray("IRQ in use")); + throw_idl(ResourceBusy, -1, countarray("IRQ in use")); insert = &list->next; list = *insert; diff --git a/kernel/include/kern/console.h b/kernel/include/kern/console.h index 9da6977..174d4c6 100644 --- a/kernel/include/kern/console.h +++ b/kernel/include/kern/console.h @@ -11,7 +11,7 @@ namespace Console { { } - virtual void write(Array buf, u64 *len) = 0; + virtual void write(Array buf, u64 *len) = 0; void write(const char *data, size_t len); }; diff --git a/kernel/include/kern/kernel.h b/kernel/include/kern/kernel.h index f90d701..5d6e8b6 100644 --- a/kernel/include/kern/kernel.h +++ b/kernel/include/kern/kernel.h @@ -15,7 +15,7 @@ using System::RunTime::countarray; using System::RunTime::Array; using System::RunTime::nullarray; -using System::RunTime::orbmm; +using System::RunTime::ORBMM; using System::Object; using System::Objects::Factory; using namespace System::Exceptions::Std; diff --git a/kernel/include/kern/mem.h b/kernel/include/kern/mem.h index a143dfb..eeb4e6e 100644 --- a/kernel/include/kern/mem.h +++ b/kernel/include/kern/mem.h @@ -348,8 +348,6 @@ namespace Mem { extern Factory addr_space_factory, proc_addr_space_factory; - using ::System::RunTime::orbmm; - static inline bool page_aligned(u64 addr) { return !(addr & (u64)(Arch::page_size - 1)); diff --git a/kernel/io/console/misc.cc b/kernel/io/console/misc.cc index 7da0324..fe91d18 100644 --- a/kernel/io/console/misc.cc +++ b/kernel/io/console/misc.cc @@ -21,7 +21,7 @@ namespace Console { void Console::write(const char *data, size_t len) { u64 len64 = len; - write(Array((octet *)data, len), &len64); + write(Array((octet *)data, len), &len64); } // All consoles will set this to themselves; the last console diff --git a/kernel/mem/addrspace.cc b/kernel/mem/addrspace.cc index 78cbe5e..3280add 100644 --- a/kernel/mem/addrspace.cc +++ b/kernel/mem/addrspace.cc @@ -567,7 +567,7 @@ namespace Mem { if (mflags.Replace) throw_idl(InvalidArgument, 3, - countarray("Replace unimplemented")); + countarray("Replace unimplemented")); Mappable *cma = Mappable::classptr(ma); if (!cma) { @@ -583,10 +583,10 @@ namespace Mem { mflags.Fixed = 1; if (!page_aligned(region.start)) - throw_idl(InvalidArgument, 1, countarray("unaligned start")); + throw_idl(InvalidArgument, 1, countarray("unaligned start")); if (!page_aligned(region.end + 1)) - throw_idl(InvalidArgument, 1, countarray("unaligned end")); + throw_idl(InvalidArgument, 1, countarray("unaligned end")); Lock::AutoLock autolock(lock); Region vregion; @@ -599,11 +599,11 @@ namespace Mem { if (is_process) { if (!valid_addr(vregion.start)) throw_idl(InvalidArgument, 2, - countarray("invalid virtual start")); + countarray("invalid virtual start")); if (!valid_addr(vregion.end)) throw_idl(InvalidArgument, 2, - countarray("invalid virtual end")); + countarray("invalid virtual end")); } if (check_overlap(vregion, prev)) @@ -612,10 +612,10 @@ namespace Mem { if (*vstart == System::Mem::AddrSpace_ns::unspecified_start) { if (fixed) - throw_idl(ResourceBusy, 2, countarray("varea overlap")); + throw_idl(ResourceBusy, 2, countarray("varea overlap")); if (!get_free_region(region.end - region.start + 1, vregion, prev)) - throw_idl(OutOfSpace, countarray("out of vspace")); + throw_idl(OutOfSpace, countarray("out of vspace")); *vstart = vregion.start; } diff --git a/kernel/mem/orbmm.cc b/kernel/mem/orbmm.cc index deb8689..9118738 100644 --- a/kernel/mem/orbmm.cc +++ b/kernel/mem/orbmm.cc @@ -20,11 +20,6 @@ namespace RunTime { ORBMM orbmm_real; ORBMM *orbmm = &orbmm_real; - ORBMM::ORBMM() - { - priv = NULL; - } - void *ORBMM::alloc(size_t size, int refs) { return reinterpret_cast(new u8[size]); diff --git a/kernel/orb/invoke.cc b/kernel/orb/invoke.cc index 7fffb61..ced7ad8 100644 --- a/kernel/orb/invoke.cc +++ b/kernel/orb/invoke.cc @@ -116,7 +116,7 @@ namespace ORB { size_t len = round_up(spib->segments[i].len, 3); if (len + copied > bufsize || len + copied < copied) - throw_idl(InvalidArgument, 0, countarray("copy_data: bad size")); + throw_idl(InvalidArgument, 0, countarray("copy_data: bad size")); dpib->segments[i].ptr = vaddr; dpib->segments[i].len = len; @@ -161,13 +161,13 @@ namespace ORB { printf("objlist len %u\n", pib.objlist_len); if (pib.objlist_len == 0) - throw_idl(InvalidArgument, 0, countarray("no objects")); + throw_idl(InvalidArgument, 0, countarray("no objects")); // FIXME: declare constants somewhere if (pib.num_segments > 64) - throw_idl(InvalidArgument, 0, countarray("too many segments")); + throw_idl(InvalidArgument, 0, countarray("too many segments")); if (pib.objlist_len > 4096) - throw_idl(InvalidArgument, 0, countarray("too many objects")); + throw_idl(InvalidArgument, 0, countarray("too many objects")); printf("&pib.objlist[0] %p\n", &pib.objlist[0]); @@ -190,8 +190,8 @@ namespace ORB { buflen += sizeof(ParamInfoBlock); buflen += pib.num_segments * sizeof(ParamInfoBlock::Segment); - u8 *args = new(orbmm) u8[buflen]; - u8 *copy = new(orbmm) u8[pib.copy_size]; + u8 *args = new(ORBMM()) u8[buflen]; + u8 *copy = new(ORBMM()) u8[pib.copy_size]; ParamInfoBlock *dpib = reinterpret_cast (args + piboff); dpib->objlist = reinterpret_cast(args + datalen); diff --git a/lib/c++/orb.cc b/lib/c++/orb.cc index 636ee9a..64df517 100644 --- a/lib/c++/orb.cc +++ b/lib/c++/orb.cc @@ -66,7 +66,7 @@ namespace RunTime { return reinterpret_cast(__builtin_return_address(0)); } - void exception_to_array(::System::VStruct *ex, Array *ar) + void exception_to_array(::System::VStruct *ex, Array *ar) { // FIXME: marshall struct } @@ -95,7 +95,7 @@ namespace RunTime { extern "C" void abort(); extern "C" void handle_message(::System::RunTime::ParamInfoBlock *pib, - ::System::RunTime::Array *ex_arr) + ::System::RunTime::Array *ex_arr) { try { ::System::RunTime::Priv::handle_message(pib); -- 2.39.2