Skip to content

Commit

Permalink
Reformat some comments located at end-of-line
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ivmai committed Sep 30, 2024
1 parent 8d7843d commit c26946a
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 22 deletions.
37 changes: 27 additions & 10 deletions include/gc/gc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion include/private/gc_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)) \
Expand Down
13 changes: 9 additions & 4 deletions include/private/gcconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
12 changes: 7 additions & 5 deletions mach_dep.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
/* <pcb> perhaps a6 should be pushed if stack frames are not being used */
/* <pcb> 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)
Expand All @@ -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
}

Expand Down
6 changes: 4 additions & 2 deletions pthread_stop_world.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit c26946a

Please sign in to comment.