@@ -92,8 +92,8 @@ struct options {
92
92
bool chaseRawPointers = false ;
93
93
bool generateJitDebugInfo = false ;
94
94
95
- friend bool operator ==(const options & lhs, const options & rhs);
96
- friend bool operator !=(const options & lhs, const options & rhs);
95
+ friend bool operator ==(const options& lhs, const options& rhs);
96
+ friend bool operator !=(const options& lhs, const options& rhs);
97
97
};
98
98
99
99
constexpr std::string_view OI_SECTION_PREFIX = " .oi." ;
@@ -102,29 +102,29 @@ class OILibrary {
102
102
friend class OILibraryImpl ;
103
103
104
104
public:
105
- OILibrary (void * TemplateFunc, options opt);
105
+ OILibrary (void * TemplateFunc, options opt);
106
106
~OILibrary ();
107
107
int init ();
108
- int getObjectSize (void * objectAddr, size_t & size);
108
+ int getObjectSize (void * objectAddr, size_t & size);
109
109
110
110
options opts;
111
111
112
112
private:
113
- class OILibraryImpl * pimpl_;
113
+ class OILibraryImpl * pimpl_;
114
114
115
- size_t (*fp)(const void *) = nullptr ;
115
+ size_t (*fp)(const void *) = nullptr ;
116
116
};
117
117
118
118
template <class T >
119
119
class CodegenHandler {
120
120
public:
121
- static int init (const options & opts = {}, bool checkOptions = true ) {
122
- OILibrary * lib;
121
+ static int init (const options& opts = {}, bool checkOptions = true ) {
122
+ OILibrary* lib;
123
123
return getLibrary (lib, opts, checkOptions);
124
124
}
125
125
126
126
static void teardown () {
127
- OILibrary * lib;
127
+ OILibrary* lib;
128
128
if (int responseCode = getLibrary (lib);
129
129
responseCode != Response::OIL_SUCCESS) {
130
130
return ;
@@ -135,64 +135,64 @@ class CodegenHandler {
135
135
delete lib;
136
136
}
137
137
138
- static int getObjectSize (const T & objectAddr, size_t & objectSize) {
139
- OILibrary * lib;
138
+ static int getObjectSize (const T& objectAddr, size_t & objectSize) {
139
+ OILibrary* lib;
140
140
if (int responseCode = getLibrary (lib);
141
141
responseCode != Response::OIL_SUCCESS) {
142
142
return responseCode;
143
143
}
144
144
145
- return lib->getObjectSize ((void *)&objectAddr, objectSize);
145
+ return lib->getObjectSize ((void *)&objectAddr, objectSize);
146
146
}
147
147
148
- static int getObjectSize (const T & objectAddr, size_t & objectSize,
149
- const options & opts, bool checkOptions = true ) {
150
- OILibrary * lib;
148
+ static int getObjectSize (const T& objectAddr, size_t & objectSize,
149
+ const options& opts, bool checkOptions = true ) {
150
+ OILibrary* lib;
151
151
if (int responseCode = getLibrary (lib, opts, checkOptions);
152
152
responseCode != Response::OIL_SUCCESS) {
153
153
return responseCode;
154
154
}
155
155
156
- return lib->getObjectSize ((void *)&objectAddr, objectSize);
156
+ return lib->getObjectSize ((void *)&objectAddr, objectSize);
157
157
}
158
158
159
159
private:
160
- static std::atomic<OILibrary *> * getLib () {
161
- static std::atomic<OILibrary *> lib = nullptr ;
160
+ static std::atomic<OILibrary*>* getLib () {
161
+ static std::atomic<OILibrary*> lib = nullptr ;
162
162
return &lib;
163
163
}
164
164
165
- static std::atomic<std::atomic<OILibrary *> *> * getBoxedLib () {
166
- static std::atomic<std::atomic<OILibrary *> *> boxedLib = nullptr ;
165
+ static std::atomic<std::atomic<OILibrary*>*>* getBoxedLib () {
166
+ static std::atomic<std::atomic<OILibrary*> *> boxedLib = nullptr ;
167
167
return &boxedLib;
168
168
}
169
169
170
- static int getLibrary (OILibrary *& result) {
171
- std::atomic<OILibrary *> * curBoxedLib = getBoxedLib ()->load ();
170
+ static int getLibrary (OILibrary*& result) {
171
+ std::atomic<OILibrary*>* curBoxedLib = getBoxedLib ()->load ();
172
172
if (curBoxedLib == nullptr )
173
173
return Response::OIL_UNINITIALISED;
174
174
175
- OILibrary * curLib = curBoxedLib->load ();
175
+ OILibrary* curLib = curBoxedLib->load ();
176
176
if (curLib == nullptr )
177
177
return Response::OIL_UNINITIALISED;
178
178
179
179
result = curLib;
180
180
return Response::OIL_SUCCESS;
181
181
}
182
182
183
- static int getLibrary (OILibrary *& result, const options & opts,
183
+ static int getLibrary (OILibrary*& result, const options& opts,
184
184
bool checkOptions) {
185
- std::atomic<OILibrary *> * curBoxedLib = getBoxedLib ()->load ();
185
+ std::atomic<OILibrary*>* curBoxedLib = getBoxedLib ()->load ();
186
186
187
187
if (curBoxedLib == nullptr ) {
188
188
if (!getBoxedLib ()->compare_exchange_strong (curBoxedLib, getLib ())) {
189
189
return Response::OIL_INITIALISING;
190
190
}
191
191
curBoxedLib = getLib ();
192
192
193
- int (*sizeFp)(const T &, size_t &) = &getObjectSize;
194
- void * typedFp = reinterpret_cast <void *>(sizeFp);
195
- OILibrary * newLib = new OILibrary (typedFp, opts);
193
+ int (*sizeFp)(const T&, size_t &) = &getObjectSize;
194
+ void * typedFp = reinterpret_cast <void *>(sizeFp);
195
+ OILibrary* newLib = new OILibrary (typedFp, opts);
196
196
197
197
if (int initCode = newLib->init (); initCode != Response::OIL_SUCCESS) {
198
198
delete newLib;
@@ -203,7 +203,7 @@ class CodegenHandler {
203
203
getLib ()->store (newLib);
204
204
}
205
205
206
- OILibrary * curLib = curBoxedLib->load ();
206
+ OILibrary* curLib = curBoxedLib->load ();
207
207
if (curLib == nullptr ) {
208
208
return Response::OIL_INITIALISING;
209
209
}
@@ -224,7 +224,7 @@ class CodegenHandler {
224
224
* Ahead-Of-Time (AOT) compilation.
225
225
*/
226
226
template <class T >
227
- int getObjectSize (const T & objectAddr, size_t & objectSize, const options & opts,
227
+ int getObjectSize (const T& objectAddr, size_t & objectSize, const options& opts,
228
228
bool checkOptions = true ) {
229
229
return CodegenHandler<T>::getObjectSize (objectAddr, objectSize, opts,
230
230
checkOptions);
@@ -234,7 +234,7 @@ int getObjectSize(const T &objectAddr, size_t &objectSize, const options &opts,
234
234
235
235
template <class T >
236
236
int __attribute__ ((weak))
237
- getObjectSizeImpl(const T & objectAddr, size_t & objectSize);
237
+ getObjectSizeImpl(const T& objectAddr, size_t & objectSize);
238
238
239
239
#endif
240
240
@@ -249,7 +249,7 @@ getObjectSizeImpl(const T &objectAddr, size_t &objectSize);
249
249
*/
250
250
template <class T >
251
251
int __attribute__ ((noinline))
252
- getObjectSize(const T & objectAddr, size_t & objectSize) {
252
+ getObjectSize(const T& objectAddr, size_t & objectSize) {
253
253
#ifdef OIL_AOT_COMPILATION
254
254
if (!getObjectSizeImpl<T>) {
255
255
return Response::OIL_UNINITIALISED;
0 commit comments