From c26946ae14353ecea00c5df93e2bf631c14c31ca Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Sun, 29 Sep 2024 00:02:30 +0300 Subject: [PATCH] Reformat some comments located at end-of-line Issue #364 (bdwgc). * include/gc/gc.h (GC_VDB_NONE, GC_VDB_MANUAL, GC_VDB_DEFAULT, GC_PROTECTS_POINTER_HEAP, GC_PROTECTS_STATIC_DATA, GC_PROTECTS_STACK, GC_DUPLICATE, GC_NO_THREADS, GC_UNIMPLEMENTED): Move comment to precede the entity (instead of being located at the end of line); refine comment. * include/private/gc_priv.h [!ANY_MSWIN] (RT_SIZE): Likewise. * include/private/gcconfig.h [NS32K] (STACKBOTTOM): Likewise. * include/private/gcconfig.h [(AARCH64 || ARM32) && MSWIN32]: Likewise. * mach_dep.c [MACOS && __MWERKS__ && !POWERPC] (PushMacRegisters): Likewise. * pthread_stop_world.c [LINT2 || THREAD_SANITIZER] (GC_usleep): Likewise. * include/private/gcconfig.h [MACOS] (DATAEND): Do not define (to empty) if CPPCHECK. --- include/gc/gc.h | 37 +++++++++++++++++++++++++++---------- include/private/gc_priv.h | 4 +++- include/private/gcconfig.h | 13 +++++++++---- mach_dep.c | 12 +++++++----- pthread_stop_world.c | 6 ++++-- 5 files changed, 50 insertions(+), 22 deletions(-) diff --git a/include/gc/gc.h b/include/gc/gc.h index 98f1e146b..d7aebe21c 100644 --- a/include/gc/gc.h +++ b/include/gc/gc.h @@ -887,10 +887,18 @@ GC_API void GC_CALL GC_set_manual_vdb_allowed(int); GC_API int GC_CALL GC_get_manual_vdb_allowed(void); /* The constants to represent available VDB techniques. */ -#define GC_VDB_NONE 0 /* means the incremental mode is unsupported */ + +/* Means the incremental mode is unsupported. */ +#define GC_VDB_NONE 0 + #define GC_VDB_MPROTECT 0x1 -#define GC_VDB_MANUAL 0x2 /* means GC_set_manual_vdb_allowed(1) has effect */ -#define GC_VDB_DEFAULT 0x4 /* means no other technique is usable */ + +/* Means GC_set_manual_vdb_allowed(1) has effect. */ +#define GC_VDB_MANUAL 0x2 + +/* Means no other technique is usable. */ +#define GC_VDB_DEFAULT 0x4 + #define GC_VDB_GWW 0x8 #define GC_VDB_PCR 0x10 #define GC_VDB_PROC 0x20 @@ -924,10 +932,16 @@ GC_API int GC_CALL GC_is_incremental_mode(void); /* Does not acquire the allocator lock. */ GC_API unsigned GC_CALL GC_get_actual_vdb(void); -#define GC_PROTECTS_POINTER_HEAP 1 /* May protect non-atomic objects. */ +/* May protect non-atomic objects. */ +#define GC_PROTECTS_POINTER_HEAP 1 + #define GC_PROTECTS_PTRFREE_HEAP 2 -#define GC_PROTECTS_STATIC_DATA 4 /* Currently never. */ -#define GC_PROTECTS_STACK 8 /* Probably impractical. */ + +/* Protects static data. But this is currently never. */ +#define GC_PROTECTS_STATIC_DATA 4 + +/* Deprecated. It is probably impractical to protect stacks. */ +#define GC_PROTECTS_STACK 8 #define GC_PROTECTS_NONE 0 @@ -1628,12 +1642,15 @@ GC_API void * GC_CALL GC_call_with_stack_base(GC_stack_base_func /* fn */, void * /* arg */) GC_ATTR_NONNULL(1); #define GC_SUCCESS 0 -#define GC_DUPLICATE 1 /* Was already registered. */ -#define GC_NO_THREADS 2 /* No thread support in GC. */ -/* GC_NO_THREADS is not returned by any GC function anymore. */ +/* Means was already registered. */ +#define GC_DUPLICATE 1 + +/* Deprecated. No thread support in GC. */ +#define GC_NO_THREADS 2 -#define GC_UNIMPLEMENTED 3 /* Not yet implemented on this platform. */ +/* Not yet implemented on this platform. */ +#define GC_UNIMPLEMENTED 3 /* Requested link not found (returned by GC_move_disappearing_link). */ #define GC_NOT_FOUND 4 diff --git a/include/private/gc_priv.h b/include/private/gc_priv.h index d1e32ff29..17c233b1b 100644 --- a/include/private/gc_priv.h +++ b/include/private/gc_priv.h @@ -1238,7 +1238,9 @@ struct roots { #ifndef ANY_MSWIN /* Size of hash table index to roots. */ # define LOG_RT_SIZE 6 -# define RT_SIZE (1 << LOG_RT_SIZE) /* Power of 2, may be != MAX_ROOT_SETS */ + + /* RT_SIZE should be a power of 2, may be != MAX_ROOT_SETS. */ +# define RT_SIZE (1 << LOG_RT_SIZE) #endif #if (!defined(MAX_HEAP_SECTS) || defined(CPPCHECK)) \ diff --git a/include/private/gcconfig.h b/include/private/gcconfig.h index ed56036a9..9c236e27f 100644 --- a/include/private/gcconfig.h +++ b/include/private/gcconfig.h @@ -960,7 +960,9 @@ EXTERN_C_BEGIN # endif /* See os_dep.c for details of global data segments. */ # define STACKBOTTOM ((ptr_t)LMGetCurStackBase()) -# define DATAEND /* not needed */ +# if !defined(CPPCHECK) +# define DATAEND /* not needed */ +# endif # endif /* MACOS */ # ifdef MSWIN32 @@ -1603,7 +1605,8 @@ EXTERN_C_BEGIN /* delimits the start of the data segment, no matter which ld */ /* options were passed through. */ # define DATASTART ((ptr_t)(&environ)) -# define STACKBOTTOM ((ptr_t)0xfffff000) /* for Encore */ + /* Note: hard-coded stack bottom for Encore. */ +# define STACKBOTTOM ((ptr_t)0xfffff000) # endif /* NS32K */ # ifdef LOONGARCH @@ -2075,7 +2078,8 @@ EXTERN_C_BEGIN # ifdef QNX /* Nothing specific. */ # endif -# ifdef MSWIN32 /* UWP */ +# ifdef MSWIN32 + /* UWP */ /* TODO: Enable MPROTECT_VDB */ # endif # ifdef NOSYS @@ -2148,7 +2152,8 @@ EXTERN_C_BEGIN void *n3ds_get_stack_bottom(void); # define STACKBOTTOM ((ptr_t)n3ds_get_stack_bottom()) # endif -# ifdef MSWIN32 /* UWP */ +# ifdef MSWIN32 + /* UWP */ /* TODO: Enable MPROTECT_VDB */ # endif # ifdef NOSYS diff --git a/mach_dep.c b/mach_dep.c index a405a685c..5debc1cdb 100644 --- a/mach_dep.c +++ b/mach_dep.c @@ -58,19 +58,20 @@ asm static void PushMacRegisters(void) { - sub.w #4,sp /* reserve space for one parameter */ + /* Reserve space for one parameter. */ + sub.w #4,sp move.l a2,(sp) jsr GC_push_one move.l a3,(sp) jsr GC_push_one move.l a4,(sp) jsr GC_push_one + /* Skip a5 (globals), a6 (frame pointer), and a7 (stack pointer). */ # if !__option(a6frames) - /* perhaps a6 should be pushed if stack frames are not being used */ + /* perhaps a6 should be pushed if stack frames are not used. */ move.l a6,(sp) - jsr GC_push_one + jsr GC_push_one # endif - /* skip a5 (globals), a6 (frame pointer), and a7 (stack pointer) */ move.l d2,(sp) jsr GC_push_one move.l d3,(sp) @@ -83,7 +84,8 @@ jsr GC_push_one move.l d7,(sp) jsr GC_push_one - add.w #4,sp /* fix stack */ + /* Fixup stack. */ + add.w #4,sp rts } diff --git a/pthread_stop_world.c b/pthread_stop_world.c index 70bbf10a7..999a161af 100644 --- a/pthread_stop_world.c +++ b/pthread_stop_world.c @@ -38,8 +38,10 @@ GC_INLINE void GC_usleep(unsigned us) # if defined(LINT2) || defined(THREAD_SANITIZER) /* Workaround "waiting while holding a lock" static analyzer warning. */ /* Workaround a rare hang in usleep() trying to acquire TSan Lock. */ - while (us-- > 0) - sched_yield(); /* pretending it takes 1us */ + while (us-- > 0) { + /* Sleep for a moment, pretending it takes 1us. */ + sched_yield(); + } # elif defined(CPPCHECK) /* || _POSIX_C_SOURCE >= 199309L */ struct timespec ts;