|
From: kosmirror <kos...@us...> - 2025-08-24 03:59:49
|
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 a36363f0469e8f95c275338d91dca59f6563b9d4 (commit)
via 00f6b33af1a410ebbd612157a257fd3e78e22128 (commit)
via 37510ee9a62138a4d38d9e1c40182764ed7b5866 (commit)
via 04b13dba01fa7be9fa1b52ced9b1f7c6908f8d5b (commit)
via 3cdc26e1601eb4b0be90ede61eef9c74c7153429 (commit)
from b0a78dfd2bdad675028b687ba8b7f691d503a15f (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 a36363f0469e8f95c275338d91dca59f6563b9d4
Author: Paul Cercueil <pa...@cr...>
Date: Fri Aug 22 23:21:08 2025 +0200
dc-chain: Prepare gthr-kos.h for inclusion from C++
Make sure the header can be included from C++.
Signed-off-by: Paul Cercueil <pa...@cr...>
commit 00f6b33af1a410ebbd612157a257fd3e78e22128
Author: Paul Cercueil <pa...@cr...>
Date: Wed Aug 20 23:36:57 2025 +0200
Compile-test gthr-kos.h with GCC >= 15
Starting from GCC 15, the C23 standard is supported.
This is important, because this standard allows the redefinition of
types, as long as the new definition matches the type of the old
definition.
Therefore, we can compile the gthr-kos.h header with the
TEST_GTHR_KOS_API macro set, which will cause all the headers that
define the symbols used in there to be included. The effect of that, is
that all the re-defined functions and types in gthr-kos.h will be
compared vs. the original one in KOS headers, and GCC will throw an
error if any of them has a different type or prototype.
Signed-off-by: Paul Cercueil <pa...@cr...>
commit 37510ee9a62138a4d38d9e1c40182764ed7b5866
Author: Paul Cercueil <pa...@cr...>
Date: Wed Aug 20 23:34:22 2025 +0200
dc-chain: Update gthr-kos.h to drop KOS specific includes
Add the prototype of the KOS functions that are bound at the beginning
of the file, without including any of the KOS headers.
Note that irq_disable() / irq_restore() are static inline in
<arch/irq.h>, so there are no symbols that can be bound. However, I do
not see how disabling IRQs is needed there, so I just dropped the
protection.
Signed-off-by: Paul Cercueil <pa...@cr...>
commit 04b13dba01fa7be9fa1b52ced9b1f7c6908f8d5b
Author: Paul Cercueil <pa...@cr...>
Date: Wed Aug 20 23:09:23 2025 +0200
thread: Include missing header in thread.h
<kos/thread.h> was missing an <arch/types.h> include to get the tid_t
and prio_t types.
Signed-off-by: Paul Cercueil <pa...@cr...>
commit 3cdc26e1601eb4b0be90ede61eef9c74c7153429
Author: Paul Cercueil <pa...@cr...>
Date: Wed Aug 20 22:31:45 2025 +0200
Revert to using <sys/cdefs.h> for sys/ headers
The whole sys/ folder is copied inside the toolchain. Therefore it
should not be using any KOS-specific header.
Signed-off-by: Paul Cercueil <pa...@cr...>
-----------------------------------------------------------------------
Summary of changes:
include/kos/thread.h | 1 +
include/sys/_pthreadtypes.h | 2 +-
include/sys/_types.h | 2 +-
include/sys/dirent.h | 2 +-
include/sys/ioctl.h | 2 +-
include/sys/lock.h | 2 +-
include/sys/sched.h | 2 +-
include/sys/select.h | 2 +-
include/sys/socket.h | 2 +-
include/sys/stdio.h | 2 +-
include/sys/uio.h | 2 +-
include/sys/utsname.h | 2 +-
kernel/thread/Makefile | 9 ++++-
utils/dc-chain/patches/gcc/gthr-kos.h | 73 +++++++++++++++++++++++++++++++----
14 files changed, 85 insertions(+), 20 deletions(-)
diff --git a/include/kos/thread.h b/include/kos/thread.h
index 23d91f13..22a798ae 100644
--- a/include/kos/thread.h
+++ b/include/kos/thread.h
@@ -41,6 +41,7 @@ __BEGIN_DECLS
#include <kos/cdefs.h>
#include <kos/tls.h>
#include <arch/irq.h>
+#include <arch/types.h>
#include <sys/queue.h>
#include <sys/reent.h>
diff --git a/include/sys/_pthreadtypes.h b/include/sys/_pthreadtypes.h
index 2c25eaba..67d6166d 100644
--- a/include/sys/_pthreadtypes.h
+++ b/include/sys/_pthreadtypes.h
@@ -8,7 +8,7 @@
#ifndef __SYS_PTHREADTYPES_H
#define __SYS_PTHREADTYPES_H
-#include <kos/cdefs.h>
+#include <sys/cdefs.h>
__BEGIN_DECLS
typedef unsigned long int pthread_t;
diff --git a/include/sys/_types.h b/include/sys/_types.h
index 723f3704..5e7a4247 100644
--- a/include/sys/_types.h
+++ b/include/sys/_types.h
@@ -10,7 +10,7 @@
#ifndef _SYS__TYPES_H
#define _SYS__TYPES_H
-#include <kos/cdefs.h>
+#include <sys/cdefs.h>
__BEGIN_DECLS
#include <sys/lock.h>
diff --git a/include/sys/dirent.h b/include/sys/dirent.h
index 61cdbceb..92b29ff4 100644
--- a/include/sys/dirent.h
+++ b/include/sys/dirent.h
@@ -19,7 +19,7 @@
#ifndef __SYS_DIRENT_H
#define __SYS_DIRENT_H
-#include <kos/cdefs.h>
+#include <sys/cdefs.h>
__BEGIN_DECLS
diff --git a/include/sys/ioctl.h b/include/sys/ioctl.h
index 3865c71f..40acd6c2 100644
--- a/include/sys/ioctl.h
+++ b/include/sys/ioctl.h
@@ -20,7 +20,7 @@
#ifndef __SYS_IOCTL_H
#define __SYS_IOCTL_H
-#include <kos/cdefs.h>
+#include <sys/cdefs.h>
__BEGIN_DECLS
diff --git a/include/sys/lock.h b/include/sys/lock.h
index 790a9b36..66529899 100644
--- a/include/sys/lock.h
+++ b/include/sys/lock.h
@@ -19,7 +19,7 @@
#ifndef __SYS_LOCK_H__
#define __SYS_LOCK_H__
-#include <kos/cdefs.h>
+#include <sys/cdefs.h>
__BEGIN_DECLS
/** \cond */
diff --git a/include/sys/sched.h b/include/sys/sched.h
index bbd4b593..2e040f62 100644
--- a/include/sys/sched.h
+++ b/include/sys/sched.h
@@ -7,7 +7,7 @@
#ifndef __SYS_SCHED_H
#define __SYS_SCHED_H
-#include <kos/cdefs.h>
+#include <sys/cdefs.h>
__BEGIN_DECLS
// These are copied from Newlib to make stuff compile as expected.
diff --git a/include/sys/select.h b/include/sys/select.h
index 588c97da..9d12ed14 100644
--- a/include/sys/select.h
+++ b/include/sys/select.h
@@ -20,7 +20,7 @@
#ifndef __SYS_SELECT_H
#define __SYS_SELECT_H
-#include <kos/cdefs.h>
+#include <sys/cdefs.h>
#include <sys/types.h>
__BEGIN_DECLS
diff --git a/include/sys/socket.h b/include/sys/socket.h
index 1fc79a11..da174d27 100644
--- a/include/sys/socket.h
+++ b/include/sys/socket.h
@@ -21,7 +21,7 @@
#ifndef __SYS_SOCKET_H
#define __SYS_SOCKET_H
-#include <kos/cdefs.h>
+#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/uio.h>
diff --git a/include/sys/stdio.h b/include/sys/stdio.h
index c9b0a5c7..dee114a5 100644
--- a/include/sys/stdio.h
+++ b/include/sys/stdio.h
@@ -8,7 +8,7 @@
#ifndef _NEWLIB_STDIO_H
#define _NEWLIB_STDIO_H
-#include <kos/cdefs.h>
+#include <sys/cdefs.h>
__BEGIN_DECLS
// Cribbed from newlib sys/stdio.h
diff --git a/include/sys/uio.h b/include/sys/uio.h
index e7d23a94..5362c99e 100644
--- a/include/sys/uio.h
+++ b/include/sys/uio.h
@@ -19,7 +19,7 @@
#ifndef __SYS_UIO_H
#define __SYS_UIO_H
-#include <kos/cdefs.h>
+#include <sys/cdefs.h>
#include <sys/types.h>
__BEGIN_DECLS
diff --git a/include/sys/utsname.h b/include/sys/utsname.h
index 72864993..dbeb4cdc 100644
--- a/include/sys/utsname.h
+++ b/include/sys/utsname.h
@@ -19,7 +19,7 @@
#ifndef __SYS_UTSNAME_H
#define __SYS_UTSNAME_H
-#include <kos/cdefs.h>
+#include <sys/cdefs.h>
__BEGIN_DECLS
diff --git a/kernel/thread/Makefile b/kernel/thread/Makefile
index 51966bd5..f1fa5a65 100644
--- a/kernel/thread/Makefile
+++ b/kernel/thread/Makefile
@@ -9,7 +9,12 @@ OBJS += thread.o rwsem.o once.o tls.o barrier.o
OBJS += oneshot_timer.o worker.o
SUBDIRS =
-include $(KOS_BASE)/Makefile.prefab
-
+# On toolchains that support the C23 standard (aka. GCC > 14), compile-test
+# our gthr-kos.h against the regular KOS includes, to make sure that the
+# toolchain file does not lag behind.
+OBJS += $(intcmp $(firstword $(subst ., ,${KOS_GCCVER})),14,,,toolchain_test.o)
+include $(KOS_BASE)/Makefile.prefab
+toolchain_test.o: ${KOS_BASE}/utils/dc-chain/patches/gcc/gthr-kos.h
+ kos-cc -DTEST_GTHR_KOS_API -std=c23 -c $< -o $@
diff --git a/utils/dc-chain/patches/gcc/gthr-kos.h b/utils/dc-chain/patches/gcc/gthr-kos.h
index e71cb923..8a383ac1 100644
--- a/utils/dc-chain/patches/gcc/gthr-kos.h
+++ b/utils/dc-chain/patches/gcc/gthr-kos.h
@@ -31,22 +31,76 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#ifndef GCC_GTHR_KOS_H
#define GCC_GTHR_KOS_H
+#include <sys/cdefs.h>
+__BEGIN_DECLS
+
/* KallistiOS threads specific definitions. */
#define __GTHREADS 1
#define __GTHREADS_CXX0X 1
#define __GTHREAD_HAS_COND 1
+#ifdef TEST_GTHR_KOS_API
#include <kos/thread.h>
#include <kos/tls.h>
#include <kos/mutex.h>
#include <kos/once.h>
#include <kos/cond.h>
#include <arch/irq.h>
-#include <time.h>
+#endif
/* 9.5.0 somehow requires this. Remove when no longer supported */
#include <pthread.h>
+#include <stdbool.h>
+#include <time.h>
+
+/* KOS types */
+struct kthread;
+
+typedef struct kthread kthread_t;
+
+typedef int kthread_key_t;
+typedef volatile int kthread_once_t;
+
+/* mutex_t / condvar_t need to be defined explicitly as we need to be able to
+ * sizeof() them */
+typedef struct kos_mutex {
+ unsigned int type;
+ kthread_t *holder;
+ int count;
+} mutex_t;
+
+typedef struct condvar {
+ int dummy;
+} condvar_t;
+
+kthread_t *thd_create(bool detach, void *(*routine)(void *param), void *param);
+void thd_pass(void);
+void thd_exit(void *rv) __noreturn;
+int thd_join(kthread_t *thd, void **value_ptr);
+int thd_detach(kthread_t *thd);
+kthread_t *thd_get_current(void);
+int kthread_setspecific(int key, const void *value);
+void *kthread_getspecific(int key);
+
+int kthread_once(volatile int *once_control, void (*init_routine)(void));
+int kthread_key_create(int *key, void (*destructor)(void *));
+int kthread_key_delete(int key);
+
+int mutex_init(mutex_t *m, unsigned int mtype) __nonnull_all;
+int __pure mutex_is_locked(const mutex_t *m) __nonnull_all;
+int mutex_lock(mutex_t *m) __nonnull_all;
+int mutex_trylock(mutex_t *m) __nonnull_all;
+int mutex_lock_timed(mutex_t *m, int timeout) __nonnull_all;
+int mutex_unlock(mutex_t *m) __nonnull_all;
+int mutex_destroy(mutex_t *m) __nonnull_all;
+
+int cond_init(condvar_t *cv) __nonnull_all;
+int cond_destroy(condvar_t *cv) __nonnull_all;
+int cond_wait(condvar_t *cv, mutex_t * m) __nonnull_all;
+int cond_wait_timed(condvar_t *cv, mutex_t *m, int timeout) __nonnull_all;
+int cond_broadcast(condvar_t *cv) __nonnull_all;
+int cond_signal(condvar_t *cv) __nonnull_all;
/* These should work just fine. */
typedef kthread_key_t __gthread_key_t;
@@ -57,6 +111,15 @@ typedef condvar_t __gthread_cond_t;
typedef kthread_t *__gthread_t;
typedef struct timespec __gthread_time_t;
+#define KTHREAD_ONCE_INIT 0
+
+#define MUTEX_TYPE_NORMAL 0
+#define MUTEX_TYPE_RECURSIVE 3
+
+#define MUTEX_INITIALIZER { MUTEX_TYPE_NORMAL, NULL, 0 }
+#define RECURSIVE_MUTEX_INITIALIZER { MUTEX_TYPE_RECURSIVE, NULL, 0 }
+#define COND_INITIALIZER { 0 }
+
#define __GTHREAD_ONCE_INIT KTHREAD_ONCE_INIT
#define __GTHREAD_MUTEX_INIT MUTEX_INITIALIZER
#define __GTHREAD_RECURSIVE_MUTEX_INIT RECURSIVE_MUTEX_INITIALIZER
@@ -176,19 +239,14 @@ static inline int __gthread_objc_mutex_allocate(objc_mutex_t mutex) {
/* Deallocate a mutex. */
static inline int __gthread_objc_mutex_deallocate(objc_mutex_t mutex) {
mutex_t *m = (mutex_t *)mutex->backend;
- uint32 old;
- old = irq_disable();
-
- while(mutex_is_locked(m)) {
+ if(mutex_is_locked(m))
mutex_unlock(m);
- }
if(mutex_destroy(m))
return -1;
mutex->backend = NULL;
- irq_restore(old);
objc_free(m);
@@ -403,5 +461,6 @@ static inline int __gthread_cond_destroy(__gthread_cond_t *cond) {
#endif /* !_LIBOBJC */
+__END_DECLS
#endif /* ! GCC_GTHR_KOS_H */
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|