1919typedef struct {
2020 int error_code ; // Error code (0 for success, non-zero for errors)
2121 union {
22- uint32_t uint32_t_value ;
2322 _Bool _Bool_value ;
24- aot_obj_data_t aot_obj_data_t_value ;
25- aot_comp_data_t aot_comp_data_t_value ;
2623 aot_comp_context_t aot_comp_context_t_value ;
24+ aot_comp_data_t aot_comp_data_t_value ;
25+ aot_obj_data_t aot_obj_data_t_value ;
26+ uint32_t uint32_t_value ;
2727 // Add other types as needed
2828 } value ;
2929} Result ;
@@ -45,40 +45,23 @@ aot_call_stack_features_init_default_checked(void *features)
4545}
4646
4747static inline Result
48- aot_create_comp_data_checked (void * wasm_module , void * target_arch ,
49- _Bool gc_enabled )
48+ aot_compile_wasm_checked (aot_comp_context_t comp_ctx )
5049{
5150 Result res ;
52- // Check for null pointer parameter: wasm_module
53- if (wasm_module == NULL ) {
54- res .error_code = -1 ;
55- return res ;
56- }
57- // Check for null pointer parameter: target_arch
58- if (target_arch == NULL ) {
59- res .error_code = -1 ;
60- return res ;
61- }
6251 // Execute the original function
63- aot_comp_data_t original_result =
64- aot_create_comp_data (wasm_module , target_arch , gc_enabled );
52+ _Bool original_result = aot_compile_wasm (comp_ctx );
6553 // Assign return value and error code
66- if (original_result != NULL ) {
67- res .error_code = 0 ;
68- res .value .aot_comp_data_t_value = original_result ;
69- }
70- else {
71- res .error_code = -2 ;
72- }
54+ res .error_code = original_result ? 0 : -2 ;
55+ res .value ._Bool_value = original_result ;
7356 return res ;
7457}
7558
7659static inline Result
77- aot_destroy_comp_data_checked ( aot_comp_data_t comp_data )
60+ aot_compiler_destroy_checked ( void )
7861{
7962 Result res ;
8063 // Execute the original function
81- aot_destroy_comp_data ( comp_data );
64+ aot_compiler_destroy ( );
8265 // Assign return value and error code
8366 res .error_code = 0 ;
8467 return res ;
@@ -96,17 +79,6 @@ aot_compiler_init_checked(void)
9679 return res ;
9780}
9881
99- static inline Result
100- aot_compiler_destroy_checked (void )
101- {
102- Result res ;
103- // Execute the original function
104- aot_compiler_destroy ();
105- // Assign return value and error code
106- res .error_code = 0 ;
107- return res ;
108- }
109-
11082static inline Result
11183aot_create_comp_context_checked (aot_comp_data_t comp_data ,
11284 aot_comp_option_t option )
@@ -127,73 +99,87 @@ aot_create_comp_context_checked(aot_comp_data_t comp_data,
12799}
128100
129101static inline Result
130- aot_destroy_comp_context_checked (aot_comp_context_t comp_ctx )
102+ aot_create_comp_data_checked (void * wasm_module , void * target_arch ,
103+ _Bool gc_enabled )
131104{
132105 Result res ;
106+ // Check for null pointer parameter: wasm_module
107+ if (wasm_module == NULL ) {
108+ res .error_code = -1 ;
109+ return res ;
110+ }
111+ // Check for null pointer parameter: target_arch
112+ if (target_arch == NULL ) {
113+ res .error_code = -1 ;
114+ return res ;
115+ }
133116 // Execute the original function
134- aot_destroy_comp_context (comp_ctx );
117+ aot_comp_data_t original_result =
118+ aot_create_comp_data (wasm_module , target_arch , gc_enabled );
135119 // Assign return value and error code
136- res .error_code = 0 ;
120+ if (original_result != NULL ) {
121+ res .error_code = 0 ;
122+ res .value .aot_comp_data_t_value = original_result ;
123+ }
124+ else {
125+ res .error_code = -2 ;
126+ }
137127 return res ;
138128}
139129
140130static inline Result
141- aot_compile_wasm_checked ( aot_comp_context_t comp_ctx )
131+ aot_destroy_aot_file_checked ( void * aot_file )
142132{
143133 Result res ;
134+ // Check for null pointer parameter: aot_file
135+ if (aot_file == NULL ) {
136+ res .error_code = -1 ;
137+ return res ;
138+ }
144139 // Execute the original function
145- _Bool original_result = aot_compile_wasm ( comp_ctx );
140+ aot_destroy_aot_file ( aot_file );
146141 // Assign return value and error code
147- res .error_code = original_result ? 0 : -2 ;
148- res .value ._Bool_value = original_result ;
142+ res .error_code = 0 ;
149143 return res ;
150144}
151145
152146static inline Result
153- aot_obj_data_create_checked (aot_comp_context_t comp_ctx )
147+ aot_destroy_comp_context_checked (aot_comp_context_t comp_ctx )
154148{
155149 Result res ;
156150 // Execute the original function
157- aot_obj_data_t original_result = aot_obj_data_create (comp_ctx );
151+ aot_destroy_comp_context (comp_ctx );
158152 // Assign return value and error code
159- if (original_result != NULL ) {
160- res .error_code = 0 ;
161- res .value .aot_obj_data_t_value = original_result ;
162- }
163- else {
164- res .error_code = -2 ;
165- }
153+ res .error_code = 0 ;
166154 return res ;
167155}
168156
169157static inline Result
170- aot_obj_data_destroy_checked ( aot_obj_data_t obj_data )
158+ aot_destroy_comp_data_checked ( aot_comp_data_t comp_data )
171159{
172160 Result res ;
173161 // Execute the original function
174- aot_obj_data_destroy ( obj_data );
162+ aot_destroy_comp_data ( comp_data );
175163 // Assign return value and error code
176164 res .error_code = 0 ;
177165 return res ;
178166}
179167
180168static inline Result
181- aot_get_aot_file_size_checked (aot_comp_context_t comp_ctx ,
182- aot_comp_data_t comp_data ,
183- aot_obj_data_t obj_data )
169+ aot_emit_aot_file_checked (aot_comp_context_t comp_ctx ,
170+ aot_comp_data_t comp_data , void * file_name )
184171{
185172 Result res ;
173+ // Check for null pointer parameter: file_name
174+ if (file_name == NULL ) {
175+ res .error_code = -1 ;
176+ return res ;
177+ }
186178 // Execute the original function
187- uint32_t original_result =
188- aot_get_aot_file_size (comp_ctx , comp_data , obj_data );
179+ _Bool original_result = aot_emit_aot_file (comp_ctx , comp_data , file_name );
189180 // Assign return value and error code
190- if (original_result == 0 ) {
191- res .error_code = 0 ;
192- res .value .uint32_t_value = original_result ;
193- }
194- else {
195- res .error_code = -2 ;
196- }
181+ res .error_code = original_result ? 0 : -2 ;
182+ res .value ._Bool_value = original_result ;
197183 return res ;
198184}
199185
@@ -270,65 +256,79 @@ aot_emit_object_file_checked(aot_comp_context_t comp_ctx, void *file_name)
270256}
271257
272258static inline Result
273- aot_emit_aot_file_checked (aot_comp_context_t comp_ctx ,
274- aot_comp_data_t comp_data , void * file_name )
259+ aot_get_aot_file_size_checked (aot_comp_context_t comp_ctx ,
260+ aot_comp_data_t comp_data ,
261+ aot_obj_data_t obj_data )
275262{
276263 Result res ;
277- // Check for null pointer parameter: file_name
278- if (file_name == NULL ) {
279- res .error_code = -1 ;
280- return res ;
281- }
282264 // Execute the original function
283- _Bool original_result = aot_emit_aot_file (comp_ctx , comp_data , file_name );
265+ uint32_t original_result =
266+ aot_get_aot_file_size (comp_ctx , comp_data , obj_data );
284267 // Assign return value and error code
285- res .error_code = original_result ? 0 : -2 ;
286- res .value ._Bool_value = original_result ;
268+ if (original_result == 0 ) {
269+ res .error_code = 0 ;
270+ res .value .uint32_t_value = original_result ;
271+ }
272+ else {
273+ res .error_code = -2 ;
274+ }
287275 return res ;
288276}
289277
290278static inline Result
291- aot_destroy_aot_file_checked (void * aot_file )
279+ aot_get_last_error_checked (void )
292280{
293281 Result res ;
294- // Check for null pointer parameter: aot_file
295- if (aot_file == NULL ) {
296- res .error_code = -1 ;
297- return res ;
298- }
299282 // Execute the original function
300- aot_destroy_aot_file ( aot_file );
283+ aot_get_last_error ( );
301284 // Assign return value and error code
302285 res .error_code = 0 ;
303286 return res ;
304287}
305288
306289static inline Result
307- aot_get_last_error_checked (void )
290+ aot_get_plt_table_size_checked (void )
308291{
309292 Result res ;
310293 // Execute the original function
311- aot_get_last_error ();
294+ uint32_t original_result = aot_get_plt_table_size ();
312295 // Assign return value and error code
313- res .error_code = 0 ;
296+ if (original_result == 0 ) {
297+ res .error_code = 0 ;
298+ res .value .uint32_t_value = original_result ;
299+ }
300+ else {
301+ res .error_code = -2 ;
302+ }
314303 return res ;
315304}
316305
317306static inline Result
318- aot_get_plt_table_size_checked ( void )
307+ aot_obj_data_create_checked ( aot_comp_context_t comp_ctx )
319308{
320309 Result res ;
321310 // Execute the original function
322- uint32_t original_result = aot_get_plt_table_size ( );
311+ aot_obj_data_t original_result = aot_obj_data_create ( comp_ctx );
323312 // Assign return value and error code
324- if (original_result == 0 ) {
313+ if (original_result != NULL ) {
325314 res .error_code = 0 ;
326- res .value .uint32_t_value = original_result ;
315+ res .value .aot_obj_data_t_value = original_result ;
327316 }
328317 else {
329318 res .error_code = -2 ;
330319 }
331320 return res ;
332321}
333322
323+ static inline Result
324+ aot_obj_data_destroy_checked (aot_obj_data_t obj_data )
325+ {
326+ Result res ;
327+ // Execute the original function
328+ aot_obj_data_destroy (obj_data );
329+ // Assign return value and error code
330+ res .error_code = 0 ;
331+ return res ;
332+ }
333+
334334#endif // AOT_EXPORT_CHECKED_H
0 commit comments