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;
46 unsigned long l[16 / sizeof(unsigned long)];
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 GrowableArray<uint8_t, ORBMM> &buf;
128 GrowableArray<ID, ORBMM> &objlist;
129 GrowableArray<NewObject, ORBMM> &newobjlist;
130 ParamInfoBlock::Segment *segs;
135 // List of GUIDs of the struct and its superstructs,
136 // starting with System.VStruct and ending with
137 // the concrete struct.
139 const unsigned long *const *const guids;
141 // Length of inheritance chain; 1 for System.VStruct
145 int (*marshall)(MarshCtx &ctx);
146 void (*unmarshall)(MarshCtx &ctx);
150 // Return the caller's PC. It'd be nice if GCC had a builtin for
151 // the current PC, so that a simple relocation could be used rather
152 // than a function call. OPT: put this in lowlevel-lib, so that
153 // architectures can provide a faster version.
155 unsigned long get_pc();
157 static inline bool in_kernel()
170 inline void *operator new(size_t len, ::System::RunTime::ORBMM orbmm,
173 return ::System::RunTime::ORBMM::alloc(len, refs);
176 inline void *operator new[](size_t len, ::System::RunTime::ORBMM orbmm,
179 return ::System::RunTime::ORBMM::alloc(len, refs);
182 // This is a macro rather than an inline template function so that the
183 // caller shows up as file/line number in the debugging information rather
184 // than this header file, and so that a variable argument list can be
185 // passed to a fixed arg ctor.
187 // To throw an IDL exception of type Foo, do this:
188 // throw_idl(Foo, args, to, foo);
190 #ifndef POLINTOS_NO_THROW_IDL
191 #define throw_idl(T, args...) do { \
192 throw T(NULL, NULL, \
193 new(::System::RunTime::ORBMM()) \
194 ::System::Exceptions::NativeCodeExceptionOriginInfo \
195 (::System::RunTime::Priv::get_pc()), \
196 ::System::RunTime::Priv::in_kernel(), ##args); \
199 #define rethrow_idl(oldex, T, args...) do { \
200 throw T(new(::System::RunTime::ORBMM()) typeof(oldex)(oldex), NULL, \
201 new(::System::RunTime::ORBMM()) \
202 ::System::Exceptions::NativeCodeExceptionOriginInfo \
203 (::System::RunTime::Priv::get_pc()), \
204 ::System::RunTime::Priv::in_kernel(), ##args); \