|
From: kosmirror <kos...@us...> - 2025-09-05 19:22:55
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "A pseudo Operating System for the Dreamcast.".
The branch, master has been updated
via a337be07e09bd884d224d39b0b4c7034ac681b97 (commit)
via afbd2ca8687d9d2d0d54eb7af0aec2f42b593e92 (commit)
via 96836a655e65739e3a0ae594f57ff371ef284530 (commit)
via 3f407f7982e29fcddf7e5e1a5e3876a3de585e21 (commit)
via 8186790920ee0c6d39ece114fdf2588ca6e8f770 (commit)
via 1a934355e0002f51a8600099c3b8f73c5ef0e532 (commit)
via 8be032ef211aa8993e3748f96f9cf7b8b4491138 (commit)
via a34e545bd0337970cc61a5eaae74dac608639450 (commit)
from d77b00786bec441e4e08dfadbc2fa1b46ff086af (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit a337be07e09bd884d224d39b0b4c7034ac681b97
Author: QuzarDC <qu...@co...>
Date: Wed Aug 6 14:44:26 2025 -0400
Remove patches for newlib < 4.
The only newlib patch left after this is in `newlib_getentropy`
which tests for functionality added in the newest minor version
4.4.0, so it seems to make sense to keep that. The rest simply
aren't needed/supported anymore.
commit afbd2ca8687d9d2d0d54eb7af0aec2f42b593e92
Author: QuzarDC <qu...@co...>
Date: Wed Aug 6 14:29:10 2025 -0400
cdefs: Replace `__no_inline` with newlib equivalent.
commit 96836a655e65739e3a0ae594f57ff371ef284530
Author: QuzarDC <qu...@co...>
Date: Wed Aug 6 14:22:31 2025 -0400
cdefs: Replace `__{un}likely()` with newlib equivalent
Newlib already provides wrappers for gcc's `__builtin_expect`.
Additionally minor whitespace cleanups.
commit 3f407f7982e29fcddf7e5e1a5e3876a3de585e21
Author: QuzarDC <qu...@co...>
Date: Wed Aug 6 14:14:25 2025 -0400
cdefs: Replace `__weak` with newlib equivalent.
Newlib is already providing a define to wrap the attribute
weak, which is `__weak_symbol`.
commit 8186790920ee0c6d39ece114fdf2588ca6e8f770
Author: QuzarDC <qu...@co...>
Date: Wed Aug 6 14:08:56 2025 -0400
cdefs: Remove duplicated cdefs.
As with previous ones that have been removed, each of these
were already being provided by newlib. We don't have a path
to function without `<sys/cdefs.h>` anyways.
While there, added myself to the header as I've made so many
changes to it.
commit 1a934355e0002f51a8600099c3b8f73c5ef0e532
Author: QuzarDC <qu...@co...>
Date: Wed Aug 6 13:03:26 2025 -0400
cdefs: Increase minimum GCC version to reflect current standard.
commit 8be032ef211aa8993e3748f96f9cf7b8b4491138
Author: QuzarDC <qu...@co...>
Date: Wed Aug 6 12:52:47 2025 -0400
cdefs: Remove broken functionality checks.
I had cargo-culted these checks out of a source that
was presuming the use of autotools that would provide
the defines. `__builtin_types_compatible_p` and `typeof`
have been available in GCC since at least v4.9.4, so we
shouldn't need to verify that we have the extensions.
commit a34e545bd0337970cc61a5eaae74dac608639450
Author: QuzarDC <qu...@co...>
Date: Wed Aug 6 11:19:35 2025 -0400
dc/fmath: Remove custom `static inline` wrapper.
We already have protection for these cases via cdefs,
and don't perform this same kind of older wrapping for
any other static inline functions we provide.
-----------------------------------------------------------------------
Summary of changes:
include/kos/cdefs.h | 97 +-------------------------------
include/kos/init_base.h | 2 +-
include/sys/_types.h | 8 +--
include/sys/select.h | 6 --
kernel/arch/dreamcast/hardware/sq.c | 2 +-
kernel/arch/dreamcast/include/dc/fmath.h | 37 +++++-------
kernel/arch/dreamcast/kernel/init.c | 4 +-
kernel/arch/dreamcast/kernel/perfctr.c | 16 +++---
kernel/arch/dreamcast/kernel/timer.c | 20 +++----
kernel/fs/fs_random.c | 10 ----
10 files changed, 39 insertions(+), 163 deletions(-)
diff --git a/include/kos/cdefs.h b/include/kos/cdefs.h
index 87ddcaa2..055118e8 100644
--- a/include/kos/cdefs.h
+++ b/include/kos/cdefs.h
@@ -4,6 +4,7 @@
Copyright (C) 2002, 2004 Megan Potter
Copyright (C) 2020, 2023 Lawrence Sebald
Copyright (C) 2023 Falco Girgis
+ Copyright (C) 2024, 2025 Donald Haase
Based loosely around some stuff in BSD's sys/cdefs.h
*/
@@ -19,6 +20,7 @@
\author Megan Potter
\author Lawrence Sebald
\author Falco Girgis
+ \author Donald Haase
*/
#ifndef __KOS_CDEFS_H
@@ -27,7 +29,7 @@
#include <sys/cdefs.h>
/* Check GCC version */
-#if __GNUC__ <= 3
+#if __GNUC__ < 9
# warning Your GCC is too old. This will probably not work right.
#endif
@@ -47,57 +49,6 @@
#define __noreturn __attribute__((__noreturn__))
#endif
-#ifndef __unused
-/** \brief Identify a function or variable that may be unused. */
-#define __unused __attribute__((__unused__))
-#endif
-
-#ifndef __used
-/** \brief Prevent a symbol from being removed from the binary. */
-#define __used __attribute__((used))
-#endif
-
-#ifndef __weak
-/** \brief Identify a function or variable that may be overridden by another symbol. */
-#define __weak __attribute__((weak))
-#endif
-
-#ifndef __packed
-/** \brief Force a structure, enum, or other type to be packed as small as possible. */
-#define __packed __attribute__((packed))
-#endif
-
-#ifndef __dead2
-/** \brief Alias for \ref __noreturn. For BSD compatibility. */
-#define __dead2 __noreturn /* BSD compat */
-#endif
-
-#ifndef __likely
-/** \brief Directive to inform the compiler the condition is in the likely path.
-
- This can be used around conditionals or loops to help inform the
- compiler which path to optimize for as the common-case.
-
- \param exp Boolean expression which expected to be true.
-
- \sa __unlikely()
-*/
-#define __likely(exp) __builtin_expect(!!(exp), 1)
-#endif
-
-#ifndef __unlikely
-/** \brief Directive to inform the compiler the condition is in the unlikely path.
-
- This can be used around conditionals or loops to help inform the
- compiler which path to optimize against as the infrequent-case.
-
- \param exp Boolean expression which is expected to be false.
-
- \sa __likely()
-*/
-#define __unlikely(exp) __builtin_expect(!!(exp), 0)
-#endif
-
#ifndef __deprecated
/** \brief Mark something as deprecated.
This should be used to warn users that a function/type/etc will be removed
@@ -115,33 +66,6 @@
#define __depr(m) __attribute__((deprecated(m)))
#endif
-/* Printf/Scanf-like declaration */
-#ifndef __printflike
-/** \brief Identify a function as accepting formatting like printf().
-
- Using this macro allows GCC to typecheck calls to printf-like functions,
- which can aid in finding mistakes.
-
- \param fmtarg The argument number (1-based) of the format string.
- \param firstvararg The argument number of the first vararg (the ...).
-*/
-#define __printflike(fmtarg, firstvararg) \
- __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
-#endif
-
-#ifndef __scanflike
-/** \brief Identify a function as accepting formatting like scanf().
-
- Using this macro allows GCC to typecheck calls to scanf-like functions,
- which can aid in finding mistakes.
-
- \param fmtarg The argument number (1-based) of the format string.
- \param firstvararg The argument number of the first vararg (the ...).
-*/
-#define __scanflike(fmtarg, firstvararg) \
- __attribute__((__format__ (__scanf__, fmtarg, firstvararg)))
-#endif
-
#if __GNUC__ >= 7
/** \brief Identify a case statement that is expected to fall through to the
statement underneath it. */
@@ -150,16 +74,6 @@
#define __fallthrough /* Fall through */
#endif
-#ifndef __always_inline
-/** \brief Ask the compiler to \a always inline a given function. */
-#define __always_inline inline __attribute__((__always_inline__))
-#endif
-
-#ifndef __no_inline
-/** \brief Ask the compiler to \a never inline a given function. */
-#define __no_inline __attribute__((__noinline__))
-#endif
-
/** @} */
/** \defgroup system_compat Language Compatibility Defines
@@ -255,16 +169,11 @@
*/
#define __array_size(arr) (sizeof(arr) / sizeof((arr)[0]) + _array_size_chk(arr))
-/* Helper for __array_size's type check */
-#if HAVE_BUILTIN_TYPES_COMPATIBLE_P && HAVE_TYPEOF
/* Two gcc extensions.
* &a[0] degrades to a pointer: a different type from an array */
#define _array_size_chk(arr) \
__build_assert_or_zero(!__builtin_types_compatible_p(typeof(arr), \
typeof(&(arr)[0])))
-#else
-#define _array_size_chk(arr) 0
-#endif
/** \brief Create a string from the argument.
diff --git a/include/kos/init_base.h b/include/kos/init_base.h
index 0ae35d2b..662535bc 100644
--- a/include/kos/init_base.h
+++ b/include/kos/init_base.h
@@ -30,7 +30,7 @@ __BEGIN_DECLS
/* Declares a weak function pointer which can be optionally
overridden and given a value later. */
#define KOS_INIT_FLAG_WEAK(func, dft_on) \
- void (*func##_weak)(void) __weak = (dft_on) ? func : NULL
+ void (*func##_weak)(void) __weak_symbol = (dft_on) ? func : NULL
/* Invokes the given function if its weak function pointer
has been overridden to point to a valid function. */
diff --git a/include/sys/_types.h b/include/sys/_types.h
index 5e7a4247..0be7feae 100644
--- a/include/sys/_types.h
+++ b/include/sys/_types.h
@@ -137,13 +137,7 @@ typedef unsigned long __mode_t;
typedef unsigned short __nlink_t;
typedef long __suseconds_t; /* microseconds (signed) */
typedef unsigned long __useconds_t; /* microseconds (unsigned) */
-
-#if __NEWLIB__ >= 3
-#define _TIME_T_ long long
-#else
-#define _TIME_T_ long
-#endif
-typedef _TIME_T_ __time_t;
+typedef long long __time_t;
#ifndef __clockid_t_defined
#define _CLOCKID_T_ unsigned long
diff --git a/include/sys/select.h b/include/sys/select.h
index 9d12ed14..e2d94561 100644
--- a/include/sys/select.h
+++ b/include/sys/select.h
@@ -27,13 +27,7 @@ __BEGIN_DECLS
#include <newlib.h>
#include <kos/opts.h>
-
-#if __NEWLIB__ > 2 || (__NEWLIB__ == 2 && __NEWLIB_MINOR__ > 2)
#include <sys/_timeval.h>
-#else
-#include <time.h>
-#include <sys/time.h>
-#endif
/* Newlib used to define fd_set and friends in <sys/types.h>, but at some point
that stopped being the case... This should tell us whether we need to define
diff --git a/kernel/arch/dreamcast/hardware/sq.c b/kernel/arch/dreamcast/hardware/sq.c
index 8fac7c6c..51bbfa70 100644
--- a/kernel/arch/dreamcast/hardware/sq.c
+++ b/kernel/arch/dreamcast/hardware/sq.c
@@ -121,7 +121,7 @@ void sq_wait(void) {
}
/* Copies n bytes from src to dest, dest must be 32-byte aligned */
-__no_inline void *sq_cpy(void *dest, const void *src, size_t n) {
+__noinline void *sq_cpy(void *dest, const void *src, size_t n) {
const uint32_t *s = src;
void *curr_dest = dest;
uint32_t *d;
diff --git a/kernel/arch/dreamcast/include/dc/fmath.h b/kernel/arch/dreamcast/include/dc/fmath.h
index b61aa967..febe1881 100644
--- a/kernel/arch/dreamcast/include/dc/fmath.h
+++ b/kernel/arch/dreamcast/include/dc/fmath.h
@@ -31,22 +31,11 @@ __BEGIN_DECLS
@{
*/
-/* Sigh... C99 treats inline stuff a lot differently than traditional GCC did,
- so we need to take care of that... */
-#if __STDC_VERSION__ >= 199901L
-#define __FMINLINE static inline
-#elif __GNUC__
-#define __FMINLINE extern inline
-#else
-/* Uhm... I guess this is the best we can do? */
-#define __FMINLINE static
-#endif
-
/**
\brief Floating point inner product.
\return v1 dot v2 (inner product)
*/
-__FMINLINE float __pure fipr(float x, float y, float z, float w,
+static inline float __pure fipr(float x, float y, float z, float w,
float a, float b, float c, float d) {
return __fipr(x, y, z, w, a, b, c, d);
}
@@ -55,7 +44,7 @@ __FMINLINE float __pure fipr(float x, float y, float z, float w,
\brief Floating point inner product w/self (square of vector magnitude)
\return v1 dot v1 (square of magnitude)
*/
-__FMINLINE float __pure fipr_magnitude_sqr(float x, float y, float z, float w) {
+static inline float __pure fipr_magnitude_sqr(float x, float y, float z, float w) {
return __fipr_magnitude_sqr(x, y, z, w);
}
@@ -64,7 +53,7 @@ __FMINLINE float __pure fipr_magnitude_sqr(float x, float y, float z, float w) {
\param r a floating point number between 0 and 2*PI
\return sin(r), where r is [0..2*PI]
*/
-__FMINLINE float __pure fsin(float r) {
+static inline float __pure fsin(float r) {
return __fsin(r);
}
@@ -73,7 +62,7 @@ __FMINLINE float __pure fsin(float r) {
\param r a floating point number between 0 and 2*PI
\return cos(r), where r is [0..2*PI]
*/
-__FMINLINE __pure float fcos(float r) {
+static inline __pure float fcos(float r) {
return __fcos(r);
}
@@ -82,7 +71,7 @@ __FMINLINE __pure float fcos(float r) {
\param r a floating point number between 0 and 2*PI
\return tan(r), where r is [0..2*PI]
*/
-__FMINLINE __pure float ftan(float r) {
+static inline __pure float ftan(float r) {
return __ftan(r);
}
@@ -91,7 +80,7 @@ __FMINLINE __pure float ftan(float r) {
\param d an integer between 0 and 65535
\return sin(d), where d is [0..65535]
*/
-__FMINLINE __pure float fisin(int d) {
+static inline __pure float fisin(int d) {
return __fisin(d);
}
@@ -100,7 +89,7 @@ __FMINLINE __pure float fisin(int d) {
\param d an integer between 0 and 65535
\return cos(d), where d is [0..65535]
*/
-__FMINLINE __pure float ficos(int d) {
+static inline __pure float ficos(int d) {
return __ficos(d);
}
@@ -109,7 +98,7 @@ __FMINLINE __pure float ficos(int d) {
\param d an integer between 0 and 65535
\return tan(d), where d is [0..65535]
*/
-__FMINLINE float __pure fitan(int d) {
+static inline float __pure fitan(int d) {
return __fitan(d);
}
@@ -117,14 +106,14 @@ __FMINLINE float __pure fitan(int d) {
\brief Floating point square root
\return sqrt(f)
*/
-__FMINLINE float __pure fsqrt(float f) {
+static inline float __pure fsqrt(float f) {
return __fsqrt(f);
}
/**
\return 1.0f / sqrt(f)
*/
-__FMINLINE float __pure frsqrt(float f) {
+static inline float __pure frsqrt(float f) {
return __frsqrt(f);
}
@@ -137,7 +126,7 @@ __FMINLINE float __pure frsqrt(float f) {
\param s Storage for the returned sine value.
\param c Storage for the returned cosine value.
*/
-__FMINLINE void fsincos(float f, float *s, float *c) {
+static inline void fsincos(float f, float *s, float *c) {
__fsincos(f, *s, *c);
}
@@ -150,7 +139,7 @@ __FMINLINE void fsincos(float f, float *s, float *c) {
\param s Storage for the returned sine value.
\param c Storage for the returned cosine value.
*/
-__FMINLINE void fsincosr(float f, float *s, float *c) {
+static inline void fsincosr(float f, float *s, float *c) {
__fsincosr(f, *s, *c);
}
@@ -178,7 +167,7 @@ __FMINLINE void fsincosr(float f, float *s, float *c) {
\note Thanks to Fredrik Ehnbom for figuring this stuff out and posting it
to the mailing list back in 2005!
*/
-__FMINLINE uint32_t __pure pvr_pack_bump(float h, float t, float q) {
+static inline uint32_t __pure pvr_pack_bump(float h, float t, float q) {
uint8_t hp = (uint8_t)(h * 255.0f);
uint8_t k1 = ~hp;
uint8_t k2 = (uint8_t)(hp * __fsin(t));
diff --git a/kernel/arch/dreamcast/kernel/init.c b/kernel/arch/dreamcast/kernel/init.c
index d80385a4..af5a99ec 100644
--- a/kernel/arch/dreamcast/kernel/init.c
+++ b/kernel/arch/dreamcast/kernel/init.c
@@ -154,7 +154,7 @@ KOS_INIT_FLAG_WEAK(library_shutdown, true);
/* Auto-init stuff: override with a non-weak symbol if you don't want all of
this to be linked into your code (and do the same with the
arch_auto_shutdown function too). */
-int __weak arch_auto_init(void) {
+int __weak_symbol arch_auto_init(void) {
/* Initialize memory management */
mm_init();
@@ -235,7 +235,7 @@ int __weak arch_auto_init(void) {
return 0;
}
-void __weak arch_auto_shutdown(void) {
+void __weak_symbol arch_auto_shutdown(void) {
KOS_INIT_FLAG_CALL(fs_dclsocket_shutdown);
if (!KOS_PLATFORM_IS_NAOMI)
KOS_INIT_FLAG_CALL(net_shutdown);
diff --git a/kernel/arch/dreamcast/kernel/perfctr.c b/kernel/arch/dreamcast/kernel/perfctr.c
index c97d6eee..b253d107 100644
--- a/kernel/arch/dreamcast/kernel/perfctr.c
+++ b/kernel/arch/dreamcast/kernel/perfctr.c
@@ -29,7 +29,7 @@
#define NS_PER_CYCLE 5
/* Get a counter's current configuration. */
-bool perf_cntr_config(perf_cntr_t counter,
+bool perf_cntr_config(perf_cntr_t counter,
perf_cntr_event_t *event,
perf_cntr_clock_t *clock) {
@@ -42,14 +42,14 @@ bool perf_cntr_config(perf_cntr_t counter,
}
/* Start a performance counter. */
-void perf_cntr_start(perf_cntr_t counter,
- perf_cntr_event_t event,
+void perf_cntr_start(perf_cntr_t counter,
+ perf_cntr_event_t event,
perf_cntr_clock_t clock) {
-
+
perf_cntr_clear(counter);
- PMCR_CTRL(counter) = PMCR_RUN |
- (clock << PMCR_PMCLK_SHIFT) |
+ PMCR_CTRL(counter) = PMCR_RUN |
+ (clock << PMCR_PMCLK_SHIFT) |
event;
}
@@ -81,7 +81,7 @@ uint64_t perf_cntr_count(perf_cntr_t counter) {
hi = PMCTR_HIGH(counter);
lo = PMCTR_LOW(counter);
hi2 = PMCTR_HIGH(counter);
- } while(__unlikely(hi != hi2));
+ } while (__predict_false(hi != hi2));
return (uint64_t)hi << 32 | lo;
}
@@ -90,7 +90,7 @@ void perf_cntr_timer_enable(void) {
perf_cntr_start(PRFC0, PMCR_ELAPSED_TIME_MODE, PMCR_COUNT_CPU_CYCLES);
}
-bool perf_cntr_timer_enabled(void) {
+bool perf_cntr_timer_enabled(void) {
perf_cntr_event_t event;
perf_cntr_clock_t clock;
diff --git a/kernel/arch/dreamcast/kernel/timer.c b/kernel/arch/dreamcast/kernel/timer.c
index b1cfc7df..d8a5fef6 100644
--- a/kernel/arch/dreamcast/kernel/timer.c
+++ b/kernel/arch/dreamcast/kernel/timer.c
@@ -20,7 +20,7 @@
#define TIMER32(o) ( *((volatile uint32_t *)(TIMER_BASE + (o))) )
/* Register base address */
-#define TIMER_BASE 0xffd80000
+#define TIMER_BASE 0xffd80000
/* Register offsets */
#define TOCR 0x00 /* Timer Output Control Register */
@@ -53,7 +53,7 @@
#define TDIV(div) (4 << (2 * div))
/* Timer Prescalar TPSC values (Peripheral clock divided by N) */
-typedef enum PCK_DIV {
+typedef enum PCK_DIV {
PCK_DIV_4, /* Pck/4 => 80ns */
PCK_DIV_16, /* Pck/16 => 320ns*/
PCK_DIV_64, /* Pck/64 => 1280ns*/
@@ -77,11 +77,11 @@ static const unsigned tcnts[] = { TCNT0, TCNT1, TCNT2 };
static const unsigned tcrs[] = { TCR0, TCR1, TCR2 };
/* Apply timer configuration to registers. */
-static int timer_prime_apply(int which, uint32_t count, int interrupts) {
+static int timer_prime_apply(int which, uint32_t count, int interrupts) {
assert(which <= TMU2);
TIMER32(tcnts[which]) = count;
- TIMER32(tcors[which]) = count;
+ TIMER32(tcors[which]) = count;
TIMER16(tcrs[which]) = TIMER_TPSC;
@@ -207,9 +207,9 @@ int timer_ints_enabled(int which) {
}
/* Seconds elapsed (since KOS startup), updated from the TMU2 underflow ISR */
-static volatile uint32_t timer_ms_counter = 0;
+static volatile uint32_t timer_ms_counter = 0;
/* Max counter value (used as TMU2 reload), to target a 1 second interval */
-static uint32_t timer_ms_countdown;
+static uint32_t timer_ms_countdown;
/* TMU2 interrupt handler, called every second. Simply updates our
running second counter and clears the underflow flag. */
@@ -249,7 +249,7 @@ typedef struct timer_value {
static timer_val_t timer_getticks(const uint32_t *tns, uint32_t shift) {
uint32_t secs, unf1, unf2, counter1, counter2, delta, ticks;
uint16_t tmu2;
-
+
do {
/* Read the underflow flag twice, and the counter twice.
- If both flags are set, it's just unrealistic that one
@@ -278,7 +278,7 @@ static timer_val_t timer_getticks(const uint32_t *tns, uint32_t shift) {
counter2 = TIMER32(tcnts[TMU2]);
tmu2 = TIMER16(tcrs[TMU2]);
unf2 = !!(tmu2 & UNF);
- } while(__unlikely(unf1 != unf2 || counter1 < counter2));
+ } while(__predict_false(unf1 != unf2 || counter1 < counter2));
delta = timer_ms_countdown - counter2;
@@ -371,7 +371,7 @@ static void tp_handler(irq_t src, irq_context_t *cxt, void *data) {
/* Call the callback, if any */
if(tp_callback)
tp_callback(cxt);
- }
+ }
/* Do we have less than a second remaining? */
else if(tp_ms_remaining < 1000) {
...<truncated>...
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|