@@ -33,7 +33,7 @@ index 4111724e1..0e44d885e 100644
3333 AS=${AS-as}
3434diff --git a/libgloss/libsysbase/Makefile.in b/libgloss/libsysbase/Makefile.in
3535new file mode 100644
36- index 000000000..7ee40deec
36+ index 000000000..edb10d215
3737--- /dev/null
3838+++ b/libgloss/libsysbase/Makefile.in
3939@@ -0,0 +1,148 @@
@@ -108,8 +108,8 @@ index 000000000..7ee40deec
108108+ isatty.o kill.o link.o lseek.o lstat.o nanosleep.o open.o read.o sbrk.o sleep.o stat.o usleep.o times.o \
109109+ unlink.o wait.o write.o _exit.o malloc_vars.o \
110110+ chdir.o mkdir.o rename.o build_argv.o statvfs.o \
111- + flock.o syscall_support.o handle_manager.o truncate.o ftruncate.o dirent.o fsync.o \
112- + fchmod.o chmod.o getreent.o rmdir.o utime.o scandir.o
111+ + flock.o handle_manager.o truncate.o ftruncate.o dirent.o fsync.o \
112+ + fchmod.o chmod.o getreent.o rmdir.o utime.o scandir.o syscall_support.o
113113+
114114+ # Object files specific to particular targets.
115115+ EVALOBJS = ${OBJS}
@@ -130,10 +130,10 @@ index 000000000..7ee40deec
130130+ AR_FLAGS = qc
131131+
132132+ .c.o:
133- + $(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $<
133+ + $(CC) $(CFLAGS_FOR_TARGET) -D_BUILDING_LIBSYSBASE - O2 $(INCLUDES) -c $(CFLAGS) $<
134134+
135135+ .C.o:
136- + $(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $<
136+ + $(CC) $(CFLAGS_FOR_TARGET) -O2 -D_BUILDING_LIBSYSBASE $(INCLUDES) -c $(CFLAGS) $<
137137+ .s.o:
138138+ $(AS) $(ASFLAGS_FOR_TARGET) $(INCLUDES) $(ASFLAGS) -o $*.o $<
139139+
@@ -187,7 +187,7 @@ index 000000000..7ee40deec
187187+ $(SHELL) config.status --recheck
188188diff --git a/libgloss/libsysbase/_exit.c b/libgloss/libsysbase/_exit.c
189189new file mode 100644
190- index 000000000..e5cb5a9ed
190+ index 000000000..6effb1105
191191--- /dev/null
192192+++ b/libgloss/libsysbase/_exit.c
193193@@ -0,0 +1,17 @@
@@ -202,8 +202,8 @@ index 000000000..e5cb5a9ed
202202+ void _exit(int rc)
203203+ {
204204+
205- + if ( __syscalls. exit ) {
206- + __syscalls.exit (rc);
205+ + if ( __has_syscall( exit) ) {
206+ + __syscall_exit (rc);
207207+ }
208208+
209209+ while(1);
@@ -889,7 +889,7 @@ index 000000000..3668b5801
889889+
890890diff --git a/libgloss/libsysbase/clocks.c b/libgloss/libsysbase/clocks.c
891891new file mode 100644
892- index 000000000..01cfee469
892+ index 000000000..b36b5c079
893893--- /dev/null
894894+++ b/libgloss/libsysbase/clocks.c
895895@@ -0,0 +1,34 @@
@@ -899,8 +899,8 @@ index 000000000..01cfee469
899899+
900900+ int clock_gettime(clockid_t clock_id, struct timespec *tp)
901901+ {
902- + if ( __syscalls. clock_gettime ) {
903- + return __syscalls.clock_gettime (clock_id, tp);
902+ + if ( __has_syscall( clock_gettime) ) {
903+ + return __syscall_clock_gettime (clock_id, tp);
904904+ } else {
905905+ errno = ENOSYS;
906906+ return -1;
@@ -909,8 +909,8 @@ index 000000000..01cfee469
909909+
910910+ int clock_settime(clockid_t clock_id, const struct timespec *tp)
911911+ {
912- + if ( __syscalls. clock_settime ) {
913- + return __syscalls.clock_settime (clock_id, tp);
912+ + if ( __has_syscall( clock_settime) ) {
913+ + return __syscall_clock_settime (clock_id, tp);
914914+ } else {
915915+ errno = ENOSYS;
916916+ return -1;
@@ -919,8 +919,8 @@ index 000000000..01cfee469
919919+
920920+ int clock_getres (clockid_t clock_id, struct timespec *res)
921921+ {
922- + if ( __syscalls. clock_getres ) {
923- + return __syscalls.clock_getres (clock_id, res);
922+ + if ( __has_syscall( clock_getres) ) {
923+ + return __syscall_clock_getres (clock_id, res);
924924+ } else {
925925+ errno = ENOSYS;
926926+ return -1;
@@ -5884,7 +5884,7 @@ index 000000000..fdce14b5f
58845884+
58855885diff --git a/libgloss/libsysbase/getreent.c b/libgloss/libsysbase/getreent.c
58865886new file mode 100644
5887- index 000000000..028d0eb77
5887+ index 000000000..a3f1e98a9
58885888--- /dev/null
58895889+++ b/libgloss/libsysbase/getreent.c
58905890@@ -0,0 +1,20 @@
@@ -5900,8 +5900,8 @@ index 000000000..028d0eb77
59005900+ #endif
59015901+
59025902+ struct _reent *__getreent() {
5903- + if ( __syscalls. getreent ) {
5904- + return __syscalls.getreent ();
5903+ + if ( __has_syscall( getreent) ) {
5904+ + return __syscall_getreent ();
59055905+ } else {
59065906+ return _impure_ptr;
59075907+ }
@@ -5910,7 +5910,7 @@ index 000000000..028d0eb77
59105910+
59115911diff --git a/libgloss/libsysbase/gettod.c b/libgloss/libsysbase/gettod.c
59125912new file mode 100644
5913- index 000000000..9d5b74724
5913+ index 000000000..4f2211248
59145914--- /dev/null
59155915+++ b/libgloss/libsysbase/gettod.c
59165916@@ -0,0 +1,33 @@
@@ -5940,7 +5940,7 @@ index 000000000..9d5b74724
59405940+ struct _reent *ptr = _REENT;
59415941+ #endif
59425942+
5943- + if ( __syscalls. gettod_r ) return __syscalls.gettod_r (ptr, ptimeval, ptimezone);
5943+ + if ( __has_syscall( gettod_r) ) return __syscall_gettod_r (ptr, ptimeval, ptimezone);
59445944+
59455945+ ptr->_errno = ENOSYS;
59465946+ return -1;
@@ -6540,7 +6540,7 @@ index 000000000..b4fcbd3d7
65406540+ }
65416541diff --git a/libgloss/libsysbase/nanosleep.c b/libgloss/libsysbase/nanosleep.c
65426542new file mode 100644
6543- index 000000000..3c96fc61b
6543+ index 000000000..a233b9df6
65446544--- /dev/null
65456545+++ b/libgloss/libsysbase/nanosleep.c
65466546@@ -0,0 +1,14 @@
@@ -6550,8 +6550,8 @@ index 000000000..3c96fc61b
65506550+
65516551+ int nanosleep(const struct timespec *req, struct timespec *rem)
65526552+ {
6553- + if ( __syscalls. nanosleep ) {
6554- + return __syscalls.nanosleep (req, rem);
6553+ + if ( __has_syscall( nanosleep) ) {
6554+ + return __syscall_nanosleep (req, rem);
65556555+ } else {
65566556+ *rem = *req;
65576557+ errno = ENOSYS;
@@ -6979,113 +6979,88 @@ index 000000000..84e221340
69796979+ }
69806980diff --git a/libgloss/libsysbase/syscall_support.c b/libgloss/libsysbase/syscall_support.c
69816981new file mode 100644
6982- index 000000000..53fead72a
6982+ index 000000000..9bb71aa0d
69836983--- /dev/null
69846984+++ b/libgloss/libsysbase/syscall_support.c
6985- @@ -0,0 +1,103 @@
6985+ @@ -0,0 +1,78 @@
69866986+ #include <sys/iosupport.h>
69876987+
6988- + //---------------------------------------------------------------------------------
6989- + __syscalls_t __syscalls = {
6990- + //---------------------------------------------------------------------------------
6991- + NULL, // sbrk
6992- + NULL, // exit
6993- + NULL, // gettod_r
6994- + NULL, // lock_init
6995- + NULL, // lock_acquire
6996- + NULL, // lock_try_acquire
6997- + NULL, // lock_release
6998- + NULL, // lock_close
6999- + NULL, // lock_init_recursive
7000- + NULL, // lock_acquire_recursive
7001- + NULL, // lock_try_acquire_recursive
7002- + NULL, // lock_release_recursive
7003- + NULL, // lock_close_recursive
7004- + NULL, // __getreent
7005- + NULL, // clock_gettime
7006- + NULL, // clock_settime
7007- + NULL, // clock_getres
7008- + NULL, // nanosleep
7009- + };
7010- +
70116988+ void __libc_lock_init(_LOCK_T *lock) {
70126989+
7013- + if ( __syscalls. lock_init ) {
7014- + __syscalls.lock_init (lock);
6990+ + if ( __has_syscall( lock_init) ) {
6991+ + __syscall_lock_init (lock);
70156992+ }
7016- +
70176993+ }
70186994+
70196995+ void __libc_lock_acquire(_LOCK_T *lock ) {
70206996+
7021- + if ( __syscalls. lock_acquire) {
7022- + __syscalls.lock_acquire (lock);
6997+ + if ( __has_syscall( lock_acquire) ) {
6998+ + __syscall_lock_acquire (lock);
70236999+ }
70247000+ }
70257001+
70267002+ int __libc_lock_try_acquire(_LOCK_T *lock ) {
70277003+
7028- + if ( __syscalls. lock_acquire) {
7029- + return __syscalls.lock_try_acquire (lock);
7004+ + if ( __has_syscall( lock_acquire) ) {
7005+ + return __syscall_lock_try_acquire (lock);
70307006+ } else {
70317007+ return 0;
70327008+ }
70337009+ }
70347010+
70357011+ void __libc_lock_release(_LOCK_T *lock ) {
70367012+
7037- + if ( __syscalls. lock_release) {
7038- + __syscalls.lock_release (lock);
7013+ + if ( __has_syscall( lock_release) ) {
7014+ + __syscall_lock_release (lock);
70397015+ }
70407016+ }
70417017+
70427018+ void __libc_lock_close(_LOCK_T *lock ) {
70437019+
7044- + if ( __syscalls. lock_close) {
7045- + __syscalls.lock_close (lock);
7020+ + if ( __has_syscall( lock_close) ) {
7021+ + __syscall_lock_close (lock);
70467022+ }
70477023+ }
70487024+
70497025+
70507026+
70517027+ void __libc_lock_init_recursive(_LOCK_RECURSIVE_T *lock) {
70527028+
7053- + if ( __syscalls. lock_init_recursive ) {
7054- + __syscalls.lock_init_recursive (lock);
7029+ + if ( __has_syscall( lock_init_recursive) ) {
7030+ + __syscall_lock_init_recursive (lock);
70557031+ }
70567032+
70577033+ }
70587034+
70597035+ void __libc_lock_acquire_recursive(_LOCK_RECURSIVE_T *lock ) {
70607036+
7061- + if ( __syscalls. lock_acquire_recursive) {
7062- + __syscalls.lock_acquire_recursive (lock);
7037+ + if ( __has_syscall( lock_acquire_recursive) ) {
7038+ + __syscall_lock_acquire_recursive (lock);
70637039+ }
70647040+ }
70657041+
70667042+ int __libc_lock_try_acquire_recursive(_LOCK_RECURSIVE_T *lock ) {
70677043+
7068- + if ( __syscalls. lock_acquire_recursive) {
7069- + return __syscalls.lock_try_acquire_recursive (lock);
7044+ + if ( __has_syscall( lock_acquire_recursive) ) {
7045+ + return __syscall_lock_try_acquire_recursive (lock);
70707046+ } else {
70717047+ return 0;
70727048+ }
70737049+ }
70747050+
70757051+ void __libc_lock_release_recursive(_LOCK_RECURSIVE_T *lock ) {
70767052+
7077- + if ( __syscalls. lock_release_recursive) {
7078- + __syscalls.lock_release_recursive (lock);
7053+ + if ( __has_syscall( lock_release_recursive) ) {
7054+ + __syscall_lock_release_recursive (lock);
70797055+ }
70807056+ }
70817057+
70827058+ void __libc_lock_close_recursive(_LOCK_RECURSIVE_T *lock ) {
70837059+
7084- + if ( __syscalls. lock_close_recursive) {
7085- + __syscalls.lock_close_recursive (lock);
7060+ + if ( __has_syscall( lock_close_recursive) ) {
7061+ + __syscall_lock_close_recursive (lock);
70867062+ }
70877063+ }
7088- +
70897064diff --git a/libgloss/libsysbase/times.c b/libgloss/libsysbase/times.c
70907065new file mode 100644
70917066index 000000000..79484e7f4
@@ -7561,10 +7536,10 @@ index 218807178..c9efd7d03 100644
75617536 #ifdef __rtems__
75627537diff --git a/newlib/libc/include/sys/iosupport.h b/newlib/libc/include/sys/iosupport.h
75637538new file mode 100644
7564- index 000000000..c190fa37d
7539+ index 000000000..7b366f593
75657540--- /dev/null
75667541+++ b/newlib/libc/include/sys/iosupport.h
7567- @@ -0,0 +1,112 @@
7542+ @@ -0,0 +1,115 @@
75687543+ //---------------------------------------------------------------------------------
75697544+ #ifndef __iosupp_h__
75707545+ #define __iosupp_h__
@@ -7637,28 +7612,31 @@ index 000000000..c190fa37d
76377612+
76387613+ extern const devoptab_t *devoptab_list[];
76397614+
7640- + typedef struct {
7641- + void *(*sbrk_r) (struct _reent *ptr, ptrdiff_t incr);
7642- + void (*exit) ( int rc );
7643- + int (*gettod_r) (struct _reent *ptr, struct timeval *tp, struct timezone *tz);
7644- + void (*lock_init) (_LOCK_T *lock);
7645- + void (*lock_acquire) (_LOCK_T *lock);
7646- + int (*lock_try_acquire) (_LOCK_T *lock);
7647- + void (*lock_release) (_LOCK_T *lock);
7648- + void (*lock_close) (_LOCK_T *lock);
7649- + void (*lock_init_recursive) (_LOCK_RECURSIVE_T *lock);
7650- + void (*lock_acquire_recursive) (_LOCK_RECURSIVE_T *lock);
7651- + int (*lock_try_acquire_recursive) (_LOCK_RECURSIVE_T *lock);
7652- + void (*lock_release_recursive) (_LOCK_RECURSIVE_T *lock);
7653- + void (*lock_close_recursive) (_LOCK_RECURSIVE_T *lock);
7654- + struct _reent *(*getreent) ();
7655- + int (*clock_gettime)(clockid_t clock_id, struct timespec *tp);
7656- + int (*clock_settime)(clockid_t clock_id, const struct timespec *tp);
7657- + int (*clock_getres)(clockid_t clock_id, struct timespec *res);
7658- + int (*nanosleep)(const struct timespec *req, struct timespec *rem);
7659- + } __syscalls_t;
7660- +
7661- + extern __syscalls_t __syscalls;
7615+ + #ifdef _BUILDING_LIBSYSBASE
7616+ + #define __SYSCALL(_name) __attribute__((weak)) __syscall_##_name
7617+ + #define __has_syscall(_name) (&__syscall_##_name)
7618+ + #else
7619+ + #define __SYSCALL(_name) __syscall_##_name
7620+ + #endif
7621+ +
7622+ + void *__SYSCALL(sbrk_r) (struct _reent *ptr, ptrdiff_t incr);
7623+ + void __SYSCALL(exit) ( int rc );
7624+ + int __SYSCALL(gettod_r) (struct _reent *ptr, struct timeval *tp, struct timezone *tz);
7625+ + void __SYSCALL(lock_init) (_LOCK_T *lock);
7626+ + void __SYSCALL(lock_acquire) (_LOCK_T *lock);
7627+ + int __SYSCALL(lock_try_acquire) (_LOCK_T *lock);
7628+ + void __SYSCALL(lock_release) (_LOCK_T *lock);
7629+ + void __SYSCALL(lock_close) (_LOCK_T *lock);
7630+ + void __SYSCALL(lock_init_recursive) (_LOCK_RECURSIVE_T *lock);
7631+ + void __SYSCALL(lock_acquire_recursive) (_LOCK_RECURSIVE_T *lock);
7632+ + int __SYSCALL(lock_try_acquire_recursive) (_LOCK_RECURSIVE_T *lock);
7633+ + void __SYSCALL(lock_release_recursive) (_LOCK_RECURSIVE_T *lock);
7634+ + void __SYSCALL(lock_close_recursive) (_LOCK_RECURSIVE_T *lock);
7635+ + struct _reent * __SYSCALL(getreent) ();
7636+ + int __SYSCALL(clock_gettime) (clockid_t clock_id, struct timespec *tp);
7637+ + int __SYSCALL(clock_settime) (clockid_t clock_id, const struct timespec *tp);
7638+ + int __SYSCALL(clock_getres) (clockid_t clock_id, struct timespec *res);
7639+ + int __SYSCALL(nanosleep) (const struct timespec *req, struct timespec *rem);
76627640+
76637641+ int AddDevice( const devoptab_t* device);
76647642+ int FindDevice(const char* name);
0 commit comments