From b08455c4d34ca4ec8ba1eed0926846675eac6732 Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Fri, 27 Dec 2013 01:44:03 +0100 Subject: [PATCH] Remove mxmpp. --- Makefile | 4 +- doc/user-guide | 11 - libc/Makefile | 35 +-- libc/decl/DIR.h | 23 -- libc/decl/FILE.h | 5 - libc/decl/NULL.h | 4 - libc/decl/WCHAR_MAX.h | 3 - libc/decl/WCHAR_MIN.h | 3 - libc/decl/WEOF.h | 3 - libc/decl/blkcnt_t.h | 4 - libc/decl/blksize_t.h | 4 - libc/decl/clock_t.h | 4 - libc/decl/clockid_t.h | 4 - libc/decl/dev_t.h | 4 - libc/decl/gid_t.h | 4 - libc/decl/id_t.h | 4 - libc/decl/in_addr_t.h | 4 - libc/decl/in_port_t.h | 4 - libc/decl/ino_t.h | 4 - libc/decl/intptr_t.h | 4 - libc/decl/locale_t.h | 7 - libc/decl/mode_t.h | 4 - libc/decl/nlink_t.h | 4 - libc/decl/off_t.h | 4 - libc/decl/pid_t.h | 4 - libc/decl/ptrdiff_t.h | 2 - libc/decl/sa_family_t.h | 4 - libc/decl/size_t.h | 2 - libc/decl/socklen_t.h | 4 - libc/decl/ssize_t.h | 4 - libc/decl/suseconds_t.h | 4 - libc/decl/time_t.h | 4 - libc/decl/timer_t.h | 4 - libc/decl/timeval.h | 8 - libc/decl/uid_t.h | 4 - libc/decl/useconds_t.h | 4 - libc/decl/va_list.h | 9 - libc/decl/wchar_t.h | 2 - libc/decl/wctrans_t.h | 7 - libc/decl/wctype_t.h | 4 - libc/decl/wint_t.h | 5 - libc/include/FILE.h | 19 +- libc/include/alloca.h | 6 +- libc/include/dirent.h | 37 ++- libc/include/fcntl.h | 5 +- libc/include/grp.h | 19 +- libc/include/inttypes.h | 6 +- libc/include/ioleast.h | 12 +- libc/include/netdb.h | 17 +- libc/include/netinet/in.h | 23 +- libc/include/poll.h | 5 +- libc/include/pwd.h | 25 +- libc/include/signal.h | 25 +- libc/include/stdio.h | 31 ++- libc/include/stdlib.h | 19 +- libc/include/string.h | 21 +- libc/include/sys/kernelinfo.h | 12 +- libc/include/sys/mman.h | 18 +- libc/include/sys/readdirents.h | 6 +- libc/include/sys/resource.h | 33 ++- libc/include/sys/select.h | 21 +- libc/include/sys/socket.h | 24 +- libc/include/sys/stat.h | 61 ++++- libc/include/sys/time.h | 21 +- libc/include/sys/times.h | 5 +- libc/include/sys/types.h | 118 ++++++++-- libc/include/sys/uio.h | 18 +- libc/include/sys/un.h | 5 +- libc/include/sys/wait.h | 5 +- libc/include/time.h | 50 +++- libc/include/timespec.h | 5 +- libc/include/unistd.h | 52 ++++- libc/include/utime.h | 5 +- libc/include/wchar.h | 74 +++++- libc/include/wctype.h | 35 ++- mxmpp/.gitignore | 1 - mxmpp/Makefile | 35 --- mxmpp/README | 1 - mxmpp/mxmpp.cpp | 414 --------------------------------- system/Makefile | 2 - 80 files changed, 715 insertions(+), 805 deletions(-) delete mode 100644 libc/decl/DIR.h delete mode 100644 libc/decl/FILE.h delete mode 100644 libc/decl/NULL.h delete mode 100644 libc/decl/WCHAR_MAX.h delete mode 100644 libc/decl/WCHAR_MIN.h delete mode 100644 libc/decl/WEOF.h delete mode 100644 libc/decl/blkcnt_t.h delete mode 100644 libc/decl/blksize_t.h delete mode 100644 libc/decl/clock_t.h delete mode 100644 libc/decl/clockid_t.h delete mode 100644 libc/decl/dev_t.h delete mode 100644 libc/decl/gid_t.h delete mode 100644 libc/decl/id_t.h delete mode 100644 libc/decl/in_addr_t.h delete mode 100644 libc/decl/in_port_t.h delete mode 100644 libc/decl/ino_t.h delete mode 100644 libc/decl/intptr_t.h delete mode 100644 libc/decl/locale_t.h delete mode 100644 libc/decl/mode_t.h delete mode 100644 libc/decl/nlink_t.h delete mode 100644 libc/decl/off_t.h delete mode 100644 libc/decl/pid_t.h delete mode 100644 libc/decl/ptrdiff_t.h delete mode 100644 libc/decl/sa_family_t.h delete mode 100644 libc/decl/size_t.h delete mode 100644 libc/decl/socklen_t.h delete mode 100644 libc/decl/ssize_t.h delete mode 100644 libc/decl/suseconds_t.h delete mode 100644 libc/decl/time_t.h delete mode 100644 libc/decl/timer_t.h delete mode 100644 libc/decl/timeval.h delete mode 100644 libc/decl/uid_t.h delete mode 100644 libc/decl/useconds_t.h delete mode 100644 libc/decl/va_list.h delete mode 100644 libc/decl/wchar_t.h delete mode 100644 libc/decl/wctrans_t.h delete mode 100644 libc/decl/wctype_t.h delete mode 100644 libc/decl/wint_t.h delete mode 100644 mxmpp/.gitignore delete mode 100644 mxmpp/Makefile delete mode 100644 mxmpp/README delete mode 100644 mxmpp/mxmpp.cpp diff --git a/Makefile b/Makefile index 499124fd..c391c414 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ MAKEFILE_NOT_MEANT_FOR_SORTIX=1 include compiler.mak include version.mak -MODULES=doc libc libm dispd games mkinitrd mxmpp utils bench ext mbr kernel +MODULES=doc libc libm dispd games mkinitrd utils bench ext mbr kernel ifndef SYSROOT SYSROOT:=$(shell pwd)/sysroot @@ -35,13 +35,11 @@ all: sysroot .PHONY: build-tools build-tools: $(MAKE) -C mkinitrd - $(MAKE) -C mxmpp $(MAKE) -C tix .PHONY: install-build-tools install-build-tools: $(MAKE) -C mkinitrd install - $(MAKE) -C mxmpp install $(MAKE) -C tix install .PHONY: sysroot-fsh diff --git a/doc/user-guide b/doc/user-guide index 20942703..cb43a163 100644 --- a/doc/user-guide +++ b/doc/user-guide @@ -174,7 +174,6 @@ Sortix comes with a number of home-made programs. Here is an overview: * `mkdir` - create directory * `mkinitrd` - create an initrd * `mv` - move a file -* `mxmpp` - silly preprocessor * `mxsh` - the shell * `pager` - display file page by page * `pong` - remake of the classic pong game @@ -514,16 +513,6 @@ filesystem and mounts it at an empty directory. make make install -### Building mxmpp ### - -The program mxmpp is a simple and hacky macro preprocessor. It supports a special -@incude(foo_t.h) directive, which is used to pre-preprocess the headers in the C -library to avoid the overhead of repeated declarations. - - cd /src/mxmpp - make - make install - ### Building mkinitrd ### This program produces a Sortix compatible initrd, the file that contains the diff --git a/libc/Makefile b/libc/Makefile index 81f6e5b7..70a59a1f 100644 --- a/libc/Makefile +++ b/libc/Makefile @@ -9,7 +9,7 @@ endif CPUDIR:=$(CPU) -CPPINCLUDES=-I preproc +CPPINCLUDES=-Iinclude CPPFLAGS=-D__is_sortix_libc $(CPPINCLUDES) FLAGS=-Wall -Wextra $(OPTLEVEL) CFLAGS=-std=gnu99 @@ -509,12 +509,7 @@ crtn.o \ MISCOBJ=\ $(CRTOBJ) \ -UNPROCHEADERDIRS:=$(shell find include -type d) -UNPROCHEADERS:=$(shell find include -type f) -HEADERDIRS:=$(patsubst include%,preproc%,$(UNPROCHEADERDIRS)) -HEADERS:=$(patsubst include%,preproc%,$(UNPROCHEADERS)) -INSTALLHEADERDIRS:=$(addprefix $(DESTDIR)$(INCLUDEDIR),$(patsubst preproc%,%,$(HEADERDIRS))) -INSTALLHEADERS:=$(addprefix $(DESTDIR)$(INCLUDEDIR),$(patsubst preproc%,%,$(HEADERS))) +HEADERS:=$(shell find include -type d) SORTIXOBJS:=$(addprefix sortix/,$(FREEOBJS)) SORTIXCPPFLAGS:=$(CPPFLAGS) -D__is_sortix_kernel @@ -571,15 +566,7 @@ crtn.o: $(CPUDIR)/crtn.o # header preprocessing $(OBJS) $(SORTIXOBJS): $(HEADERS) -$(HEADERDIRS): - mkdir -p $@ - -preproc/%: include/% - mxmpp -I decl $< -o $@ - -$(HEADERS): | $(HEADERDIRS) - -headers: $(HEADERDIRS) $(HEADERS) +headers: # standard library %.o: %.c @@ -600,19 +587,13 @@ sortix/%.o: %.cpp clean: rm -f $(wildcard *.o) $(wildcard */*.o) $(wildcard */*/*.o) $(wildcard *.a) - rm -rf $(HEADERDIRS) # Installation into sysroot install: install-headers install-libs install-libs-kernel -$(INSTALLHEADERDIRS) $(DESTDIR)$(LIBDIR): +$(DESTDIR)$(LIBDIR): mkdir -p $@ -$(DESTDIR)$(INCLUDEDIR)/%: preproc/% - cp $< $@ - -$(INSTALLHEADERS): | $(INSTALLHEADERDIRS) - $(DESTDIR)$(LIBDIR)/%: % cp -P $< $@ @@ -620,11 +601,11 @@ $(INSTALLLIBS): | $(DESTDIR)$(LIBDIR) $(INSTALLLIBSKERNEL): | $(DESTDIR)$(LIBDIR) -$(DESTDIR)$(INCLUDEDIR) $(DESTDIR)$(LIBDIR) $(INSTALLHEADERS): FORCE +install-include-dirs: headers + mkdir -p $(DESTDIR)$(INCLUDEDIR) -install-include-dirs: $(INSTALLHEADERDIRS) - -install-headers: $(INSTALLHEADERDIRS) $(INSTALLHEADERS) +install-headers: install-include-dirs headers + cp -RTv include $(DESTDIR)$(INCLUDEDIR) install-lib-dirs: $(DESTDIR)$(LIBDIR) diff --git a/libc/decl/DIR.h b/libc/decl/DIR.h deleted file mode 100644 index f1578e48..00000000 --- a/libc/decl/DIR.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef _DIR_DECL -#define _DIR_DECL -struct dirent; - -#define _DIR_REGISTERED (1<<0) -#define _DIR_ERROR (1<<1) -#define _DIR_EOF (1<<2) -typedef struct _DIR -{ - void* user; - int (*read_func)(void* user, struct dirent* dirent, size_t* size); - int (*rewind_func)(void* user); - int (*fd_func)(void* user); - int (*close_func)(void* user); - void (*free_func)(struct _DIR* dir); - /* Application writers shouldn't use anything beyond this point. */ - struct _DIR* prev; - struct _DIR* next; - struct dirent* entry; - size_t entrysize; - int flags; -} DIR; -#endif diff --git a/libc/decl/FILE.h b/libc/decl/FILE.h deleted file mode 100644 index 8e6e8a0d..00000000 --- a/libc/decl/FILE.h +++ /dev/null @@ -1,5 +0,0 @@ -#ifndef _FILE_DECL -#define _FILE_DECL -typedef struct FILE FILE; -#define FILE FILE -#endif diff --git a/libc/decl/NULL.h b/libc/decl/NULL.h deleted file mode 100644 index f54c92c3..00000000 --- a/libc/decl/NULL.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef NULL -#define __need_NULL -#include -#endif diff --git a/libc/decl/WCHAR_MAX.h b/libc/decl/WCHAR_MAX.h deleted file mode 100644 index 9fa66500..00000000 --- a/libc/decl/WCHAR_MAX.h +++ /dev/null @@ -1,3 +0,0 @@ -#ifndef WCHAR_MAX -#define WCHAR_MAX __WCHAR_MAX -#endif diff --git a/libc/decl/WCHAR_MIN.h b/libc/decl/WCHAR_MIN.h deleted file mode 100644 index eebe2970..00000000 --- a/libc/decl/WCHAR_MIN.h +++ /dev/null @@ -1,3 +0,0 @@ -#ifndef WCHAR_MIN -#define WCHAR_MIN __WCHAR_MIN -#endif diff --git a/libc/decl/WEOF.h b/libc/decl/WEOF.h deleted file mode 100644 index 18878996..00000000 --- a/libc/decl/WEOF.h +++ /dev/null @@ -1,3 +0,0 @@ -#ifndef WEOF -#define WEOF (-1) -#endif diff --git a/libc/decl/blkcnt_t.h b/libc/decl/blkcnt_t.h deleted file mode 100644 index c9174ac0..00000000 --- a/libc/decl/blkcnt_t.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef _BLKCNT_T_DECL -#define _BLKCNT_T_DECL -typedef __blkcnt_t blkcnt_t; -#endif diff --git a/libc/decl/blksize_t.h b/libc/decl/blksize_t.h deleted file mode 100644 index 5ae42412..00000000 --- a/libc/decl/blksize_t.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef _BLKSIZE_T_DECL -#define _BLKSIZE_T_DECL -typedef __blksize_t blksize_t; -#endif diff --git a/libc/decl/clock_t.h b/libc/decl/clock_t.h deleted file mode 100644 index 86f0607a..00000000 --- a/libc/decl/clock_t.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef _CLOCK_T_DECL -#define _CLOCK_T_DECL -typedef __clock_t clock_t; -#endif diff --git a/libc/decl/clockid_t.h b/libc/decl/clockid_t.h deleted file mode 100644 index 8f526a56..00000000 --- a/libc/decl/clockid_t.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef _CLOCKID_T_DECL -#define _CLOCKID_T_DECL -typedef __clockid_t clockid_t; -#endif diff --git a/libc/decl/dev_t.h b/libc/decl/dev_t.h deleted file mode 100644 index bc99ab43..00000000 --- a/libc/decl/dev_t.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef _DEV_T_DECL -#define _DEV_T_DECL -typedef __dev_t dev_t; -#endif diff --git a/libc/decl/gid_t.h b/libc/decl/gid_t.h deleted file mode 100644 index 49e42cfd..00000000 --- a/libc/decl/gid_t.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef _GID_T_DECL -#define _GID_T_DECL -typedef __gid_t gid_t; -#endif diff --git a/libc/decl/id_t.h b/libc/decl/id_t.h deleted file mode 100644 index 2648b8e5..00000000 --- a/libc/decl/id_t.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef _ID_T_DECL -#define _ID_T_DECL -typedef __id_t id_t; -#endif diff --git a/libc/decl/in_addr_t.h b/libc/decl/in_addr_t.h deleted file mode 100644 index bc7b3cc2..00000000 --- a/libc/decl/in_addr_t.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef _IN_ADDR_T_DECL -#define _IN_ADDR_T_DECL -typedef uint32_t in_addr_t; -#endif diff --git a/libc/decl/in_port_t.h b/libc/decl/in_port_t.h deleted file mode 100644 index 46a69111..00000000 --- a/libc/decl/in_port_t.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef _IN_PORT_T_DECL -#define _IN_PORT_T_DECL -typedef uint16_t in_port_t; -#endif diff --git a/libc/decl/ino_t.h b/libc/decl/ino_t.h deleted file mode 100644 index 38c89605..00000000 --- a/libc/decl/ino_t.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef _INO_T_DECL -#define _INO_T_DECL -typedef __ino_t ino_t; -#endif diff --git a/libc/decl/intptr_t.h b/libc/decl/intptr_t.h deleted file mode 100644 index 4f69866b..00000000 --- a/libc/decl/intptr_t.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef _INTPTR_T_DECL -#define _INTPTR_T_DECL -typedef __intptr_t intptr_t; -#endif diff --git a/libc/decl/locale_t.h b/libc/decl/locale_t.h deleted file mode 100644 index 4a74fa86..00000000 --- a/libc/decl/locale_t.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef _LOCALE_T_DECL -#define _LOCALT_T_DECL -/* TODO: figure out what this does and typedef it properly. This is just a - temporary assignment. */ -typedef int __locale_t; -typedef __locale_t locale_t; -#endif diff --git a/libc/decl/mode_t.h b/libc/decl/mode_t.h deleted file mode 100644 index 6a53a9b2..00000000 --- a/libc/decl/mode_t.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef _MODE_T_DECL -#define _MODE_T_DECL -typedef __mode_t mode_t; -#endif diff --git a/libc/decl/nlink_t.h b/libc/decl/nlink_t.h deleted file mode 100644 index 3a7b2f83..00000000 --- a/libc/decl/nlink_t.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef _NLINK_T_DECL -#define _NLINK_T_DECL -typedef __nlink_t nlink_t; -#endif diff --git a/libc/decl/off_t.h b/libc/decl/off_t.h deleted file mode 100644 index e5eacfd2..00000000 --- a/libc/decl/off_t.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef _OFF_T_DECL -#define _OFF_T_DECL -typedef __off_t off_t; -#endif diff --git a/libc/decl/pid_t.h b/libc/decl/pid_t.h deleted file mode 100644 index 68441f57..00000000 --- a/libc/decl/pid_t.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef _PID_T_DECL -#define _PID_T_DECL -typedef __pid_t pid_t; -#endif diff --git a/libc/decl/ptrdiff_t.h b/libc/decl/ptrdiff_t.h deleted file mode 100644 index acb0ab81..00000000 --- a/libc/decl/ptrdiff_t.h +++ /dev/null @@ -1,2 +0,0 @@ -#define __need_ptrdiff_t -#include diff --git a/libc/decl/sa_family_t.h b/libc/decl/sa_family_t.h deleted file mode 100644 index e1fdab6a..00000000 --- a/libc/decl/sa_family_t.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef _SA_FAMILY_T_DECL -#define _SA_FAMILY_T_DECL -typedef unsigned short int sa_family_t; -#endif diff --git a/libc/decl/size_t.h b/libc/decl/size_t.h deleted file mode 100644 index 318dbd40..00000000 --- a/libc/decl/size_t.h +++ /dev/null @@ -1,2 +0,0 @@ -#define __need_size_t -#include diff --git a/libc/decl/socklen_t.h b/libc/decl/socklen_t.h deleted file mode 100644 index abea7153..00000000 --- a/libc/decl/socklen_t.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef _SOCKLEN_T_DECL -#define _SOCKLEN_T_DECL -typedef __socklen_t socklen_t; -#endif diff --git a/libc/decl/ssize_t.h b/libc/decl/ssize_t.h deleted file mode 100644 index 5870f192..00000000 --- a/libc/decl/ssize_t.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef _SSIZE_T_DECL -#define _SSIZE_T_DECL -typedef __ssize_t ssize_t; -#endif diff --git a/libc/decl/suseconds_t.h b/libc/decl/suseconds_t.h deleted file mode 100644 index ecb8d261..00000000 --- a/libc/decl/suseconds_t.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef _SUSECONDS_T_DECL -#define _SUSECONDS_T_DECL -typedef __suseconds_t suseconds_t; -#endif diff --git a/libc/decl/time_t.h b/libc/decl/time_t.h deleted file mode 100644 index 5aae828b..00000000 --- a/libc/decl/time_t.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef _TIME_T_DECL -#define _TIME_T_DECL -typedef __time_t time_t; -#endif diff --git a/libc/decl/timer_t.h b/libc/decl/timer_t.h deleted file mode 100644 index c626d67a..00000000 --- a/libc/decl/timer_t.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef _TIMER_T_DECL -#define _TIMER_T_DECL -typedef __timer_t timer_t; -#endif diff --git a/libc/decl/timeval.h b/libc/decl/timeval.h deleted file mode 100644 index 393e85f5..00000000 --- a/libc/decl/timeval.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef _TIMEVAL_T_DECL -#define _TIMEVAL_T_DECL -struct timeval -{ - time_t tv_sec; - suseconds_t tv_usec; -}; -#endif diff --git a/libc/decl/uid_t.h b/libc/decl/uid_t.h deleted file mode 100644 index b69159a4..00000000 --- a/libc/decl/uid_t.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef _UID_T_DECL -#define _UID_T_DECL -typedef __uid_t uid_t; -#endif diff --git a/libc/decl/useconds_t.h b/libc/decl/useconds_t.h deleted file mode 100644 index 97db54cf..00000000 --- a/libc/decl/useconds_t.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef _USECONDS_T_DECL -#define _USECONDS_T_DECL -typedef __useconds_t useconds_t; -#endif diff --git a/libc/decl/va_list.h b/libc/decl/va_list.h deleted file mode 100644 index 19663eda..00000000 --- a/libc/decl/va_list.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef _VALIST_DECL -#define _VALIST_DECL -#define va_start(v,l) __builtin_va_start(v,l) -#define va_arg(v,l) __builtin_va_arg(v,l) -#define va_end(v) __builtin_va_end(v) -#define va_copy(d,s) __builtin_va_copy(d,s) -typedef __builtin_va_list __gnuc_va_list; -typedef __gnuc_va_list va_list; -#endif diff --git a/libc/decl/wchar_t.h b/libc/decl/wchar_t.h deleted file mode 100644 index 210d8d0e..00000000 --- a/libc/decl/wchar_t.h +++ /dev/null @@ -1,2 +0,0 @@ -#define __need_wchar_t -#include diff --git a/libc/decl/wctrans_t.h b/libc/decl/wctrans_t.h deleted file mode 100644 index a0b41a76..00000000 --- a/libc/decl/wctrans_t.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef _WCTRANS_T_DECL -#define _WCTRANS_T_DECL -/* TODO: figure out what this does and typedef it properly. This is just a - temporary assignment. */ -typedef unsigned int __wctrans_t; -typedef __wctrans_t wctrans_t; -#endif diff --git a/libc/decl/wctype_t.h b/libc/decl/wctype_t.h deleted file mode 100644 index c983014c..00000000 --- a/libc/decl/wctype_t.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef _WCTYPE_T_DECL -#define _WCTYPE_T_DECL -typedef int (*wctype_t)(wint_t); -#endif diff --git a/libc/decl/wint_t.h b/libc/decl/wint_t.h deleted file mode 100644 index ffe3fecb..00000000 --- a/libc/decl/wint_t.h +++ /dev/null @@ -1,5 +0,0 @@ -#ifndef _WINT_T_DECL -#define _WINT_T_DECL -typedef int __wint_t; -typedef __wint_t wint_t; -#endif diff --git a/libc/include/FILE.h b/libc/include/FILE.h index 0b9c422a..8c516963 100644 --- a/libc/include/FILE.h +++ b/libc/include/FILE.h @@ -31,9 +31,22 @@ __BEGIN_DECLS -@include(off_t.h) -@include(size_t.h) -@include(FILE.h) +#ifndef __off_t_defined +#define __off_t_defined +typedef __off_t off_t; +#endif + +#ifndef __size_t_defined +#define __size_t_defined +#define __need_size_t +#include +#endif + +#ifndef __FILE_defined +#define __FILE_defined +typedef struct FILE FILE; +#define FILE FILE +#endif #define _FILE_REGISTERED (1<<0) #define _FILE_BUFFER_MODE_SET (1<<1) diff --git a/libc/include/alloca.h b/libc/include/alloca.h index 543c0895..35839868 100644 --- a/libc/include/alloca.h +++ b/libc/include/alloca.h @@ -31,7 +31,11 @@ __BEGIN_DECLS -@include(size_t.h) +#ifndef __size_t_defined +#define __size_t_defined +#define __need_size_t +#include +#endif /* If somehow another declaration of alloca happened. This shouldn't happen, but glibc does this and we might as well do it also. */ diff --git a/libc/include/dirent.h b/libc/include/dirent.h index 68a24359..9ac7c364 100644 --- a/libc/include/dirent.h +++ b/libc/include/dirent.h @@ -31,9 +31,40 @@ __BEGIN_DECLS -@include(ino_t.h) -@include(size_t.h) -@include(DIR.h) +#ifndef __ino_t_defined +#define __ino_t_defined +typedef __ino_t ino_t; +#endif + +#ifndef __size_t_defined +#define __size_t_defined +#define __need_size_t +#include +#endif + +#ifndef __DIR_defined +#define __DIR_defined +struct dirent; + +#define _DIR_REGISTERED (1<<0) +#define _DIR_ERROR (1<<1) +#define _DIR_EOF (1<<2) +typedef struct _DIR +{ + void* user; + int (*read_func)(void* user, struct dirent* dirent, size_t* size); + int (*rewind_func)(void* user); + int (*fd_func)(void* user); + int (*close_func)(void* user); + void (*free_func)(struct _DIR* dir); + /* Application writers shouldn't use anything beyond this point. */ + struct _DIR* prev; + struct _DIR* next; + struct dirent* entry; + size_t entrysize; + int flags; +} DIR; +#endif struct dirent { diff --git a/libc/include/fcntl.h b/libc/include/fcntl.h index 2edcf83e..7f91f875 100644 --- a/libc/include/fcntl.h +++ b/libc/include/fcntl.h @@ -59,7 +59,10 @@ __BEGIN_DECLS /* TODO: POSIX_FADV_* missing here */ -@include(pid_t.h) +#ifndef __pid_t_defined +#define __pid_t_defined +typedef __pid_t pid_t; +#endif struct flock { diff --git a/libc/include/grp.h b/libc/include/grp.h index 6086485d..c3ebe291 100644 --- a/libc/include/grp.h +++ b/libc/include/grp.h @@ -31,9 +31,22 @@ __BEGIN_DECLS -@include(FILE.h) -@include(gid_t.h) -@include(size_t.h) +#ifndef __FILE_defined +#define __FILE_defined +typedef struct FILE FILE; +#define FILE FILE +#endif + +#ifndef __gid_t_defined +#define __gid_t_defined +typedef __gid_t gid_t; +#endif + +#ifndef __size_t_defined +#define __size_t_defined +#define __need_size_t +#include +#endif struct group { diff --git a/libc/include/inttypes.h b/libc/include/inttypes.h index 53297c7b..75802b3f 100644 --- a/libc/include/inttypes.h +++ b/libc/include/inttypes.h @@ -201,7 +201,11 @@ __BEGIN_DECLS -@include(wchar_t.h) +#ifndef __wchar_t_defined +#define __wchar_t_defined +#define __need_wchar_t +#include +#endif typedef struct { diff --git a/libc/include/ioleast.h b/libc/include/ioleast.h index 265454e7..3965f243 100644 --- a/libc/include/ioleast.h +++ b/libc/include/ioleast.h @@ -34,8 +34,16 @@ __BEGIN_DECLS -@include(off_t.h) -@include(size_t.h) +#ifndef __off_t_defined +#define __off_t_defined +typedef __off_t off_t; +#endif + +#ifndef __size_t_defined +#define __size_t_defined +#define __need_size_t +#include +#endif size_t preadall(int fd, void* buf, size_t count, off_t off); size_t preadleast(int fd, void* buf, size_t least, size_t max, off_t off); diff --git a/libc/include/netdb.h b/libc/include/netdb.h index ed955f60..2edb03b1 100644 --- a/libc/include/netdb.h +++ b/libc/include/netdb.h @@ -33,9 +33,20 @@ __BEGIN_DECLS -@include(in_port_t.h) -@include(in_addr_t.h) -@include(socklen_t.h) +#ifndef __in_port_t_defined +#define __in_port_t_defined +typedef uint16_t in_port_t; +#endif + +#ifndef __in_addr_t_defined +#define __in_addr_t_defined +typedef uint32_t in_addr_t; +#endif + +#ifndef __socklen_t_defined +#define __socklen_t_defined +typedef __socklen_t socklen_t; +#endif struct hostent { diff --git a/libc/include/netinet/in.h b/libc/include/netinet/in.h index fdc68e6a..6c31ca96 100644 --- a/libc/include/netinet/in.h +++ b/libc/include/netinet/in.h @@ -34,10 +34,25 @@ __BEGIN_DECLS -@include(in_port_t.h) -@include(in_addr_t.h) -@include(sa_family_t.h) -@include(socklen_t.h) +#ifndef __in_port_t_defined +#define __in_port_t_defined +typedef uint16_t in_port_t; +#endif + +#ifndef __in_addr_t_defined +#define __in_addr_t_defined +typedef uint32_t in_addr_t; +#endif + +#ifndef __sa_family_t_defined +#define __sa_family_t_defined +typedef unsigned short int sa_family_t; +#endif + +#ifndef __socklen_t_defined +#define __socklen_t_defined +typedef __socklen_t socklen_t; +#endif struct in_addr { diff --git a/libc/include/poll.h b/libc/include/poll.h index 5366da52..7104b817 100644 --- a/libc/include/poll.h +++ b/libc/include/poll.h @@ -31,7 +31,10 @@ __BEGIN_DECLS -@include(time_t.h) +#ifndef __time_t_defined +#define __time_t_defined +typedef __time_t time_t; +#endif __END_DECLS #include diff --git a/libc/include/pwd.h b/libc/include/pwd.h index 5ede722e..32bf3e6b 100644 --- a/libc/include/pwd.h +++ b/libc/include/pwd.h @@ -31,10 +31,27 @@ __BEGIN_DECLS -@include(FILE.h) -@include(gid_t.h) -@include(size_t.h) -@include(uid_t.h) +#ifndef __FILE_defined +#define __FILE_defined +typedef struct FILE FILE; +#define FILE FILE +#endif + +#ifndef __gid_t_defined +#define __gid_t_defined +typedef __gid_t gid_t; +#endif + +#ifndef __size_t_defined +#define __size_t_defined +#define __need_size_t +#include +#endif + +#ifndef __uid_t_defined +#define __uid_t_defined +typedef __uid_t uid_t; +#endif struct passwd { diff --git a/libc/include/signal.h b/libc/include/signal.h index 501985ab..eb744fe5 100644 --- a/libc/include/signal.h +++ b/libc/include/signal.h @@ -33,11 +33,28 @@ __BEGIN_DECLS -@include(uid_t.h) -@include(pid_t.h) -@include(size_t.h) +#ifndef __uid_t_defined +#define __uid_t_defined +typedef __uid_t uid_t; +#endif + +#ifndef __pid_t_defined +#define __pid_t_defined +typedef __pid_t pid_t; +#endif + +#ifndef __size_t_defined +#define __size_t_defined +#define __need_size_t +#include +#endif + /* TODO: POSIX says this header declares struct timespec, but not time_t... */ -@include(time_t.h) +#ifndef __time_t_defined +#define __time_t_defined +typedef __time_t time_t; +#endif + /* TODO: pthread_t */ /* TODO: pthread_attr_t */ diff --git a/libc/include/stdio.h b/libc/include/stdio.h index 2d64a316..f19c5250 100644 --- a/libc/include/stdio.h +++ b/libc/include/stdio.h @@ -41,11 +41,32 @@ __BEGIN_DECLS -@include(off_t.h) -@include(size_t.h) -@include(ssize_t.h) -@include(NULL.h) -@include(FILE.h) +#ifndef __off_t_defined +#define __off_t_defined +typedef __off_t off_t; +#endif + +#ifndef __size_t_defined +#define __size_t_defined +#define __need_size_t +#include +#endif + +#ifndef __ssize_t_defined +#define __ssize_t_defined +typedef __ssize_t ssize_t; +#endif + +#ifndef NULL +#define __need_NULL +#include +#endif + +#ifndef __FILE_defined +#define __FILE_defined +typedef struct FILE FILE; +#define FILE FILE +#endif typedef off_t fpos_t; diff --git a/libc/include/stdlib.h b/libc/include/stdlib.h index a4d82680..0590ba66 100644 --- a/libc/include/stdlib.h +++ b/libc/include/stdlib.h @@ -60,9 +60,22 @@ typedef struct long long rem; } lldiv_t; -@include(NULL.h) -@include(size_t.h) -@include(wchar_t.h) +#ifndef NULL +#define __need_NULL +#include +#endif + +#ifndef __size_t_defined +#define __size_t_defined +#define __need_size_t +#include +#endif + +#ifndef __wchar_t_defined +#define __wchar_t_defined +#define __need_wchar_t +#include +#endif void abort(void) __attribute__ ((__noreturn__)); int abs(int value); diff --git a/libc/include/string.h b/libc/include/string.h index 8eb88e94..a926a4f9 100644 --- a/libc/include/string.h +++ b/libc/include/string.h @@ -33,9 +33,24 @@ __BEGIN_DECLS -@include(NULL.h) -@include(size_t.h) -@include(locale_t.h) +#ifndef NULL +#define __need_NULL +#include +#endif + +#ifndef __size_t_defined +#define __size_t_defined +#define __need_size_t +#include +#endif + +#ifndef __locale_t_defined +#define __locale_t_defined +/* TODO: figure out what this does and typedef it properly. This is just a + temporary assignment. */ +typedef int __locale_t; +typedef __locale_t locale_t; +#endif int ffs(int); int ffsl(long int); diff --git a/libc/include/sys/kernelinfo.h b/libc/include/sys/kernelinfo.h index d4bd3bfd..f518fd8e 100644 --- a/libc/include/sys/kernelinfo.h +++ b/libc/include/sys/kernelinfo.h @@ -31,8 +31,16 @@ __BEGIN_DECLS -@include(size_t.h) -@include(ssize_t.h) +#ifndef __size_t_defined +#define __size_t_defined +#define __need_size_t +#include +#endif + +#ifndef __ssize_t_defined +#define __ssize_t_defined +typedef __ssize_t ssize_t; +#endif ssize_t kernelinfo(const char* req, char* resp, size_t resplen); diff --git a/libc/include/sys/mman.h b/libc/include/sys/mman.h index b66b7758..059de1f7 100644 --- a/libc/include/sys/mman.h +++ b/libc/include/sys/mman.h @@ -33,9 +33,21 @@ __BEGIN_DECLS -@include(mode_t.h) -@include(off_t.h) -@include(size_t.h) +#ifndef __mode_t_defined +#define __mode_t_defined +typedef __mode_t mode_t; +#endif + +#ifndef __off_t_defined +#define __off_t_defined +typedef __off_t off_t; +#endif + +#ifndef __size_t_defined +#define __size_t_defined +#define __need_size_t +#include +#endif void* mmap(void*, size_t, int, int, int, off_t); int mprotect(const void*, size_t, int); diff --git a/libc/include/sys/readdirents.h b/libc/include/sys/readdirents.h index 828cc72d..56373ef8 100644 --- a/libc/include/sys/readdirents.h +++ b/libc/include/sys/readdirents.h @@ -36,7 +36,11 @@ __BEGIN_DECLS -@include(size_t.h) +#ifndef __size_t_defined +#define __size_t_defined +#define __need_size_t +#include +#endif ssize_t readdirents(int fd, struct kernel_dirent* dirent, size_t size); diff --git a/libc/include/sys/resource.h b/libc/include/sys/resource.h index 5601401c..a7aa36da 100644 --- a/libc/include/sys/resource.h +++ b/libc/include/sys/resource.h @@ -33,11 +33,34 @@ __BEGIN_DECLS -@include(id_t.h) -@include(pid_t.h) -@include(time_t.h) -@include(suseconds_t.h) -@include(timeval.h) +#ifndef __id_t_defined +#define __id_t_defined +typedef __id_t id_t; +#endif + +#ifndef __pid_t_defined +#define __pid_t_defined +typedef __pid_t pid_t; +#endif + +#ifndef __time_t_defined +#define __time_t_defined +typedef __time_t time_t; +#endif + +#ifndef __suseconds_t_defined +#define __suseconds_t_defined +typedef __suseconds_t suseconds_t; +#endif + +#ifndef __timeval_defined +#define __timeval_defined +struct timeval +{ + time_t tv_sec; + suseconds_t tv_usec; +}; +#endif #define RUSAGE_SELF 0 #define RUSAGE_CHILDREN 1 diff --git a/libc/include/sys/select.h b/libc/include/sys/select.h index 1c500c15..e405792b 100644 --- a/libc/include/sys/select.h +++ b/libc/include/sys/select.h @@ -34,9 +34,24 @@ __BEGIN_DECLS -@include(time_t.h) -@include(suseconds_t.h) -@include(timeval.h) +#ifndef __time_t_defined +#define __time_t_defined +typedef __time_t time_t; +#endif + +#ifndef __suseconds_t_defined +#define __suseconds_t_defined +typedef __suseconds_t suseconds_t; +#endif + +#ifndef __timeval_defined +#define __timeval_defined +struct timeval +{ + time_t tv_sec; + suseconds_t tv_usec; +}; +#endif __BEGIN_DECLS #include diff --git a/libc/include/sys/socket.h b/libc/include/sys/socket.h index 0d324b01..042f1184 100644 --- a/libc/include/sys/socket.h +++ b/libc/include/sys/socket.h @@ -33,10 +33,26 @@ __BEGIN_DECLS -@include(socklen_t.h) -@include(size_t.h) -@include(ssize_t.h) -@include(sa_family_t.h) +#ifndef __socklen_t_defined +#define __socklen_t_defined +typedef __socklen_t socklen_t; +#endif + +#ifndef __size_t_defined +#define __size_t_defined +#define __need_size_t +#include +#endif + +#ifndef __ssize_t_defined +#define __ssize_t_defined +typedef __ssize_t ssize_t; +#endif + +#ifndef __sa_family_t_defined +#define __sa_family_t_defined +typedef unsigned short int sa_family_t; +#endif __END_DECLS diff --git a/libc/include/sys/stat.h b/libc/include/sys/stat.h index 892958da..4ac9b762 100644 --- a/libc/include/sys/stat.h +++ b/libc/include/sys/stat.h @@ -30,16 +30,57 @@ #include __BEGIN_DECLS -@include(blkcnt_t.h) -@include(blksize_t.h) -@include(dev_t.h) -@include(ino_t.h) -@include(mode_t.h) -@include(nlink_t.h) -@include(uid_t.h) -@include(gid_t.h) -@include(off_t.h) -@include(time_t.h) + +#ifndef __blkcnt_t_defined +#define __blkcnt_t_defined +typedef __blkcnt_t blkcnt_t; +#endif + +#ifndef __blksize_t_defined +#define __blksize_t_defined +typedef __blksize_t blksize_t; +#endif + +#ifndef __dev_t_defined +#define __dev_t_defined +typedef __dev_t dev_t; +#endif + +#ifndef __ino_t_defined +#define __ino_t_defined +typedef __ino_t ino_t; +#endif + +#ifndef __mode_t_defined +#define __mode_t_defined +typedef __mode_t mode_t; +#endif + +#ifndef __nlink_t_defined +#define __nlink_t_defined +typedef __nlink_t nlink_t; +#endif + +#ifndef __uid_t_defined +#define __uid_t_defined +typedef __uid_t uid_t; +#endif + +#ifndef __gid_t_defined +#define __gid_t_defined +typedef __gid_t gid_t; +#endif + +#ifndef __off_t_defined +#define __off_t_defined +typedef __off_t off_t; +#endif + +#ifndef __time_t_defined +#define __time_t_defined +typedef __time_t time_t; +#endif + __END_DECLS #include diff --git a/libc/include/sys/time.h b/libc/include/sys/time.h index 9a16fdf2..eff8faee 100644 --- a/libc/include/sys/time.h +++ b/libc/include/sys/time.h @@ -31,9 +31,24 @@ __BEGIN_DECLS -@include(time_t.h) -@include(suseconds_t.h) -@include(timeval.h) +#ifndef __time_t_defined +#define __time_t_defined +typedef __time_t time_t; +#endif + +#ifndef __suseconds_t_defined +#define __suseconds_t_defined +typedef __suseconds_t suseconds_t; +#endif + +#ifndef __timeval_defined +#define __timeval_defined +struct timeval +{ + time_t tv_sec; + suseconds_t tv_usec; +}; +#endif int gettimeofday(struct timeval* __restrict tp, void* __restrict tzp); diff --git a/libc/include/sys/times.h b/libc/include/sys/times.h index d8168e2b..7372e975 100644 --- a/libc/include/sys/times.h +++ b/libc/include/sys/times.h @@ -31,7 +31,10 @@ __BEGIN_DECLS -@include(clock_t.h); +#ifndef __clock_t_defined +#define __clock_t_defined +typedef __clock_t clock_t; +#endif struct tms { diff --git a/libc/include/sys/types.h b/libc/include/sys/types.h index 23fa9192..a23592ef 100644 --- a/libc/include/sys/types.h +++ b/libc/include/sys/types.h @@ -33,29 +33,109 @@ __BEGIN_DECLS -@include(blkcnt_t.h) -@include(blksize_t.h) -@include(clock_t.h) -@include(clockid_t.h) -@include(dev_t.h) +#ifndef __blkcnt_t_defined +#define __blkcnt_t_defined +typedef __blkcnt_t blkcnt_t; +#endif + +#ifndef __blksize_t_defined +#define __blksize_t_defined +typedef __blksize_t blksize_t; +#endif + +#ifndef __clock_t_defined +#define __clock_t_defined +typedef __clock_t clock_t; +#endif + +#ifndef __clockid_t_defined +#define __clockid_t_defined +typedef __clockid_t clockid_t; +#endif + +#ifndef __dev_t_defined +#define __dev_t_defined +typedef __dev_t dev_t; +#endif + /* TODO: fsblkcnt_t */ + /* TODO: fsfilcnt_t */ -@include(gid_t.h) -@include(id_t.h) -@include(ino_t.h) + +#ifndef __gid_t_defined +#define __gid_t_defined +typedef __gid_t gid_t; +#endif + +#ifndef __id_t_defined +#define __id_t_defined +typedef __id_t id_t; +#endif + +#ifndef __ino_t_defined +#define __ino_t_defined +typedef __ino_t ino_t; +#endif + /* TODO: key_t */ -@include(mode_t.h) -@include(nlink_t.h) -@include(off_t.h) -@include(pid_t.h) -@include(size_t.h) -@include(ssize_t.h) -@include(suseconds_t.h) -@include(time_t.h) -@include(timer_t.h) + +#ifndef __mode_t_defined +#define __mode_t_defined +typedef __mode_t mode_t; +#endif + +#ifndef __nlink_t_defined +#define __nlink_t_defined +typedef __nlink_t nlink_t; +#endif + +#ifndef __off_t_defined +#define __off_t_defined +typedef __off_t off_t; +#endif + +#ifndef __pid_t_defined +#define __pid_t_defined +typedef __pid_t pid_t; +#endif + +#ifndef __size_t_defined +#define __size_t_defined +#define __need_size_t +#include +#endif + +#ifndef __ssize_t_defined +#define __ssize_t_defined +typedef __ssize_t ssize_t; +#endif + +#ifndef __suseconds_t_defined +#define __suseconds_t_defined +typedef __suseconds_t suseconds_t; +#endif + +#ifndef __time_t_defined +#define __time_t_defined +typedef __time_t time_t; +#endif + +#ifndef __timer_t_defined +#define __timer_t_defined +typedef __timer_t timer_t; +#endif + /* TODO: trace*_t */ -@include(uid_t.h) -@include(useconds_t.h) + +#ifndef __uid_t_defined +#define __uid_t_defined +typedef __uid_t uid_t; +#endif + +#ifndef __useconds_t_defined +#define __useconds_t_defined +typedef __useconds_t useconds_t; +#endif #if !defined(__is_sortix_kernel) /* TODO: pthread*_t */ diff --git a/libc/include/sys/uio.h b/libc/include/sys/uio.h index b8c17a2f..ec4aa0ce 100644 --- a/libc/include/sys/uio.h +++ b/libc/include/sys/uio.h @@ -31,9 +31,21 @@ __BEGIN_DECLS -@include(size_t.h) -@include(ssize_t.h) -@include(off_t.h) +#ifndef __size_t_defined +#define __size_t_defined +#define __need_size_t +#include +#endif + +#ifndef __ssize_t_defined +#define __ssize_t_defined +typedef __ssize_t ssize_t; +#endif + +#ifndef __off_t_defined +#define __off_t_defined +typedef __off_t off_t; +#endif __END_DECLS diff --git a/libc/include/sys/un.h b/libc/include/sys/un.h index fea5eaf9..42fcb505 100644 --- a/libc/include/sys/un.h +++ b/libc/include/sys/un.h @@ -31,7 +31,10 @@ __BEGIN_DECLS -@include(sa_family_t.h) +#ifndef __sa_family_t_defined +#define __sa_family_t_defined +typedef unsigned short int sa_family_t; +#endif struct sockaddr_un { diff --git a/libc/include/sys/wait.h b/libc/include/sys/wait.h index 5d6f18dd..93ca3d44 100644 --- a/libc/include/sys/wait.h +++ b/libc/include/sys/wait.h @@ -35,7 +35,10 @@ __BEGIN_DECLS -@include(pid_t.h) +#ifndef __pid_t_defined +#define __pid_t_defined +typedef __pid_t pid_t; +#endif /* TODO: These are not implemented in sortix libc yet. */ #if 0 diff --git a/libc/include/time.h b/libc/include/time.h index 8af7a415..d8bd5c85 100644 --- a/libc/include/time.h +++ b/libc/include/time.h @@ -31,13 +31,44 @@ __BEGIN_DECLS -@include(clock_t.h) -@include(size_t.h) -@include(time_t.h) -@include(clockid_t.h) -@include(timer_t.h) -@include(locale_t.h) -@include(pid_t.h) +#ifndef __clock_t_defined +#define __clock_t_defined +typedef __clock_t clock_t; +#endif + +#ifndef __size_t_defined +#define __size_t_defined +#define __need_size_t +#include +#endif + +#ifndef __time_t_defined +#define __time_t_defined +typedef __time_t time_t; +#endif + +#ifndef __clockid_t_defined +#define __clockid_t_defined +typedef __clockid_t clockid_t; +#endif + +#ifndef __timer_t_defined +#define __timer_t_defined +typedef __timer_t timer_t; +#endif + +#ifndef __locale_t_defined +#define __locale_t_defined +/* TODO: figure out what this does and typedef it properly. This is just a + temporary assignment. */ +typedef int __locale_t; +typedef __locale_t locale_t; +#endif + +#ifndef __pid_t_defined +#define __pid_t_defined +typedef __pid_t pid_t; +#endif struct sigevent; @@ -62,7 +93,10 @@ __END_DECLS #endif __BEGIN_DECLS -@include(NULL.h) +#ifndef NULL +#define __need_NULL +#include +#endif #define CLOCKS_PER_SEC 1000000l diff --git a/libc/include/timespec.h b/libc/include/timespec.h index 11591bb2..aa9323a1 100644 --- a/libc/include/timespec.h +++ b/libc/include/timespec.h @@ -33,7 +33,10 @@ __BEGIN_DECLS -@include(time_t.h) +#ifndef __time_t_defined +#define __time_t_defined +typedef __time_t time_t; +#endif __END_DECLS diff --git a/libc/include/unistd.h b/libc/include/unistd.h index bf33a367..5ab4fee3 100644 --- a/libc/include/unistd.h +++ b/libc/include/unistd.h @@ -38,7 +38,10 @@ #include #include __BEGIN_DECLS -@include(time_t.h) +#ifndef __time_t_defined +#define __time_t_defined +typedef __time_t time_t; +#endif __END_DECLS #include #include @@ -63,7 +66,10 @@ __BEGIN_DECLS /* TODO: _POSIX_*, _POSIX2_* is missing here. */ -@include(NULL.h) +#ifndef NULL +#define __need_NULL +#include +#endif #define _CS_PATH 0 #define _CS_POSIX_V7_ILP32_OFF32_CFLAGS 1 @@ -253,13 +259,41 @@ __BEGIN_DECLS /* TODO: _POSIX_VDISABLE is missing here. */ -@include(size_t.h) -@include(ssize_t.h) -@include(uid_t.h) -@include(gid_t.h) -@include(off_t.h) -@include(pid_t.h) -@include(useconds_t.h) +#ifndef __size_t_defined +#define __size_t_defined +#define __need_size_t +#include +#endif + +#ifndef __ssize_t_defined +#define __ssize_t_defined +typedef __ssize_t ssize_t; +#endif + +#ifndef __uid_t_defined +#define __uid_t_defined +typedef __uid_t uid_t; +#endif + +#ifndef __gid_t_defined +#define __gid_t_defined +typedef __gid_t gid_t; +#endif + +#ifndef __off_t_defined +#define __off_t_defined +typedef __off_t off_t; +#endif + +#ifndef __pid_t_defined +#define __pid_t_defined +typedef __pid_t pid_t; +#endif + +#ifndef __useconds_t_defined +#define __useconds_t_defined +typedef __useconds_t useconds_t; +#endif #if defined(_WANT_ENVIRON) extern char** environ; diff --git a/libc/include/utime.h b/libc/include/utime.h index 69065846..68013543 100644 --- a/libc/include/utime.h +++ b/libc/include/utime.h @@ -31,7 +31,10 @@ __BEGIN_DECLS -@include(time_t.h) +#ifndef __time_t_defined +#define __time_t_defined +typedef __time_t time_t; +#endif struct utimbuf { diff --git a/libc/include/wchar.h b/libc/include/wchar.h index a6eb9d55..0bcd8c1e 100644 --- a/libc/include/wchar.h +++ b/libc/include/wchar.h @@ -35,17 +35,69 @@ __BEGIN_DECLS -@include(size_t.h) -@include(off_t.h) -@include(FILE.h) -@include(locale_t.h) -@include(va_list.h) -@include(wchar_t.h) -@include(wint_t.h) -@include(WCHAR_MAX.h) -@include(WCHAR_MIN.h) -@include(WEOF.h) -@include(NULL.h) +#ifndef __size_t_defined +#define __size_t_defined +#define __need_size_t +#include +#endif + +#ifndef __off_t_defined +#define __off_t_defined +typedef __off_t off_t; +#endif + +#ifndef __FILE_defined +#define __FILE_defined +typedef struct FILE FILE; +#define FILE FILE +#endif + +#ifndef __locale_t_defined +#define __locale_t_defined +/* TODO: figure out what this does and typedef it properly. This is just a + temporary assignment. */ +typedef int __locale_t; +typedef __locale_t locale_t; +#endif + +#ifndef __valist_defined +#define __valist_defined +#define va_start(v,l) __builtin_va_start(v,l) +#define va_arg(v,l) __builtin_va_arg(v,l) +#define va_end(v) __builtin_va_end(v) +#define va_copy(d,s) __builtin_va_copy(d,s) +typedef __builtin_va_list __gnuc_va_list; +typedef __gnuc_va_list va_list; +#endif + +#ifndef __wchar_t_defined +#define __wchar_t_defined +#define __need_wchar_t +#include +#endif + +#ifndef __wint_t_defined +#define __wint_t_defined +typedef int __wint_t; +typedef __wint_t wint_t; +#endif + +#ifndef WCHAR_MAX +#define WCHAR_MAX __WCHAR_MAX +#endif + +#ifndef WCHAR_MIN +#define WCHAR_MIN __WCHAR_MIN +#endif + +#ifndef WEOF +#define WEOF (-1) +#endif + +#ifndef NULL +#define __need_NULL +#include +#endif #ifndef __mbstate_t_defined /* Conversion state information. */ diff --git a/libc/include/wctype.h b/libc/include/wctype.h index e1b5e5a6..b6bdf5b8 100644 --- a/libc/include/wctype.h +++ b/libc/include/wctype.h @@ -31,11 +31,36 @@ __BEGIN_DECLS -@include(wint_t.h) -@include(wctrans_t.h) -@include(wctype_t.h) -@include(locale_t.h) -@include(WEOF.h) +#ifndef __wint_t_defined +#define __wint_t_defined +typedef int __wint_t; +typedef __wint_t wint_t; +#endif + +#ifndef __wctrans_t_defined +#define __wctrans_t_defined +/* TODO: figure out what this does and typedef it properly. This is just a + temporary assignment. */ +typedef unsigned int __wctrans_t; +typedef __wctrans_t wctrans_t; +#endif + +#ifndef __wctype_t_defined +#define __wctype_t_defined +typedef int (*wctype_t)(wint_t); +#endif + +#ifndef __locale_t_defined +#define __locale_t_defined +/* TODO: figure out what this does and typedef it properly. This is just a + temporary assignment. */ +typedef int __locale_t; +typedef __locale_t locale_t; +#endif + +#ifndef WEOF +#define WEOF (-1) +#endif int iswalnum(wint_t); int iswalpha(wint_t); diff --git a/mxmpp/.gitignore b/mxmpp/.gitignore deleted file mode 100644 index 729c8784..00000000 --- a/mxmpp/.gitignore +++ /dev/null @@ -1 +0,0 @@ -mxmpp diff --git a/mxmpp/Makefile b/mxmpp/Makefile deleted file mode 100644 index dda4996e..00000000 --- a/mxmpp/Makefile +++ /dev/null @@ -1,35 +0,0 @@ -include ../compiler.mak -include ../version.mak -include ../dirs.mak - -ifndef OPTLEVEL - OPTLEVEL=-g -O2 -endif - -ifndef CXXFLAGS - CXXFLAGS:=$(OPTLEVEL) -endif - -CXXFLAGS:=$(CXXFLAGS) -Wall -Wextra -fno-exceptions -fno-rtti - -BINARIES=mxmpp - -INSTALLBINARIES:=$(addprefix $(DESTDIR)$(BINDIR)/,$(BINARIES)) - -all: $(BINARIES) - -.PHONY: all install uninstall clean - -%: %.cpp - $(CXX) -std=gnu++11 $(CPPFLAGS) $(CXXFLAGS) $< -o $@ - -clean: - rm -f $(BINARIES) - -install: all - mkdir -p $(DESTDIR)$(BINDIR) - install $(BINARIES) $(DESTDIR)$(BINDIR) - -uninstall: - rm -f $(INSTALLBINARIES) - diff --git a/mxmpp/README b/mxmpp/README deleted file mode 100644 index 4b3b51a0..00000000 --- a/mxmpp/README +++ /dev/null @@ -1 +0,0 @@ -This is a small stupid macro processor used for building Sortix's libc. diff --git a/mxmpp/mxmpp.cpp b/mxmpp/mxmpp.cpp deleted file mode 100644 index 3e8173fe..00000000 --- a/mxmpp/mxmpp.cpp +++ /dev/null @@ -1,414 +0,0 @@ -/******************************************************************************* - - Copyright(C) Jonas 'Sortie' Termansen 2012. - - This file is part of mxmpp. - - mxmpp is free software: you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation, either version 3 of the License, or (at your option) any later - version. - - mxmpp is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - details. - - You should have received a copy of the GNU General Public License along with - mxmpp. If not, see . - - mxmpp.cpp - A simple macro preprocessor. - -*******************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include - -#ifndef S_IRGRP -#define S_IRGRP (0) -#endif -#ifndef S_IWGRP -#define S_IWGRP (0) -#endif -#ifndef S_IROTH -#define S_IROTH (0) -#endif -#ifndef S_IWOTH -#define S_IWOTH (0) -#endif - -#define writeall mxmpp_writeall -bool writeall(int fd, const void* p, size_t size) -{ - const uint8_t* buffer = (const uint8_t*) p; - - size_t bytesWritten = 0; - - while ( bytesWritten < size ) - { - ssize_t written = write(fd, buffer + bytesWritten, size - bytesWritten); - if ( written < 0 ) { perror("write"); return false; } - bytesWritten += written; - } - - return true; -} - -void usage(int /*argc*/, char* argv[]) -{ - printf("usage: %s [OPTIONS] [FILE]...\n", argv[0]); - printf("Preprocess FILE(s), or standard input."); - printf("\n"); - printf("Options:\n"); - printf(" -o Write output to this file\n"); - printf(" Default = Standard Output\n"); - printf(" -I Add this directory to the include search paths\n"); - printf(" If no paths are set, include from working dir\n"); - printf(" -q Surpress normal output\n"); - printf(" -v Be verbose\n"); - printf(" --usage Display this screen\n"); - printf(" --help Display this screen\n"); - printf(" --version Display version information\n"); -} - -void version() -{ - printf("The Maxsi Macro PreProcessor 0.1\n"); - printf("Copyright (C) 2011 Jonas 'Sortie' Termansen\n"); - printf("This is free software; see the source for copying conditions. There is NO\n"); - printf("warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"); - printf("website: http://www.maxsi.org/software/mxmpp/\n"); -} - -struct searchpath -{ - const char* path; - searchpath* next; -}; - -struct inputfile -{ - const char* path; - inputfile* next; -}; - -int outfd = -1; - -searchpath* firstpath = NULL; -inputfile* firstfile = NULL; - -const size_t CONSTRUCT_SIZE = 511; -const size_t BUFFER_SIZE = 4096; - -bool verbose = false; - -char* search(const char* filename); -bool include(const char* parameter); -bool expand(const char* command, const char* parameter); -bool process(int fd); -bool process(const char* path); - -char* search(const char* filename) -{ - size_t filenamelen = strlen(filename); - - for ( searchpath* path = firstpath; path != NULL; path = path->next ) - { - size_t searchpathlen = strlen(path->path); - size_t filepathlen = searchpathlen + 1 + filenamelen; - char* filepath = new char[filepathlen + 1]; - strcpy(filepath, path->path); - strcpy(filepath + searchpathlen, "/"); - strcpy(filepath + searchpathlen + 1, filename); - - struct stat sts; - int statrs = stat(filepath, &sts); - if ( statrs < 0 && errno != ENOENT ) - { - fprintf(stderr, "error: could not stat file '%s': %s\n", filepath, strerror(errno)); return NULL; - } - - bool found = ( statrs != -1 ); - - if ( verbose ) - { - fprintf(stderr, "info: searching for '%s': %s\n", filepath, ( found ) ? "found" : "not found"); - } - - if ( found ) - { - return filepath; - } - - delete[] filepath; - } - - return NULL; -} - -bool include(const char* parameter) -{ - if ( parameter[0] == '\0' ) - { - fprintf(stderr, "error: @include expects a non-empty parameter\n"); - return false; - } - - if ( parameter[0] == '/' ) - { - return process(parameter); - } - - char* included = search(parameter); - - if ( included == NULL ) - { - fprintf(stderr, "error: could not find included file '%s'\n", parameter); - return false; - } - - bool result = process(included); - delete[] included; - - return result; -} - -bool expand(const char* command, const char* parameter) -{ - if ( strcmp(command, "@include") == 0 ) - { - return include(parameter); - } - else - { - fprintf(stderr, "error: unknown macro command %s\n", command); - return false; - } -} - -bool process(int fd) -{ - char construct[CONSTRUCT_SIZE+1]; - char buffer[BUFFER_SIZE]; - size_t constructed = 0; - int phase = 0; - - const char* command = NULL; - const char* parameter = NULL; - - bool quote = false; - bool backslash = false; - - while ( true ) - { - ssize_t numread = read(fd, buffer, BUFFER_SIZE); - if ( numread == 0 ) { break; } - if ( numread < 0 ) { perror("read"); return false; } - size_t writefrom = 0; - - for ( ssize_t i = 0; i < numread; i++ ) - { - if ( constructed == 0 ) - { - if ( buffer[i] == '\\' ) { backslash = !backslash; continue; } - if ( buffer[i] == '"' && !backslash ) { quote = !quote; } - if ( buffer[i] == '@' && !quote ) - { - if ( i - writefrom > 0 ) - { - if ( !writeall(outfd, buffer + writefrom, i - writefrom) ) { return false; } - } - construct[0] = '@'; constructed++; - } - backslash = false; - } - else - { - if ( phase == 0 ) - { - if ( ( ('a' <= buffer[i] && buffer[i] <= 'z' ) || - ('A' <= buffer[i] && buffer[i] <= 'Z' ) ) && - ( constructed < CONSTRUCT_SIZE) ) - { - construct[constructed] = buffer[i]; constructed++; - } - else if ( buffer[i] == '(' ) - { - construct[constructed] = '\0'; constructed++; - command = construct; - parameter = construct + constructed; - phase++; - continue; - } - else - { - construct[constructed] = '\0'; - fprintf(stderr, "error: expected '(' after '%s'\n", construct); - return false; - } - } - if ( phase == 1 ) - { - if ( buffer[i] == ')' ) - { - construct[constructed] = '\0'; - if ( !expand(command, parameter) ) { return false; } - phase = 0; - constructed = 0; - writefrom = i + 1; - } - else if ( buffer[i] != '\n' && buffer[i] != '\r' && constructed < CONSTRUCT_SIZE ) - { - construct[constructed] = buffer[i]; constructed++; - } - else - { - construct[constructed] = '\0'; - fprintf(stderr, "error: expected ')' after '%s'\n", parameter); - return false; - } - } - } - } - - if ( constructed == 0 && numread - writefrom > 0 ) - { - if ( !writeall(outfd, buffer + writefrom, numread - writefrom) ) { return false; } - } - } - - return true; -} - -bool process(const char* path) -{ - int fd; - if ( strcmp(path, "-") == 0 ) { fd = 0; } - else if ( (fd = open(path, O_RDONLY) ) < 0 ) - { - fprintf(stderr, "error: couldn't open file '%s'\n", path); return false; - } - - if ( verbose ) - { - fprintf(stderr, "info: including file '%s'\n", path); - } - - bool result = process(fd); - - if ( verbose ) - { - fprintf(stderr, "info: end of file '%s'\n", path); - } - - if ( close(fd) < 0 ) - { - perror("close"); return false; - } - - return result; -} - -int main(int argc, char* argv[]) -{ - const char* dest = NULL; - searchpath* lastpath = NULL; - inputfile* lastfile = NULL; - - for ( int i = 1; i < argc; i++ ) - { - if ( strcmp(argv[i], "-I") == 0 ) - { - if ( 2 <= argc - i ) - { - searchpath* path = new searchpath(); - path->path = argv[i+1]; - path->next = NULL; - if ( firstpath == NULL ) { firstpath = path; } else { lastpath->next = path; } - lastpath = path; - i++; - } - } - else if ( strcmp(argv[i], "-o") == 0 ) - { - if ( 2 <= argc - i ) - { - dest = argv[i+1]; - i++; - } - } - else if ( strcmp(argv[i], "-v") == 0 ) - { - verbose = true; - } - else if ( strcmp(argv[i], "-q") == 0 ) - { - verbose = false; - } - else if ( strcmp(argv[i], "--help") == 0 ) - { - usage(argc, argv); - return 0; - } - else if ( strcmp(argv[i], "--usage") == 0 ) - { - usage(argc, argv); - return 0; - } - else if ( strcmp(argv[i], "--version") == 0 ) - { - version(); - return 0; - } - else - { - inputfile* file = new inputfile(); - file->path = argv[i]; - file->next = NULL; - if ( firstfile == NULL ) { firstfile = file; } else { lastfile->next = file; } - lastfile = file; - } - } - - if ( dest == NULL || strcmp(dest, "-") == 0 ) { outfd = 1; } - else if ( (outfd = open(dest, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) ) < 0 ) - { - fprintf(stderr, "error: couldn't open file '%s'\n", dest); return 1; - } - - if ( firstpath == NULL ) - { - firstpath = new searchpath; - firstpath->path = "."; - firstpath->next = NULL; - lastpath = firstpath; - } - - if ( firstfile == NULL ) - { - firstfile = new inputfile; - firstfile->path = "-"; - firstfile->next = NULL; - lastfile = firstfile; - } - - inputfile* tmp = firstfile; - while ( tmp != NULL ) - { - if ( !process(tmp->path) ) { return 1; } - tmp = tmp->next; - } - - if ( close(outfd) < 0 ) - { - perror("close"); return 1; - } - - return 0; -} diff --git a/system/Makefile b/system/Makefile index 45e2e290..6688a191 100644 --- a/system/Makefile +++ b/system/Makefile @@ -23,7 +23,6 @@ clean: $(MAKE) -B -C $(SRCDIR)/bench clean $(MAKE) -B -C $(SRCDIR)/games clean $(MAKE) -B -C $(SRCDIR)/mkinitrd clean - $(MAKE) -B -C $(SRCDIR)/mxmpp clean $(MAKE) -B -C $(SRCDIR)/utils clean $(MAKE) -B -C $(SRCDIR)/ext clean $(MAKE) -B -C $(SRCDIR)/mbr clean @@ -69,7 +68,6 @@ system: $(MAKE) -B -C $(SRCDIR)/dispd install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/lib $(MAKE) -B -C $(SRCDIR)/games install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/lib $(MAKE) -B -C $(SRCDIR)/mkinitrd install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/lib - $(MAKE) -B -C $(SRCDIR)/mxmpp install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/lib $(MAKE) -B -C $(SRCDIR)/utils install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/lib $(MAKE) -B -C $(SRCDIR)/bench install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/lib $(MAKE) -B -C $(SRCDIR)/ext install DESTDIR=$(ROOT) C_INCLUDE_PATH=$(ROOT)/include CPLUS_INCLUDE_PATH=$(ROOT)/include LIBRARY_PATH=$(ROOT)/$(cputype)/lib