Framework for exporting system header to user space (#59)
authorLunaixsky <lunaixsky@qq.com>
Mon, 5 May 2025 14:45:39 +0000 (15:45 +0100)
committerGitHub <noreply@github.com>
Mon, 5 May 2025 14:45:39 +0000 (15:45 +0100)
* make rule for user header file install

+ and syscall header file auto generation
+ some clean up

* renamed and cleaned up export header files to match linux convention

89 files changed:
lunaix-os/.gitignore
lunaix-os/arch/generic/includes/asm-generic/syscall_nr.inc
lunaix-os/arch/x86/includes/asm/syscall_nr.inc [moved from lunaix-os/arch/x86/syscall_nr.inc with 100% similarity]
lunaix-os/arch/x86/syscall_lut.S
lunaix-os/hal/term/term.c
lunaix-os/includes/hal/term.h
lunaix-os/includes/lunaix/foptions.h
lunaix-os/includes/lunaix/fs/api.h
lunaix-os/includes/lunaix/ioctl.h
lunaix-os/includes/lunaix/mm/mm.h
lunaix-os/includes/lunaix/process.h
lunaix-os/includes/lunaix/signal.h
lunaix-os/includes/lunaix/syscall.h
lunaix-os/includes/lunaix/types.h
lunaix-os/includes/usr/headers [new file with mode: 0644]
lunaix-os/includes/usr/headers_autogen [new file with mode: 0644]
lunaix-os/includes/usr/lunaix/device.h
lunaix-os/includes/usr/lunaix/dirent.h [moved from lunaix-os/includes/usr/lunaix/dirent_defs.h with 68% similarity]
lunaix-os/includes/usr/lunaix/fcntl.h [new file with mode: 0644]
lunaix-os/includes/usr/lunaix/fcntl_defs.h [deleted file]
lunaix-os/includes/usr/lunaix/fstypes.h
lunaix-os/includes/usr/lunaix/gfx.h
lunaix-os/includes/usr/lunaix/ioctl.h [moved from lunaix-os/includes/usr/lunaix/ioctl_defs.h with 83% similarity]
lunaix-os/includes/usr/lunaix/lxdirent.h [deleted file]
lunaix-os/includes/usr/lunaix/mman.h [moved from lunaix-os/includes/usr/lunaix/mann_flags.h with 88% similarity]
lunaix-os/includes/usr/lunaix/poll.h
lunaix-os/includes/usr/lunaix/serial.h
lunaix-os/includes/usr/lunaix/signal.h [moved from lunaix-os/includes/usr/lunaix/signal_defs.h with 81% similarity]
lunaix-os/includes/usr/lunaix/status.h
lunaix-os/includes/usr/lunaix/syscallid.h [deleted file]
lunaix-os/includes/usr/lunaix/term.h
lunaix-os/includes/usr/lunaix/threads.h
lunaix-os/includes/usr/lunaix/types.h
lunaix-os/includes/usr/lunaix/wait.h [new file with mode: 0644]
lunaix-os/install_headers.mk [new file with mode: 0644]
lunaix-os/kernel.mk
lunaix-os/kernel/device/devfs.c
lunaix-os/kernel/fs/iso9660/directory.c
lunaix-os/kernel/fs/path_walk.c
lunaix-os/kernel/fs/vfs.c
lunaix-os/kernel/mm/mmap.c
lunaix-os/kernel/process/taskfs.c
lunaix-os/makefile
lunaix-os/makeinc/kbuild_deps.mkinc [new file with mode: 0644]
lunaix-os/scripts/gen-syscall-header [new file with mode: 0755]
lunaix-os/usr/.gitignore
lunaix-os/usr/LBuild
lunaix-os/usr/includes [deleted symlink]
lunaix-os/usr/init/init.c
lunaix-os/usr/libc/arch/i386/crt0.S
lunaix-os/usr/libc/arch/i386/trampoline.S
lunaix-os/usr/libc/arch/x86_64/crt0.S
lunaix-os/usr/libc/arch/x86_64/trampoline.S
lunaix-os/usr/libc/includes/dirent.h
lunaix-os/usr/libc/includes/errno.h
lunaix-os/usr/libc/includes/fcntl.h
lunaix-os/usr/libc/includes/lunaix/ioctl.h [deleted file]
lunaix-os/usr/libc/includes/lunaix/lunaix.h [deleted file]
lunaix-os/usr/libc/includes/lunaix/syscall.h [deleted file]
lunaix-os/usr/libc/includes/pthread.h
lunaix-os/usr/libc/includes/signal.h
lunaix-os/usr/libc/includes/stdio.h
lunaix-os/usr/libc/includes/stdlib.h
lunaix-os/usr/libc/includes/string.h
lunaix-os/usr/libc/includes/sys/ioctl.h [new file with mode: 0644]
lunaix-os/usr/libc/includes/sys/lunaix.h [new file with mode: 0644]
lunaix-os/usr/libc/includes/sys/mman.h [moved from lunaix-os/usr/libc/includes/lunaix/mann.h with 50% similarity]
lunaix-os/usr/libc/includes/sys/mount.h [moved from lunaix-os/usr/libc/includes/lunaix/mount.h with 64% similarity]
lunaix-os/usr/libc/includes/sys/types.h [new file with mode: 0644]
lunaix-os/usr/libc/includes/sys/wait.h [new file with mode: 0644]
lunaix-os/usr/libc/includes/syscall.h [new file with mode: 0644]
lunaix-os/usr/libc/includes/termios.h
lunaix-os/usr/libc/includes/unistd.h
lunaix-os/usr/libc/src/posix/dirent.c
lunaix-os/usr/libc/src/posix/errno.c
lunaix-os/usr/libc/src/posix/fcntl.c
lunaix-os/usr/libc/src/posix/ioctl.c
lunaix-os/usr/libc/src/posix/lunaix.c
lunaix-os/usr/libc/src/posix/mann.c
lunaix-os/usr/libc/src/posix/mount.c
lunaix-os/usr/libc/src/posix/signal.c
lunaix-os/usr/libc/src/posix/unistd.c
lunaix-os/usr/libc/src/pthread.c
lunaix-os/usr/libc/src/termios.c
lunaix-os/usr/maze.c
lunaix-os/usr/sh/sh.c
lunaix-os/usr/signal_demo.c
lunaix-os/usr/stat.c
lunaix-os/usr/testp.c

index 9a6b6a87ca5499c131b731a1928866ae267e6895..e70eed3faf06a1cbef06f0fdb068485cd3c4e786 100644 (file)
@@ -18,7 +18,7 @@
 !LConfig
 !makefile
 !live_debug.sh
-!kernel.mk
+!*.mk
 
 *.[od]
 *.ld
index 0da2e62dff3b70f9c4ba70e3f87146d094dde43c..6429afd4bf9aee51e64f2c86441cdbdf24f64e47 100644 (file)
@@ -2,81 +2,81 @@
 #   error "SYSCALL missing pointer type"
 #endif
 
-SYSCALL 0
-SYSCALL __lxsys_fork          /* 1 */
-SYSCALL __lxsys_yield
-SYSCALL __lxsys_sbrk
-SYSCALL __lxsys_brk
-SYSCALL __lxsys_getpid        /* 5 */
-SYSCALL __lxsys_getppid
-SYSCALL __lxsys_sleep
-SYSCALL __lxsys_exit
-SYSCALL __lxsys_wait          
-SYSCALL __lxsys_waitpid       /* 10 */
-SYSCALL __lxsys_sigreturn
-SYSCALL __lxsys_sigprocmask
-SYSCALL __lxsys_sys_sigaction
-SYSCALL __lxsys_pause
-SYSCALL __lxsys_kill          /* 15 */
-SYSCALL __lxsys_alarm
-SYSCALL __lxsys_sigpending
-SYSCALL __lxsys_sigsuspend
-SYSCALL __lxsys_open
-SYSCALL __lxsys_close         /* 20 */
-SYSCALL __lxsys_read
-SYSCALL __lxsys_write
-SYSCALL __lxsys_sys_readdir
-SYSCALL __lxsys_mkdir
-SYSCALL __lxsys_lseek         /* 25 */
-SYSCALL __lxsys_geterrno
-SYSCALL __lxsys_readlink
-SYSCALL __lxsys_readlinkat
-SYSCALL __lxsys_rmdir
-SYSCALL __lxsys_unlink        /* 30 */
-SYSCALL __lxsys_unlinkat
-SYSCALL __lxsys_link
-SYSCALL __lxsys_fsync
-SYSCALL __lxsys_dup
-SYSCALL __lxsys_dup2          /* 35 */
-SYSCALL __lxsys_realpathat
-SYSCALL __lxsys_symlink
-SYSCALL __lxsys_chdir
-SYSCALL __lxsys_fchdir
-SYSCALL __lxsys_getcwd        /* 40 */
-SYSCALL __lxsys_rename
-SYSCALL __lxsys_mount
-SYSCALL __lxsys_unmount
-SYSCALL __lxsys_getxattr
-SYSCALL __lxsys_setxattr      /* 45 */
-SYSCALL __lxsys_fgetxattr
-SYSCALL __lxsys_fsetxattr
-SYSCALL __lxsys_ioctl
-SYSCALL __lxsys_getpgid
-SYSCALL __lxsys_setpgid       /* 50 */
-SYSCALL __lxsys_syslog
-SYSCALL __lxsys_sys_mmap
-SYSCALL __lxsys_munmap
-SYSCALL __lxsys_execve
-SYSCALL __lxsys_fstat         /* 55 */
-SYSCALL __lxsys_pollctl
-SYSCALL __lxsys_th_create
-SYSCALL __lxsys_th_self
-SYSCALL __lxsys_th_exit
-SYSCALL __lxsys_th_join       /* 60 */
-SYSCALL __lxsys_th_kill
-SYSCALL __lxsys_th_detach
-SYSCALL __lxsys_th_sigmask
-SYSCALL __lxsys_getuid
-SYSCALL __lxsys_getgid
-SYSCALL __lxsys_geteuid
-SYSCALL __lxsys_getegid
-SYSCALL __lxsys_getgroups
-SYSCALL __lxsys_setuid
-SYSCALL __lxsys_setgid
-SYSCALL __lxsys_seteuid
-SYSCALL __lxsys_setegid
-SYSCALL __lxsys_setgroups
-SYSCALL __lxsys_chroot
-SYSCALL __lxsys_fchmodat
-SYSCALL __lxsys_fchownat
-SYSCALL __lxsys_faccessat
\ No newline at end of file
+SYSCALL(0)
+SYSCALL(__lxsys_fork)
+SYSCALL(__lxsys_yield)
+SYSCALL(__lxsys_sbrk)
+SYSCALL(__lxsys_brk)
+SYSCALL(__lxsys_getpid)
+SYSCALL(__lxsys_getppid)
+SYSCALL(__lxsys_sleep)
+SYSCALL(__lxsys_exit)
+SYSCALL(__lxsys_wait)
+SYSCALL(__lxsys_waitpid)
+SYSCALL(__lxsys_sigreturn)
+SYSCALL(__lxsys_sigprocmask)
+SYSCALL(__lxsys_sys_sigaction)
+SYSCALL(__lxsys_pause)
+SYSCALL(__lxsys_kill)
+SYSCALL(__lxsys_alarm)
+SYSCALL(__lxsys_sigpending)
+SYSCALL(__lxsys_sigsuspend)
+SYSCALL(__lxsys_open)
+SYSCALL(__lxsys_close)
+SYSCALL(__lxsys_read)
+SYSCALL(__lxsys_write)
+SYSCALL(__lxsys_sys_readdir)
+SYSCALL(__lxsys_mkdir)
+SYSCALL(__lxsys_lseek)
+SYSCALL(__lxsys_geterrno)
+SYSCALL(__lxsys_readlink)
+SYSCALL(__lxsys_readlinkat)
+SYSCALL(__lxsys_rmdir)
+SYSCALL(__lxsys_unlink)
+SYSCALL(__lxsys_unlinkat)
+SYSCALL(__lxsys_link)
+SYSCALL(__lxsys_fsync)
+SYSCALL(__lxsys_dup)
+SYSCALL(__lxsys_dup2)
+SYSCALL(__lxsys_realpathat)
+SYSCALL(__lxsys_symlink)
+SYSCALL(__lxsys_chdir)
+SYSCALL(__lxsys_fchdir)
+SYSCALL(__lxsys_getcwd)
+SYSCALL(__lxsys_rename)
+SYSCALL(__lxsys_mount)
+SYSCALL(__lxsys_unmount)
+SYSCALL(__lxsys_getxattr)
+SYSCALL(__lxsys_setxattr)
+SYSCALL(__lxsys_fgetxattr)
+SYSCALL(__lxsys_fsetxattr)
+SYSCALL(__lxsys_ioctl)
+SYSCALL(__lxsys_getpgid)
+SYSCALL(__lxsys_setpgid)
+SYSCALL(__lxsys_syslog)
+SYSCALL(__lxsys_sys_mmap)
+SYSCALL(__lxsys_munmap)
+SYSCALL(__lxsys_execve)
+SYSCALL(__lxsys_fstat)
+SYSCALL(__lxsys_pollctl)
+SYSCALL(__lxsys_th_create)
+SYSCALL(__lxsys_th_self)
+SYSCALL(__lxsys_th_exit)
+SYSCALL(__lxsys_th_join)
+SYSCALL(__lxsys_th_kill)
+SYSCALL(__lxsys_th_detach)
+SYSCALL(__lxsys_th_sigmask)
+SYSCALL(__lxsys_getuid)
+SYSCALL(__lxsys_getgid)
+SYSCALL(__lxsys_geteuid)
+SYSCALL(__lxsys_getegid)
+SYSCALL(__lxsys_getgroups)
+SYSCALL(__lxsys_setuid)
+SYSCALL(__lxsys_setgid)
+SYSCALL(__lxsys_seteuid)
+SYSCALL(__lxsys_setegid)
+SYSCALL(__lxsys_setgroups)
+SYSCALL(__lxsys_chroot)
+SYSCALL(__lxsys_fchmodat)
+SYSCALL(__lxsys_fchownat)
+SYSCALL(__lxsys_faccessat)
index 4bee0b414e44756296b15f68da6274feb545a271..d3c9b863a68ca9215041f5d8b0aa7e066a6d4844 100644 (file)
@@ -2,18 +2,18 @@
 #include <lunaix/syscall.h>
 
 #ifdef CONFIG_ARCH_X86_64
-#   define SYSCALL     .8byte
+#   define SYSCALL(x)     .8byte x
 #   define SIZE    8
 #else
+#   define SYSCALL(x)     .4byte x
 #   define SIZE    4
-#   define SYSCALL     .4byte
 #endif
 
 .section .data
     .global __syscall_table
     __syscall_table:
         1:
-        #include "syscall_nr.inc"
+        #include <asm/syscall_nr.inc>
         2:
         .rept __SYSCALL_MAX - (2b - 1b) / SIZE
             .long 0
index a71f93ca688089445cfc1d8b5ac77002153a2c29..59b7ebe81de1e5c96c53ec03aadfa17591cbd650 100644 (file)
@@ -7,7 +7,7 @@
 #include <lunaix/status.h>
 #include <lunaix/syslog.h>
 
-#include <usr/lunaix/ioctl_defs.h>
+#include <usr/lunaix/ioctl.h>
 
 LOG_MODULE("term");
 
index be7abd0fdcda89163fb59139079e4b0299d2231f..07acec91f43566e37d0847cb91d3a1a93d92a1f6 100644 (file)
@@ -4,8 +4,8 @@
 #include <lunaix/device.h>
 #include <lunaix/ds/rbuffer.h>
 #include <lunaix/ds/waitq.h>
-#include <lunaix/signal_defs.h>
 
+#include <usr/lunaix/signal.h>
 #include <usr/lunaix/term.h>
 
 struct term;
index 38b055a9d18dd1b3a73ed6e7cccf02b3bb38361a..3ed7592f0c226e559a077bbdb82407471affca8c 100644 (file)
@@ -1,6 +1,6 @@
 #ifndef __LUNAIX_FOPTIONS_H
 #define __LUNAIX_FOPTIONS_H
 
-#include <usr/lunaix/fcntl_defs.h>
+#include <usr/lunaix/fcntl.h>
 
 #endif /* __LUNAIX_FOPTIONS_H */
index e9c1437fbad306724f8c956962fbdbbbd89748b4..81aaa56be50683cf5beeb0939f088a2ecaa82982 100644 (file)
@@ -2,11 +2,11 @@
 #define __LUNAIX_FSAPI_H
 
 #include <lunaix/fs.h>
-#include <lunaix/fcntl_defs.h>
 #include <lunaix/blkbuf.h>
 #include <klibc/string.h>
 
-#include <usr/lunaix/dirent_defs.h>
+#include <usr/lunaix/fcntl.h>
+#include <usr/lunaix/dirent.h>
 
 struct fsapi_vsb_ops
 {
index ed7c4f7316e7a82265506f7c3aecbd03b1e0a76f..0b8f0ac91fa481f18e8fe23b5ff47fb6f51e3fb9 100644 (file)
@@ -1,6 +1,6 @@
 #ifndef __LUNAIX_IOCTL_H
 #define __LUNAIX_IOCTL_H
 
-#include <usr/lunaix/ioctl_defs.h>
+#include <usr/lunaix/ioctl.h>
 
 #endif /* __LUNAIX_IOCTL_H */
index abb18cf1545b74b11608db8441aa2bf278153a30..742ee1d4139cd1532c234bbc08138ec54dd413e6 100644 (file)
@@ -6,7 +6,7 @@
 
 #include <asm/pagetable.h>
 
-#include <usr/lunaix/mann_flags.h>
+#include <usr/lunaix/mman.h>
 
 /**
  * @brief 私有区域,该区域中的页无法进行任何形式的共享。
index 868a9fc290bc97a53ee3bac804b401cf87da54fd..a9f307c704a8688b521cccd8c1817cc39658cd11 100644 (file)
@@ -15,6 +15,8 @@
 #include <lunaix/hart_state.h>
 #include <lunaix/usrscope.h>
 
+#include <usr/lunaix/wait.h>
+
 #include <stdint.h>
 
 
index 556823b7d4632aee2d56d9ab5e7dec29e2c08047..63723254e33681413220267e449acffb8c1ec5a6 100644 (file)
@@ -2,7 +2,7 @@
 #define __LUNAIX_SIGNAL_H
 
 #include <lunaix/types.h>
-#include <usr/lunaix/signal_defs.h>
+#include <usr/lunaix/signal.h>
 
 #define _SIG_NUM 16
 
index 1b9778f79b2a783e09b2509ab908a9a2bdbb637b..1460013961cb553db28e7d1c85f5e0c96741a41b 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef __LUNAIX_SYSCALL_H
 #define __LUNAIX_SYSCALL_H
 
-#include <usr/lunaix/syscallid.h>
+#define __SYSCALL_MAX 1024
 
 #ifndef __ASM__
 
index 6ce5fcf3b71873e3ea2b7ce4243c03bff658aac0..c7b09e87acd8a3f0cbc2b7710142de3e244e905a 100644 (file)
@@ -1,33 +1,39 @@
 #ifndef __LUNAIX_TYPES_H
 #define __LUNAIX_TYPES_H
 
+#include <stdarg.h>
 #include <lunaix/compiler.h>
 #include <lunaix/limits.h>
-#include <stdarg.h>
 #include <usr/lunaix/types.h>
 
-// TODO: WTERMSIG
-
-// TODO: replace the integer type with these. To make thing more portable.
+#undef  NULL
+#define NULL                (void*)0
 
-typedef unsigned char u8_t;
-typedef unsigned short u16_t;
-typedef unsigned int u32_t;
-typedef unsigned long ptr_t;
-typedef unsigned long reg_t;
+typedef unsigned char       u8_t;
+typedef unsigned short      u16_t;
+typedef unsigned int        u32_t;
 
 #ifndef CONFIG_ARCH_BITS_64
-typedef unsigned long long u64_t;
+typedef unsigned long long  u64_t;
 #else
-typedef unsigned long u64_t;
+typedef unsigned long       u64_t;
 #endif
 
-typedef int pid_t;
-typedef signed long ssize_t;
+typedef __lunaix_pid_t      pid_t;
+typedef __lunaix_tid_t      tid_t;
+typedef __lunaix_uid_t      uid_t;
+typedef __lunaix_gid_t      gid_t;
+typedef __lunaix_size_t     size_t;
+typedef __lunaix_ssize_t    ssize_t;
+typedef __lunaix_size_t     off_t;
+typedef __lunaix_ino_t      ino_t;
 
-typedef unsigned int cpu_t;
+typedef unsigned long       ptr_t;
+typedef unsigned long       reg_t;
+typedef unsigned int        cpu_t;
+typedef u64_t               lba_t;
 
-typedef u64_t lba_t;
+typedef __lunaix_dev_t      dev_t;
 
 #define true 1
 #define false 0
diff --git a/lunaix-os/includes/usr/headers b/lunaix-os/includes/usr/headers
new file mode 100644 (file)
index 0000000..5e33d5a
--- /dev/null
@@ -0,0 +1,15 @@
+lunaix/fstypes.h
+lunaix/status.h
+lunaix/fcntl.h
+lunaix/signal.h
+lunaix/term.h
+lunaix/mman.h
+lunaix/dirent.h
+lunaix/poll.h
+lunaix/types.h
+lunaix/serial.h
+lunaix/device.h
+lunaix/ioctl.h
+lunaix/threads.h
+lunaix/gfx.h
+lunaix/wait.h
diff --git a/lunaix-os/includes/usr/headers_autogen b/lunaix-os/includes/usr/headers_autogen
new file mode 100644 (file)
index 0000000..4ec2da9
--- /dev/null
@@ -0,0 +1 @@
+lunaix/syscallid.h
\ No newline at end of file
index 9f8d2e03aed869ac185eebddc30a65929e507238..4e4c4197d4f979f919c5518a7fafcea99be943b9 100644 (file)
@@ -1,7 +1,7 @@
-#ifndef __LUNAIX_UDEVICE_H
-#define __LUNAIX_UDEVICE_H
+#ifndef _LUNAIX_UHDR_UDEVICE_H
+#define _LUNAIX_UHDR_UDEVICE_H
 
-#include "ioctl_defs.h"
+#include "ioctl.h"
 
 struct dev_info
 {
@@ -20,4 +20,4 @@ struct dev_info
     } dev_name;
 };
 
-#endif /* __LUNAIX_UDEVICE_H */
+#endif /* _LUNAIX_UHDR_UDEVICE_H */
similarity index 68%
rename from lunaix-os/includes/usr/lunaix/dirent_defs.h
rename to lunaix-os/includes/usr/lunaix/dirent.h
index 9142a4dc440d8ea802fa9ee65ea967ba73fbe412..d8342ddb72ea9725f23715ed1b07a18d3e10d670 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef __LUNAIX_SYS_DIRENT_DEFS_H
-#define __LUNAIX_SYS_DIRENT_DEFS_H
+#ifndef _LUNAIX_UHDR_SYS_DIRENT_DEFS_H
+#define _LUNAIX_UHDR_SYS_DIRENT_DEFS_H
 
 #define DIRENT_NAME_MAX_LEN 256
 
@@ -16,4 +16,4 @@ struct lx_dirent
     char d_name[DIRENT_NAME_MAX_LEN];
 };
 
-#endif /* __LUNAIX_DIRENT_DEFS_H */
+#endif /* _LUNAIX_UHDR_DIRENT_DEFS_H */
diff --git a/lunaix-os/includes/usr/lunaix/fcntl.h b/lunaix-os/includes/usr/lunaix/fcntl.h
new file mode 100644 (file)
index 0000000..ba88b5b
--- /dev/null
@@ -0,0 +1,68 @@
+#ifndef _LUNAIX_UHDR_SYS_FCNTL_DEFS_H
+#define _LUNAIX_UHDR_SYS_FCNTL_DEFS_H
+
+#include "fstypes.h"
+#include "types.h"
+
+#define FO_CREATE               0x1
+#define FO_APPEND               0x2
+#define FO_DIRECT               0x4
+#define FO_WRONLY               0x8
+#define FO_RDONLY               0x10
+#define FO_RDWR                 0x20
+#define FO_TRUNC                0x40
+
+#define FO_NOFOLLOW             0x10000
+
+#define FSEEK_SET               0x1
+#define FSEEK_CUR               0x2
+#define FSEEK_END               0x3
+
+#define O_CREAT                 FO_CREATE
+#define O_APPEND                FO_APPEND
+#define O_DIRECT                FO_DIRECT
+#define O_WRONLY                FO_WRONLY
+#define O_RDONLY                FO_RDONLY
+#define O_RDWR                  FO_RDWR
+#define O_TRUNC                 FO_TRUNC
+
+#define AT_SYMLINK_FOLLOW       0b0000
+#define AT_SYMLINK_NOFOLLOW     0b0001
+#define AT_FDCWD                0b0010
+#define AT_EACCESS              0b0100
+
+#define R_OK                    0b100100100
+#define W_OK                    0b010010010
+#define X_OK                    0b001001001
+#define F_OK                    0b111111111
+
+/* Mount with read-only flag */
+#define MNT_RO                  (1 << 0)
+
+/* Mount with block-cache-disabled flag */
+#define MNT_NC                  (1 << 1)
+
+typedef unsigned int mode_t;
+typedef unsigned int nlink_t;
+
+struct file_stat
+{
+    __lunaix_dev_t   st_dev;
+    __lunaix_ino_t   st_ino;
+    mode_t           st_mode;
+    nlink_t          st_nlink;
+    __lunaix_uid_t   st_uid;
+    __lunaix_gid_t   st_gid;
+    __lunaix_dev_t   st_rdev;
+    __lunaix_size_t  st_size;
+    __lunaix_size_t  st_blksize;
+    __lunaix_size_t  st_blocks;
+
+    unsigned long    st_atim;
+    unsigned long    st_ctim;
+    unsigned long    st_mtim;
+
+    __lunaix_size_t  st_ioblksize;
+};
+
+#endif /* _LUNAIX_UHDR_FNCTL_DEFS_H */
diff --git a/lunaix-os/includes/usr/lunaix/fcntl_defs.h b/lunaix-os/includes/usr/lunaix/fcntl_defs.h
deleted file mode 100644 (file)
index 36af62e..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-#ifndef __LUNAIX_SYS_FCNTL_DEFS_H
-#define __LUNAIX_SYS_FCNTL_DEFS_H
-
-#include "fstypes.h"
-#include "types.h"
-
-#define FO_CREATE   0x1
-#define FO_APPEND   0x2
-#define FO_DIRECT   0x4
-#define FO_WRONLY   0x8
-#define FO_RDONLY   0x10
-#define FO_RDWR     0x20
-#define FO_TRUNC    0x40
-
-#define FO_NOFOLLOW 0x10000
-
-#define FSEEK_SET 0x1
-#define FSEEK_CUR 0x2
-#define FSEEK_END 0x3
-
-#define O_CREAT FO_CREATE
-#define O_APPEND FO_APPEND
-#define O_DIRECT FO_DIRECT
-#define O_WRONLY FO_WRONLY
-#define O_RDONLY FO_RDONLY
-#define O_RDWR FO_RDWR
-#define O_TRUNC FO_TRUNC
-
-#define AT_SYMLINK_FOLLOW       0b0000
-#define AT_SYMLINK_NOFOLLOW     0b0001
-#define AT_FDCWD                0b0010
-#define AT_EACCESS              0b0100
-
-#define R_OK                    0b100100100
-#define W_OK                    0b010010010
-#define X_OK                    0b001001001
-#define F_OK                    0b111111111
-
-/* Mount with read-only flag */
-#define MNT_RO (1 << 0)
-
-/* Mount with block-cache-disabled flag */
-#define MNT_NC (1 << 1)
-
-typedef unsigned int mode_t;
-typedef unsigned int nlink_t;
-
-struct file_stat
-{
-    dev_t   st_dev;
-    ino_t   st_ino;
-    mode_t  st_mode;
-    nlink_t st_nlink;
-    uid_t   st_uid;
-    gid_t   st_gid;
-    dev_t   st_rdev;
-    off_t   st_size;
-    size_t  st_blksize;
-    size_t  st_blocks;
-
-    unsigned long st_atim;
-    unsigned long st_ctim;
-    unsigned long st_mtim;
-
-    size_t  st_ioblksize;
-};
-
-#endif /* __LUNAIX_FNCTL_DEFS_H */
index 680a8222f7d34dcb6548ecdf4ccf6c7104f44db4..9bbd4284fd5b78f7df9a5c758d52f0d3b844e6b1 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef __LUNAIX_FSTYPES_H
-#define __LUNAIX_FSTYPES_H
+#ifndef _LUNAIX_UHDR_FSTYPES_H
+#define _LUNAIX_UHDR_FSTYPES_H
 
 /*
   7 6 5 4 3   2 1 0
@@ -20,4 +20,4 @@
 #define F_PIPE      0b00010000
 #define F_SYMLINK   0b00100000
 
-#endif /* __LUNAIX_FSTYPES_H */
+#endif /* _LUNAIX_UHDR_FSTYPES_H */
index e583be1e850f3fd3c1d078377b58effd54393eda..6c5e5d89b5380f46500fd5c516322f4d1c079ded 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef __LUNAIX_UGFX_H
-#define __LUNAIX_UGFX_H
+#ifndef _LUNAIX_UHDR_UGFX_H
+#define _LUNAIX_UHDR_UGFX_H
 
 #define GFX_CMDA(type, cmd_id) (((type) << 8) | ((cmd_id) & 0xf))
 
@@ -41,4 +41,4 @@ struct gfxa_clut
     size_t len;
 };
 
-#endif /* __LUNAIX_UGFX_H */
+#endif /* _LUNAIX_UHDR_UGFX_H */
similarity index 83%
rename from lunaix-os/includes/usr/lunaix/ioctl_defs.h
rename to lunaix-os/includes/usr/lunaix/ioctl.h
index dd5709f6ca99c9559e923062129fdd83dce6389c..44254b9eadcdc24192b92a8a69ec6456acd08952 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef __LUNAIX_SYS_IOCTL_DEFS_H
-#define __LUNAIX_SYS_IOCTL_DEFS_H
+#ifndef _LUNAIX_UHDR_SYS_IOCTL_H
+#define _LUNAIX_UHDR_SYS_IOCTL_H
 
 #define IOREQ(cmd, arg_num) ((((cmd) & 0xffff) << 8) | ((arg_num) & 0xff))
 
@@ -22,4 +22,4 @@
 
 #define TIMERIO_GETINFO IOREQ(1, 0)
 
-#endif /* __LUNAIX_IOCTL_DEFS_H */
+#endif /* _LUNAIX_UHDR_IOCTL_H */
diff --git a/lunaix-os/includes/usr/lunaix/lxdirent.h b/lunaix-os/includes/usr/lunaix/lxdirent.h
deleted file mode 100644 (file)
index 6793d99..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef __LUNAIX_SYS_LXDIRENT_H
-#define __LUNAIX_SYS_LXDIRENT_H
-
-#include <lunaix/dirent_defs.h>
-
-int sys_readdir(int fd, struct lx_dirent* dirent);
-
-#endif /* __LUNAIX_DIRENT_H */
similarity index 88%
rename from lunaix-os/includes/usr/lunaix/mann_flags.h
rename to lunaix-os/includes/usr/lunaix/mman.h
index dcd3a3479282c2252c8ac84637b79bd62cf66370..8f9641d65d521ac949f2cdb23c4711ad0d41083e 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef __LUNAIX_SYS_MANN_FLAGS_H
-#define __LUNAIX_SYS_MANN_FLAGS_H
+#ifndef _LUNAIX_UHDR_SYS_MMAN_H
+#define _LUNAIX_UHDR_SYS_MMAN_H
 
 // POSIX compliant.
 
@@ -40,4 +40,4 @@ struct usr_mmap_param
     unsigned long offset;
 };
 
-#endif /* __LUNAIX_MANN_FLAGS_H */
+#endif /* _LUNAIX_UHDR_MMAN_H */
index 8fed581f120f8140d0a43b77c4874f845cedbfca..62631561f5dd467f67d07eb0bd8c8803f80958d5 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef __LUNAIX_UPOLL_H
-#define __LUNAIX_UPOLL_H
+#ifndef _LUNAIX_UHDR_UPOLL_H
+#define _LUNAIX_UHDR_UPOLL_H
 
 struct poll_info
 {
@@ -25,4 +25,4 @@ struct poll_info
 #define _POLLEE_ALWAYS 1
 #define _POLLEE_RM_ON_ERR (1 << 1)
 
-#endif /* __LUNAIX_UPOLL_H */
+#endif /* _LUNAIX_UHDR_UPOLL_H */
index 6f731554547d6f8ffa03d896bbaf8f767de66191..ee10002198462bd78242b8a4a0c7c136434a239a 100644 (file)
@@ -1,7 +1,7 @@
-#ifndef __LUNAIX_USERIAL_H
-#define __LUNAIX_USERIAL_H
+#ifndef _LUNAIX_UHDR_USERIAL_H
+#define _LUNAIX_UHDR_USERIAL_H
 
-#include "ioctl_defs.h"
+#include "ioctl.h"
 
 #define SERIO_RXEN          IOREQ(1, 0)
 #define SERIO_RXDA          IOREQ(2, 0)
@@ -13,4 +13,4 @@
 #define SERIO_SETCNTRLMODE  IOREQ(6, 0)
 #define SERIO_SETBRDBASE    IOREQ(7, 0)
 
-#endif /* __LUNAIX_USERIAL_H */
+#endif /* _LUNAIX_UHDR_USERIAL_H */
similarity index 81%
rename from lunaix-os/includes/usr/lunaix/signal_defs.h
rename to lunaix-os/includes/usr/lunaix/signal.h
index 7c8148a20bc5ffa29a19886560e216b16fda0254..18b28ee0cbb8850934f50ff9fae19b3719df4db3 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef __LUNAIX_SYS_SIGNAL_DEFS_H
-#define __LUNAIX_SYS_SIGNAL_DEFS_H
+#ifndef _LUNAIX_UHDR_SYS_SIGNAL_DEFS_H
+#define _LUNAIX_UHDR_SYS_SIGNAL_DEFS_H
 
 #define SIGALRM 1
 #define SIGCHLD 2
@@ -35,4 +35,4 @@ struct siginfo
     // TODO
 };
 
-#endif /* __LUNAIX_SIGNAL_DEFS_H */
+#endif /* _LUNAIX_UHDR_SIGNAL_DEFS_H */
index e4572322c0f019988fd15c4ce86ec77f158b8592..49657872fdfca96f68dd249df800748e2d84a1fb 100644 (file)
@@ -1,42 +1,35 @@
-#ifndef __LUNAIX_STATUS_H
-#define __LUNAIX_STATUS_H
+#ifndef _LUNAIX_UHDR_STATUS_H
+#define _LUNAIX_UHDR_STATUS_H
 
-#define LXPROCFULL -(1)
-#define LXHEAPFULL -(2)
-#define LXINVLDPTR -(2)
-#define LXOUTOFMEM -(3)
-#define LXSEGFAULT -(5)
-#define EINVAL -(6)
+#define ENOMEM              -3
+#define EINVAL              -6
+#define EINTR               -7
+#define EMFILE              -8
+#define ENOENT              -9
+#define ENAMETOOLONG        -10
+#define ENOTDIR             -11
+#define EEXIST              -12
+#define EBADF               -13
+#define ENOTSUP             -14
+#define EIO                 -15
+#define ELOOP               -16
+#define ENOTEMPTY           -17
+#define EROFS               -18
+#define EISDIR              -19
+#define EBUSY               -20
+#define EXDEV               -21
+#define ENODEV              -22
+#define ERANGE              -23
+#define ENOTDEV             -24
+#define EOVERFLOW           -25
+#define ENOTBLK             -26
+#define ENOEXEC             -27
+#define E2BIG               -28
+#define ELIBBAD             -29
+#define EAGAIN              -30
+#define EDEADLK             -31
+#define EDQUOT              -32
+#define EPERM               -33
+#define EACCESS             -34
 
-#define EINTR -(7)
-
-#define EMFILE -8
-#define ENOENT -9
-#define ENAMETOOLONG -10
-#define ENOTDIR -11
-#define EEXIST -12
-#define EBADF -13
-#define ENOTSUP -14
-#define EIO -15
-#define ELOOP -16
-#define ENOTEMPTY -17
-#define EROFS -18
-#define EISDIR -19
-#define EBUSY -20
-#define EXDEV -21
-#define ENODEV -22
-#define ERANGE -23
-#define ENOMEM LXOUTOFMEM
-#define ENOTDEV -24
-#define EOVERFLOW -25
-#define ENOTBLK -26
-#define ENOEXEC -27
-#define E2BIG -28
-#define ELIBBAD -29
-#define EAGAIN -30
-#define EDEADLK -31
-#define EDQUOT -32
-#define EPERM -33
-#define EACCESS -34
-
-#endif /* __LUNAIX_STATUS_H */
+#endif /* _LUNAIX_UHDR_STATUS_H */
diff --git a/lunaix-os/includes/usr/lunaix/syscallid.h b/lunaix-os/includes/usr/lunaix/syscallid.h
deleted file mode 100644 (file)
index 7e995f1..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-#ifndef __LUNAIX_SYSCALLID_H
-#define __LUNAIX_SYSCALLID_H
-
-#define __SYSCALL_fork 1
-#define __SYSCALL_yield 2
-#define __SYSCALL_sbrk 3
-#define __SYSCALL_brk 4
-#define __SYSCALL_getpid 5
-#define __SYSCALL_getppid 6
-#define __SYSCALL_sleep 7
-#define __SYSCALL__exit 8
-#define __SYSCALL_wait 9
-#define __SYSCALL_waitpid 10
-
-#define __SYSCALL_sigreturn 11
-#define __SYSCALL_sigprocmask 12
-#define __SYSCALL_sys_sigaction 13
-#define __SYSCALL_pause 14
-#define __SYSCALL_kill 15
-#define __SYSCALL_alarm 16
-#define __SYSCALL_sigpending 17
-#define __SYSCALL_sigsuspend 18
-#define __SYSCALL_open 19
-#define __SYSCALL_close 20
-
-#define __SYSCALL_read 21
-#define __SYSCALL_write 22
-#define __SYSCALL_sys_readdir 23
-#define __SYSCALL_mkdir 24
-#define __SYSCALL_lseek 25
-#define __SYSCALL_geterrno 26
-#define __SYSCALL_readlink 27
-#define __SYSCALL_readlinkat 28
-#define __SYSCALL_rmdir 29
-
-#define __SYSCALL_unlink 30
-#define __SYSCALL_unlinkat 31
-#define __SYSCALL_link 32
-#define __SYSCALL_fsync 33
-#define __SYSCALL_dup 34
-#define __SYSCALL_dup2 35
-#define __SYSCALL_realpathat 36
-#define __SYSCALL_symlink 37
-#define __SYSCALL_chdir 38
-#define __SYSCALL_fchdir 39
-#define __SYSCALL_getcwd 40
-#define __SYSCALL_rename 41
-#define __SYSCALL_mount 42
-#define __SYSCALL_unmount 43
-#define __SYSCALL_getxattr 44
-#define __SYSCALL_setxattr 45
-#define __SYSCALL_fgetxattr 46
-#define __SYSCALL_fsetxattr 47
-
-#define __SYSCALL_ioctl 48
-#define __SYSCALL_getpgid 49
-#define __SYSCALL_setpgid 50
-
-#define __SYSCALL_syslog 51
-
-#define __SYSCALL_sys_mmap 52
-#define __SYSCALL_munmap 53
-
-#define __SYSCALL_execve 54
-
-#define __SYSCALL_fstat 55
-#define __SYSCALL_pollctl 56
-
-#define __SYSCALL_th_create 57
-#define __SYSCALL_th_self 58
-#define __SYSCALL_th_exit 59
-#define __SYSCALL_th_join 60
-#define __SYSCALL_th_kill 61
-#define __SYSCALL_th_detach 62
-#define __SYSCALL_th_sigmask 63
-
-#define __SYSCALL_MAX 0x200
-
-#endif /* __LUNAIX_SYSCALLID_H */
index b1f6c1fff37eef5ec71d9c84b30123eeb94edc59..e9d79024819698d3bee7ff66ffb0e8b5ec523a16 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef __LUNAIX_UTERM_H
-#define __LUNAIX_UTERM_H
+#ifndef _LUNAIX_UHDR_UTERM_H
+#define _LUNAIX_UHDR_UTERM_H
 
 #define _BRKINT (1)
 #define _ICRNL (1 << 1)
@@ -104,4 +104,4 @@ struct termios
     speed_t c_baud;
 };
 
-#endif /* __LUNAIX_UTERM_H */
+#endif /* _LUNAIX_UHDR_UTERM_H */
index a20b52ff69afe5bd689ed1ef399baad7d5c6ed5e..c70e40711df21058cfff43c8a49efe117b07cef5 100644 (file)
@@ -1,11 +1,12 @@
-#ifndef __LUNAIX_USR_THREADS_H
-#define __LUNAIX_USR_THREADS_H
+#ifndef _LUNAIX_UHDR_USR_THREADS_H
+#define _LUNAIX_UHDR_USR_THREADS_H
 
 #include "types.h"
 
-struct uthread_param {
+struct uthread_param 
+{
     void* th_handler;
     void* arg1;
 };
 
-#endif /* __LUNAIX_USR_THREADS_H */
+#endif /* _LUNAIX_UHDR_USR_THREADS_H */
index 3dbddb528c7d6f3a53019644229e4db94ce4002e..8a3410a77ace2a490dc3cf70d77c3a181924b99a 100644 (file)
@@ -1,43 +1,19 @@
-#ifndef __LUNAIX_SYS_TYPES_H
-#define __LUNAIX_SYS_TYPES_H
-
-#undef NULL
-#define NULL (void*)0
-#define NULLPTR 0
-
-#define PEXITTERM 0x100
-#define PEXITSTOP 0x200
-#define PEXITSIG 0x400
-
-#define PEXITNUM(flag, code) (flag | (code & 0xff))
-
-#define WNOHANG 1
-#define WUNTRACED 2
-#define WEXITSTATUS(wstatus) ((wstatus & 0xff))
-#define WIFSTOPPED(wstatus) ((wstatus & PEXITSTOP))
-#define WIFEXITED(wstatus)                                                     \
-    ((wstatus & PEXITTERM) && ((char)WEXITSTATUS(wstatus) >= 0))
-
-#define WIFSIGNALED(wstatus) ((wstatus & PEXITSIG))
-
-typedef signed long ssize_t;
-
-typedef int pid_t;
-typedef int tid_t;
-typedef int uid_t;
-typedef int gid_t;
-
-typedef __SIZE_TYPE__ size_t;
-
-typedef __SIZE_TYPE__ off_t;
-
-typedef unsigned int ino_t;
-
-typedef struct dev_t
+#ifndef _LUNAIX_UHDR_SYS_TYPES_H
+#define _LUNAIX_UHDR_SYS_TYPES_H
+
+typedef int             __lunaix_pid_t;
+typedef int             __lunaix_tid_t;
+typedef int             __lunaix_uid_t;
+typedef int             __lunaix_gid_t;
+typedef unsigned long   __lunaix_size_t;
+typedef signed long     __lunaix_ssize_t;
+typedef unsigned int    __lunaix_ino_t;
+
+typedef struct
 {
     unsigned int meta;
     unsigned int unique;
     unsigned int index;
-} dev_t;
+} __lunaix_dev_t;
 
-#endif /* __LUNAIX_TYPES_H */
+#endif /* _LUNAIX_UHDR_TYPES_H */
diff --git a/lunaix-os/includes/usr/lunaix/wait.h b/lunaix-os/includes/usr/lunaix/wait.h
new file mode 100644 (file)
index 0000000..222923b
--- /dev/null
@@ -0,0 +1,19 @@
+#ifndef _LUNAIX_UHDR_WAIT_H
+#define _LUNAIX_UHDR_WAIT_H
+
+#define PEXITTERM   0x100
+#define PEXITSTOP   0x200
+#define PEXITSIG    0x400
+
+#define WNOHANG     1
+#define WUNTRACED   2
+
+#define PEXITNUM(flag, code)    (flag | (code & 0xff))
+#define WEXITSTATUS(wstatus)    ((wstatus & 0xff))
+#define WIFSTOPPED(wstatus)     ((wstatus & PEXITSTOP))
+#define WIFSIGNALED(wstatus)    ((wstatus & PEXITSIG))
+
+#define WIFEXITED(wstatus)                                                     \
+    ((wstatus & PEXITTERM) && ((char)WEXITSTATUS(wstatus) >= 0))
+
+#endif /* _LUNAIX_UHDR_WAIT_H */
diff --git a/lunaix-os/install_headers.mk b/lunaix-os/install_headers.mk
new file mode 100644 (file)
index 0000000..d636375
--- /dev/null
@@ -0,0 +1,28 @@
+include kbuild_deps.mkinc
+
+ifndef PREFIX
+       $(error "Must specify PREFIX to header install location")
+endif
+
+USR_HEADER := includes/usr
+
+HEADERS := $(shell cat $(USR_HEADER)/headers)
+HEADERS += $(shell cat $(USR_HEADER)/headers_autogen)
+
+INSTALL := $(addprefix $(PREFIX)/,$(HEADERS))
+
+export CFLAGS=$(kcflags)
+$(PREFIX)/lunaix/syscallid.h:
+       @scripts/gen-syscall-header "$@"
+
+.SECONDEXPANSION:
+.PRECIOUS: $(PREFIX)/%/
+
+$(PREFIX)/%/:
+       @mkdir -p $@
+
+$(PREFIX)/%.h : $(USR_HEADER)/%.h $$(dir $$@)
+       $(call status,INSTALL,$@)
+       @cp $< $@
+
+all: $(INSTALL)
\ No newline at end of file
index bb64364e30194471f6da0b2fbf31b970415d03d6..a0a24040ebf40e82d0449d077d19f97d44928528 100644 (file)
@@ -1,42 +1,31 @@
-include toolchain.mkinc
-include lunabuild.mkinc
-
-include $(lbuild_mkinc)
+include kbuild_deps.mkinc
 
 kbin_dir := $(BUILD_DIR)
 kbin := $(BUILD_NAME)
 
-ksrc_objs := $(addsuffix .o,$(_LBUILD_SRCS))
-ksrc_deps := $(addsuffix .d,$(_LBUILD_SRCS))
-khdr_opts := $(addprefix -include ,$(_LBUILD_HDRS))
-kinc_opts := $(addprefix -I,$(_LBUILD_INCS))
-config_h += -include $(lbuild_config_h)
-
 tmp_kbin  := $(BUILD_DIR)/tmpk.bin
 klinking  := link/lunaix.ld
 
-CFLAGS += $(khdr_opts) $(kinc_opts) $(config_h) -MMD -MP
-
--include $(ksrc_deps)
+CFLAGS += $(kcflags) -MMD -MP
 
 all_linkable = $(filter-out $(klinking),$(1))
 
 %.S.o: %.S $(khdr_files) kernel.mk
-       $(call status_,AS,$<)
+       $(call status,AS,$<)
        @$(CC) $(CFLAGS) -c $< -o $@
 
 %.c.o: %.c kernel.mk
-       $(call status_,CC,$<)
+       $(call status,CC,$<)
        @$(CC) $(CFLAGS) -c $< -o $@
 
 
 $(klinking): link/lunaix.ldx
-       $(call status_,PP,$<)
+       $(call status,PP,$<)
        @$(CC) $(CFLAGS) -x c -E -P $< -o $@
 
 
 $(tmp_kbin): $(klinking) $(ksrc_objs)
-       $(call status_,LD,$@)
+       $(call status,LD,$@)
 
        @$(CC) -T $(klinking) $(config_h) $(LDFLAGS) -o $@ \
                        $(call all_linkable,$^)
@@ -47,13 +36,13 @@ ksecsmap  := lunaix_ksecsmap.o
 kautogen  := $(ksecsmap) $(ksymtable)
 
 $(ksymtable): $(tmp_kbin)
-       $(call status_,KSYM,$@)
+       $(call status,KSYM,$@)
        @ARCH=$(ARCH) scripts/gen-ksymtable DdRrTtAGg $< > lunaix_ksymtable.S
 
        @$(CC) $(CFLAGS) -c lunaix_ksymtable.S -o $@
 
 $(ksecsmap): $(tmp_kbin)
-       $(call status_,KGEN,$@)
+       $(call status,KGEN,$@)
        @scripts/elftool.tool -p -i $< > lunaix_ksecsmap.S
 
        @$(CC) $(CFLAGS) -c lunaix_ksecsmap.S -o $@
@@ -61,7 +50,7 @@ $(ksecsmap): $(tmp_kbin)
 .PHONY: __do_relink
 
 __do_relink: $(klinking) $(ksrc_objs) $(kautogen)
-       $(call status_,LD,$(kbin))
+       $(call status,LD,$(kbin))
 
        @$(CC) -T $(klinking) $(config_h) $(LDFLAGS) -o $(kbin) \
                        $(call all_linkable,$^)
index 969c8288b2f0b58b91d8c6183e16dc017f770284..f8a20a14932e8fb0929b299ebd91696680758c9b 100644 (file)
@@ -3,7 +3,7 @@
 #include <lunaix/fs/devfs.h>
 #include <lunaix/spike.h>
 
-#include <usr/lunaix/dirent_defs.h>
+#include <usr/lunaix/dirent.h>
 
 extern struct v_inode_ops devfs_inode_ops;
 extern struct v_file_ops devfs_file_ops;
index b022d425d7880cc863476bffd5090de804a64865..a4dcb10ba32b5a0a0906ecd3e8e305ecc1552ebe 100644 (file)
@@ -6,7 +6,7 @@
 
 #include <klibc/string.h>
 
-#include <usr/lunaix/dirent_defs.h>
+#include <usr/lunaix/dirent.h>
 
 extern struct cake_pile* drec_cache_pile;
 
index 246e90327cc3219af3f03d418c0fba366dc4aea6..df0942bdce955a26c5cfacaaf05f3db2dab9334d 100644 (file)
@@ -3,7 +3,7 @@
 #include <lunaix/process.h>
 #include <lunaix/spike.h>
 
-#include <usr/lunaix/fcntl_defs.h>
+#include <usr/lunaix/fcntl.h>
 
 #include <klibc/string.h>
 
index 2402cc57438e7b95a63944dd7dc7779656fe7928..8bcb64430d9b2eac65f8414c6075f7dbf76f988b 100644 (file)
@@ -55,7 +55,7 @@
 
 #include <lunaix/fs/twifs.h>
 
-#include <usr/lunaix/dirent_defs.h>
+#include <usr/lunaix/dirent.h>
 
 #define INODE_ACCESSED  0
 #define INODE_MODIFY    1
index 493d26cf3fe0876df64b1d5594f64fcfda67bd01..ac23bd6ffe0509d0e27e328b11eed9b1ee1a6ba7 100644 (file)
@@ -7,7 +7,7 @@
 
 #include <asm/mm_defs.h>
 
-#include <usr/lunaix/mann_flags.h>
+#include <usr/lunaix/mman.h>
 
 // any size beyond this is bullshit
 #define BS_SIZE (KERNEL_RESIDENT - USR_MMAP)
index 2015aec4ecbee608e0bffda7251078c19849f3ba..8ab3d65d6555204a31073de63958a3f135de9a72 100644 (file)
@@ -8,7 +8,7 @@
 #include <klibc/strfmt.h>
 #include <klibc/string.h>
 
-#include <usr/lunaix/dirent_defs.h>
+#include <usr/lunaix/dirent.h>
 
 #define COUNTER_MASK ((1 << 16) - 1)
 
index 9895780868e743be2f6d6d8e3376899706df1a66..5d6d2af897512b574a17f21f3772dd2290a90198 100644 (file)
@@ -34,6 +34,8 @@ $(kbuild_dir):
        @mkdir -p $(os_img_dir)/usr
 
 .PHONY: kernel
+.PHONY: rootfs all clean-user clean tool
+
 export BUILD_DIR=$(kbin_dir)
 export BUILD_NAME=$(kbin)
 kernel: $(lbuild_mkinc)
@@ -41,32 +43,32 @@ kernel: $(lbuild_mkinc)
 
        @$(MAKE) $(MKFLAGS) -I $(mkinc_dir) -f kernel.mk all
 
-.PHONY: rootfs all clean-user clean tool
-
-tool:
-       $(call status,TASK,$@)
-       @$(MAKE) $(MKFLAGS) -C scripts all -I $(mkinc_dir)
-
 .NOTPARALLEL:
 export LBUILD ARCH MODE
 all: $(kbuild_dir) tool kernel
 
-rootfs: usr/build
-       $(call status,TASK,$(notdir $@))
-       @./scripts/mkrootfs
+# --- begin stock user --- #
 
-usr/build: user
-
-prepare: $(os_img_dir)
+export PREFIX=usr/includes
+usr/includes: install-header
 
 export LBUILD ARCH MODE
-user:
+user: usr/includes
        $(call status,TASK,$@)
        @$(MAKE) $(MKFLAGS) -C usr all -I $(mkinc_dir)
 
 clean-user:
        @$(MAKE) -C usr clean -I $(mkinc_dir)
 
+rootfs: usr/build
+       $(call status,TASK,$(notdir $@))
+       @./scripts/mkrootfs
+
+usr/build: user
+
+# --- end stock user --- #
+
+
 clean:
        @$(MAKE) $(MKFLAGS) -C usr clean -I $(mkinc_dir)
        @$(MAKE) $(MKFLAGS) -C scripts clean -I $(mkinc_dir)
@@ -76,6 +78,18 @@ clean:
        @rm -rf $(kbuild_dir) || exit 1
        @rm -rf .builder || exit 1
 
+
+# --- begin misc --- #
+
 export CFLAGS=-include $(lbuild_config_h)
 unit-test: $(lbuild_config_h)
-       @$(MAKE) $(MKFLAGS) -C tests/units run 
\ No newline at end of file
+       @$(MAKE) $(MKFLAGS) -C tests/units run 
+
+tool:
+       $(call status,TASK,$@)
+       @$(MAKE) $(MKFLAGS) -C scripts all -I $(mkinc_dir)
+
+install-header:
+       @$(MAKE) $(MKFLAGS) -I $(mkinc_dir) -f install_headers.mk all
+
+# --- end misc --- #
\ No newline at end of file
diff --git a/lunaix-os/makeinc/kbuild_deps.mkinc b/lunaix-os/makeinc/kbuild_deps.mkinc
new file mode 100644 (file)
index 0000000..92e11b1
--- /dev/null
@@ -0,0 +1,15 @@
+include toolchain.mkinc
+include lunabuild.mkinc
+include utils.mkinc
+
+include $(lbuild_mkinc)
+
+ksrc_objs := $(addsuffix .o,$(_LBUILD_SRCS))
+ksrc_deps := $(addsuffix .d,$(_LBUILD_SRCS))
+khdr_opts := $(addprefix -include ,$(_LBUILD_HDRS))
+kinc_opts := $(addprefix -I,$(_LBUILD_INCS))
+config_h += -include $(lbuild_config_h)
+
+kcflags := $(khdr_opts) $(kinc_opts) $(config_h)
+
+-include $(ksrc_deps)
\ No newline at end of file
diff --git a/lunaix-os/scripts/gen-syscall-header b/lunaix-os/scripts/gen-syscall-header
new file mode 100755 (executable)
index 0000000..b32a52d
--- /dev/null
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+outfile="$1"
+
+read -d '' payload <<EOF
+#define SYSCALL(x) __NR##x __COUNTER__
+#include <asm/syscall_nr.inc>
+EOF
+
+body=$(echo "$payload" \
+      | gcc $CFLAGS -x none -E - -o- -nostdlib -P \
+      | sed -e 's/^__NR__/#define __NR__/' \
+      | sed -e '/#define/!d')
+
+cat <<EOF > "$outfile" 
+#ifndef __LUNAIX_SYSCALL_H
+#define __LUNAIX_SYSCALL_H
+
+$body
+
+#endif
+EOF
\ No newline at end of file
index 0d7662583bbafaaa47e5d53e683d33326342800d..d9b84aa2f01228c6452face945a1c763ba2a5601 100644 (file)
@@ -2,4 +2,6 @@
 build/
 .vscode/
 
-uexec.ld
\ No newline at end of file
+uexec.ld
+
+includes/**
\ No newline at end of file
index 320bbebd3c3da3711a373d254f1e6ca143d9a0bd..0561206b9c4d4987227391bd211ce641577577ef 100644 (file)
@@ -9,7 +9,6 @@ sources([
     "maze",
     "mkdir",
     "rm",
-    "testfork",
     "fragfile",
 ])
 
diff --git a/lunaix-os/usr/includes b/lunaix-os/usr/includes
deleted file mode 120000 (symlink)
index 6e4b52e..0000000
+++ /dev/null
@@ -1 +0,0 @@
-../includes/usr
\ No newline at end of file
index 804b8f82199a210660ba6ff5029073e710429b95..67a73f995835e71442612ce38f7f63fcc721f058 100644 (file)
@@ -1,11 +1,13 @@
 #include <errno.h>
 #include <fcntl.h>
-#include <lunaix/lunaix.h>
-#include <lunaix/mount.h>
+#include <sys/wait.h>
+#include <sys/mount.h>
 #include <termios.h>
 #include <stdio.h>
 #include <unistd.h>
 
+#include <sys/lunaix.h>
+
 #define must_mount(src, target, fs, opts)                                      \
     do {                                                                       \
         int err = 0;                                                           \
index 1418068d4a32aceb63be88dc0383905bc727a1cc..49fbcb771026e35ff2f386df956563e1bab3ca7e 100644 (file)
@@ -24,7 +24,7 @@
         
     1:
         movl %eax, %ebx
-        movl $__SYSCALL__exit, %eax
+        movl $__NR__lxsys_exit, %eax
         int $33
 
         ud2 // should not reach
\ No newline at end of file
index 3ff23e27adc6463df2d75beb436b481ffeb3b6dd..378dce4b561f6336a53ee0178e29c9377d82892c 100644 (file)
@@ -15,7 +15,7 @@
 
         addl $12, %esp
         
-        movl $__SYSCALL_sigreturn, %eax
+        movl $__NR__lxsys_sigreturn, %eax
         popl %ebx
         int $33
 
@@ -28,5 +28,5 @@
         calll *%eax
 
         movl %eax, %ebx
-        movl $__SYSCALL_th_exit, %eax
+        movl $__NR__lxsys_th_exit, %eax
         int $33
\ No newline at end of file
index 25786df1094825aa5a4e75a5c4fb8a6f87e45bf8..01c69db46f277f58ba11e9c594759eb8e60271ec 100644 (file)
@@ -21,7 +21,7 @@
         
     1:
         movq %rax, %rbx
-        movq $__SYSCALL__exit, %rax
+        movq $__NR__lxsys_exit, %rax
         int $33
 
         ud2 // should not reach
\ No newline at end of file
index 62064c2ef4ad0d0f42386f65af449f08f533ea4a..a820550873dceed67060618db35a2b80e36a127a 100644 (file)
@@ -20,7 +20,7 @@
         leaq 4(%rax), %rdx     // (struct siguctx*)&sigact
         call sig_dohandling
         
-        movq $__SYSCALL_sigreturn, %rax
+        movq $__NR__lxsys_sigreturn, %rax
         popq %rbx
         int $33
     
@@ -32,5 +32,5 @@
         callq *%rax
 
         movq %rax, %rbx
-        movq $__SYSCALL_th_exit, %rax
+        movq $__NR__lxsys_th_exit, %rax
         int $33
\ No newline at end of file
index 9748c8c90d3206bed5e1de29028f006e02c2b657..4c5bd3b10c27e37c1b18749f875c9cb6b32c5b77 100644 (file)
@@ -1,7 +1,7 @@
-#ifndef __LUNAIX_SYS_DIRENT_H
-#define __LUNAIX_SYS_DIRENT_H
+#ifndef __LUNALIBC_SYS_DIRENT_H
+#define __LUNALIBC_SYS_DIRENT_H
 
-#include <lunaix/dirent_defs.h>
+#include <lunaix/dirent.h>
 
 typedef struct
 {
@@ -27,4 +27,4 @@ readdir(DIR* dir);
 extern int
 sys_readdir(int fd, struct lx_dirent* dirent);
 
-#endif /* __LUNAIX_DIRENT_H */
+#endif /* __LUNALIBC_DIRENT_H */
index 437719067616f576ad111e9dc3ff99b071567b53..c59d5391febab8f22927521d2bcfd208b7df0395 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef __LUNAIX_SYS_ERRNO_H
-#define __LUNAIX_SYS_ERRNO_H
+#ifndef __LUNALIBC_SYS_ERRNO_H
+#define __LUNALIBC_SYS_ERRNO_H
 
 #include <lunaix/status.h>
 
@@ -7,4 +7,4 @@ extern int geterrno();
 
 #define errno (geterrno())
 
-#endif /* __LUNAIX_ERRNO_H */
+#endif /* __LUNALIBC_ERRNO_H */
index 7e89dc265662ae8fe2ddd21194e4032bcce44a48..d527c9c5dece40969d8d7580b70f49be8857e13c 100644 (file)
@@ -1,8 +1,8 @@
-#ifndef __LUNAIX_SYS_FCNTL_H
-#define __LUNAIX_SYS_FCNTL_H
+#ifndef __LUNALIBC_SYS_FCNTL_H
+#define __LUNALIBC_SYS_FCNTL_H
 
-#include <lunaix/fcntl_defs.h>
-#include <lunaix/types.h>
+#include <lunaix/fcntl.h>
+#include <sys/types.h>
 
 extern int
 open(const char* path, int flags);
@@ -10,4 +10,4 @@ open(const char* path, int flags);
 extern int
 fstat(int fd, struct file_stat* stat);
 
-#endif /* __LUNAIX_FCNTL_H */
+#endif /* __LUNALIBC_FCNTL_H */
diff --git a/lunaix-os/usr/libc/includes/lunaix/ioctl.h b/lunaix-os/usr/libc/includes/lunaix/ioctl.h
deleted file mode 100644 (file)
index b185ac2..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef __LUNAIX_SYS_IOCTL_H
-#define __LUNAIX_SYS_IOCTL_H
-
-#include <lunaix/ioctl_defs.h>
-
-int ioctl(int fd, int req, ...);
-
-#endif /* __LUNAIX_IOCTL_H */
diff --git a/lunaix-os/usr/libc/includes/lunaix/lunaix.h b/lunaix-os/usr/libc/includes/lunaix/lunaix.h
deleted file mode 100644 (file)
index c793dad..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#ifndef __LUNAIX_SYS_LUNAIX_H
-#define __LUNAIX_SYS_LUNAIX_H
-
-#include <lunaix/types.h>
-#include <stddef.h>
-
-void
-yield();
-
-pid_t
-wait(int* status);
-
-pid_t
-waitpid(pid_t pid, int* status, int flags);
-
-void
-syslog(int level, const char* fmt, ...);
-
-int
-realpathat(int fd, char* buf, size_t size);
-
-#endif /* __LUNAIX_LUNAIX_H */
diff --git a/lunaix-os/usr/libc/includes/lunaix/syscall.h b/lunaix-os/usr/libc/includes/lunaix/syscall.h
deleted file mode 100644 (file)
index 26ab167..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef __LUNAIX_OSDEPS_SYSCALL_H
-#define __LUNAIX_OSDEPS_SYSCALL_H
-
-#include <lunaix/syscallid.h>
-
-extern unsigned long
-do_lunaix_syscall(unsigned long call_id, ...);
-
-#endif /* __LUNAIX_OSDEPS_SYSCALL_H */
index 3fc925a8a78d3b68a366eccbf11f1392a5cb6ea0..8dee741c35522f5b58cf319b99fec017f22921d6 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef __LUNAIX_PTHREAD_H
-#define __LUNAIX_PTHREAD_H
+#ifndef __LUNALIBC_PTHREAD_H
+#define __LUNALIBC_PTHREAD_H
 
 #include <lunaix/threads.h>
 
@@ -30,4 +30,4 @@ pthread_t pthread_self(void);
 
 
 
-#endif /* __LUNAIX_PTHREAD_H */
+#endif /* __LUNALIBC_PTHREAD_H */
index 4d934efd060df9076a149d26753c81a5991054ca..fbf8c7c7d4aee3742536a0dc716b172bad63e7e1 100644 (file)
@@ -1,8 +1,8 @@
-#ifndef __LUNAIX_SYS_SIGNAL_H
-#define __LUNAIX_SYS_SIGNAL_H
+#ifndef __LUNALIBC_SYS_SIGNAL_H
+#define __LUNALIBC_SYS_SIGNAL_H
 
-#include <lunaix/signal_defs.h>
-#include <lunaix/types.h>
+#include <lunaix/signal.h>
+#include <sys/types.h>
 
 extern sighandler_t
 signal(int signum, sighandler_t handler);
@@ -29,4 +29,4 @@ int
 pthread_sigmask(int how, const sigset_t *restrict set,
                     sigset_t *restrict oset);
 
-#endif /* __LUNAIX_SIGNAL_H */
+#endif /* __LUNALIBC_SIGNAL_H */
index f62e46e035bd118c42040d6032a6b5fba64b9857..5aae9fa5ff38cad1e7eae087f8e84cae5c298724 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef __LUNAIX_USTDIO_H
-#define __LUNAIX_USTDIO_H
+#ifndef __LUNALIBC_USTDIO_H
+#define __LUNALIBC_USTDIO_H
 
 #include <stdarg.h>
 
@@ -15,4 +15,4 @@ vsnprintf(char* buffer, unsigned int size, const char* fmt, va_list ap);
 int
 snprintf(char* buffer, unsigned int size, const char* fmt, ...);
 
-#endif /* __LUNAIX_USTDIO_H */
+#endif /* __LUNALIBC_USTDIO_H */
index 72bd6636d079f81511cf0175e531eeb52cb517ff..2200a913698a70d9b8cec4bcb9ad3eed037bf02c 100644 (file)
@@ -1,6 +1,6 @@
-#ifndef __LUNAIX_STDLIB_H
-#define __LUNAIX_STDLIB_H
+#ifndef __LUNALIBC_STDLIB_H
+#define __LUNALIBC_STDLIB_H
 
 extern char* itoa(int value, char* str, int base);
 
-#endif /* __LUNAIX_STDLIB_H */
+#endif /* __LUNALIBC_STDLIB_H */
index e9313b7805b890d9d3aeaaee6ddaf2afd5a9be4a..333667173484e1a046fedf836deff2d61c357e1c 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef __LUNAIX_STRING_H
-#define __LUNAIX_STRING_H
+#ifndef __LUNALIBC_STRING_H
+#define __LUNALIBC_STRING_H
 
 #include <stddef.h>
 
@@ -15,4 +15,4 @@ extern char* strcpy(char* dest, const char* src);
 
 extern int strcmp(const char* s1, const char* s2);
 
-#endif /* __LUNAIX_STRING_H */
+#endif /* __LUNALIBC_STRING_H */
diff --git a/lunaix-os/usr/libc/includes/sys/ioctl.h b/lunaix-os/usr/libc/includes/sys/ioctl.h
new file mode 100644 (file)
index 0000000..70a621d
--- /dev/null
@@ -0,0 +1,8 @@
+#ifndef __LUNALIBC_SYS_IOCTL_H
+#define __LUNALIBC_SYS_IOCTL_H
+
+#include <lunaix/ioctl.h>
+
+int ioctl(int fd, int req, ...);
+
+#endif /* __LUNALIBC_IOCTL_H */
diff --git a/lunaix-os/usr/libc/includes/sys/lunaix.h b/lunaix-os/usr/libc/includes/sys/lunaix.h
new file mode 100644 (file)
index 0000000..6500436
--- /dev/null
@@ -0,0 +1,16 @@
+#ifndef __LUNALIBC_SYS_LUNAIX_H
+#define __LUNALIBC_SYS_LUNAIX_H
+
+#include <sys/types.h>
+#include <stddef.h>
+
+void
+yield();
+
+void
+syslog(int level, const char* fmt, ...);
+
+int
+realpathat(int fd, char* buf, size_t size);
+
+#endif /* __LUNALIBC_LUNAIX_H */
similarity index 50%
rename from lunaix-os/usr/libc/includes/lunaix/mann.h
rename to lunaix-os/usr/libc/includes/sys/mman.h
index 2527572c6e86a26fc4cea8ee304beb8b937ffb6d..0ddf7652d87a30eae6588e2641009da02f385655 100644 (file)
@@ -1,12 +1,12 @@
-#ifndef __LUNAIX_SYS_MANN_H
-#define __LUNAIX_SYS_MANN_H
+#ifndef __LUNALIBC_SYS_MANN_H
+#define __LUNALIBC_SYS_MANN_H
 
 #include <stddef.h>
-#include <lunaix/mann_flags.h>
-#include <lunaix/types.h>
+#include <lunaix/mman.h>
+#include <sys/types.h>
 
 void* mmap(void* addr, size_t length, int proct, int flags, int fd, off_t offset);
 
 int munmap(void* addr, size_t length);
 
-#endif /* __LUNAIX_MANN_H */
+#endif /* __LUNALIBC_MANN_H */
similarity index 64%
rename from lunaix-os/usr/libc/includes/lunaix/mount.h
rename to lunaix-os/usr/libc/includes/sys/mount.h
index 4f41c70ecb3627c48460edb4d7f67e2f29966cb7..156810af7c249af1c3afdc4d7035c92d4c44a54a 100644 (file)
@@ -1,7 +1,7 @@
-#ifndef __LUNAIX_SYS_MOUNT_H
-#define __LUNAIX_SYS_MOUNT_H
+#ifndef __LUNALIBC_SYS_MOUNT_H
+#define __LUNALIBC_SYS_MOUNT_H
 
-#include <lunaix/types.h>
+#include <sys/types.h>
 
 extern int mount(const char* source, const char* target, const char* fstype, int flags);
 
@@ -11,4 +11,4 @@ static inline int umount(const char* target)
 {
   return unmount(target);
 }
-#endif /* __LUNAIX_MOUNT_H */
+#endif /* __LUNALIBC_MOUNT_H */
diff --git a/lunaix-os/usr/libc/includes/sys/types.h b/lunaix-os/usr/libc/includes/sys/types.h
new file mode 100644 (file)
index 0000000..34c629d
--- /dev/null
@@ -0,0 +1,17 @@
+#ifndef __LUNAIX_TYPES_H
+#define __LUNAIX_TYPES_H
+
+#include <lunaix/types.h>
+
+typedef __lunaix_pid_t      pid_t;
+typedef __lunaix_tid_t      tid_t;
+typedef __lunaix_uid_t      uid_t;
+typedef __lunaix_gid_t      gid_t;
+typedef __lunaix_size_t     size_t;
+typedef __lunaix_ssize_t    ssize_t;
+typedef __lunaix_size_t     off_t;
+typedef __lunaix_ino_t      ino_t;
+
+typedef __lunaix_dev_t       dev_t;
+
+#endif /* __LUNAIX_TYPES_H */
diff --git a/lunaix-os/usr/libc/includes/sys/wait.h b/lunaix-os/usr/libc/includes/sys/wait.h
new file mode 100644 (file)
index 0000000..23f3447
--- /dev/null
@@ -0,0 +1,13 @@
+#ifndef __LUNAIX_WAIT_H
+#define __LUNAIX_WAIT_H
+
+#include <lunaix/wait.h>
+#include <sys/types.h>
+
+pid_t
+wait(int* status);
+
+pid_t
+waitpid(pid_t pid, int* status, int flags);
+
+#endif /* __LUNAIX_WAIT_H */
diff --git a/lunaix-os/usr/libc/includes/syscall.h b/lunaix-os/usr/libc/includes/syscall.h
new file mode 100644 (file)
index 0000000..4ec2a2a
--- /dev/null
@@ -0,0 +1,8 @@
+#ifndef __LUNALIBC_SYSCALL_H
+#define __LUNALIBC_SYSCALL_H
+
+#include <lunaix/syscallid.h>
+
+unsigned long do_lunaix_syscall(int num, ...);
+
+#endif /* __LUNALIBC_SYSCALL_H */
index abdcf8562b1321b523a29315215b0bfea7f308b1..aa4478dc06a540f1b2430bc1cfe031cf5de48cbb 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef __LUNAIX_TERMIOS_H
-#define __LUNAIX_TERMIOS_H
+#ifndef __LUNALIBC_TERMIOS_H
+#define __LUNALIBC_TERMIOS_H
 
 #include <lunaix/term.h>
 
@@ -118,4 +118,4 @@ int     tcgetattr(int, struct termios *);
 int     tcsendbreak(int, int);
 int     tcsetattr(int, int, const struct termios *);
 
-#endif /* __LUNAIX_TERMIOS_H */
+#endif /* __LUNALIBC_TERMIOS_H */
index fc607faa45eb41304631371c31e9e29e9297a695..355197cec4f27f2e623e32a7f5e8f6f657b79b51 100644 (file)
@@ -1,7 +1,7 @@
-#ifndef __LUNAIX_SYS_UNISTD_H
-#define __LUNAIX_SYS_UNISTD_H
+#ifndef __LUNALIBC_SYS_UNISTD_H
+#define __LUNALIBC_SYS_UNISTD_H
 
-#include <lunaix/types.h>
+#include <sys/types.h>
 #include <stddef.h>
 
 extern const char** environ;
@@ -111,4 +111,4 @@ fsetxattr(int fd, const char* name, void* value, size_t len);
 extern int
 execve(const char* filename, const char* argv[], const char* envp[]);
 
-#endif /* __LUNAIX_UNISTD_H */
+#endif /* __LUNALIBC_UNISTD_H */
index 6651d5e84c2868bd987ebb708ca2493ce8c3613f..ff261d07d63c1d86b3f94cf863ea5b8f46a91418 100644 (file)
@@ -1,8 +1,8 @@
-#include <lunaix/syscall.h>
-#include <lunaix/dirent_defs.h>
+#include <syscall.h>
+#include <lunaix/dirent.h>
 
 int
 sys_readdir(int fd, struct lx_dirent* dirent)
 {
-    return do_lunaix_syscall(__SYSCALL_sys_readdir, fd, dirent);
+    return do_lunaix_syscall(__NR__lxsys_sys_readdir, fd, dirent);
 }
\ No newline at end of file
index 1652995596ac03e9affea28973ab06330b10316b..b81b84bffa76f5c46522f640de94c63a099498e3 100644 (file)
@@ -1,8 +1,8 @@
-#include <lunaix/syscall.h>
+#include <syscall.h>
 #include <errno.h>
 
 int
 geterrno()
 {
-    return do_lunaix_syscall(__SYSCALL_geterrno);
+    return do_lunaix_syscall(__NR__lxsys_geterrno);
 }
\ No newline at end of file
index 28f1ff36e774de7dc84ed76eaec8a101ac5eaaf4..f8c319e7f4be96223380f3f4bd3bab1c6752efd3 100644 (file)
@@ -1,14 +1,14 @@
-#include <lunaix/syscall.h>
+#include <syscall.h>
 #include <fcntl.h>
 
 int
 open(const char* path, int options)
 {
-    return do_lunaix_syscall(__SYSCALL_open, path, options);
+    return do_lunaix_syscall(__NR__lxsys_open, path, options);
 }
 
 int
 fstat(int fd, struct file_stat* stat)
 {
-    return do_lunaix_syscall(__SYSCALL_fstat, fd, stat);
+    return do_lunaix_syscall(__NR__lxsys_fstat, fd, stat);
 }
\ No newline at end of file
index d3a89a8106a70781ac18b85633505ab20227d362..3585a059cbb2057d40be874916cfc6f05a78415d 100644 (file)
@@ -1,5 +1,5 @@
-#include <lunaix/syscall.h>
-#include <lunaix/ioctl.h>
+#include <syscall.h>
+#include <sys/ioctl.h>
 #include <stdarg.h>
 
 int __attribute__((noinline))
@@ -8,7 +8,7 @@ ioctl(int fd, int req, ...)
     va_list ap;
     va_start(ap, req);
 
-    int ret = do_lunaix_syscall(__SYSCALL_ioctl, fd, req, &ap);
+    int ret = do_lunaix_syscall(__NR__lxsys_ioctl, fd, req, &ap);
     
     va_end(ap);
     return ret;
index 452f02ddbfd773a0ce88c1140f57d0e3cbbff1e9..deba1017108750057c8724a03f3950bcd670d02c 100644 (file)
@@ -1,23 +1,23 @@
-#include <lunaix/syscall.h>
-#include <lunaix/types.h>
+#include <syscall.h>
+#include <sys/types.h>
 #include <stdio.h>
 
 void
 yield()
 {
-    do_lunaix_syscall(__SYSCALL_yield);
+    do_lunaix_syscall(__NR__lxsys_yield);
 }
 
 pid_t
 wait(int* status)
 {
-    return do_lunaix_syscall(__SYSCALL_wait, status);
+    return do_lunaix_syscall(__NR__lxsys_wait, status);
 }
 
 pid_t
 waitpid(pid_t pid, int* status, int options)
 {
-    return do_lunaix_syscall(__SYSCALL_waitpid, pid, status, options);
+    return do_lunaix_syscall(__NR__lxsys_waitpid, pid, status, options);
 }
 
 void
@@ -28,7 +28,7 @@ syslog(int level, const char* fmt, ...)
     va_start(ap, fmt);
 
     unsigned int size = vsnprintf(buf, 1024, fmt, ap);
-    do_lunaix_syscall(__SYSCALL_syslog, level, buf, size);
+    do_lunaix_syscall(__NR__lxsys_syslog, level, buf, size);
 
     va_end(ap);
 }
@@ -36,5 +36,5 @@ syslog(int level, const char* fmt, ...)
 int
 realpathat(int fd, char* buf, size_t size)
 {
-    return do_lunaix_syscall(__SYSCALL_realpathat, fd, buf, size);
+    return do_lunaix_syscall(__NR__lxsys_realpathat, fd, buf, size);
 }
\ No newline at end of file
index f2fe1865fe4246e82331b5f988cdf785a0549623..1481c122a4a5ec6bbf522e07813573833219e0fe 100644 (file)
@@ -1,6 +1,6 @@
-#include <lunaix/syscall.h>
-#include <lunaix/mann.h>
-#include <lunaix/types.h>
+#include <syscall.h>
+#include <sys/mman.h>
+#include <sys/types.h>
 
 void*
 mmap(void* addr, size_t length, int proct, int flags, int fd, off_t offset)
@@ -14,11 +14,11 @@ mmap(void* addr, size_t length, int proct, int flags, int fd, off_t offset)
         .offset = offset
     };
 
-    return (void*)do_lunaix_syscall(__SYSCALL_sys_mmap, &mparam);
+    return (void*)do_lunaix_syscall(__NR__lxsys_sys_mmap, &mparam);
 }
 
 int
 munmap(void* addr, size_t length)
 {
-    return do_lunaix_syscall(__SYSCALL_munmap, addr, length);
+    return do_lunaix_syscall(__NR__lxsys_munmap, addr, length);
 }
index 930930ca91c8ea5df0a8c0dbc9fd60eaa405a0a9..a44a8791701947a094dd3ffc109539f4426bec65 100644 (file)
@@ -1,14 +1,14 @@
-#include <lunaix/syscall.h>
+#include <syscall.h>
 
 int
 mount(const char* source, const char* target,
       const char* fstype, int options)
 {
-    return do_lunaix_syscall(__SYSCALL_mount, source, target, fstype, options);
+    return do_lunaix_syscall(__NR__lxsys_mount, source, target, fstype, options);
 }
 
 int
 unmount(const char* target)
 {
-    return do_lunaix_syscall(__SYSCALL_unmount, target);
+    return do_lunaix_syscall(__NR__lxsys_unmount, target);
 }
\ No newline at end of file
index 8c93fa208ed72c57eeaed65f8409b6dd57731e0b..17a83fe0e07bae6660712acccea6e23f02b238da 100644 (file)
@@ -1,35 +1,35 @@
-#include <lunaix/syscall.h>
-#include <lunaix/signal_defs.h>
-#include <lunaix/types.h>
+#include <syscall.h>
+#include <lunaix/signal.h>
+#include <sys/types.h>
 
 int
 sigpending(sigset_t *set)
 {
-    return do_lunaix_syscall(__SYSCALL_sigpending, set);
+    return do_lunaix_syscall(__NR__lxsys_sigpending, set);
 }
 
 int
 sigsuspend(const sigset_t *mask)
 {
-    return do_lunaix_syscall(__SYSCALL_sigsuspend, mask);
+    return do_lunaix_syscall(__NR__lxsys_sigsuspend, mask);
 }
 
 int
 sigprocmask(int how, const sigset_t *set, sigset_t *oldset)
 {
-    return do_lunaix_syscall(__SYSCALL_sigprocmask, how, set, oldset);
+    return do_lunaix_syscall(__NR__lxsys_sigprocmask, how, set, oldset);
 }
 
 int
 sys_sigaction(int signum, struct sigaction* action)
 {
-    return do_lunaix_syscall(__SYSCALL_sys_sigaction, signum, action);
+    return do_lunaix_syscall(__NR__lxsys_sys_sigaction, signum, action);
 }
 
 int
 kill(pid_t pid, int signum)
 {
-    return do_lunaix_syscall(__SYSCALL_kill, pid, signum);
+    return do_lunaix_syscall(__NR__lxsys_kill, pid, signum);
 }
 
 extern void
index 8e17324c0ba8a260da8490a6e89c39e7028a245a..b6234ed51b460d8f5195eb0574f8c1d1103533d4 100644 (file)
-#include <lunaix/syscall.h>
-#include <lunaix/types.h>
+#include <syscall.h>
+#include <sys/types.h>
 
 pid_t
 fork()
 {
-    return do_lunaix_syscall(__SYSCALL_fork);
+    return do_lunaix_syscall(__NR__lxsys_fork);
 }
 
 int
 brk(void* addr)
 {
-    return do_lunaix_syscall(__SYSCALL_brk, addr);
+    return do_lunaix_syscall(__NR__lxsys_brk, addr);
 }
 
 void*
 sbrk(ssize_t size)
 {
-    return (void*)do_lunaix_syscall(__SYSCALL_sbrk, size);
+    return (void*)do_lunaix_syscall(__NR__lxsys_sbrk, size);
 }
 
 pid_t
 getpid()
 {
-    return do_lunaix_syscall(__SYSCALL_getpid);
+    return do_lunaix_syscall(__NR__lxsys_getpid);
 }
 
 pid_t
 getppid()
 {
-    return do_lunaix_syscall(__SYSCALL_getppid);
+    return do_lunaix_syscall(__NR__lxsys_getppid);
 }
 
 pid_t
 getpgid()
 {
-    return do_lunaix_syscall(__SYSCALL_getpgid);
+    return do_lunaix_syscall(__NR__lxsys_getpgid);
 }
 
 pid_t
 setpgid(pid_t pid, pid_t pgid)
 {
-    return do_lunaix_syscall(__SYSCALL_setpgid, pid, pgid);
+    return do_lunaix_syscall(__NR__lxsys_setpgid, pid, pgid);
 }
 void
 _exit(int status)
 {
-    do_lunaix_syscall(__SYSCALL__exit, status);
+    do_lunaix_syscall(__NR__lxsys_exit, status);
 }
 
 unsigned int
 sleep(unsigned int seconds)
 {
-    return do_lunaix_syscall(__SYSCALL_sleep, seconds);
+    return do_lunaix_syscall(__NR__lxsys_sleep, seconds);
 }
 
 int
 pause()
 {
-    return do_lunaix_syscall(__SYSCALL_pause);
+    return do_lunaix_syscall(__NR__lxsys_pause);
 }
 
 unsigned int
 alarm(unsigned int seconds)
 {
-    return do_lunaix_syscall(__SYSCALL_alarm, seconds);
+    return do_lunaix_syscall(__NR__lxsys_alarm, seconds);
 }
 
 int
 link(const char* oldpath, const char* newpath)
 {
-    return do_lunaix_syscall(__SYSCALL_link, oldpath, newpath);
+    return do_lunaix_syscall(__NR__lxsys_link, oldpath, newpath);
 }
 
 int
 rmdir(const char* pathname)
 {
-    return do_lunaix_syscall(__SYSCALL_rmdir, pathname);
+    return do_lunaix_syscall(__NR__lxsys_rmdir, pathname);
 }
 
 int
 read(int fd, void* buf, size_t count)
 {
-    return do_lunaix_syscall(__SYSCALL_read, fd, buf, count);
+    return do_lunaix_syscall(__NR__lxsys_read, fd, buf, count);
 }
 
 int
 write(int fd, void* buf, size_t count)
 {
-    return do_lunaix_syscall(__SYSCALL_write, fd, buf, count);
+    return do_lunaix_syscall(__NR__lxsys_write, fd, buf, count);
 }
 
 int
 readlink(const char* path, char* buf, size_t size)
 {
-    return do_lunaix_syscall(__SYSCALL_readlink, path, buf, size);
+    return do_lunaix_syscall(__NR__lxsys_readlink, path, buf, size);
 }
 
 int
 lseek(int fd, off_t offset, int options)
 {
-    return do_lunaix_syscall(__SYSCALL_lseek, fd, offset, options);
+    return do_lunaix_syscall(__NR__lxsys_lseek, fd, offset, options);
 }
 
 int
 unlink(const char* pathname)
 {
-    return do_lunaix_syscall(__SYSCALL_unlink, pathname);
+    return do_lunaix_syscall(__NR__lxsys_unlink, pathname);
 }
 
 int
 close(int fd)
 {
-    return do_lunaix_syscall(__SYSCALL_close, fd);
+    return do_lunaix_syscall(__NR__lxsys_close, fd);
 }
 
 int
 dup2(int oldfd, int newfd)
 {
-    return do_lunaix_syscall(__SYSCALL_dup2, oldfd, newfd);
+    return do_lunaix_syscall(__NR__lxsys_dup2, oldfd, newfd);
 }
 
 int
 dup(int oldfd)
 {
-    return do_lunaix_syscall(__SYSCALL_dup, oldfd);
+    return do_lunaix_syscall(__NR__lxsys_dup, oldfd);
 }
 
 int
 fsync(int fildes)
 {
-    return do_lunaix_syscall(__SYSCALL_fsync, fildes);
+    return do_lunaix_syscall(__NR__lxsys_fsync, fildes);
 }
 
 int
 symlink(const char* pathname, const char* link_target)
 {
-    return do_lunaix_syscall(__SYSCALL_symlink, pathname, link_target);
+    return do_lunaix_syscall(__NR__lxsys_symlink, pathname, link_target);
 }
 
 int
 chdir(const char* path)
 {
-    return do_lunaix_syscall(__SYSCALL_chdir, path);
+    return do_lunaix_syscall(__NR__lxsys_chdir, path);
 }
 
 int
 fchdir(int fd)
 {
-    return do_lunaix_syscall(__SYSCALL_fchdir, fd);
+    return do_lunaix_syscall(__NR__lxsys_fchdir, fd);
 }
 
 char*
 getcwd(char* buf, size_t size)
 {
-    return (char*)do_lunaix_syscall(__SYSCALL_getcwd, buf, size);
+    return (char*)do_lunaix_syscall(__NR__lxsys_getcwd, buf, size);
 }
 
 int
 rename(const char* oldpath, const char* newpath)
 {
-    return do_lunaix_syscall(__SYSCALL_rename, oldpath, newpath);
+    return do_lunaix_syscall(__NR__lxsys_rename, oldpath, newpath);
 }
 
 int
 getxattr(const char* path, const char* name, void* value, size_t len)
 {
-    return do_lunaix_syscall(__SYSCALL_getxattr, path, name, value, len);
+    return do_lunaix_syscall(__NR__lxsys_getxattr, path, name, value, len);
 }
 
 int
 setxattr(const char* path, const char* name, void* value, size_t len)
 {
-    return do_lunaix_syscall(__SYSCALL_setxattr, path, name, value, len);
+    return do_lunaix_syscall(__NR__lxsys_setxattr, path, name, value, len);
 }
 
 int
 fgetxattr(int fd, const char* name, void* value, size_t len)
 {
-    return do_lunaix_syscall(__SYSCALL_fgetxattr, fd, name, value, len);
+    return do_lunaix_syscall(__NR__lxsys_fgetxattr, fd, name, value, len);
 }
 
 int
 fsetxattr(int fd, const char* name, void* value, size_t len)
 {
-    return do_lunaix_syscall(__SYSCALL_fsetxattr, fd, name, value, len);
+    return do_lunaix_syscall(__NR__lxsys_fsetxattr, fd, name, value, len);
 }
 
 int
 readlinkat(int dirfd, const char* pathname, char* buf, size_t size)
 {
-    return do_lunaix_syscall(__SYSCALL_readlinkat, dirfd, pathname, buf, size);
+    return do_lunaix_syscall(__NR__lxsys_readlinkat, dirfd, pathname, buf, size);
 }
 
 int
 unlinkat(int fd, const char* pathname)
 {
-    return do_lunaix_syscall(__SYSCALL_unlinkat, fd, pathname);
+    return do_lunaix_syscall(__NR__lxsys_unlinkat, fd, pathname);
 }
 
 int
 mkdir(const char* path)
 {
-    return do_lunaix_syscall(__SYSCALL_mkdir, path);
+    return do_lunaix_syscall(__NR__lxsys_mkdir, path);
 }
 
 int
 execve(const char* filename, const char** argv, const char** envp)
 {
-    return do_lunaix_syscall(__SYSCALL_execve, filename, argv, envp);
+    return do_lunaix_syscall(__NR__lxsys_execve, filename, argv, envp);
 }
index 26d6abfb18c4f50a8bdc3fd5015094ba0853fb95..5a51b1c7ef4b821b6f48caf14b078cfbf28376aa 100644 (file)
@@ -1,4 +1,4 @@
-#include <lunaix/syscall.h>
+#include <syscall.h>
 #include <pthread.h>
 
 int 
@@ -14,7 +14,7 @@ pthread_create(pthread_t* thread,
     th_param.arg1 = arg;
 
     extern void th_trampoline();
-    ret = do_lunaix_syscall(__SYSCALL_th_create, thread, 
+    ret = do_lunaix_syscall(__NR__lxsys_th_create, thread, 
                             &th_param, th_trampoline);
     return ret;
 }
@@ -22,29 +22,29 @@ pthread_create(pthread_t* thread,
 int 
 pthread_detach(pthread_t thread)
 {
-    return do_lunaix_syscall(__SYSCALL_th_detach, thread);
+    return do_lunaix_syscall(__NR__lxsys_th_detach, thread);
 }
 
 void 
 pthread_exit(void *value_ptr)
 {
-    do_lunaix_syscall(__SYSCALL_th_exit, value_ptr);
+    do_lunaix_syscall(__NR__lxsys_th_exit, value_ptr);
 }
 
 int 
 pthread_join(pthread_t thread, void **value_ptr)
 {
-    return do_lunaix_syscall(__SYSCALL_th_join, thread, value_ptr);
+    return do_lunaix_syscall(__NR__lxsys_th_join, thread, value_ptr);
 }
 
 int 
 pthread_kill(pthread_t thread, int sig)
 {
-    return do_lunaix_syscall(__SYSCALL_th_kill, thread, sig);
+    return do_lunaix_syscall(__NR__lxsys_th_kill, thread, sig);
 }
 
 pthread_t 
 pthread_self(void)
 {
-    return do_lunaix_syscall(__SYSCALL_th_self);
+    return do_lunaix_syscall(__NR__lxsys_th_self);
 }
index 52c97e4b609fd99b2f2fb952d9482201c3b57ebe..6c20ece800d4c68ca6f7be79cd9efad7008be917 100644 (file)
@@ -1,5 +1,5 @@
 #include <termios.h>
-#include <lunaix/ioctl.h>
+#include <sys/ioctl.h>
 
 int
 tcgetattr(int fd, struct termios* termios_p) 
index 748b8142e1717fd61231c1cd0ff871a6bad9709b..e9a5211afd700433fededd2a485c4bba4fc217db 100644 (file)
@@ -1,6 +1,6 @@
 #include <errno.h>
 #include <fcntl.h>
-#include <lunaix/lunaix.h>
+#include <sys/lunaix.h>
 #include <stdio.h>
 #include <string.h>
 #include <unistd.h>
index 764404b0910a54fe50c33891b20967388c3de20e..c18b5edc0c435a690e5455bb9b4edf2ee1bce64f 100644 (file)
@@ -1,6 +1,6 @@
 #include <errno.h>
-#include <lunaix/ioctl.h>
-#include <lunaix/lunaix.h>
+#include <sys/ioctl.h>
+#include <sys/wait.h>
 #include <signal.h>
 #include <stdio.h>
 #include <string.h>
index 352d0de463db81619589c771408f86042586bac3..532b9b9f5343c5c17f89374d48d9cd01349b85f7 100644 (file)
@@ -1,4 +1,4 @@
-#include <lunaix/lunaix.h>
+#include <sys/wait.h>
 #include <signal.h>
 #include <stdio.h>
 #include <unistd.h>
index 1bd79f3a25a270720b0ff8b9a509f41819c3808c..3e782e96a428dd658304efaf6418c3c23f32661e 100644 (file)
@@ -2,6 +2,7 @@
 #include <fcntl.h>
 #include <stdio.h>
 #include <unistd.h>
+#include <sys/types.h>
 
 static char buf[256];
 
index ee33fe6f69710ee37c05b6635dd2cb880a6763da..c7d4c3882e97aa923e78a4234e3c802517f515be 100644 (file)
@@ -1,6 +1,6 @@
 #include <errno.h>
 #include <fcntl.h>
-#include <lunaix/lunaix.h>
+#include <sys/wait.h>
 #include <stdio.h>
 #include <string.h>
 #include <unistd.h>