24
24
void aco_runtime_test (void ){
25
25
#ifdef __i386__
26
26
_Static_assert (sizeof (void * ) == 4 , "require 'sizeof(void*) == 4'" );
27
- #elif __x86_64__
27
+ #elif __x86_64__
28
28
_Static_assert (sizeof (void * ) == 8 , "require 'sizeof(void*) == 8'" );
29
29
_Static_assert (sizeof (__uint128_t ) == 16 , "require 'sizeof(__uint128_t) == 16'" );
30
30
#else
@@ -171,7 +171,7 @@ static __thread aco_cofuncp_t aco_gtls_last_word_fp = aco_default_protector_last
171
171
172
172
#ifdef __i386__
173
173
static __thread void * aco_gtls_fpucw_mxcsr [2 ];
174
- #elif __x86_64__
174
+ #elif __x86_64__
175
175
static __thread void * aco_gtls_fpucw_mxcsr [1 ];
176
176
#else
177
177
#error "platform no support yet"
@@ -184,8 +184,8 @@ void aco_thread_init(aco_cofuncp_t last_word_co_fp){
184
184
aco_gtls_last_word_fp = last_word_co_fp ;
185
185
}
186
186
187
- // This function `aco_funcp_protector` should never be
188
- // called. If it's been called, that means the offending
187
+ // This function `aco_funcp_protector` should never be
188
+ // called. If it's been called, that means the offending
189
189
// `co` didn't call aco_exit(co) instead of `return` to
190
190
// finish its execution.
191
191
void aco_funcp_protector (void ){
@@ -216,7 +216,7 @@ aco_share_stack_t* aco_share_stack_new2(size_t sz, char guard_page_enabled){
216
216
217
217
size_t u_pgsz = 0 ;
218
218
if (guard_page_enabled != 0 ){
219
- // although gcc's Built-in Functions to Perform Arithmetic with
219
+ // although gcc's Built-in Functions to Perform Arithmetic with
220
220
// Overflow Checking is better, but it would require gcc >= 5.0
221
221
long pgsz = sysconf (_SC_PAGESIZE );
222
222
// pgsz must be > 0 && a power of two
@@ -244,7 +244,7 @@ aco_share_stack_t* aco_share_stack_new2(size_t sz, char guard_page_enabled){
244
244
}
245
245
}
246
246
247
- aco_share_stack_t * p = malloc (sizeof (aco_share_stack_t ));
247
+ aco_share_stack_t * p = ( aco_share_stack_t * ) malloc (sizeof (aco_share_stack_t ));
248
248
assertalloc_ptr (p );
249
249
memset (p , 0 , sizeof (aco_share_stack_t ));
250
250
@@ -266,7 +266,7 @@ aco_share_stack_t* aco_share_stack_new2(size_t sz, char guard_page_enabled){
266
266
p -> ptr = malloc (sz );
267
267
assertalloc_ptr (p -> ptr );
268
268
}
269
-
269
+
270
270
p -> owner = NULL ;
271
271
#ifdef ACO_USE_VALGRIND
272
272
p -> valgrind_stk_id = VALGRIND_STACK_REGISTER (
@@ -277,7 +277,7 @@ aco_share_stack_t* aco_share_stack_new2(size_t sz, char guard_page_enabled){
277
277
uintptr_t u_p = (uintptr_t )(p -> sz - (sizeof (void * ) << 1 ) + (uintptr_t )p -> ptr );
278
278
u_p = (u_p >> 4 ) << 4 ;
279
279
p -> align_highptr = (void * )u_p ;
280
- p -> align_retptr = (void * )(u_p - sizeof (void * ));
280
+ p -> align_retptr = (void * )(u_p - sizeof (void * ));
281
281
* ((void * * )(p -> align_retptr )) = (void * )(aco_funcp_protector_asm );
282
282
assert (p -> sz > (16 + (sizeof (void * ) << 1 ) + sizeof (void * )));
283
283
p -> align_limit = p -> sz - 16 - (sizeof (void * ) << 1 );
@@ -304,11 +304,11 @@ void aco_share_stack_destroy(aco_share_stack_t* sstk){
304
304
}
305
305
306
306
aco_t * aco_create (
307
- aco_t * main_co , aco_share_stack_t * share_stack ,
307
+ aco_t * main_co , aco_share_stack_t * share_stack ,
308
308
size_t save_stack_sz , aco_cofuncp_t fp , void * arg
309
309
){
310
310
311
- aco_t * p = malloc (sizeof (aco_t ));
311
+ aco_t * p = ( aco_t * ) malloc (sizeof (aco_t ));
312
312
assertalloc_ptr (p );
313
313
memset (p , 0 , sizeof (aco_t ));
314
314
@@ -362,7 +362,7 @@ aco_t* aco_create(
362
362
363
363
aco_attr_no_asan
364
364
void aco_resume (aco_t * resume_co ){
365
- assert (resume_co != NULL && resume_co -> main_co != NULL
365
+ assert (resume_co != NULL && resume_co -> main_co != NULL
366
366
&& resume_co -> is_end == 0
367
367
);
368
368
if (resume_co -> share_stack -> owner != resume_co ){
@@ -385,9 +385,9 @@ void aco_resume(aco_t* resume_co){
385
385
(uintptr_t )(owner_co -> reg [ACO_REG_IDX_SP ])
386
386
)
387
387
);
388
- owner_co -> save_stack .valid_sz =
388
+ owner_co -> save_stack .valid_sz =
389
389
(uintptr_t )(owner_co -> share_stack -> align_retptr )
390
- -
390
+ -
391
391
(uintptr_t )(owner_co -> reg [ACO_REG_IDX_SP ]);
392
392
if (owner_co -> save_stack .sz < owner_co -> save_stack .valid_sz ){
393
393
free (owner_co -> save_stack .ptr );
@@ -408,13 +408,13 @@ void aco_resume(aco_t* resume_co){
408
408
#ifdef __x86_64__
409
409
aco_amd64_optimized_memcpy_drop_in (
410
410
owner_co -> save_stack .ptr ,
411
- owner_co -> reg [ACO_REG_IDX_SP ],
411
+ owner_co -> reg [ACO_REG_IDX_SP ],
412
412
owner_co -> save_stack .valid_sz
413
413
);
414
414
#else
415
415
memcpy (
416
416
owner_co -> save_stack .ptr ,
417
- owner_co -> reg [ACO_REG_IDX_SP ],
417
+ owner_co -> reg [ACO_REG_IDX_SP ],
418
418
owner_co -> save_stack .valid_sz
419
419
);
420
420
#endif
@@ -427,35 +427,35 @@ void aco_resume(aco_t* resume_co){
427
427
owner_co -> share_stack -> align_validsz = 0 ;
428
428
#else
429
429
#error "platform no support yet"
430
- #endif
430
+ #endif
431
431
}
432
432
assert (resume_co -> share_stack -> owner == NULL );
433
433
#if defined(__i386__ ) || defined(__x86_64__ )
434
434
assert (
435
- resume_co -> save_stack .valid_sz
436
- <=
435
+ resume_co -> save_stack .valid_sz
436
+ <=
437
437
resume_co -> share_stack -> align_limit - sizeof (void * )
438
438
);
439
439
// TODO: optimize the performance penalty of memcpy function call
440
440
// for very short memory span
441
441
if (resume_co -> save_stack .valid_sz > 0 ) {
442
442
#ifdef __x86_64__
443
- aco_amd64_optimized_memcpy_drop_in (
443
+ aco_amd64_optimized_memcpy_drop_in (
444
444
(void * )(
445
- (uintptr_t )(resume_co -> share_stack -> align_retptr )
445
+ (uintptr_t )(resume_co -> share_stack -> align_retptr )
446
446
-
447
447
resume_co -> save_stack .valid_sz
448
- ),
448
+ ),
449
449
resume_co -> save_stack .ptr ,
450
450
resume_co -> save_stack .valid_sz
451
451
);
452
452
#else
453
453
memcpy (
454
454
(void * )(
455
- (uintptr_t )(resume_co -> share_stack -> align_retptr )
455
+ (uintptr_t )(resume_co -> share_stack -> align_retptr )
456
456
-
457
457
resume_co -> save_stack .valid_sz
458
- ),
458
+ ),
459
459
resume_co -> save_stack .ptr ,
460
460
resume_co -> save_stack .valid_sz
461
461
);
@@ -469,7 +469,7 @@ void aco_resume(aco_t* resume_co){
469
469
resume_co -> share_stack -> owner = resume_co ;
470
470
#else
471
471
#error "platform no support yet"
472
- #endif
472
+ #endif
473
473
}
474
474
aco_gtls_co = resume_co ;
475
475
acosw (resume_co -> main_co , resume_co );
@@ -479,7 +479,7 @@ void aco_resume(aco_t* resume_co){
479
479
void aco_destroy (aco_t * co ){
480
480
assertptr (co );
481
481
if (aco_is_main_co (co )){
482
- free (co );
482
+ free (co );
483
483
} else {
484
484
if (co -> share_stack -> owner == co ){
485
485
co -> share_stack -> owner = NULL ;
0 commit comments