* srfi-18: define all of the components of the *primordial-thread* thread object
* srfi-18: pthread-terminate! takes a thread object as argument
Handle this by checking if the argument is the primordial thread,
current thread or another thread.
The first two cases remain almost identical to the previous implementation.
To terminate a thread (which is not the caller) we use a pthread key
which contains the thread data. The destructor is set to Cyc_end_thread
and will terminate the thread when pthread_cancel is called. This ensures
that Cyc_end_thread is called with the correct thread data by the thread
which will be terminated.
* runtime: cast to the required type for pthread_key_create
* runtime: clear the thread_key before exiting the thread
* runtime: handle cancelled threads separately
We probably don't want to call pthread_exit in the destructor.
Similarly, we don't want to perform a longjmp (i.e. GC(...))
in the desctructor.
* runtime: do a minor GC for cancelled threads
The main idea is to avoid a longjmp and return to the destructor
for the cancelled thread. So, adjust GC and gc_minor to allow
for a NULL continuation.
GCC 14 has enabled various warnings as errors by default, e.g.
-Wimplicit-function-declaration. This causes the current feature
detection code for `open_memstream(3)` and `fmemopen(3)` to fail
with GCC 14.
This commit restores compatibility with GCC 14 in this regard.
Note that it may also be beneficial to pass a feature test macro
such as -D_POSIX_C_SOURCE. See the feature test macro requirements
for open_memstream(3)` and `fmemopen(3)`.
* WIP - C unit testing stubs
* Get test-lib to compile and run
* Add test-lib to CI
* Use cflags for test-lib
* Build runtime library
* Fix typo
* Break into separate CI tasks
* Cleanup
* Add example tests for non-CPS
* Include -g option for test-lib
* Add CI to build C runtime
Can expand into scheme at some point, this is a first step.
* Use latest upload workflow
Perform full scanning of function application list to ensure self-recursive calls are found. This prevents infinite loops in the beta expansion code when compiling simple recursive calls.
This change defines *ai-v4mapped* to zero when AI_V4MAPPED is undefined
and similarly for *ai-all* (similar to other patches). This allows
(srfi 106) to be available on NetBSD and other platforms without
AI_V4MAPPED and is the recommended behaviour by the author of SRFI-106:
https://srfi-email.schemers.org/srfi-106/msg/2762553/
This changes the behaviour to match r7rs (round x) instead of C round(x).
An answer to https://stackoverflow.com/questions/32746523/ieee-754-compliant-round-half-to-even
suggests using remainder(). The following will work if FE_TONEAREST is defined, but C11
requires FE_TONEAREST to be defined if and only if the implemenetation supports it in
fegetround() and fesetround() [Draft N1570]. On the other hand, remainder() must be defined.
C23 will have roundeven(), but this is not yet available on all platforms.
The behaviour of remainder is described in Draft N1570, page 254, footnote 239.
Alternative implementation:
double round_to_nearest_even(double x)
{
#pragma STDC FENV_ACCESS ON
int mode;
double nearest;
mode = fegetround();
fesetround(FE_TONEAREST);
nearest = nearbyint(x);
fesetround(mode);
#pragma STDC FENV_ACCESS OFF
return nearest;
}