Skip to content

Commit

Permalink
wip! improve support for hermit
Browse files Browse the repository at this point in the history
  • Loading branch information
johnyob committed Sep 9, 2024
1 parent 1ea9c57 commit 4391562
Show file tree
Hide file tree
Showing 97 changed files with 6,697 additions and 5,252 deletions.
1,006 changes: 334 additions & 672 deletions newlib/Makefile.in

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions newlib/configure.host
Original file line number Diff line number Diff line change
Expand Up @@ -595,8 +595,8 @@ case "${host}" in
syscall_dir=syscalls
;;
*-*-hermit*)
newlib_cflags="${newlib_cflags} -DREENTRANT_SYSCALLS_PROVIDED -D__DYNAMIC_REENT__ -DSIGNAL_PROVIDED -DHAVE_NANOSLEEP -DMALLOC_PROVIDED"
+ ;;
newlib_cflags="${newlib_cflags} -DREENTRANT_SYSCALLS_PROVIDED -D__DYNAMIC_REENT__ -DHAVE_NANOSLEEP -DMALLOC_PROVIDED"
;;
# RTEMS supplies its own versions of some routines:
# malloc() (reentrant version)
# exit() RTEMS has a "global" reent to flush
Expand Down
3 changes: 3 additions & 0 deletions newlib/libc/include/sys/_timespec.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,12 @@ typedef _TIME_T_ time_t;
#define _TIME_T_DECLARED
#endif

#if !defined(_TIMESPEC_DECLARED)
struct timespec {
time_t tv_sec; /* seconds */
long tv_nsec; /* and nanoseconds */
};
#define _TIMESPEC_DECLARED
#endif

#endif /* !_SYS__TIMESPEC_H_ */
4 changes: 4 additions & 0 deletions newlib/libc/include/sys/_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,12 @@ typedef _CLOCK_T_ __clock_t;
typedef _TIME_T_ __time_t;

#ifndef __machine_clockid_t_defined
#if defined(__hermit__)
#define _CLOCKID_T_ int
#else
#define _CLOCKID_T_ unsigned long
#endif
#endif

typedef _CLOCKID_T_ __clockid_t;

Expand Down
2 changes: 1 addition & 1 deletion newlib/libc/include/sys/select.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
includes the W32api winsock[2].h header must know what it is doing;
it must not call the Cygwin select function.
*/
# if !(defined (_WINSOCK_H) || defined(__hermit__) || defined (_WINSOCKAPI_) || defined (__USE_W32_SOCKETS))
# if !(defined (_WINSOCK_H) || defined (_WINSOCKAPI_) || defined (__USE_W32_SOCKETS))

#include <sys/cdefs.h>
#include <sys/_sigset.h>
Expand Down
2 changes: 2 additions & 0 deletions newlib/libc/include/sys/signal.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ int sigwait (const sigset_t *, int *);
#define sigemptyset(what) (*(what) = 0, 0)
#define sigfillset(what) (*(what) = ~(0), 0)
#define sigismember(what,sig) (((*(what)) & (1<<(sig))) != 0)
#define sigorset(dst, sig1, sig2) (*(dst) = (*(sig1) | *(sig2)), 0)
#define sigandset(dst, sig1, sig2) (*(dst) = (*(sig1) & *(sig2)), 0)
#endif /* !__CYGWIN__ && !__rtems__ */
#endif /* __POSIX_VISIBLE */

Expand Down
4 changes: 3 additions & 1 deletion newlib/libc/include/sys/stat.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ extern "C" {
#ifdef _LIBC
#define stat64 stat
#endif
#elif defined(__hermit__)
#include <hermit/stat.h>
#else
struct stat
{
Expand Down Expand Up @@ -142,7 +144,7 @@ int mkfifo (const char *__path, mode_t __mode );
int stat (const char *__restrict __path, struct stat *__restrict __sbuf );
mode_t umask (mode_t __mask );

#if defined (__SPU__) || defined(__rtems__) || defined(__CYGWIN__)
#if defined (__SPU__) || defined(__rtems__) || defined(__CYGWIN__) || defined(__hermit__)
int lstat (const char *__restrict __path, struct stat *__restrict __buf );
int mknod (const char *__path, mode_t __mode, dev_t __dev );
#endif
Expand Down
52 changes: 18 additions & 34 deletions newlib/libc/sys/hermit/Makefile.inc
Original file line number Diff line number Diff line change
@@ -1,38 +1,22 @@
libc_a_SOURCES += \
%D%/chown.c \
%D%/clock_getres.c \
%D%/clock_gettime.c \
%D%/clock_nanosleep.c \
%D%/clock_settime.c \
%D%/close.c \
%D%/environ.c \
%D%/errno.c \
%D%/execve.c \
%D%/_exit.c \
%D%/fork.c \
%D%/fstat.c \
%D%/getpagesize.c \
%D%/getpid.c \
%D%/gettod.c \
%D%/isatty.c \
%D%/kill.c \
%D%/link.c \
%D%/lseek.c \
%D%/nanosleep.c \
%D%/open.c \
%D%/read.c \
%D%/readlink.c \
%D%/signal/kill.c \
%D%/signal/sigaction.c \
%D%/signal/sigprocmask.c \
%D%/signal/sigtimedwait.c \
%D%/stdio/rename.c \
%D%/conf.c \
%D%/dirent.c \
%D%/env.c \
%D%/fcntl.c \
%D%/ldso.c \
%D%/malloc.c \
%D%/misc.c \
%D%/mman.c \
%D%/network.c \
%D%/process.c \
%D%/sbrk.c \
%D%/sched.c \
%D%/setitimer.c \
%D%/signal.c \
%D%/select.c \
%D%/stat.c \
%D%/symlink.c \
%D%/sysconf.c \
%D%/times.c \
%D%/unlink.c \
%D%/wait.c \
%D%/write.c \
%D%/context.S \
%D%/makecontext.c \
%D%/inet_ntoa.c
%D%/time.c \
%D%/unistd.c
9 changes: 9 additions & 0 deletions newlib/libc/sys/hermit/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Hermit Newlib Port

This directory contains all the system dependent code for the Hermit Newlib port.

For the syscalls, see `syscall.h` in `include/hermit`.

The port is based on some of Musl's libc files. The files are copied from the Musl libc
repository and modified to work with Newlib. All original files are referenced in the header
of the file.
44 changes: 0 additions & 44 deletions newlib/libc/sys/hermit/_exit.c

This file was deleted.

51 changes: 0 additions & 51 deletions newlib/libc/sys/hermit/chown.c

This file was deleted.

39 changes: 0 additions & 39 deletions newlib/libc/sys/hermit/clock_getres.c

This file was deleted.

39 changes: 0 additions & 39 deletions newlib/libc/sys/hermit/clock_gettime.c

This file was deleted.

39 changes: 0 additions & 39 deletions newlib/libc/sys/hermit/clock_nanosleep.c

This file was deleted.

39 changes: 0 additions & 39 deletions newlib/libc/sys/hermit/clock_settime.c

This file was deleted.

Loading

0 comments on commit 4391562

Please sign in to comment.