9 #include <lowlevel/barriers.h>
10 #include <lowlevel/bitops.h>
12 #include <util/array.h>
22 using namespace ::Util::Arrays;
28 typedef ::System::Mem::Region Region;
30 static void *alloc(size_t size, int refs = 1);
31 static void retain(void *ptr, int refs = 1);
32 static void release(void *ptr, int refs = 1);
33 static void add_region(Region region, bool unmap_orig, int refs = 1);
40 const IFaceInfo *info;
41 const ptrdiff_t offset;
49 uintptr_t downcast(::System::_i_Object *obj, const GUID *new_guid);
51 // FIXME: use above typedef
52 static inline bool guids_equal(const unsigned long *guid1,
53 const unsigned long *guid2)
55 return (guid1[0] == guid2[0] &&
56 guid1[1] == guid2[1] &&
58 (guid1[2] == guid2[2] &&
59 guid1[3] == guid2[3])));
62 struct ParamInfoBlock {
66 uint32_t objlist_len, newobj_len;
67 uint32_t num_segments;
100 struct InvokeMethod {
114 void (*invoke)(Array<ID, ORBMM> objlist,
115 ParamInfoBlock::Segment *segs,
117 ::System::_i_Object *(*wrapper)(ID id);
121 uint32_t guid_hash[5]; // SHA-1 hash of Interface GUIDs
123 uint32_t reserved[3]; // must be zero
127 // List of GUIDs of the struct and its superstructs,
128 // starting with System.VStruct and ending with
129 // the concrete struct.
131 const unsigned long *const *const guids;
133 // Length of inheritance chain; 1 for System.VStruct
137 int (*marshall)(GrowableArray<uint8_t, ORBMM> &buf,
138 GrowableArray<ID, ORBMM> &objlist,
139 GrowableArray<NewObject, ORBMM> &newobjlist,
140 ParamInfoBlock::Segment *segs,
142 void (*unmarshall)(Array<uint8_t, ORBMM> buf,
143 Array< ::System::_i_Object *, ORBMM> objlist,
144 ParamInfoBlock::Segment *segs,
149 // Return the caller's PC. It'd be nice if GCC had a builtin for
150 // the current PC, so that a simple relocation could be used rather
151 // than a function call. OPT: put this in lowlevel-lib, so that
152 // architectures can provide a faster version.
154 unsigned long get_pc();
156 static inline bool in_kernel()
168 inline void *operator new(size_t len, ::System::RunTime::ORBMM orbmm,
171 return ::System::RunTime::ORBMM::alloc(len, refs);
174 inline void *operator new[](size_t len, ::System::RunTime::ORBMM orbmm,
177 return ::System::RunTime::ORBMM::alloc(len, refs);
180 // This is a macro rather than an inline template function so that the
181 // caller shows up as file/line number in the debugging information rather
182 // than this header file, and so that a variable argument list can be
183 // passed to a fixed arg ctor.
185 // To throw an IDL exception of type Foo, do this:
186 // throw_idl(Foo, args, to, foo);
188 #ifndef POLINTOS_NO_THROW_IDL
189 #define throw_idl(T, args...) do { \
190 throw T(NULL, NULL, \
191 new(::System::RunTime::ORBMM()) \
192 ::System::Exceptions::NativeCodeExceptionOriginInfo \
193 (::System::RunTime::Priv::get_pc()), \
194 ::System::RunTime::Priv::in_kernel(), ##args); \
197 #define rethrow_idl(oldex, T, args...) do { \
198 throw T(new(::System::RunTime::ORBMM()) typeof(oldex)(oldex), NULL, \
199 new(::System::RunTime::ORBMM()) \
200 ::System::Exceptions::NativeCodeExceptionOriginInfo \
201 (::System::RunTime::Priv::get_pc()), \
202 ::System::RunTime::Priv::in_kernel(), ##args); \