core: Use unsigned constants.

* src/gc.c (FRAME_SIZE, M2_CELL_SIZE): Declare unsigned.
(gc_init): Use unsigned suffixes for divisions.
* src/posix.c (TIME_UNITS_PER_SECOND): Declare unsigned.
(UL1000000000): New constant.
(seconds_and_nanoseconds_to_long): Use it.
* src/gc.c (U10, U100): New constants.
(gc_init): Use them.
This commit is contained in:
Jan (janneke) Nieuwenhuizen 2021-01-01 10:24:22 +01:00
parent b237308f26
commit 8f67315eb6
No known key found for this signature in database
GPG key ID: F3C1A0D9C1D65273
2 changed files with 13 additions and 7 deletions

View file

@ -30,7 +30,7 @@
int g_dump_filedes;
#define M2_CELL_SIZE 1
#define M2_CELL_SIZE 1U
// CONSTANT M2_CELL_SIZE 12
char *
@ -47,6 +47,10 @@ news_bytes (struct scm *x)
return p + (2 * sizeof (long));
}
#define U10 10U
// CONSTANT U10 10
#define U100 100U
// CONSTANT U100 100
void
gc_init ()
{
@ -71,11 +75,11 @@ gc_init ()
p = getenv ("MES_ARENA");
if (p != 0)
ARENA_SIZE = atoi (p);
JAM_SIZE = ARENA_SIZE / 10;
JAM_SIZE = ARENA_SIZE / U10;
p = getenv ("MES_JAM");
if (p != 0)
JAM_SIZE = atoi (p);
GC_SAFETY = ARENA_SIZE / 100;
GC_SAFETY = ARENA_SIZE / U100;
p = getenv ("MES_SAFETY");
if (p != 0)
GC_SAFETY = atoi (p);

View file

@ -380,11 +380,11 @@ waitpid_ (struct scm *pid, struct scm *options)
#if __x86_64__
/* Nanoseconds on 64-bit systems with POSIX timers. */
// CONSTANT TIME_UNITS_PER_SECOND 1000000000
#define TIME_UNITS_PER_SECOND 1000000000
#define TIME_UNITS_PER_SECOND 1000000000U
#else
/* Milliseconds for everyone else. */
// CONSTANT TIME_UNITS_PER_SECOND 1000
#define TIME_UNITS_PER_SECOND 1000
#define TIME_UNITS_PER_SECOND 1000U
#endif
struct scm *
@ -408,6 +408,8 @@ gettimeofday_ () /*:((name . "gettimeofday")) */
return cons (make_number (time->tv_sec), make_number (time->tv_usec));
}
#define UL1000000000 1000000000UL
// CONSTANT UL1000000000 1000000000
long
seconds_and_nanoseconds_to_long (long s, long ns)
{
@ -415,9 +417,9 @@ seconds_and_nanoseconds_to_long (long s, long ns)
if (ns < 0)
{
uns = - ns;
return s * TIME_UNITS_PER_SECOND - uns / (1000000000 / TIME_UNITS_PER_SECOND);
return s * TIME_UNITS_PER_SECOND - uns / (UL1000000000 / TIME_UNITS_PER_SECOND);
}
return s * TIME_UNITS_PER_SECOND + uns / (1000000000 / TIME_UNITS_PER_SECOND);
return s * TIME_UNITS_PER_SECOND + uns / (UL1000000000 / TIME_UNITS_PER_SECOND);
}
struct scm *