Skip to content

Commit 5c51bf7

Browse files
committed
Remove folding marks
1 parent bec9d88 commit 5c51bf7

File tree

471 files changed

+7562
-16483
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

471 files changed

+7562
-16483
lines changed

TSRM/TSRM.c

Lines changed: 53 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ TSRM_TLS uint8_t is_thread_shutdown = 0;
117117

118118
/* Startup TSRM (call once for the entire process) */
119119
TSRM_API int tsrm_startup(int expected_threads, int expected_resources, int debug_level, char *debug_filename)
120-
{/*{{{*/
120+
{
121121
#if defined(TSRM_WIN32)
122122
tls_key = TlsAlloc();
123123
#else
@@ -159,12 +159,12 @@ TSRM_API int tsrm_startup(int expected_threads, int expected_resources, int debu
159159
tsrm_env_mutex = tsrm_mutex_alloc();
160160

161161
return 1;
162-
}/*}}}*/
162+
}
163163

164164

165165
/* Shutdown TSRM (call once for the entire process) */
166166
TSRM_API void tsrm_shutdown(void)
167-
{/*{{{*/
167+
{
168168
int i;
169169

170170
if (is_thread_shutdown) {
@@ -224,21 +224,20 @@ TSRM_API void tsrm_shutdown(void)
224224

225225
tsrm_reserved_pos = 0;
226226
tsrm_reserved_size = 0;
227-
}/*}}}*/
227+
}
228228

229-
/* {{{ */
230229
/* environ lock api */
231230
TSRM_API void tsrm_env_lock() {
232231
tsrm_mutex_lock(tsrm_env_mutex);
233232
}
234233

235234
TSRM_API void tsrm_env_unlock() {
236235
tsrm_mutex_unlock(tsrm_env_mutex);
237-
} /* }}} */
236+
}
238237

239238
/* enlarge the arrays for the already active threads */
240239
static void tsrm_update_active_threads(void)
241-
{/*{{{*/
240+
{
242241
int i;
243242

244243
for (i=0; i<tsrm_tls_table_size; i++) {
@@ -264,12 +263,12 @@ static void tsrm_update_active_threads(void)
264263
p = p->next;
265264
}
266265
}
267-
}/*}}}*/
266+
}
268267

269268

270269
/* allocates a new thread-safe-resource id */
271270
TSRM_API ts_rsrc_id ts_allocate_id(ts_rsrc_id *rsrc_id, size_t size, ts_allocate_ctor ctor, ts_allocate_dtor dtor)
272-
{/*{{{*/
271+
{
273272
TSRM_ERROR((TSRM_ERROR_LEVEL_CORE, "Obtaining a new resource id, %d bytes", size));
274273

275274
tsrm_mutex_lock(tsmm_mutex);
@@ -302,20 +301,20 @@ TSRM_API ts_rsrc_id ts_allocate_id(ts_rsrc_id *rsrc_id, size_t size, ts_allocate
302301

303302
TSRM_ERROR((TSRM_ERROR_LEVEL_CORE, "Successfully allocated new resource id %d", *rsrc_id));
304303
return *rsrc_id;
305-
}/*}}}*/
304+
}
306305

307306

308307
/* Reserve space for fast thread-safe-resources */
309308
TSRM_API void tsrm_reserve(size_t size)
310-
{/*{{{*/
309+
{
311310
tsrm_reserved_pos = 0;
312311
tsrm_reserved_size = TSRM_ALIGNED_SIZE(size);
313-
}/*}}}*/
312+
}
314313

315314

316315
/* allocates a new fast thread-safe-resource id */
317316
TSRM_API ts_rsrc_id ts_allocate_fast_id(ts_rsrc_id *rsrc_id, size_t *offset, size_t size, ts_allocate_ctor ctor, ts_allocate_dtor dtor)
318-
{/*{{{*/
317+
{
319318
TSRM_ERROR((TSRM_ERROR_LEVEL_CORE, "Obtaining a new fast resource id, %d bytes", size));
320319

321320
tsrm_mutex_lock(tsmm_mutex);
@@ -360,11 +359,11 @@ TSRM_API ts_rsrc_id ts_allocate_fast_id(ts_rsrc_id *rsrc_id, size_t *offset, siz
360359

361360
TSRM_ERROR((TSRM_ERROR_LEVEL_CORE, "Successfully allocated new resource id %d", *rsrc_id));
362361
return *rsrc_id;
363-
}/*}}}*/
362+
}
364363

365364

366365
static void allocate_new_resource(tsrm_tls_entry **thread_resources_ptr, THREAD_T thread_id)
367-
{/*{{{*/
366+
{
368367
int i;
369368

370369
TSRM_ERROR((TSRM_ERROR_LEVEL_CORE, "Creating data structures for thread %x", thread_id));
@@ -404,12 +403,12 @@ static void allocate_new_resource(tsrm_tls_entry **thread_resources_ptr, THREAD_
404403
}
405404

406405
tsrm_mutex_unlock(tsmm_mutex);
407-
}/*}}}*/
406+
}
408407

409408

410409
/* fetches the requested resource for the current thread */
411410
TSRM_API void *ts_resource_ex(ts_rsrc_id id, THREAD_T *th_id)
412-
{/*{{{*/
411+
{
413412
THREAD_T thread_id;
414413
int hash_value;
415414
tsrm_tls_entry *thread_resources;
@@ -467,12 +466,12 @@ TSRM_API void *ts_resource_ex(ts_rsrc_id id, THREAD_T *th_id)
467466
* changes to the structure as we read it.
468467
*/
469468
TSRM_SAFE_RETURN_RSRC(thread_resources->storage, id, thread_resources->count);
470-
}/*}}}*/
469+
}
471470

472471

473472
/* frees all resources allocated for the current thread */
474473
void ts_free_thread(void)
475-
{/*{{{*/
474+
{
476475
tsrm_tls_entry *thread_resources;
477476
int i;
478477
THREAD_T thread_id = tsrm_thread_id();
@@ -513,11 +512,11 @@ void ts_free_thread(void)
513512
thread_resources = thread_resources->next;
514513
}
515514
tsrm_mutex_unlock(tsmm_mutex);
516-
}/*}}}*/
515+
}
517516

518517
/* deallocates all occurrences of a given id */
519518
void ts_free_id(ts_rsrc_id id)
520-
{/*{{{*/
519+
{
521520
int i;
522521
int j = TSRM_UNSHUFFLE_RSRC_ID(id);
523522

@@ -548,7 +547,7 @@ void ts_free_id(ts_rsrc_id id)
548547
tsrm_mutex_unlock(tsmm_mutex);
549548

550549
TSRM_ERROR((TSRM_ERROR_LEVEL_CORE, "Successfully freed resource id %d", id));
551-
}/*}}}*/
550+
}
552551

553552

554553
/*
@@ -557,18 +556,18 @@ void ts_free_id(ts_rsrc_id id)
557556

558557
/* Obtain the current thread id */
559558
TSRM_API THREAD_T tsrm_thread_id(void)
560-
{/*{{{*/
559+
{
561560
#ifdef TSRM_WIN32
562561
return GetCurrentThreadId();
563562
#else
564563
return pthread_self();
565564
#endif
566-
}/*}}}*/
565+
}
567566

568567

569568
/* Allocate a mutex */
570569
TSRM_API MUTEX_T tsrm_mutex_alloc(void)
571-
{/*{{{*/
570+
{
572571
MUTEX_T mutexp;
573572
#ifdef TSRM_WIN32
574573
mutexp = malloc(sizeof(CRITICAL_SECTION));
@@ -581,12 +580,12 @@ TSRM_API MUTEX_T tsrm_mutex_alloc(void)
581580
printf("Mutex created thread: %d\n",mythreadid());
582581
#endif
583582
return( mutexp );
584-
}/*}}}*/
583+
}
585584

586585

587586
/* Free a mutex */
588587
TSRM_API void tsrm_mutex_free(MUTEX_T mutexp)
589-
{/*{{{*/
588+
{
590589
if (mutexp) {
591590
#ifdef TSRM_WIN32
592591
DeleteCriticalSection(mutexp);
@@ -599,78 +598,78 @@ TSRM_API void tsrm_mutex_free(MUTEX_T mutexp)
599598
#ifdef THR_DEBUG
600599
printf("Mutex freed thread: %d\n",mythreadid());
601600
#endif
602-
}/*}}}*/
601+
}
603602

604603

605604
/*
606605
Lock a mutex.
607606
A return value of 0 indicates success
608607
*/
609608
TSRM_API int tsrm_mutex_lock(MUTEX_T mutexp)
610-
{/*{{{*/
609+
{
611610
TSRM_ERROR((TSRM_ERROR_LEVEL_INFO, "Mutex locked thread: %ld", tsrm_thread_id()));
612611
#ifdef TSRM_WIN32
613612
EnterCriticalSection(mutexp);
614613
return 0;
615614
#else
616615
return pthread_mutex_lock(mutexp);
617616
#endif
618-
}/*}}}*/
617+
}
619618

620619

621620
/*
622621
Unlock a mutex.
623622
A return value of 0 indicates success
624623
*/
625624
TSRM_API int tsrm_mutex_unlock(MUTEX_T mutexp)
626-
{/*{{{*/
625+
{
627626
TSRM_ERROR((TSRM_ERROR_LEVEL_INFO, "Mutex unlocked thread: %ld", tsrm_thread_id()));
628627
#ifdef TSRM_WIN32
629628
LeaveCriticalSection(mutexp);
630629
return 0;
631630
#else
632631
return pthread_mutex_unlock(mutexp);
633632
#endif
634-
}/*}}}*/
633+
}
635634

636635
/*
637636
Changes the signal mask of the calling thread
638637
*/
639638
#ifdef HAVE_SIGPROCMASK
640639
TSRM_API int tsrm_sigmask(int how, const sigset_t *set, sigset_t *oldset)
641-
{/*{{{*/
640+
{
642641
TSRM_ERROR((TSRM_ERROR_LEVEL_INFO, "Changed sigmask in thread: %ld", tsrm_thread_id()));
643642

644643
return pthread_sigmask(how, set, oldset);
645-
}/*}}}*/
644+
}
646645
#endif
647646

648647

649648
TSRM_API void *tsrm_set_new_thread_begin_handler(tsrm_thread_begin_func_t new_thread_begin_handler)
650-
{/*{{{*/
649+
{
651650
void *retval = (void *) tsrm_new_thread_begin_handler;
652651

653652
tsrm_new_thread_begin_handler = new_thread_begin_handler;
654653
return retval;
655-
}/*}}}*/
654+
}
656655

657656

658657
TSRM_API void *tsrm_set_new_thread_end_handler(tsrm_thread_end_func_t new_thread_end_handler)
659-
{/*{{{*/
658+
{
660659
void *retval = (void *) tsrm_new_thread_end_handler;
661660

662661
tsrm_new_thread_end_handler = new_thread_end_handler;
663662
return retval;
664-
}/*}}}*/
663+
}
665664

666665

667666
TSRM_API void *tsrm_set_shutdown_handler(tsrm_shutdown_func_t shutdown_handler)
668-
{/*{{{*/
667+
{
669668
void *retval = (void *) tsrm_shutdown_handler;
670669

671670
tsrm_shutdown_handler = shutdown_handler;
672671
return retval;
673-
}/*}}}*/
672+
}
674673

675674

676675
/*
@@ -679,7 +678,7 @@ TSRM_API void *tsrm_set_shutdown_handler(tsrm_shutdown_func_t shutdown_handler)
679678

680679
#if TSRM_DEBUG
681680
int tsrm_error(int level, const char *format, ...)
682-
{/*{{{*/
681+
{
683682
if (level<=tsrm_error_level) {
684683
va_list args;
685684
int size;
@@ -694,12 +693,12 @@ int tsrm_error(int level, const char *format, ...)
694693
} else {
695694
return 0;
696695
}
697-
}/*}}}*/
696+
}
698697
#endif
699698

700699

701700
void tsrm_error_set(int level, char *debug_filename)
702-
{/*{{{*/
701+
{
703702
tsrm_error_level = level;
704703

705704
#if TSRM_DEBUG
@@ -716,16 +715,16 @@ void tsrm_error_set(int level, char *debug_filename)
716715
tsrm_error_file = stderr;
717716
}
718717
#endif
719-
}/*}}}*/
718+
}
720719

721720
TSRM_API void *tsrm_get_ls_cache(void)
722-
{/*{{{*/
721+
{
723722
return tsrm_tls_get();
724-
}/*}}}*/
723+
}
725724

726725
/* Returns offset of tsrm_ls_cache slot from Thread Control Block address */
727726
TSRM_API size_t tsrm_get_ls_cache_tcb_offset(void)
728-
{/*{{{*/
727+
{
729728
#if defined(__APPLE__) && defined(__x86_64__)
730729
// TODO: Implement support for fast JIT ZTS code ???
731730
return 0;
@@ -744,25 +743,25 @@ TSRM_API size_t tsrm_get_ls_cache_tcb_offset(void)
744743
#else
745744
return 0;
746745
#endif
747-
}/*}}}*/
746+
}
748747

749748
TSRM_API uint8_t tsrm_is_main_thread(void)
750-
{/*{{{*/
749+
{
751750
return in_main_thread;
752-
}/*}}}*/
751+
}
753752

754753
TSRM_API uint8_t tsrm_is_shutdown(void)
755-
{/*{{{*/
754+
{
756755
return is_thread_shutdown;
757-
}/*}}}*/
756+
}
758757

759758
TSRM_API const char *tsrm_api_name(void)
760-
{/*{{{*/
759+
{
761760
#if defined(TSRM_WIN32)
762761
return "Windows Threads";
763762
#else
764763
return "POSIX Threads";
765764
#endif
766-
}/*}}}*/
765+
}
767766

768767
#endif /* ZTS */

0 commit comments

Comments
 (0)