Merge branch 'master' of git://ted.mutabah.net/acess2
authorJohn Hodge (sonata) <[email protected]>
Tue, 11 Mar 2014 00:05:37 +0000 (08:05 +0800)
committerJohn Hodge (sonata) <[email protected]>
Tue, 11 Mar 2014 00:05:37 +0000 (08:05 +0800)
Conflicts:
Usermode/Libraries/libpsocket.so_src/pton.c

87 files changed:
BuildConf/x86/Makefile.cfg
Externals/ACPICA/Makefile
Externals/ACPICA/Makefile.kinc
Externals/bochs/Makefile [new file with mode: 0644]
Externals/bochs/patches/config.h.in.patch [new file with mode: 0644]
Externals/bochs/patches/config.sub.patch [new file with mode: 0644]
Externals/common.mk [deleted file]
Externals/common_automake.mk [new file with mode: 0644]
Externals/config.mk
Externals/core.mk
Externals/cross-compiler/Makefile
Externals/cross-compiler/patches/binutils/bfd/config.bfd.patch
Externals/cross-compiler/patches/binutils/ld/Makefile.in.patch
Externals/cross-compiler/patches/binutils/ld/configure.tgt.patch
Externals/cross-compiler/patches/binutils/ld/emulparams/acess2_amd64.sh [new file with mode: 0644]
Externals/cross-compiler/patches/config/override.m4.patch [new file with mode: 0644]
Externals/cross-compiler/patches/gcc/gcc/config.gcc.patch
Externals/cross-compiler/patches/gcc/gcc/config/acess2.h
Externals/cross-compiler/patches/gcc/libgcc/config.host.patch
Externals/dropbear/Makefile
Externals/dropbear/patches/config.sub.patch [new file with mode: 0644]
Externals/dropbear/patches/options.h.patch
Externals/sdl12/Makefile
Externals/sdl12/patches/configure.in.patch [deleted file]
Externals/sdl12/patches/configure.patch [new file with mode: 0644]
Externals/zlib/Makefile
KernelLand/Kernel/arch/x86/mm_virt.c
KernelLand/Kernel/vfs/mmap.c
KernelLand/Modules/Filesystems/InitRD/GenerateInitRD.php
KernelLand/Modules/Filesystems/InitRD/files.lst
Makefile
Tools/GCCProxy/gccproxy.sh
Tools/GCCProxy/getconfig.mk
Usermode/Applications/Makefile.cfg
Usermode/Applications/Makefile.tpl
Usermode/Libraries/Makefile.cfg
Usermode/Libraries/Makefile.tpl
Usermode/Libraries/ld-acess.so_src/include_exp/acess/sys.h
Usermode/Libraries/libc++.so_src/Makefile [new file with mode: 0644]
Usermode/Libraries/libc++.so_src/cxxabi.cc [new file with mode: 0644]
Usermode/Libraries/libc++.so_src/guard.cc [new file with mode: 0644]
Usermode/Libraries/libc++.so_src/include_exp/cxxabi.h [new file with mode: 0644]
Usermode/Libraries/libc++.so_src/include_exp/typeinfo [new file with mode: 0644]
Usermode/Libraries/libc++.so_src/misc.cc [new file with mode: 0644]
Usermode/Libraries/libc++.so_src/new.cc [new file with mode: 0644]
Usermode/Libraries/libc++.so_src/typeinfo.cc [new file with mode: 0644]
Usermode/Libraries/libc.so_src/Makefile
Usermode/Libraries/libc.so_src/ctype.c [new file with mode: 0644]
Usermode/Libraries/libc.so_src/errno.c
Usermode/Libraries/libc.so_src/include_exp/assert.h
Usermode/Libraries/libc.so_src/include_exp/ctype.h
Usermode/Libraries/libc.so_src/include_exp/errno.enum.h
Usermode/Libraries/libc.so_src/include_exp/locale.h [new file with mode: 0644]
Usermode/Libraries/libc.so_src/include_exp/setjmp.h
Usermode/Libraries/libc.so_src/include_exp/signal.h
Usermode/Libraries/libc.so_src/include_exp/stdio.h
Usermode/Libraries/libc.so_src/include_exp/stdlib.h
Usermode/Libraries/libc.so_src/include_exp/string.h
Usermode/Libraries/libc.so_src/include_exp/time.h
Usermode/Libraries/libc.so_src/stdio.c
Usermode/Libraries/libc.so_src/stdio_files.c [new file with mode: 0644]
Usermode/Libraries/libc.so_src/string.c
Usermode/Libraries/libc.so_src/time.c
Usermode/Libraries/libc.so_src/timeconv.c [new file with mode: 0644]
Usermode/Libraries/libc.so_src/timeconv.h [new file with mode: 0644]
Usermode/Libraries/libm.so_src/include_exp/math.h
Usermode/Libraries/libm.so_src/pow.c
Usermode/Libraries/libposix.so_src/Makefile
Usermode/Libraries/libposix.so_src/include_exp/dirent.h
Usermode/Libraries/libposix.so_src/include_exp/libposix_stdlib.h [new file with mode: 0644]
Usermode/Libraries/libposix.so_src/include_exp/sys/mman.h [new file with mode: 0644]
Usermode/Libraries/libposix.so_src/include_exp/sys/stat.h
Usermode/Libraries/libposix.so_src/include_exp/sys/time.h
Usermode/Libraries/libposix.so_src/include_exp/sys/types.h
Usermode/Libraries/libposix.so_src/include_exp/unistd.h
Usermode/Libraries/libposix.so_src/include_exp/utime.h [new file with mode: 0644]
Usermode/Libraries/libposix.so_src/mktemp.c [new file with mode: 0644]
Usermode/Libraries/libposix.so_src/unistd.c
Usermode/Libraries/libposix.so_src/utime.c [new file with mode: 0644]
Usermode/Libraries/libpsocket.so_src/Makefile
Usermode/Libraries/libpsocket.so_src/byteordering.c [new file with mode: 0644]
Usermode/Libraries/libpsocket.so_src/getaddrinfo.c
Usermode/Libraries/libpsocket.so_src/include_exp/arpa/inet.h
Usermode/Libraries/libpsocket.so_src/include_exp/netdb.h
Usermode/Libraries/libpsocket.so_src/include_exp/netinet/in.h
Usermode/Libraries/libpsocket.so_src/include_exp/sys/socket.h
Usermode/Libraries/libpsocket.so_src/pton.c

index 65777d1..6559146 100644 (file)
@@ -3,6 +3,7 @@
 #
 
 CC = i586-elf-gcc
+CXX = i586-elf-g++
 #CC = clang -m32
 LD = i586-elf-ld
 #CC = gcc
index 60c188f..950f0ab 100644 (file)
@@ -4,7 +4,7 @@ include $(dir $(lastword $(MAKEFILE_LIST)))../../Makefile.cfg
 
 ACPI_DEBUG ?= no
 
-BIN := ../bin-$(ARCH)/libacpica.a
+BIN := ../Output/$(ARCH)-kernel/libacpica.a
 
 _VERS := $(patsubst acpica-unix-%.tar.gz,%,$(wildcard acpica-unix-*.tar.gz))
 _VERS := $(sort $(_VERS))
index 6410f51..f42e795 100644 (file)
@@ -1,7 +1,9 @@
+ACPICA_OBJECT := $(ACESSDIR)/Externals/Output/$(ARCH)-kernel/libacpica.a
+
 CPPFLAGS += -I $(ACESSDIR)/Externals/ACPICA/include -D_ACESS -D__KERNEL__
-EXTERN_OBJS += $(ACESSDIR)/Externals/bin-$(ARCH)/libacpica.a
+EXTERN_OBJS += $(ACPICA_OBJECT)
 
-$(ACESSDIR)/Externals/bin-$(ARCH)/libacpica.a:
+$(ACPICA_OBJECT):
        @make -C $(ACESSDIR)/Externals/ACPICA
        @make -C $(ACESSDIR)/Externals/ACPICA
 
diff --git a/Externals/bochs/Makefile b/Externals/bochs/Makefile
new file mode 100644 (file)
index 0000000..25b85e3
--- /dev/null
@@ -0,0 +1,17 @@
+#
+# Acess2 Externals - bochs
+# - Patches and Makefile by John Hodge (thePowersGang)
+#
+
+DEPS := sdl12 cross-compiler
+TARBALL_PATTERN := bochs-*.tar.gz
+TARBALL_TO_DIR_L := bochs-%.tar.gz
+TARBALL_TO_DIR_R := bochs-%
+PATCHES := config.h.in config.sub
+
+#AUTORECONF = yes
+CONFIGURE_ARGS := --with-sdl --without-x11 LDFLAGS=-lpsocket
+
+include ../common_automake.mk
+
+
diff --git a/Externals/bochs/patches/config.h.in.patch b/Externals/bochs/patches/config.h.in.patch
new file mode 100644 (file)
index 0000000..3e8f898
--- /dev/null
@@ -0,0 +1,6 @@
+--- bochs-2.6.2_orig/config.h.in       2013-06-17 11:39:39.670720710 +0800
++++ bochs-2.6.2/config.h.in    2013-06-17 11:48:09.149384231 +0800
+@@ -57,2 +57,2 @@
+ // Define to 1 if you have <locale.h>
+-#define HAVE_LOCALE_H 0
++#undef HAVE_LOCALE_H
diff --git a/Externals/bochs/patches/config.sub.patch b/Externals/bochs/patches/config.sub.patch
new file mode 100644 (file)
index 0000000..9a3adc3
--- /dev/null
@@ -0,0 +1,7 @@
+--- bochs-2.6.2_orig/config.sub        2013-06-17 11:39:39.670720710 +0800
++++ bochs-2.6.2/config.sub     2013-06-17 11:48:09.149384231 +0800
+@@ -1299,2 +1299,3 @@
+             | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
++            | -acess2 \
+             | -aos* | -aros* \
+
diff --git a/Externals/common.mk b/Externals/common.mk
deleted file mode 100644 (file)
index 575c51a..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-# 
-# Acess2 OS - "Externals"
-# - By John Hodge (thePowersGang)
-#
-# common.mk
-# - Common makefile code for many autoconf(-like) externals
-
-include $(dir $(lastword $(MAKEFILE_LIST)))/core.mk
-
-CONFIGURE_LINE ?= $(SDIR)/configure --host=$(HOST) --prefix=$(PREFIX) --exec-prefix=$(EPREFIX) $(CONFIGURE_ARGS)
-
-
-CONFIGSCRIPT := $(BDIR)/$(firstword $(CONFIGURE_LINE))
-PATCHED_ACFILES := $(filter %/configure.in %/config.sub, $(PATCHED_FILES))
-$(warning $(CONFIGSCRIPT): $(PATCHED_ACFILES))
-
-$(CONFIGSCRIPT): $(PATCHED_ACFILES)
-ifeq ($(AUTORECONF),)
-else
-       cd $(DIR) && autoreconf --force --install
-endif
-
-$(BDIR)/Makefile: _patch $(CONFIGSCRIPT) ../common.mk Makefile 
-       mkdir -p $(BDIR)
-       cd $(BDIR) && PATH=$(PREFIX)-BUILD/bin:$(PATH) $(CONFIGURE_LINE)
-
-_build: $(BDIR)/Makefile
-       cd $(BDIR) && make $(BTARGETS)
-
-install: all
-       cd $(BDIR) && make $(ITARGETS)
-
diff --git a/Externals/common_automake.mk b/Externals/common_automake.mk
new file mode 100644 (file)
index 0000000..70b1978
--- /dev/null
@@ -0,0 +1,32 @@
+# 
+# Acess2 OS - "Externals"
+# - By John Hodge (thePowersGang)
+#
+# common.mk
+# - Common makefile code for many autoconf(-like) externals
+
+include $(dir $(lastword $(MAKEFILE_LIST)))/core.mk
+
+CONFIGURE_LINE ?= $(SDIR)/configure --host=$(HOST) --prefix=$(PREFIX) --exec-prefix=$(EPREFIX) $(CONFIGURE_ARGS)
+
+
+CONFIGSCRIPT := $(BDIR)/$(firstword $(CONFIGURE_LINE))
+PATCHED_ACFILES := $(filter %/configure.in %/config.sub, $(PATCHED_FILES))
+$(warning $(CONFIGSCRIPT): $(PATCHED_ACFILES))
+
+$(CONFIGSCRIPT): $(PATCHED_ACFILES)
+ifeq ($(AUTORECONF),)
+else
+#      cd $(DIR) && aclocal --force -I acinclude
+#      cd $(DIR) && libtoolize --force
+       cd $(DIR) && autoreconf --force --install $(AUTORECONF_ARGS)
+endif
+
+$(BDIR)/Makefile: _patch $(CONFIGSCRIPT) ../common_automake.mk Makefile 
+       mkdir -p $(BDIR)
+       cd $(BDIR) && $(CONFIGURE_ENV) PATH=$(PATH) $(CONFIGURE_LINE)
+
+_build: $(BDIR)/Makefile
+       PATH=$(PATH) make $(BTARGETS) -C $(BDIR)
+       PATH=$(PATH) make DESTDIR=$(OUTDIR) $(ITARGETS) -C $(BDIR)
+
index 5e688b5..3d7913b 100644 (file)
@@ -11,10 +11,17 @@ else
  $(error No BFD translation for $(ARCH) in Externals/config.mk)
 endif
 
-#PREFIX=$(ACESSDIR)/Externals/Output
-#EPREFIX=$(ACESSDIR)/Externals/Output/$(BFD)
-PREFIX=$(ACESSDIR)/Externals/Output/$(ARCH)
-EPREFIX=$(PREFIX)
+OUTDIR=$(ACESSDIR)/Externals/Output/$(ARCH)
+BUILD_OUTDIR=$(OUTDIR)-BUILD
 SYSROOT=$(ACESSDIR)/Externals/Output/sysroot-$(BFD)
-HOST=$(BFD)-acess_proxy-elf
+
+PATH:=$(BUILD_OUTDIR)/bin:$(PATH)
+INCLUDE_DIR=$(SYSROOT)/usr/include
+
+# Runtime Options
+PREFIX=/Acess/usr/
+EPREFIX=$(PREFIX)
+HOST=$(BFD)-pc-acess2
+
+PARLEVEL ?= 1
 
index 56d4050..bc7a5b8 100644 (file)
@@ -44,7 +44,7 @@ endif
 DIR := $(patsubst $(TARBALL_TO_DIR_L),$(TARBALL_TO_DIR_R),$(ARCHIVE))
 
 ifeq ($(NOBDIR),)
- BDIR := build-$(DIR)
+ BDIR := build-$(ARCH)
 else
  BDIR := $(DIR)
 endif
@@ -57,14 +57,9 @@ all: $(DIR) _patch _build
 clean:
        rm -rf $(DIR) $(BDIR)
 
-$(DIR): $(ARCHIVE) patches/UNIFIED.patch
+$(DIR): $(ARCHIVE)
        tar -xf $(ARCHIVE)
-ifneq ($(wildcard patches/UNIFIED.patch),)
-       cd $(DIR) && patch -p1 < ../patches/UNIFIED.patch
-endif
 
-patches/UNIFIED.patch:
-       
 
 $(DIR)/%: patches/%.patch
        @echo [PATCH] $@
@@ -77,4 +72,8 @@ $(DIR)/%: patches/%
        @cp $< $@
 
 PATCHED_FILES := $(addprefix $(DIR)/,$(PATCHES))
-_patch: $(DIR) $(PATCHED_FILES)
+
+_patch: $(DIR) $(PATCHED_FILES) $(wildcard patches/UNIFIED.patch)
+ifneq ($(wildcard patches/UNIFIED.patch),)
+       cd $(DIR) && patch -p1 < ../patches/UNIFIED.patch
+endif
index 5239709..9dde5d8 100644 (file)
@@ -1,27 +1,23 @@
 
--include ../../Makefile.cfg
+
+-include ../config.mk
 
 GCC_ARCHIVE:=$(lastword $(sort $(wildcard gcc-*.tar.bz2)))
 GCC_DIR:=$(GCC_ARCHIVE:%.tar.bz2=%)
 BINUTILS_ARCHIVE:=$(lastword $(sort $(wildcard binutils-*.tar.bz2)))
 BINUTILS_DIR:=$(BINUTILS_ARCHIVE:%.tar.bz2=%)
 
-BINUTILS_CHANGES := config.sub bfd/config.bfd gas/configure.tgt ld/configure.tgt ld/emulparams/acess2_i386.sh ld/Makefile.in
-GCC_CHANGES := config.sub gcc/config.gcc gcc/config/acess2.h libgcc/config.host 
-
-ifeq ($(ARCH),x86)
- BFDARCH:=i586
-else ifeq ($(ARCH),x86_64)
- BFDARCH:=x86_64
-else
- $(error Arch $(ARCH) is not supported by magic gcc makfile)
-endif
+BINUTILS_CHANGES := config.sub bfd/config.bfd gas/configure.tgt ld/configure.tgt ld/emulparams/acess2_i386.sh ld/emulparams/acess2_amd64.sh ld/Makefile.in
+GCC_CHANGES := config.sub gcc/config.gcc gcc/config/acess2.h libgcc/config.host
+# libstdc++-v3/crossconfig.m4 config/override.m4
 
-PARLEVEL ?= 1
+TARGET=$(HOST)
+GCC_TARGETS := gcc target-libgcc
+# target-libstdc++-v3 
 
-TARGET=$(BFDARCH)-pc-acess2
-PREFIX=$(shell pwd)/cross
-SYSROOT=$(shell pwd)/sysroot-$(ARCH)
+PREFIX := $(OUTDIR)-BUILD
+BDIR_GCC := build-$(ARCH)/gcc
+BDIR_BINUTILS := build-$(ARCH)/binutils
 
 .PHONY: all clean binutils gcc include
 
@@ -30,8 +26,8 @@ all: include binutils gcc
 include:
        mkdir -p $(PREFIX)
        mkdir -p $(SYSROOT)/usr
-       -ln -s $(ACESSDIR)/Usermode/include $(SYSROOT)/usr/include
-       -ln -s $(ACESSDIR)/Usermode/Output/$(ARCH)/Libs $(SYSROOT)/usr/lib
+       ln -sf $(ACESSDIR)/Usermode/include $(SYSROOT)/usr/include
+       ln -sf $(ACESSDIR)/Usermode/Output/$(ARCH)/Libs $(SYSROOT)/usr/lib
 
 gcc: $(GCC_DIR) $(PREFIX)/bin/$(TARGET)-gcc
 
@@ -60,8 +56,8 @@ $(BINUTILS_DIR)/%: patches/binutils/%
        @echo [CP] $@
        @cp $< $@
 
-BDIR_GCC := build-$(ARCH)/gcc
-BDIR_BINUTILS := build-$(ARCH)/binutils
+$(GCC_DIR)/libstdc++-v3/configure: $(GCC_DIR)/libstdc++-v3/crossconfig.m4
+       cd $(GCC_DIR)/libstdc++-v3/ && autoconf
 
 $(BDIR_BINUTILS)/Makefile: $(addprefix $(BINUTILS_DIR)/,$(BINUTILS_CHANGES))
        @mkdir -p $(BDIR_BINUTILS)
@@ -71,13 +67,12 @@ $(PREFIX)/bin/$(TARGET)-ld: $(BDIR_BINUTILS)/Makefile
        @make -C $(BDIR_BINUTILS) all -j $(PARLEVEL)
        @make -C $(BDIR_BINUTILS) install
 
-$(BDIR_GCC)/Makefile: Makefile $(addprefix $(GCC_DIR)/,$(GCC_CHANGES))
+$(BDIR_GCC)/Makefile: Makefile $(addprefix $(GCC_DIR)/,$(GCC_CHANGES)) $(GCC_DIR)/libstdc++-v3/configure
        @mkdir -p $(BDIR_GCC)
        @cd $(BDIR_GCC) && PATH=$(PREFIX)/bin:$$PATH ../../$(GCC_DIR)/configure --target=$(TARGET) --prefix=$(PREFIX) --disable-nls --enable-langs=c,c++ --includedir=$(ACESSDIR)/Usermode/include "--with-sysroot=$(SYSROOT)"
 
 $(PREFIX)/bin/$(TARGET)-gcc: $(BDIR_GCC)/Makefile
-       @PATH=$(PREFIX)/bin:$$PATH make -C $(BDIR_GCC) all-gcc -j $(PARLEVEL)
-       @PATH=$(PREFIX)/bin:$$PATH make -C $(BDIR_GCC) all-target-libgcc -j $(PARLEVEL)
-       @make -C $(BDIR_GCC) install-gcc install-target-libgcc
+       @PATH=$(PREFIX)/bin:$$PATH make -C $(BDIR_GCC) $(GCC_TARGETS:%=all-%) -j $(PARLEVEL)
+       @PATH=$(PREFIX)/bin:$$PATH make -C $(BDIR_GCC) $(GCC_TARGETS:%=install-%)
 
 
index f3b8d3e..6b61642 100644 (file)
@@ -1,14 +1,18 @@
 --- bfd/config.bfd 2011-07-29 00:00:00.000000 +0000
 +++ bfd/config.bfd 2013-03-01 10:45:00.000000 +0800
-@@ -1576,2 +1576,11 @@
+@@ -1576,2 +1576,15 @@
    ;;
 +  i[3-7]86-*-acess2)
 +    targ_defvec=bfd_elf32_i386_vec
-+    targ_selvecs=i386coff_vec
++    targ_selvecs="bfd_elf32_i386_vec i386coff_vec"
 +    ;;
 +  x86_64-*-acess2)
 +    targ_defvec=bfd_elf64_x86_64_vec
 +    targ_selvecs="bfd_elf32_i386_vec bfd_elf32_x86_64_vec i386linux_vec i386pei_vec x86_64pei_vec bfd_elf64_l1om_vec bfd_elf64_k1om_vec"
 +    want64=true
++    ;;
++  arm-*-acess2)
++    targ_defvec=bfd_elf32_arm_vec
++    targ_selvecs="bfd_elf32_arm_vec"
 +    ;;
  # END OF targmatch.h
index f47e9f7..7643961 100644 (file)
@@ -1,7 +1,9 @@
 --- ld/Makefile.in
 +++ ld/Makefile.in
-@@ -2627,2 +2627,4 @@
+@@ -2627,2 +2627,6 @@
        ${GENSCRIPTS} elf32xtensa "$(tdir_elf32xtensa)"
 +eacess2_i386.c: $(srcdir)/emulparams/acess2_i386.sh $(ELF_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
 +      ${GENSCRIPTS} acess2_i386 "$(tdir_acess2_i386)"
++eacess2_amd64.c: $(srcdir)/emulparams/acess2_amd64.sh $(ELF_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
++      ${GENSCRIPTS} acess2_amd64 "$(tdir_acess2_amd64)"
  eelf_i386.c: $(srcdir)/emulparams/elf_i386.sh \
index 828b07c..8d6a302 100644 (file)
@@ -1,6 +1,7 @@
 --- ld/configure.tgt
 +++ ld/configure.tgt
-@@ -167,1 +167,2 @@
+@@ -167,1 +167,3 @@
  i[3-7]86-*-nto-qnx*)    targ_emul=i386nto ;;
 +i[3-7]86-*-acess2*)    targ_emul=acess2_i386 ;;
++x86_64-*-acess2*)    targ_emul=acess2_amd64 ;;
 
diff --git a/Externals/cross-compiler/patches/binutils/ld/emulparams/acess2_amd64.sh b/Externals/cross-compiler/patches/binutils/ld/emulparams/acess2_amd64.sh
new file mode 100644 (file)
index 0000000..d31dae9
--- /dev/null
@@ -0,0 +1,18 @@
+SCRIPT_NAME=elf
+OUTPUT_FORMAT=elf64-x86_64
+TEXT_START_ADDR=0x00400000
+MAXPAGESIZE="CONSTANT (MAXPAGESIZE)"
+COMMONPAGESIZE="CONSTANT (COMMONPAGESIZE)"
+TEMPLATE_NAME=elf64
+
+ARCH=x86_64
+MACHINE=
+NOP=0x90909090
+GENERATE_SHLIB_SCRIPT=yes
+GENERATE_PIE_SCRIPT=yes
+
+NO_SMALL_DATA=yes
+SEPARATE_GOTPLT=12
+
+ELF_INTERPRETER_NAME=\"/Acess/Libs/ld-acess.so\"
+
diff --git a/Externals/cross-compiler/patches/config/override.m4.patch b/Externals/cross-compiler/patches/config/override.m4.patch
new file mode 100644 (file)
index 0000000..ea2aafb
--- /dev/null
@@ -0,0 +1,15 @@
+--- orig/gcc-4.7.1/config/override.m4  2014-03-08 22:29:42.765585740 +0800
++++ gcc-4.7.1/config/override.m4       2011-03-05 15:32:50.000000000 +0800
+@@ -39,9 +39,9 @@
+ dnl without rewriting this file.
+ dnl Or for updating the whole tree at once with the definition above.
+ AC_DEFUN([_GCC_AUTOCONF_VERSION_CHECK],
++[dnl m4_if(m4_defn([_GCC_AUTOCONF_VERSION]),
++ dnl  m4_defn([m4_PACKAGE_VERSION]), [],
++ dnl [m4_fatal([Please use exactly Autoconf ]_GCC_AUTOCONF_VERSION[ instead of ]m4_defn([m4_PACKAGE_VERSION])[.])])
+-[m4_if(m4_defn([_GCC_AUTOCONF_VERSION]),
+-  m4_defn([m4_PACKAGE_VERSION]), [],
+-  [m4_fatal([Please use exactly Autoconf ]_GCC_AUTOCONF_VERSION[ instead of ]m4_defn([m4_PACKAGE_VERSION])[.])])
+ ])
+ m4_define([AC_INIT], m4_defn([AC_INIT])[
+ _GCC_AUTOCONF_VERSION_CHECK
index c8545ff..4a1525f 100644 (file)
@@ -4,7 +4,7 @@
  # Common parts for widely ported systems.
  case ${target} in
 +*-*-acess2*)
-+  extra_parts="crt0.o crtbegin.o crtend.o"
++  extra_parts="crtbegin.o crtend.o"
 +  gas=yes
 +  gnu_ld=yes
 +  default_use_cxa_atexit=yes
index c7ca51a..ec3c113 100644 (file)
@@ -7,7 +7,8 @@
     builtin_assert ("system=unix");   \
   } while(0);
 
-#define LIB_SPEC       "-lc -lld-acess"
+#define LIB_SPEC       "-lc -lld-acess -lposix"
+#define LIBSTDCXX "c++"
 
 /*
 #undef TARGET_VERSION                                     // note that adding these two lines cause an error in gcc-4.7.0
index 1ad2b3e..bcf7a4a 100644 (file)
@@ -5,11 +5,11 @@
        tmake_file="$tmake_file i386/t-crtstuff t-crtstuff-pic t-libgcc-pic"
        ;;
 +i[3-7]86-*-acess2*)
-+      extra_parts="crt0.o crtbegin.o crtend.o"
++      extra_parts="crtbegin.o crtend.o"
 +      tmake_file="$tmake_file i386/t-crtstuff"
 +      ;;
 +x86_64-*-acess2*)
-+      extra_parts="crt0.o crtbegin.o crtend.o"
++      extra_parts="crtbegin.o crtend.o"
 +      tmake_file="$tmake_file i386/t-crtstuff t-crtstuff-pic t-libgcc-pic"
 +      ;;
  i[34567]86-*-freebsd*)
index 2ae2894..d9f59e8 100644 (file)
@@ -7,10 +7,11 @@ DEPS := zlib
 TARBALL_PATTERN := dropbear-*.tar.bz2
 TARBALL_TO_DIR_L := %.tar.bz2
 TARBALL_TO_DIR_R := %
-PATCHES := options.h
-CONFIGURE_ARGS = --with-zlib=$(PREFIX) --disable-utmp --disable-wtmp --disable-lastlog
+PATCHES := options.h config.sub
+CONFIGURE_ARGS = --with-zlib=$(OUTDIR) --disable-utmp --disable-wtmp --disable-lastlog DSS_PRIV_FILENAME=/Acess/Conf/dropbear/host_key_dss RSA_PRIV_FILENAME=/Acess/Conf/dropbear/host_key_rsa MOTD_FILENAME=/Acess/Conf/dropbear/motd
+CONFIGURE_ENV = LIBS=-lpsocket
 BTARGETS = dbclient dropbear
 ITARGETS = inst_dbclient inst_dropbear
 
-include ../common.mk
+include ../common_automake.mk
 
diff --git a/Externals/dropbear/patches/config.sub.patch b/Externals/dropbear/patches/config.sub.patch
new file mode 100644 (file)
index 0000000..cbbd73f
--- /dev/null
@@ -0,0 +1,9 @@
+--- config.sub
++++ config.sub
+@@ -1344,3 +1344,6 @@
+               os=-mint
+               ;;
++      -acess2)
++              os=-acess2
++              ;;
+       -aros*)
index 9ff95cb..0022eb9 100644 (file)
@@ -1,10 +1,24 @@
 --- options.h
 +++ options.h
-@@ -54,2 +54,2 @@
+@@ -23,6 +23,6 @@
+ #ifndef DSS_PRIV_FILENAME
+-#define DSS_PRIV_FILENAME "/etc/dropbear/dropbear_dss_host_key"
++#define DSS_PRIV_FILENAME "/Acess/Conf/dropbear/host_key_dss"
+ #endif
+ #ifndef RSA_PRIV_FILENAME
+-#define RSA_PRIV_FILENAME "/etc/dropbear/dropbear_rsa_host_key"
++#define RSA_PRIV_FILENAME "/Acess/Conf/dropbear/host_key_rsa"
+ #endif
+@@ -55,2 +55,2 @@
  /* Enable X11 Forwarding - server only */
 -#define ENABLE_X11FWD
 +//#define ENABLE_X11FWD
-@@ -217,2 +217,2 @@
+@@ -163,3 +163,3 @@
+ #ifndef MOTD_FILENAME
+-#define MOTD_FILENAME "/etc/motd"
++#define MOTD_FILENAME "/Acess/Conf/dropbear/motd"
+ #endif
+@@ -216,2 +216,2 @@
   * rsa/dss key generation */
 -#define DROPBEAR_URANDOM_DEV "/dev/urandom"
 +#define DROPBEAR_URANDOM_DEV "/Devices/frandom"
index 6ee50f8..c247e60 100644 (file)
@@ -7,9 +7,10 @@ DEPS :=
 TARBALL_PATTERN := SDL-*.tar.gz
 TARBALL_TO_DIR_L := %.tar.gz
 TARBALL_TO_DIR_R := %
-PATCHES := configure.in src/video/acess/ptyvideo.c src/video/SDL_video.c src/video/SDL_sysvideo.h
-CONFIGURE_ARGS = 
-AUTORECONF = yes
+PATCHES := configure build-scripts/config.sub
+PATCHES += src/video/acess/ptyvideo.c src/video/SDL_video.c src/video/SDL_sysvideo.h
+CONFIGURE_ARGS = --includedir=$(INCLUDEDIR) --bindir=$(OUTDIR)-BUILD/bin/
+#AUTORECONF = yes
 
-include ../common.mk
+include ../common_automake.mk
 
diff --git a/Externals/sdl12/patches/configure.in.patch b/Externals/sdl12/patches/configure.in.patch
deleted file mode 100644 (file)
index df2154d..0000000
+++ /dev/null
@@ -1,167 +0,0 @@
---- SDL-1.2.15_orig/configure.in       2013-06-17 11:39:39.670720710 +0800
-+++ SDL-1.2.15/configure.in    2013-06-17 11:48:09.149384231 +0800
-@@ -43,6 +43,147 @@
- AC_SUBST(LT_REVISION)
- AC_SUBST(LT_AGE)
-+AH_TEMPLATE(HAVE_ALTIVEC_H, [])
-+AH_TEMPLATE(HAVE_CLOCK_GETTIME, [])
-+AH_TEMPLATE(HAVE_LIBC, [])
-+AH_TEMPLATE(HAVE_MEMCMP, [])
-+AH_TEMPLATE(HAVE_MPROTECT, [])
-+AH_TEMPLATE(HAVE_SA_SIGACTION, [])
-+AH_TEMPLATE(HAVE_SEM_TIMEDWAIT, [])
-+AH_TEMPLATE(HAVE_STRTOD, [])
-+AH_TEMPLATE(SDL_ALTIVEC_BLITTERS, [])
-+AH_TEMPLATE(SDL_ASSEMBLY_ROUTINES, [])
-+AH_TEMPLATE(SDL_AUDIO_DISABLED, [])
-+AH_TEMPLATE(SDL_AUDIO_DRIVER_ALSA, [])
-+AH_TEMPLATE(SDL_AUDIO_DRIVER_ALSA_DYNAMIC, [])
-+AH_TEMPLATE(SDL_AUDIO_DRIVER_ARTS, [])
-+AH_TEMPLATE(SDL_AUDIO_DRIVER_ARTS_DYNAMIC, [])
-+AH_TEMPLATE(SDL_AUDIO_DRIVER_BAUDIO, [])
-+AH_TEMPLATE(SDL_AUDIO_DRIVER_BSD, [])
-+AH_TEMPLATE(SDL_AUDIO_DRIVER_COREAUDIO, [])
-+AH_TEMPLATE(SDL_AUDIO_DRIVER_DISK, [])
-+AH_TEMPLATE(SDL_AUDIO_DRIVER_DMEDIA, [])
-+AH_TEMPLATE(SDL_AUDIO_DRIVER_DSOUND, [])
-+AH_TEMPLATE(SDL_AUDIO_DRIVER_DUMMY, [])
-+AH_TEMPLATE(SDL_AUDIO_DRIVER_ESD, [])
-+AH_TEMPLATE(SDL_AUDIO_DRIVER_ESD_DYNAMIC, [])
-+AH_TEMPLATE(SDL_AUDIO_DRIVER_MINT, [])
-+AH_TEMPLATE(SDL_AUDIO_DRIVER_MMEAUDIO, [])
-+AH_TEMPLATE(SDL_AUDIO_DRIVER_NAS, [])
-+AH_TEMPLATE(SDL_AUDIO_DRIVER_NAS_DYNAMIC, [])
-+AH_TEMPLATE(SDL_AUDIO_DRIVER_OSS, [])
-+AH_TEMPLATE(SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H, [])
-+AH_TEMPLATE(SDL_AUDIO_DRIVER_PAUD, [])
-+AH_TEMPLATE(SDL_AUDIO_DRIVER_PULSE, [])
-+AH_TEMPLATE(SDL_AUDIO_DRIVER_PULSE_DYNAMIC, [])
-+AH_TEMPLATE(SDL_AUDIO_DRIVER_QNXNTO, [])
-+AH_TEMPLATE(SDL_AUDIO_DRIVER_SUNAUDIO, [])
-+AH_TEMPLATE(SDL_AUDIO_DRIVER_WAVEOUT, [])
-+AH_TEMPLATE(SDL_BYTEORDER, [])
-+AH_TEMPLATE(SDL_CDROM_AIX, [])
-+AH_TEMPLATE(SDL_CDROM_BEOS, [])
-+AH_TEMPLATE(SDL_CDROM_BSDI, [])
-+AH_TEMPLATE(SDL_CDROM_DISABLED, [])
-+AH_TEMPLATE(SDL_CDROM_FREEBSD, [])
-+AH_TEMPLATE(SDL_CDROM_LINUX, [])
-+AH_TEMPLATE(SDL_CDROM_MACOSX, [])
-+AH_TEMPLATE(SDL_CDROM_MINT, [])
-+AH_TEMPLATE(SDL_CDROM_OPENBSD, [])
-+AH_TEMPLATE(SDL_CDROM_OSF, [])
-+AH_TEMPLATE(SDL_CDROM_QNX, [])
-+AH_TEMPLATE(SDL_CDROM_WIN32, [])
-+AH_TEMPLATE(SDL_CPUINFO_DISABLED, [])
-+AH_TEMPLATE(SDL_EVENTS_DISABLED, [])
-+AH_TEMPLATE(SDL_FILE_DISABLED, [])
-+AH_TEMPLATE(SDL_HAS_64BIT_TYPE, [])
-+AH_TEMPLATE(SDL_HERMES_BLITTERS, [])
-+AH_TEMPLATE(SDL_INPUT_LINUXEV, [])
-+AH_TEMPLATE(SDL_INPUT_TSLIB, [])
-+AH_TEMPLATE(SDL_JOYSTICK_BEOS, [])
-+AH_TEMPLATE(SDL_JOYSTICK_DISABLED, [])
-+AH_TEMPLATE(SDL_JOYSTICK_DUMMY, [])
-+AH_TEMPLATE(SDL_JOYSTICK_IOKIT, [])
-+AH_TEMPLATE(SDL_JOYSTICK_LINUX, [])
-+AH_TEMPLATE(SDL_JOYSTICK_MINT, [])
-+AH_TEMPLATE(SDL_JOYSTICK_RISCOS, [])
-+AH_TEMPLATE(SDL_JOYSTICK_USBHID, [])
-+AH_TEMPLATE(SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H, [])
-+AH_TEMPLATE(SDL_JOYSTICK_WINMM, [])
-+AH_TEMPLATE(SDL_LOADSO_BEOS, [])
-+AH_TEMPLATE(SDL_LOADSO_DISABLED, [])
-+AH_TEMPLATE(SDL_LOADSO_DLCOMPAT, [])
-+AH_TEMPLATE(SDL_LOADSO_DLOPEN, [])
-+AH_TEMPLATE(SDL_LOADSO_LDG, [])
-+AH_TEMPLATE(SDL_LOADSO_WIN32, [])
-+AH_TEMPLATE(SDL_THREADS_DISABLED, [])
-+AH_TEMPLATE(SDL_THREAD_BEOS, [])
-+AH_TEMPLATE(SDL_THREAD_PTH, [])
-+AH_TEMPLATE(SDL_THREAD_PTHREAD, [])
-+AH_TEMPLATE(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX, [])
-+AH_TEMPLATE(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP, [])
-+AH_TEMPLATE(SDL_THREAD_SPROC, [])
-+AH_TEMPLATE(SDL_THREAD_WIN32, [])
-+AH_TEMPLATE(SDL_TIMERS_DISABLED, [])
-+AH_TEMPLATE(SDL_TIMER_BEOS, [])
-+AH_TEMPLATE(SDL_TIMER_MINT, [])
-+AH_TEMPLATE(SDL_TIMER_RISCOS, [])
-+AH_TEMPLATE(SDL_TIMER_UNIX, [])
-+AH_TEMPLATE(SDL_TIMER_WIN32, [])
-+AH_TEMPLATE(SDL_TIMER_WINCE, [])
-+AH_TEMPLATE(SDL_VIDEO_DISABLED, [])
-+AH_TEMPLATE(SDL_VIDEO_DISABLE_SCREENSAVER, [])
-+AH_TEMPLATE(SDL_VIDEO_DRIVER_AALIB, [])
-+AH_TEMPLATE(SDL_VIDEO_DRIVER_ACESS, [])
-+AH_TEMPLATE(SDL_VIDEO_DRIVER_BWINDOW, [])
-+AH_TEMPLATE(SDL_VIDEO_DRIVER_CACA, [])
-+AH_TEMPLATE(SDL_VIDEO_DRIVER_DDRAW, [])
-+AH_TEMPLATE(SDL_VIDEO_DRIVER_DGA, [])
-+AH_TEMPLATE(SDL_VIDEO_DRIVER_DIRECTFB, [])
-+AH_TEMPLATE(SDL_VIDEO_DRIVER_DUMMY, [])
-+AH_TEMPLATE(SDL_VIDEO_DRIVER_FBCON, [])
-+AH_TEMPLATE(SDL_VIDEO_DRIVER_GEM, [])
-+AH_TEMPLATE(SDL_VIDEO_DRIVER_GGI, [])
-+AH_TEMPLATE(SDL_VIDEO_DRIVER_IPOD, [])
-+AH_TEMPLATE(SDL_VIDEO_DRIVER_NANOX, [])
-+AH_TEMPLATE(SDL_VIDEO_DRIVER_PHOTON, [])
-+AH_TEMPLATE(SDL_VIDEO_DRIVER_PICOGUI, [])
-+AH_TEMPLATE(SDL_VIDEO_DRIVER_PS2GS, [])
-+AH_TEMPLATE(SDL_VIDEO_DRIVER_PS3, [])
-+AH_TEMPLATE(SDL_VIDEO_DRIVER_QTOPIA, [])
-+AH_TEMPLATE(SDL_VIDEO_DRIVER_QUARTZ, [])
-+AH_TEMPLATE(SDL_VIDEO_DRIVER_RISCOS, [])
-+AH_TEMPLATE(SDL_VIDEO_DRIVER_SVGALIB, [])
-+AH_TEMPLATE(SDL_VIDEO_DRIVER_TOOLBOX, [])
-+AH_TEMPLATE(SDL_VIDEO_DRIVER_VGL, [])
-+AH_TEMPLATE(SDL_VIDEO_DRIVER_WINDIB, [])
-+AH_TEMPLATE(SDL_VIDEO_DRIVER_WSCONS, [])
-+AH_TEMPLATE(SDL_VIDEO_DRIVER_X11, [])
-+AH_TEMPLATE(SDL_VIDEO_DRIVER_X11_DGAMOUSE, [])
-+AH_TEMPLATE(SDL_VIDEO_DRIVER_X11_DYNAMIC, [])
-+AH_TEMPLATE(SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT, [])
-+AH_TEMPLATE(SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR, [])
-+AH_TEMPLATE(SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER, [])
-+AH_TEMPLATE(SDL_VIDEO_DRIVER_X11_VIDMODE, [])
-+AH_TEMPLATE(SDL_VIDEO_DRIVER_X11_XINERAMA, [])
-+AH_TEMPLATE(SDL_VIDEO_DRIVER_X11_XME, [])
-+AH_TEMPLATE(SDL_VIDEO_DRIVER_X11_XRANDR, [])
-+AH_TEMPLATE(SDL_VIDEO_DRIVER_X11_XV, [])
-+AH_TEMPLATE(SDL_VIDEO_DRIVER_XBIOS, [])
-+AH_TEMPLATE(SDL_VIDEO_OPENGL, [])
-+AH_TEMPLATE(SDL_VIDEO_OPENGL_GLX, [])
-+AH_TEMPLATE(SDL_VIDEO_OPENGL_OSMESA, [])
-+AH_TEMPLATE(SDL_VIDEO_OPENGL_OSMESA_DYNAMIC, [])
-+AH_TEMPLATE(SDL_VIDEO_OPENGL_WGL, [])
-+AH_TEMPLATE(int8_t,  [Signed 8-bit int])
-+AH_TEMPLATE(int16_t, [Signed 16-bit int])
-+AH_TEMPLATE(int32_t, [Signed 32-bit int])
-+AH_TEMPLATE(int64_t, [Signed 64-bit int])
-+AH_TEMPLATE(uint8_t,  [Unigned 8-bit int])
-+AH_TEMPLATE(uint16_t, [Unigned 16-bit int])
-+AH_TEMPLATE(uint32_t, [Unigned 32-bit int])
-+AH_TEMPLATE(uint64_t, [Unigned 64-bit int])
-+AH_TEMPLATE(uintptr_t, [Unsigned pointer-sized integer])
-+
- dnl Detect the canonical build and host environments
- AC_CONFIG_AUX_DIR([build-scripts])
- dnl AC_CANONICAL_HOST
-@@ -2831,6 +2972,16 @@
-         # The RISC OS platform requires special setup.
-         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ljpeg -ltiff -lpng -lz"
-         ;;
-+    *-acess*)
-+        ARCH=acess
-+        # Set up files for the video library
-+        if test x$enable_video = xyes; then
-+            AC_DEFINE(SDL_VIDEO_DRIVER_ACESS)
-+            SOURCES="$SOURCES $srcdir/src/video/acess/*.c"
-+            have_video=yes
-+        fi
-+       # TODO: Joystick
-+        ;;
-     *)
-         AC_MSG_ERROR([
- *** Unsupported host:  Please add to configure.in
diff --git a/Externals/sdl12/patches/configure.patch b/Externals/sdl12/patches/configure.patch
new file mode 100644 (file)
index 0000000..234ab6b
--- /dev/null
@@ -0,0 +1,19 @@
+--- configure
++++ configure
+@@ -30162,4 +30162,16 @@
+         # The RISC OS platform requires special setup.
+         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ljpeg -ltiff -lpng -lz"
+         ;;
++    *-acess*)
++        ARCH=acess
++        # Set up files for the video library
++        if test x$enable_video = xyes; then
++            cat >>confdefs.h <<\_ACEOF
++#define SDL_VIDEO_DRIVER_ACESS 1
++_ACEOF
++            SOURCES="$SOURCES $srcdir/src/video/acess/*.c"
++            have_video=yes
++        fi
++       # TODO: Joystick
++        ;;
+     *)
index 01e6c49..7f14e62 100644 (file)
@@ -8,8 +8,8 @@ TARBALL_PATTERN := zlib-*.tar.gz
 TARBALL_TO_DIR_L := %.tar.gz
 TARBALL_TO_DIR_R := %
 PATCHES := 
-CONFIGURE_LINE = CC=$(HOST)-gcc $(SDIR)/configure --static --prefix=$(PREFIX) --eprefix=$(EPREFIX)
+CONFIGURE_LINE = CC=$(HOST)-gcc $(SDIR)/configure --static --prefix=$(PREFIX) --eprefix=$(EPREFIX) --includedir=$(INCLUDE_DIR)
 NOBDIR = yes
 
-include ../common.mk
+include ../common_automake.mk
 
index ae7cd8e..5e5ccd3 100644 (file)
@@ -57,6 +57,7 @@ extern void   Threads_SegFault(tVAddr Addr);
 void   MM_PreinitVirtual(void);
 void   MM_InstallVirtual(void);
 void   MM_PageFault(tVAddr Addr, Uint ErrorCode, tRegs *Regs);
+void   MM_DumpTables_Print(tVAddr Start, Uint32 Orig, size_t Size, void *Node);
 //void MM_DumpTables(tVAddr Start, tVAddr End);
 //void MM_ClearUser(void);
 tPAddr MM_DuplicatePage(tVAddr VAddr);
@@ -256,6 +257,37 @@ void MM_PageFault(tVAddr Addr, Uint ErrorCode, tRegs *Regs)
        Panic("Page Fault at 0x%x (Accessed 0x%x)", Regs->eip, Addr);
 }
 
+void MM_DumpTables_Print(tVAddr Start, Uint32 Orig, size_t Size, void *Node)
+{
+       if( (Orig & ~(PAGE_SIZE-1)) == giMM_ZeroPage )
+       {
+               Log( "0x%08x => ZERO + 0x%08x (%s%s%s%s%s) %p",
+                       Start,
+                       Size,
+                       (Orig & PF_NOPAGE ? "P" : "-"),
+                       (Orig & PF_COW ? "C" : "-"),
+                       (Orig & PF_GLOBAL ? "G" : "-"),
+                       (Orig & PF_USER ? "U" : "-"),
+                       (Orig & PF_WRITE ? "W" : "-"),
+                       Node
+                       );
+       }
+       else
+       {
+               Log(" 0x%08x => 0x%08x + 0x%08x (%s%s%s%s%s) %p",
+                       Start,
+                       Orig & ~0xFFF,
+                       Size,
+                       (Orig & PF_NOPAGE ? "P" : "-"),
+                       (Orig & PF_COW ? "C" : "-"),
+                       (Orig & PF_GLOBAL ? "G" : "-"),
+                       (Orig & PF_USER ? "U" : "-"),
+                       (Orig & PF_WRITE ? "W" : "-"),
+                       Node
+                       );
+       }
+}
+
 /**
  * \fn void MM_DumpTables(tVAddr Start, tVAddr End)
  * \brief Dumps the layout of the page tables
@@ -299,17 +331,7 @@ void MM_DumpTables(tVAddr Start, tVAddr End)
                {
                        if(expected) {
                                tPAddr  orig = gaPageTable[rangeStart>>12];
-                               Log(" 0x%08x => 0x%08x - 0x%08x (%s%s%s%s%s) %p",
-                                       rangeStart,
-                                       orig & ~0xFFF,
-                                       curPos - rangeStart,
-                                       (orig & PF_NOPAGE ? "P" : "-"),
-                                       (orig & PF_COW ? "C" : "-"),
-                                       (orig & PF_GLOBAL ? "G" : "-"),
-                                       (orig & PF_USER ? "U" : "-"),
-                                       (orig & PF_WRITE ? "W" : "-"),
-                                       expected_node
-                                       );
+                               MM_DumpTables_Print(rangeStart, orig, curPos - rangeStart, expected_node);
                                expected = 0;
                        }
                        if( !(gaPageDir[curPos>>22] & PF_PRESENT) )     continue;
@@ -319,22 +341,13 @@ void MM_DumpTables(tVAddr Start, tVAddr End)
                        MM_GetPageNode(expected, &expected_node);
                        rangeStart = curPos;
                }
-               if(expected)    expected += 0x1000;
+               if(expected && (expected & ~(PAGE_SIZE-1)) != giMM_ZeroPage)
+                       expected += 0x1000;
        }
        
        if(expected) {
                tPAddr  orig = gaPageTable[rangeStart>>12];
-               Log("0x%08x => 0x%08x - 0x%08x (%s%s%s%s%s) %p",
-                       rangeStart,
-                       orig & ~0xFFF,
-                       curPos - rangeStart,
-                       (orig & PF_NOPAGE ? "p" : "-"),
-                       (orig & PF_COW ? "C" : "-"),
-                       (orig & PF_GLOBAL ? "G" : "-"),
-                       (orig & PF_USER ? "U" : "-"),
-                       (orig & PF_WRITE ? "W" : "-"),
-                       expected_node
-                       );
+               MM_DumpTables_Print(rangeStart, orig, curPos - rangeStart, expected_node);
                expected = 0;
        }
 }
@@ -405,9 +418,9 @@ int MM_Map(volatile void *VAddr, tPAddr PAddr)
        #endif
 
        // Sanity check
-       if( PAddr & 0xFFF || (tVAddr)VAddr & 0xFFF ) {
-               Log_Warning("MM_Virt", "MM_Map - Physical or Virtual Addresses are not aligned (0x%P and %p)",
-                       PAddr, VAddr);
+       if( (PAddr & 0xFFF) || ((tVAddr)VAddr & 0xFFF) ) {
+               Log_Warning("MM_Virt", "MM_Map - Physical or Virtual Addresses are not aligned (%P and %p) - %p",
+                       PAddr, VAddr, __builtin_return_address(0));
                //LEAVE('i', 0);
                return 0;
        }
index 591ae28..b6d5c2d 100644 (file)
@@ -71,7 +71,7 @@ void *VFS_MMap(void *DestHint, size_t Length, int Protection, int Flags, int FD,
        // - Sorted list of 16 page blocks
        for(
                pb = h->Node->MMapInfo, prev = NULL;
-               pb && pb->BaseOffset + MMAP_PAGES_PER_BLOCK < pagenum;
+               pb && pb->BaseOffset + MMAP_PAGES_PER_BLOCK <= pagenum;
                prev = pb, pb = pb->Next
                )
                ;
@@ -98,6 +98,8 @@ void *VFS_MMap(void *DestHint, size_t Length, int Protection, int Flags, int FD,
        // - Map (and allocate) pages
        while( npages -- )
        {
+               assert( pagenum >= pb->BaseOffset );
+               assert( pagenum - pb->BaseOffset < MMAP_PAGES_PER_BLOCK );
                if( MM_GetPhysAddr( mapping_dest ) == 0 )
                {
                        if( pb->PhysAddrs[pagenum - pb->BaseOffset] == 0 )
index 3229ef2..5034b4b 100644 (file)
@@ -146,7 +146,7 @@ EOF;
                        echo $path,"\n";
                        $size = filesize($path);
        
-                       $_sym = "_binary_".str_replace(array("/","-","."), "_", $path)."_start";
+                       $_sym = "_binary_".str_replace(array("/","-",".","+"), "_", $path)."_start";
                        $gOutput .= "extern Uint8 {$_sym}[];";
                        $gSymFiles[] = $path;
                        $gOutput .= <<<EOF
index 6d2d19c..efae3be 100644 (file)
@@ -5,6 +5,8 @@ Dir "SBin" {
        File "__BIN__/SBin/dhcpc"
        File "__BIN__/SBin/insmod"
        File "__BIN__/SBin/automount"
+       
+       OptFile "__EXT__/Acess/usr/sbin/dropbear"
 }
 Dir "Bin" {
        File "__BIN__/Bin/CLIShell"
@@ -18,13 +20,16 @@ Dir "Bin" {
        File "__BIN__/Bin/irc"
        File "__BIN__/Bin/bomb"
        
-       OptFile "__EXT__/bin/dbclient"
-       OptFile "__EXT__/bin/vttest"
+       OptFile "__EXT__/Acess/usr/bin/dbclient"
+       OptFile "__EXT__/Acess/usr/bin/vttest"
+       OptFile "__EXT__/Acess/usr/bin/bochs"
 }
 Dir "Libs" {
        File "__BIN__/Libs/ld-acess.so"
        File "__BIN__/Libs/libld-acess.so"
        File "__BIN__/Libs/libc.so"
+       File "__BIN__/Libs/libm.so"
+       File "__BIN__/Libs/libc++.so"
        File "__BIN__/Libs/libreadline.so"
        File "__BIN__/Libs/libnet.so"
        File "__BIN__/Libs/liburi.so"
@@ -37,6 +42,13 @@ Dir "Libs" {
 Dir "Conf" {
        File "__FS__/Conf/inittab"
 }
+Dir "usr" {
+       Dir "share" {
+               Dir "bochs" {
+                       OptFile "__EXT__/Acess/usr/share/bochs/BIOS-bochs-latest"
+               }
+       }
+}
 Dir "Apps" {
        Dir "AxWin" {
                Dir "3.0" {
index a8345ac..0edc983 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -10,9 +10,9 @@
 
 SUBMAKE = $(MAKE) --no-print-directory
 
-USRLIBS := crt0.o acess.ld ld-acess.so libc.so libposix.so
+USRLIBS := crt0.o acess.ld ld-acess.so libc.so libc++.so libposix.so
 USRLIBS += libreadline.so libnet.so liburi.so libpsocket.so
-USRLIBS += libimage_sif.so libunicode.so
+USRLIBS += libimage_sif.so libunicode.so libm.so
 
 EXTLIBS := 
 #libspiderscript
index 410a476..5988081 100755 (executable)
@@ -1,5 +1,7 @@
 #!/bin/bash
 
+toolname=${0##*-}
+
 # Get invocation path (which could be a symlink in $PATH)
 fullpath=`which "$0"`
 if [[ !$? ]]; then
@@ -16,7 +18,9 @@ _miscargs=""
 _compile=0
 _linktype=Applications
 
-echo [GCCProxy] $* >&2
+echo [GCCProxy] $toolname $* >&2
+
+
 
 while [[ $# -gt 0 ]]; do
        case "$1" in
@@ -73,6 +77,10 @@ while [[ $# -gt 0 ]]; do
                echo $0 --inv=ld
                exit 0
                ;;
+       -print-search-dirs)
+               _compile=1
+               _cflags=$_cflags" $1"
+               ;;
        -print-multi-os-directory)
                _compile=1
                _cflags=$_cflags" $1"
@@ -110,6 +118,16 @@ rm $cfgfile
 
 #echo "_compile = $_compile, _preproc = $_preproc"
 
+if [[ "$toolname" == "g++" ]]; then
+       COMPILER=$_CXX
+       _libs="-lc++ $_libs"
+elif [[ "$toolname" == "gcc" ]]; then
+       COMPILER=$_CC
+else
+       echo "ERROR: Unknown tool name $toolname" >&2
+       exit 1
+fi
+
 if [[ "x$_verarg" != "x" ]]; then
        if [[ "x$_actas" == "xld" ]]; then
                run $_LD $_miscargs $_verarg
@@ -137,11 +155,11 @@ elif [[ $_compile -eq 1 ]]; then
 elif echo " $_miscargs" | grep '\.c' >/dev/null; then
        tmpout=`mktemp acess_gccproxy.XXXXXXXXXX.o --tmpdir`
        run $_CC $CFLAGS $_cflags $_miscargs -c -o $tmpout
-       run $_LD $LDFLAGS $_ldflags $_libs $tmpout $_outfile $_libs $LIBGCC_PATH
+       run $_LD $LDFLAGS $_ldflags $CRTBEGIN $_libs $tmpout $_outfile $_libs $LIBGCC_PATH $CRTEND
        _rv=$?
        rm $tmpout
        exit $_rv
 else
-       run $_LD $_ldflags $_miscargs $_outfile $LDFLAGS $_libs $LIBGCC_PATH
+       run $_LD $_ldflags $CRTBEGIN $_miscargs $_outfile $LDFLAGS $_libs $LIBGCC_PATH $CRTEND
 fi
 
index e1b6cdd..fb0f076 100644 (file)
@@ -4,7 +4,11 @@ include $(dir $(lastword $(MAKEFILE_LIST)))../../Usermode/$(TYPE)/Makefile.cfg
 
 shellvars:
        @echo '_CC="$(CC)"'
+       @echo '_CXX="$(CXX)"'
        @echo '_LD="$(LD)"'
        @echo 'LDFLAGS="$(LDFLAGS)"'
-       @echo 'CFLAGS="$(CFLAGS)"'
+       @echo 'CFLAGS="$(patsubst -std=%,,$(CFLAGS))"'
+       @echo 'CXXFLAGS="$(patsubst -std=%,,$(CXXFLAGS))"'
        @echo 'LIBGCC_PATH="$(LIBGCC_PATH)"'
+       @echo 'CRTBEGIN="$(CRTBEGIN)"'
+       @echo 'CRTEND="$(CRTEND)"'
index a1a0141..ef17a14 100644 (file)
@@ -25,4 +25,7 @@ LDFLAGS += -rpath-link $(OUTPUTDIR)Libs
 # Extra-verbose errors!
 #CFLAGS += -Wall -Wextra -Wwrite-strings -Wshadow -Wswitch-default -Wswitch-enum -Wstrict-overflow=5 -Wfloat-equal -Wundef -Wmissing-declarations -Wlogical-op  -Wformat=2 -Winit-self -Wmissing-include-dirs -Wswitch-default -Wswitch-enum -Wsync-nand -Wunused -Wstrict-overflow=5 -Wfloat-equal -Wundef -Wno-endif-labels -Wshadow -Wunsafe-loop-optimizations -Wbad-function-cast -Wc++-compat -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion -Wlogical-op -Waggregate-return -Wstrict-prototypes -Wold-style-definition -Wmissing-declarations -Wnormalized=nfc -Wpacked -Wpadded -Wredundant-decls -Wnested-externs -Winline -Winvalid-pch -Wdisabled-optimization -Woverlength-strings
 
+CRTBEGIN = $(shell $(CC) $(CFLAGS) -print-file-name=crtbegin.o)
+CRTEND = $(shell $(CC) $(CFLAGS) -print-file-name=crtend.o)
+
 DIR = Bin
index 4f9dde5..efcb57d 100644 (file)
@@ -48,7 +48,7 @@ install: $(_BIN)
 $(_BIN): $(OUTPUTDIR)Libs/acess.ld $(OUTPUTDIR)Libs/crt0.o $(_LIBS) $(OBJ)
        @mkdir -p $(dir $(_BIN))
        @echo [LD] -o $@
-       $V$(LD) -g $(LDFLAGS) -o $@ $(OBJ) $(LIBGCC_PATH)
+       $V$(LD) -g $(LDFLAGS) -o $@ $(CRTBEGIN) $(OBJ) $(LIBGCC_PATH) $(CRTEND)
        $V$(DISASM) $(_BIN) > $(_OBJPREFIX)$(BIN).dsm
 
 $(OBJ): $(_OBJPREFIX)%.o: %.c
index d134c85..5920059 100644 (file)
@@ -14,6 +14,7 @@ ifeq ($(ARCHDIR),native)
  else
   LDFLAGS += -Wl,-init,SoMain
   CFLAGS += -fPIC
+  CXXFLAGS += -fPIC
  endif
 else ifneq ($(HOST_ARCH),)
  ASFLAGS += -D ARCHDIR=$(ARCHDIR) -D __ASSEMBLER__=1
@@ -23,10 +24,12 @@ else ifneq ($(HOST_ARCH),)
  else
   LDFLAGS += -Wl,-init,SoMain
   CFLAGS += -fPIC
+  CXXFLAGS += -fPIC
  endif
 else
  CPPFLAGS := -ffreestanding
  CFLAGS   := -fno-stack-protector -fPIC
+ CXXFLAGS   := -fno-stack-protector -fPIC
  LDFLAGS  := -I/Acess/Libs/ld-acess.so -lld-acess `$(CC) -print-libgcc-file-name`
 endif
 LDFLAGS += -g -nostdlib -shared -eSoMain -x --no-undefined -L$(OUTPUTDIR)Libs/
index 00913ce..a99ff14 100644 (file)
@@ -92,6 +92,11 @@ $(_OBJPREFIX)%.o: %.c
        @mkdir -p $(dir $@)
        $V$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $< -MMD -MP -MT $@ -MF [email protected]
 
+$(_OBJPREFIX)%.o: %.cc
+       @echo [CXX] -o $@
+       @mkdir -p $(dir $@)
+       $V$(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $@ -c $< -MMD -MP -MT $@ -MF [email protected]
+
 $(_OBJPREFIX)%.ao: %.$(ASSUFFIX)
        @echo [AS] -o $@
        @mkdir -p $(dir $@)
index ce9752c..d32f8c3 100644 (file)
@@ -8,6 +8,10 @@
 #include <stddef.h>    // size_t
 #include "syscall_types.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 // === CONSTANTS ===
 #ifndef NULL
 # define NULL  ((void*)0)
@@ -70,8 +74,8 @@ extern void   _SysTimedSleep(int64_t Delay);
 // --- Permissions ---
 extern int     _SysGetUID(void);
 extern int     _SysGetGID(void);
-extern void    setuid(int id);
-extern void    setgid(int id);
+extern int     setuid(int id);
+extern int     setgid(int id);
 
 // --- VFS ---
 extern int     _SysChdir(const char *dir);
@@ -111,4 +115,8 @@ extern void *_SysLoadBin(const char *path, void **entry);
 extern int     _SysUnloadBin(void *base);
 extern void    SysSetFaultHandler(int (*Hanlder)(int));
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
diff --git a/Usermode/Libraries/libc++.so_src/Makefile b/Usermode/Libraries/libc++.so_src/Makefile
new file mode 100644 (file)
index 0000000..6cec94f
--- /dev/null
@@ -0,0 +1,20 @@
+# Acess2 C++ Library\r
+# Makefile\r
+\r
+-include ../Makefile.cfg\r
+\r
+CPPFLAGS += \r
+CFLAGS   += -Wall -Werror -Wextra\r
+CXXFLAGS += -Wall -Werror -Wextra\r
+ASFLAGS  +=\r
+LDFLAGS  += -Map map.txt -lc\r
+\r
+OBJ  = misc.o new.o guard.o cxxabi.o typeinfo.o\r
+DEPFILES := $(OBJ:%.o=%.d)\r
+BIN = libc++.so\r
+ifeq ($(ARCHDIR),native)\r
+ OBJ := $(filter-out heap.o,$(OBJ))\r
+ BIN = libc++_acess.so\r
+endif\r
+\r
+include ../Makefile.tpl\r
diff --git a/Usermode/Libraries/libc++.so_src/cxxabi.cc b/Usermode/Libraries/libc++.so_src/cxxabi.cc
new file mode 100644 (file)
index 0000000..adda291
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Acess2 C++ Library
+ * - By John Hodge (thePowersGang)
+ *
+ * cxxabi.cc
+ * - C++ ABI Namespace
+ */
+#include <cxxabi.h>
+
+namespace __cxxabiv1 {
+
+// --- RTTI --
+// - No inheritance class
+__class_type_info::~__class_type_info()
+{
+       // nop
+}
+
+// - Single inheritance class
+__si_class_type_info::~__si_class_type_info()
+{
+       
+}
+
+// - Multiple inheritance class
+__vmi_class_type_info::~__vmi_class_type_info()
+{
+       
+}
+
+};     // namespace __cxxabiv1
+
diff --git a/Usermode/Libraries/libc++.so_src/guard.cc b/Usermode/Libraries/libc++.so_src/guard.cc
new file mode 100644 (file)
index 0000000..a075a7b
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Acess2 C++ Library
+ * - By John Hodge (thePowersGang)
+ *
+ * guard.cc
+ * - One-time construction API
+ */
+#include <stdint.h>
+
+extern "C" int __cxa_guard_acquire ( int64_t *guard_object )
+{
+       // TODO: Mutex!
+       if( *guard_object )
+               return 1;
+       *guard_object = 1;
+       return 0;
+}
+
+extern "C" void __cxa_guard_release ( int64_t *guard_object )
+{
+       *guard_object = 0;
+}
+
+extern "C" void __cxa_guard_abort ( int64_t *guard_object )
+{
+       *guard_object = 0;
+       // TODO: abort
+}
+
diff --git a/Usermode/Libraries/libc++.so_src/include_exp/cxxabi.h b/Usermode/Libraries/libc++.so_src/include_exp/cxxabi.h
new file mode 100644 (file)
index 0000000..a8e1f5c
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * Acess2 C++ Library
+ * - By John Hodge (thePowersGang)
+ *
+ * cxxabi.h
+ * - C++ ABI Namespace
+ */
+#ifndef _LIBCXX__CXXABI_H_
+#define _LIBCXX__CXXABI_H_
+
+#include <typeinfo>
+
+namespace __cxxabiv1 {
+
+class __class_type_info : public std::type_info
+{
+public:
+       virtual ~__class_type_info();
+};
+
+class __si_class_type_info : public __class_type_info
+{
+public:
+       virtual ~__si_class_type_info();
+       
+       const __class_type_info *__base_type;
+};
+
+struct __base_class_type_info
+{
+public:
+       
+       const __class_type_info *__base_type;
+       long __offset_flags;
+
+       enum __offset_flags_masks {
+               __virtual_mask = 0x1,
+               __public_mask = 0x2,
+               __offset_shift = 8
+       };
+
+};
+
+class __vmi_class_type_info : public __class_type_info
+{
+public:
+       virtual ~__vmi_class_type_info();
+       
+       unsigned int    __flags;
+       unsigned int    __base_count;
+       __base_class_type_info  __base_info[1];
+       
+       enum __flags_masks {
+               __non_diamond_repeat_mask = 0x1,
+               __diamond_shaped_mask = 0x2,
+       };
+};
+
+class __pbase_type_info : public std::type_info
+{
+public:
+       unsigned int __flags;
+       const std::type_info *__pointee;
+
+       enum __masks {
+               __const_mask = 0x1,
+               __volatile_mask = 0x2,
+               __restrict_mask = 0x4,
+               __incomplete_mask = 0x8,
+               __incomplete_class_mask = 0x10
+       };
+};
+
+};     // namespace __cxxabiv1
+
+#endif
diff --git a/Usermode/Libraries/libc++.so_src/include_exp/typeinfo b/Usermode/Libraries/libc++.so_src/include_exp/typeinfo
new file mode 100644 (file)
index 0000000..c02d388
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Acess2 C++ Library
+ * - By John Hodge (thePowersGang)
+ *
+ * typeinfo (header)
+ * - typeid and dynamic_cast
+ */
+#ifndef _LIBCXX__TYPEINFO_
+#define _LIBCXX__TYPEINFO_
+
+namespace std {
+
+// Type information class
+class type_info
+{
+public:
+       virtual ~type_info();
+       bool operator==(const type_info &) const;
+       bool operator!=(const type_info &) const;
+       bool before(const type_info &) const;
+       const char* name() const;
+private:
+       type_info (const type_info& rhs);
+       type_info& operator= (const type_info& rhs);
+       
+       // CXX ABI
+       const char *__type_name;
+};
+
+};
+
+#endif
+
+// vim: ft=cpp
+
diff --git a/Usermode/Libraries/libc++.so_src/misc.cc b/Usermode/Libraries/libc++.so_src/misc.cc
new file mode 100644 (file)
index 0000000..ed0a2eb
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * Acess2 C++ Library
+ * - By John Hodge (thePowersGang)
+ *
+ * misc.cc
+ * - Miscelanious functions
+ */
+#include <string.h>
+
+extern "C" int SoMain()
+{
+       // nope
+       return 0;
+}
+
+extern "C" void __cxa_pure_virtual()
+{
+       // dunno
+}
+
+extern "C" void __gxx_personality_v0()
+{
+       // TODO: Handle __gxx_personality_v0 somehow
+}
+
+
+// DSO Support 
+#define MAX_ATEXIT     32
+static struct {
+       void (*destructor) (void *);
+       void    *arg;
+       void    *dso_handle;
+} __cxa_atexit_funcs[MAX_ATEXIT];
+static int     __cxa_atexit_func_count;
+
+extern "C" int __cxa_atexit(void (*destructor) (void *), void *arg, void *dso_handle)
+{
+       if( __cxa_atexit_func_count == MAX_ATEXIT )
+       {
+               return 1;
+       }
+       
+       __cxa_atexit_funcs[__cxa_atexit_func_count].destructor = destructor;
+       __cxa_atexit_funcs[__cxa_atexit_func_count].arg = arg;
+       __cxa_atexit_funcs[__cxa_atexit_func_count].dso_handle = dso_handle;
+       __cxa_atexit_func_count ++;
+       return 0;
+}
+
+extern "C" void __cxa_finalize(void *f)
+{
+       if( f == 0 )
+       {
+               for( int i = __cxa_atexit_func_count; i --; )
+               {
+                       if( __cxa_atexit_funcs[i].dso_handle == f )
+                       {
+                               __cxa_atexit_funcs[i].destructor(__cxa_atexit_funcs[i].arg);
+                               memmove(
+                                       &__cxa_atexit_funcs[i],
+                                       &__cxa_atexit_funcs[i+1],
+                                       (__cxa_atexit_func_count-i)*sizeof(__cxa_atexit_funcs[0])
+                                       );
+                               i ++;
+                               __cxa_atexit_func_count --;
+                       }
+               }
+       }
+       else
+       {
+               for( int i = __cxa_atexit_func_count; i --; )
+               {
+                       __cxa_atexit_funcs[i].destructor(__cxa_atexit_funcs[i].arg);
+               }
+               __cxa_atexit_func_count = 0;
+       }
+}
+
diff --git a/Usermode/Libraries/libc++.so_src/new.cc b/Usermode/Libraries/libc++.so_src/new.cc
new file mode 100644 (file)
index 0000000..1d09fbc
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Acess2 C++ Library
+ * - By John Hodge (thePowersGang)
+ *
+ * new.cc
+ * - new/delete
+ */
+#include <stddef.h>
+#include <stdlib.h>
+
+// === CODE ===
+void *operator new( size_t size )
+{
+       return malloc( size );
+}
+
+void *operator new[]( size_t size )
+{
+       return malloc( size );
+}
+
+void operator delete(void *ptr)
+{
+       free(ptr);
+}
+
+void operator delete[](void *ptr)
+{
+       free(ptr);
+}
+
diff --git a/Usermode/Libraries/libc++.so_src/typeinfo.cc b/Usermode/Libraries/libc++.so_src/typeinfo.cc
new file mode 100644 (file)
index 0000000..b0a9b3e
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Acess2 C++ Library
+ * - By John Hodge (thePowersGang)
+ *
+ * typeinfo.cc
+ * - typeid and dynamic_cast
+ */
+#include <typeinfo>
+
+namespace std {
+
+type_info::~type_info()
+{
+       // nop
+}
+
+bool type_info::operator==(const type_info& other) const
+{
+       return this->__type_name == other.__type_name;
+}
+
+bool type_info::operator!=(const type_info& other) const
+{
+       return this->__type_name != other.__type_name;
+}
+
+bool type_info::before(const type_info& other) const
+{
+       return this->__type_name < other.__type_name;
+}
+
+const char *type_info::name() const
+{
+       return this->__type_name;
+}
+
+// Private
+type_info::type_info(const type_info& rhs):
+       __type_name(rhs.__type_name)
+{
+}
+type_info& type_info::operator=(const type_info& rhs)
+{
+       __type_name = rhs.__type_name;
+       return *this;
+}
+
+
+};     // namespace std
+
index 4c37d18..c615b6e 100644 (file)
@@ -10,9 +10,10 @@ LDFLAGS  += -Map map.txt
 \r
 INCFILES := stdio.h stdlib.h\r
 \r
-OBJ  = stub.o heap.o stdlib.o env.o stdio.o string.o rand.o\r
-OBJ += scanf.o signals.o strtoi.o strtof.o\r
-OBJ += printf.o time.o errno.o\r
+OBJ  = stub.o heap.o stdlib.o env.o string.o rand.o\r
+OBJ += scanf.o signals.o strtoi.o strtof.o \r
+OBJ += printf.o time.o timeconv.o errno.o ctype.o\r
+OBJ += stdio.o stdio_files.o\r
 OBJ += arch/$(ARCHDIR).ao\r
 # signals.o\r
 DEPFILES := $(OBJ:%.o=%.d)\r
diff --git a/Usermode/Libraries/libc.so_src/ctype.c b/Usermode/Libraries/libc.so_src/ctype.c
new file mode 100644 (file)
index 0000000..d5a5e97
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Acess2 C Library
+ * - By John Hodge (thePowersGang)
+ *
+ * ctype.c
+ * - Character Types
+ */
+#include <ctype.h>
+
+int isalpha(int ch)
+{
+       if('A'<=ch&&ch<='Z')    return 1;
+       if('a'<=ch&&ch<='z')    return 1;
+       return 0;
+}
+int isdigit(int ch) {
+       if('0'<=ch&&ch<='9')    return 1;
+       return 0;
+}
+
+int isalnum(int ch) {
+       return isalpha(ch) || isdigit(ch);
+}
+
+int toupper(int ch) {
+       if('a'<=ch && ch <='z')
+               return ch - 'a' + 'A';
+       return ch;
+}
+int tolower(int ch) {
+       if('A'<=ch && ch <='Z')
+               return ch - 'A' + 'a';
+       return ch;
+}
+
+int isprint(int ch ) {
+       if( ch < ' ' )  return 0;
+       if( ch > 'z' )  return 0;
+       return 1;
+}
+
+int isspace(int ch) {
+       if(ch == ' ')   return 1;
+       if(ch == '\t')  return 1;
+       if(ch == '\r')  return 1;
+       if(ch == '\n')  return 1;
+       return 0;
+}
+
+int isxdigit(int ch) {
+       if('0'<=ch&&ch<='9')    return 1;
+       if('a'<=ch&&ch<='f')    return 1;
+       if('F'<=ch&&ch<='F')    return 1;
+       return 0;
+}
+
+// C99
+int isblank(int ch) {
+       if(ch == ' ')   return 1;
+       if(ch == '\t')  return 1;
+       return 0;
+}
+
index e2948d6..6f95457 100644 (file)
@@ -45,6 +45,7 @@ EXPORT char *strerror(int errnum)
        case EPERM:     return "Operation not permitted";
        case ENOTTY:    return "Not a TTY";
        case EAGAIN:    return "Try again";
+       case EFBIG:     return "File too big";
        case EALREADY:  return "Operation was no-op";
        case EAFNOSUPPORT:      return "Address family not supported";
        case EINTERNAL: return "Internal error";
index dde4aee..d7029e5 100644 (file)
@@ -8,6 +8,10 @@
 #ifndef _LIBC__ASSERT_H_
 #define _LIBC__ASSERT_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include <stdlib.h>
 //#include <stdio.h>
 #include <acess/sys.h>
@@ -20,5 +24,9 @@
 # define assert(expr)  do{if(!(expr)) { _SysDebug("%s:%i: Assertion '%s' failed", __FILE__, __LINE__, #expr); exit(-1);}}while(0)
 #endif
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
 
index 60753a6..75e4ce8 100644 (file)
@@ -8,51 +8,29 @@
 #ifndef _CTYPE_H_
 #define _CTYPE_H_
 
-static inline int isalpha(int ch) {
-       if('A'<=ch&&ch<='Z')    return 1;
-       if('a'<=ch&&ch<='z')    return 1;
-       return 0;
-}
-static inline int isdigit(int ch) {
-       if('0'<=ch&&ch<='9')    return 1;
-       return 0;
-}
+#ifdef __cplusplus
+extern "C" {
+#endif
 
-static inline int isalnum(int ch) {
-       return isalpha(ch) || isdigit(ch);
-}
+extern int isalpha(int ch);
+extern int isdigit(int ch);
 
-static inline int toupper(int ch) {
-       if('a'<=ch && ch <='z')
-               return ch - 'a' + 'A';
-       return ch;
-}
-static inline int tolower(int ch) {
-       if('A'<=ch && ch <='Z')
-               return ch - 'A' + 'a';
-       return ch;
-}
+extern int isalnum(int ch);
 
-static inline int isspace(int ch) {
-       if(ch == ' ')   return 1;
-       if(ch == '\t')  return 1;
-       if(ch == '\r')  return 1;
-       if(ch == '\n')  return 1;
-       return 0;
-}
+extern int toupper(int ch);
+extern int tolower(int ch);
 
-static inline int isxdigit(int ch) {
-       if('0'<=ch&&ch<='9')    return 1;
-       if('a'<=ch&&ch<='f')    return 1;
-       if('F'<=ch&&ch<='F')    return 1;
-       return 0;
-}
+extern int isprint(int ch);
+
+extern int isspace(int ch);
+
+extern int isxdigit(int ch);
 
 // C99
-static inline int isblank(int ch) {
-       if(ch == ' ')   return 1;
-       if(ch == '\t')  return 1;
-       return 0;
+extern int isblank(int ch);
+
+#ifdef __cplusplus
 }
+#endif
 
 #endif
index 6d33bd4..f943654 100755 (executable)
@@ -27,6 +27,8 @@ enum libc_eErrorNumbers {
 
        EAGAIN, // Try again
        EALREADY,       // Operation was a NOP
+       
+       EFBIG,  // File too large
 
        // psockets
        EAFNOSUPPORT,   
diff --git a/Usermode/Libraries/libc.so_src/include_exp/locale.h b/Usermode/Libraries/libc.so_src/include_exp/locale.h
new file mode 100644 (file)
index 0000000..802e820
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * Acess2 C Library
+ * - By John Hodge (thePowersGang)
+ * 
+ * locale.h
+ * - Locale management
+ */
+#ifndef _LIBC_LOCALE_H_
+#define _LIBC_LOCALE_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
index fe545af..5eb7bb5 100644 (file)
@@ -8,6 +8,10 @@
 #ifndef _LIBC_SETJMP_H_
 #define _LIBC_SETJMP_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #if defined(__i386__)
 typedef void   *jmp_buf[8];
 #elif defined(__amd64__)
@@ -19,5 +23,9 @@ typedef void  *jmp_buf[16];
 extern int     setjmp(jmp_buf buf);
 extern void    longjmp(jmp_buf buf, int val);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
 
index a4c8bd3..38de258 100644 (file)
@@ -8,6 +8,10 @@
 #ifndef _SIGNAL_H_
 #define _SIGNAL_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include "signal_list.h"
 
 typedef void (*sighandler_t)(int);
@@ -15,9 +19,9 @@ typedef void (*sighandler_t)(int);
 //! Atomic integer type
 typedef volatile int   sig_atomic_t;
 
-#define SIG_IGN        ((void*)1)
-#define SIG_DFL        ((void*)0)
-#define SIG_ERR        ((void*)-1)
+#define SIG_IGN        ((sighandler_t)1)
+#define SIG_DFL        ((sighandler_t)0)
+#define SIG_ERR        ((sighandler_t)-1)
 
 extern sighandler_t    signal(int signum, sighandler_t handler);
 
@@ -55,5 +59,9 @@ struct sigaction
 
 extern int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact);
 
+#if __cplusplus
+}
+#endif
+
 #endif
 
index 4d812a7..ed1fce5 100644 (file)
@@ -9,6 +9,10 @@
 #include <stdarg.h>
 #include <stddef.h>    // size_t
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* === Types === */
 typedef struct sFILE   FILE;
 
@@ -58,6 +62,8 @@ typedef struct sFILE  FILE;
 #define getchar        acess_getchar
 #define putchar        acess_putchar
 
+#define rename acess_rename
+
 #define fprintf        acess_fprintf
 #define vfprintf       acess_vfprintf
 
@@ -86,10 +92,13 @@ extern FILE *freopen(const char *file, const char *mode, FILE *fp);
 extern FILE    *fmemopen(void *buffer, size_t length, const char *mode);
 extern FILE    *open_memstream(char **bufferptr, size_t *lengthptr);
 extern FILE    *fdopen(int fd, const char *modes);
+extern FILE    *tmpfile(void);
 extern int     fclose(FILE *fp);
 extern void    fflush(FILE *fp);
 extern off_t   ftell(FILE *fp);
+extern off_t   ftello(FILE *fp);
 extern int     fseek(FILE *fp, long int amt, int whence);
+extern int     fseeko(FILE *fp, off_t amt, int whence);
 extern void    clearerr(FILE *stream);
 extern int     feof(FILE *stream);
 extern int     ferror(FILE *stream);
@@ -109,6 +118,8 @@ extern int  putchar(int ch);
 extern int     fprintf(FILE *fp, const char *format, ...);
 extern int     vfprintf(FILE *fp, const char *format, va_list args);
 
+extern int     rename(const char *oldpath, const char *newpath);
+
 // scanf
 extern int     scanf(const char *format, ...);
 extern int     fscanf(FILE *stream, const char *format, ...);
@@ -121,5 +132,9 @@ extern FILE *stdin;
 extern FILE    *stdout;
 extern FILE    *stderr;
 
+#if __cplusplus
+}
+#endif
+
 #endif
 
index 7169150..07fc81f 100644 (file)
@@ -9,6 +9,10 @@
 #include <stdarg.h>\r
 #include <sys/types.h>\r
 \r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
 #define EXIT_FAILURE   1\r
 #define EXIT_SUCCESS   0\r
 \r
@@ -31,6 +35,8 @@
 # define labs  acess_labs\r
 # define llabs acess_llabs\r
 \r
+# define mktemp        acess_mktemp\r
+\r
 # define getenv        acess_getenv\r
 # define putenv        acess_putenv\r
 \r
@@ -62,6 +68,8 @@ extern long   strtol(const char *ptr, char **end, int base);
 extern unsigned long long      strtoull(const char *ptr, char **end, int base);\r
 extern unsigned long   strtoul(const char *ptr, char **end, int base);\r
 extern int     atoi(const char *ptr);\r
+extern long    atol(const char *ptr);\r
+extern long long       atoll(const char *ptr);\r
 \r
 extern double  strtod(const char *ptr, char **end);\r
 extern float   strtof(const char *ptr, char **end);\r
@@ -74,6 +82,8 @@ extern int    abs(int j);
 extern long int        labs(long int j);\r
 extern long long int   llabs(long long int j);\r
 \r
+extern char    *mktemp(char *__template);\r
+\r
 /* --- Environment --- */\r
 extern char    *getenv(const char *name);\r
 extern int     putenv(char *string);\r
@@ -102,4 +112,10 @@ extern int rand_p(unsigned int *seedp);
 # define SEEK_END      (-1)\r
 #endif\r
 \r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+#include <libposix_stdlib.h>\r
+\r
 #endif\r
index 493d5ef..7ef1bc7 100644 (file)
@@ -7,6 +7,10 @@
 
 #include <stddef.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Strings */
 extern size_t  strlen(const char *string);
 extern size_t  strnlen(const char *string, size_t maxlen);
@@ -26,6 +30,9 @@ extern char   *strstr(const char *str1, const char *str2);
 extern size_t  strcspn(const char *haystack, const char *reject);
 extern size_t  strspn(const char *haystack, const char *accept);
 
+extern char    *strtok(char *str, const char *delim);
+extern char    *strtok_r(char *str, const char *delim, char **saveptr);
+
 /* Memory */
 extern void *memset(void *dest, int val, size_t count);
 extern void *memcpy(void *dest, const void *src, size_t count);
@@ -33,4 +40,8 @@ extern void *memmove(void *dest, const void *src, size_t count);
 extern int     memcmp(const void *mem1, const void *mem2, size_t count);
 extern void    *memchr(const void *ptr, int value, size_t num);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
index 8480d68..c06d128 100644 (file)
 #include <sys/types.h> // time_t
 #include <stddef.h>    // size_t
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 struct tm
 {
         int    tm_sec; // 0-60
@@ -47,16 +51,24 @@ extern time_t       time(time_t *t);
 //
 //! Convert the time structure into a string of form 'Sun Sep 16 01:03:52 1973\n\0'
 extern char *asctime(const struct tm *timeptr);
+extern char *asctime_r(const struct tm *timeptr, char *buf);
 
 //! asctime(localtime(timer))
 extern char *ctime(const time_t *timer);
+extern char *ctime_r(const time_t *timer, char *buf);
 
 //! Convert \a timter into UTC
 extern struct tm *gmtime(const time_t *timer);
+extern struct tm *gmtime_r(const time_t *timer, struct tm *result);
 
 extern struct tm *localtime(const time_t *timer);
+extern struct tm *localtime_r(const time_t *timep, struct tm *result);
+
+extern size_t strftime(char*s, size_t maxsize, const char*format, const struct tm*timeptr);
 
-extern size_t strftime(char*restrict s, size_t maxsize, const char*restrict format, const struct tm*restrict timeptr);
+#ifdef __cplusplus
+};
+#endif
 
 #include <libposix_time.h>
 
index e98ca42..1bb90cd 100644 (file)
@@ -223,6 +223,33 @@ EXPORT FILE *open_memstream(char **bufferptr, size_t *lengthptr)
        return ret;\r
 }\r
 \r
+EXPORT FILE *fdopen(int fd, const char *mode)\r
+{\r
+       FILE    *ret;\r
+       \r
+       if( fd < 0 || !mode )   return NULL;\r
+       \r
+       ret = get_file_struct();\r
+       \r
+       ret->FD = fd;\r
+       ret->Flags = _fopen_modetoflags(mode);\r
+       if(ret->Flags == -1) {\r
+               ret->Flags = 0;\r
+               return NULL;\r
+       }\r
+       \r
+       ret->Buffer = NULL;\r
+       ret->BufferPos = 0;\r
+       ret->BufferSpace = 0;\r
+       \r
+       return ret;\r
+}\r
+\r
+EXPORT FILE *tmpfile(void)\r
+{\r
+       return NULL;\r
+}\r
+\r
 EXPORT int fclose(FILE *fp)\r
 {\r
        if( !(fp->Flags & FILE_FLAG_ALLOC) )\r
@@ -452,7 +479,7 @@ int _fseek_memstream(FILE *fp, long int amt, int whence)
        return 0;\r
 }\r
 \r
-EXPORT int fseek(FILE *fp, long int amt, int whence)\r
+EXPORT int fseeko(FILE *fp, off_t amt, int whence)\r
 {\r
        if(!fp || fp->FD == FD_NOTOPEN) {\r
                errno = EBADF;\r
@@ -473,6 +500,11 @@ EXPORT int fseek(FILE *fp, long int amt, int whence)
        }\r
 }\r
 \r
+EXPORT int fseek(FILE *fp, long int amt, int whence)\r
+{\r
+       return fseeko(fp, amt, whence);\r
+}\r
+\r
 size_t _fwrite_unbuffered(FILE *fp, size_t size, size_t num, const void *data)\r
 {\r
        size_t  ret = 0, bytes;\r
@@ -723,7 +755,7 @@ EXPORT size_t fread(void *ptr, size_t size, size_t num, FILE *fp)
 EXPORT int fputs(const char *s, FILE *fp)\r
 {\r
        int len = strlen(s);\r
-       return fwrite(s, 1, len, fp);\r
+       return fwrite(s, len, 1, fp);\r
 }\r
 \r
 /**\r
diff --git a/Usermode/Libraries/libc.so_src/stdio_files.c b/Usermode/Libraries/libc.so_src/stdio_files.c
new file mode 100644 (file)
index 0000000..cae4f8b
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Acess2 C Library
+ * - By John Hodge (thePowersGang)
+ *
+ * stdio_files.c
+ * - non-stream file manipulation
+ */
+#include <stdio.h>
+#include <acess/sys.h> // _SysDebug
+
+// === CODE ===
+int remove(const char *filename)
+{
+       _SysDebug("TODO: libc remove('%s')", filename);
+       return 1;
+}
+
+int rename(const char *old, const char *new)
+{
+       _SysDebug("TODO: libc rename('%s','%s')", old, new);
+       return 1;
+}
+
index 6ee6d6c..aa79ec9 100644 (file)
@@ -7,6 +7,7 @@
 #include <stdio.h>
 #include <ctype.h>
 #include "lib.h"
+#include <string.h>
 
 /**
  * \fn EXPORT int strcmp(const char *s1, const char *s2)
@@ -367,3 +368,35 @@ EXPORT size_t strspn(const char *haystack, const char *accept)
        }
        return ret;
 }
+
+char *strtok(char *str, const char *delim)
+{
+       static char *__saveptr;
+       return strtok_r(str, delim, &__saveptr);
+}
+char *strtok_r(char *str, const char *delim, char **saveptr)
+{
+       char *pos = (str ? str : *saveptr);
+       
+       while( strchr(delim, *pos) )
+               pos ++;
+
+       if( *pos == '\0' )
+               return NULL;
+
+       char *ret = pos;
+       while( !strchr(delim, *pos) )
+               pos ++;
+       
+       // Cap the returned string
+       // - If we're at the end of the original string, don't shift pos
+       if( *pos != '\0' ) {
+               *pos = '\0';
+               pos ++;
+       }
+       
+       *saveptr = pos;
+       
+       return ret;
+}
+
index 412475b..185af88 100644 (file)
@@ -8,12 +8,35 @@
 #include <time.h>
 #include <acess/sys.h>
 #include <string.h>
+#include "timeconv.h"
+#include <errno.h>
+#include <stdio.h>     // sprintf
+
+#define UNIX_TO_2K     ((30*365*3600*24) + (7*3600*24))        //Normal years + leap years
 
 clock_t clock(void)
 {
        return _SysTimestamp();
 }
 
+time_t mktime(struct tm *timeptr)
+{
+       time_t ret = seconds_since_y2k(
+               timeptr->tm_year - 2000,
+               timeptr->tm_mon,
+               timeptr->tm_mday,
+               timeptr->tm_hour,
+               timeptr->tm_min,
+               timeptr->tm_sec
+               );
+       if( ret == 0 && errno ) {
+               // Bad date
+       }
+       ret += UNIX_TO_2K;
+       
+       return ret;
+}
+
 time_t time(time_t *t)
 {
        time_t ret = _SysTimestamp() / 1000;
@@ -22,26 +45,79 @@ time_t time(time_t *t)
        return ret;
 }
 
+//! Convert the time structure into a string of form 'Sun Sep 16 01:03:52 1973\n\0'
+char *asctime(const struct tm *timeptr)
+{
+       static char staticbuf[sizeof("Sun Sep 16 01:03:52 1973\n")];
+       return asctime_r(timeptr, staticbuf);
+}
+char *asctime_r(const struct tm *timeptr, char *buf)
+{
+       const char *WDAYS[] = {"Sun","Mon","Tue","Wed","Thu","Fri","Sat","Sun"};
+       const char *MONS[] = {"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
+       sprintf(buf,
+               "%s %s %i %02i:%02i:%02i %4i\n",
+               WDAYS[timeptr->tm_wday],
+               MONS[timeptr->tm_mon],
+               timeptr->tm_mday,
+               timeptr->tm_hour,
+               timeptr->tm_min,
+               timeptr->tm_sec,
+               timeptr->tm_year
+               );
+       return buf;
+}
+
+//! asctime(localtime(timer))
+char *ctime(const time_t *timer)
+{
+       struct tm       time_buf;
+       localtime_r(timer, &time_buf);
+       return asctime(&time_buf);
+}
+extern char *ctime_r(const time_t *timer, char *buf)
+{
+       struct tm       time_buf;
+       localtime_r(timer, &time_buf);
+       return asctime_r(&time_buf, buf);
+}
+
+//! Convert \a timter into UTC
+struct tm *gmtime(const time_t *timer)
+{
+       // Ignore UTC
+       return localtime(timer);
+}
+struct tm *gmtime_r(const time_t *timer, struct tm *result)
+{
+       return localtime_r(timer, result);
+}
+
 static struct tm       static_tm;
 
 struct tm *localtime(const time_t *timer)
 {
-       struct tm *ret = &static_tm;
+       return localtime_r(timer, &static_tm);
 
-       // TODO: This breaks on negative timestamps
-
-       int64_t day = *timer / (1000*60*60*24);
-       int64_t iday = *timer % (1000*60*60*24);        
+}
+struct tm *localtime_r(const time_t *timer, struct tm *ret)
+{
+       // Hours, Mins, Seconds
+       int64_t days = get_days_since_y2k(*timer, &ret->tm_hour, &ret->tm_min, &ret->tm_sec);
+       
+       // Week day
+       ret->tm_wday = (days + 6) % 7;  // Sun = 0, 1 Jan 2000 was Sat (6)
+       
+       // Year and Day of Year
+       bool    is_ly;
+       ret->tm_year = 2000 + get_years_since_y2k(days, &is_ly, &ret->tm_yday);
 
-       ret->tm_sec = (iday / 1000) % 60;;
-       ret->tm_min = (iday / (1000*60)) % 60;
-       ret->tm_hour = (iday / (1000*60*60));
-       ret->tm_year = 0;
-       ret->tm_mon = 0;
-       ret->tm_mday = 0;
-       ret->tm_wday = (day + 6) % 7;   // 1 Jan 2000 was a saturday
-       ret->tm_yday = 0;
+       // Month and Day of Month
+       get_month_day(ret->tm_yday, is_ly, &ret->tm_mon, &ret->tm_mday);
+       ret->tm_mon --;
+       
        ret->tm_isdst = 0;      // Fuck DST
+       
        return ret;
 }
 
diff --git a/Usermode/Libraries/libc.so_src/timeconv.c b/Usermode/Libraries/libc.so_src/timeconv.c
new file mode 100644 (file)
index 0000000..6fed585
--- /dev/null
@@ -0,0 +1,206 @@
+/*
+ * Acess2 C Library
+ * - By John Hodge (thePowersGang)
+ *
+ * timeconv.c
+ * - Shared User/Kernel time conversion code
+ */
+#include "timeconv.h"
+#include <errno.h>
+
+#define ENABLE_LEAP_SECONDS    1
+
+static const short DAYS_IN[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
+static const short DAYS_BEFORE[] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
+#define DEC31  365
+#define JUN30  181
+
+#if ENABLE_LEAP_SECONDS
+// Leap seconds after 2000 (stored as day numbers of application)
+// - Leap seconds apply after the last second of said day (23:59:60)
+// TODO: Need to encode possible double leap seconds, and negative leap seconds
+static int64_t leap_seconds_after[] = {
+       // ls + (year + leap + day + thisleap)
+       (5*365+2+DEC31+0),      // Dec 31 2005
+       (8*365+2+DEC31+1),      // Dec 31 2008
+       (12*365+3+JUN30+1)      // Jun 30 2012
+};
+static int     n_leap_seconds_after = sizeof(leap_seconds_after)/sizeof(leap_seconds_after[0]);
+#endif
+
+static int YearIsLeap(int year) {
+       return (year % 4 == 0) - (year % 100 == 0) + (year % 400 == 0);
+}
+static int DaysUntilYear(int year) {
+       return year*365 + (year/400) - (year/100) + (year/4);
+}
+
+int64_t seconds_since_y2k(int years_since, int mon, int day, int h, int m, int s)
+{
+       errno = EINVAL;
+       if( !(1 <= mon && mon <= 12) )  return 0;
+       if( !(1 <= day && day <= DAYS_IN[mon-1]) )      return 0;
+       if( !(0 <= h && h <= 23) )      return 0;
+       if( !(0 <= m && m <= 59) )      return 0;
+       if( !(0 <= s && s <= 60) )      return 0;
+
+       // Special case check for leap days
+       if( mon == 2 && day == 29 )
+       {
+               if( !YearIsLeap(years_since) )
+                       return 0;
+       }
+
+       // Day
+       int64_t days = DaysUntilYear(years_since);
+       days += DAYS_BEFORE[mon-1];
+       if(mon > 2 && YearIsLeap(years_since))
+               days ++;
+       days += day;
+       
+       // Seconds
+       int64_t seconds = h * 60*60 + m * 60;
+       seconds += s;
+       bool today_has_ls = false;
+       #if ENABLE_LEAP_SECONDS
+       if( days > 0 )
+       {
+               for( int i = 0; i < n_leap_seconds_after; i ++ )
+               {
+                       if( days < leap_seconds_after[i] )
+                               break ;
+                       if(days > leap_seconds_after[i])
+                               seconds ++;
+                       else
+                               today_has_ls = true;
+                       // A leap second on this day is handled with s=60
+               }
+       }
+
+       // Now that we know if this day has a leap second, sanity check leap seconds
+       if( s == 60 )
+       {
+               if( !today_has_ls || !(h == 23 && m == 59) )
+                       return 0;
+       }
+       #else
+       if( s == 60 )   return 0;
+       #endif
+
+       errno = 0;
+       
+       return days * 24*60*60 + seconds;
+}
+
+// returns number of days
+int64_t get_days_since_y2k(int64_t ts, int *h, int *m, int *s)
+{
+       #if ENABLE_LEAP_SECONDS
+       // Calculate leap second count
+        int    n_leap = 0;
+       bool    is_ls = false;
+       if( ts > 0 )
+       {
+               for( int i = 0; i < n_leap_seconds_after; i ++ )
+               {
+                       // lts = Timestamp of the leap second
+                       int64_t lts = leap_seconds_after[i] * 24*60*60 + 23*60*60 + 59*60 + 60 + i;
+                       if( lts > ts )  break;
+                       if( lts == ts )
+                               is_ls = true;
+                       n_leap ++;
+               }
+       }
+       ts -= n_leap;
+       #endif
+       
+       int64_t days = ts / 24*60*60;
+       int64_t seconds = ts % (24*60*60);
+       *s = (is_ls ? 60 : seconds % 60);
+       *m = (seconds/60 % 24);
+       *h = seconds / (60*60);
+       
+       return days;
+}
+
+/**
+ * \param days Days since 1 Jan 2000
+ */
+int64_t get_years_since_y2k(int64_t days, bool *is_leap, int *doy)
+{
+       // Calculate Year
+       bool    is_ly = false;
+       // Year (400 yr blocks) - (400/4-3) leap years
+       const int       days_per_400_yrs = 365*400 + (400/4-3);
+        int year = 400 * days / days_per_400_yrs;
+       days = days % days_per_400_yrs;
+       if( days < 366 )        // First year in 400 is a leap
+               is_ly = true;
+       else
+       {
+               // 100 yr blocks - 100/4-1 leap years
+               const int       days_per_100_yrs = 365*100 + (100/4-1);
+               year += 100 * days / days_per_100_yrs;
+               days = days % days_per_100_yrs;
+               if( days < 366 )        // First year in 100 isn't a leap
+                       is_ly = false;
+               else
+               {
+                       const int       days_per_4_yrs = 365*4 + 1;
+                       year += 4 * days / days_per_4_yrs;
+                       days = days % days_per_4_yrs;
+                       if( days < 366 )        // First year in 4 is a leap
+                               is_ly = true;
+                       else {
+                               year += days / 365;
+                               days = days % 365;
+                       }
+               }
+       }
+       *doy = days;
+       *is_leap = is_ly;
+       
+       return year;
+}
+
+void get_month_day(int doy, bool is_ly, int *mon, int *day)
+{
+       if( doy > 365+(is_ly?1:0) ) {
+               *mon = 0;
+               *day = 0;
+       }
+       
+       bool mon_day_set = false;
+       if( doy >= DAYS_BEFORE[2] && is_ly )
+       {
+               if( doy == DAYS_BEFORE[2] ) {
+                       *mon = 2;
+                       *day = 29;
+                       mon_day_set = true;
+               }
+               doy --;
+       }
+       for( int i = 1; i < 12+1 && !mon_day_set; i ++ )
+       {
+               if( doy < DAYS_BEFORE[i] )
+               {
+                       *mon = i;
+                       *day = doy - DAYS_BEFORE[i];
+                       mon_day_set = true;
+               }
+       }
+}
+
+int expand_from_secs_since_y2k(int64_t ts, int *years_since, int *mon, int *day, int *h, int *m, int *s)
+{
+       int64_t days = get_days_since_y2k(ts, h, m, s);
+       
+       bool    is_ly;
+        int    doy;
+       *years_since = get_years_since_y2k(days, &is_ly, &doy);
+
+       // Calculate month/day of month
+       get_month_day(doy, is_ly, mon, day);
+       return 0;
+}
+
diff --git a/Usermode/Libraries/libc.so_src/timeconv.h b/Usermode/Libraries/libc.so_src/timeconv.h
new file mode 100644 (file)
index 0000000..1adba8f
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Acess2 C Library
+ * - By John Hodge (thePowersGang)
+ *
+ * timeconv.h
+ * - Shared User/Kernel time conversion code
+ */
+#ifndef _LIBC_TIMECONV_H_
+#define _LIBC_TIMECONV_H_
+
+#include <stdint.h>
+#include <stdbool.h>
+
+extern int64_t seconds_since_y2k(int years_since, int mon, int day, int h, int m, int s);
+
+/**
+ * \return Number of days since Y2K
+ * 
+ * Extracts the time of day from the timestamp, (possibly taking into account leap seconds)
+ */
+extern int64_t get_days_since_y2k(int64_t ts, int *h, int *m, int *s);
+
+/**
+ * \param days Number of days since Y2K
+ * \return Number of years since Y2K
+ * 
+ * Converts a count of days since Y2K, and returns the number of years. Extracting the day of
+ * year, and if that year is a leap year.
+ */
+extern int64_t get_years_since_y2k(int64_t days, bool *is_leap, int *doy);
+
+
+/**
+ * Gets the month and day of month from a day of year and leap year status
+ */
+extern void    get_month_day(int doy, bool is_ly, int *mon, int *day);
+
+#endif
+
index 349547e..d6d988f 100644 (file)
@@ -8,6 +8,16 @@
 #ifndef _LIBM__MATH_H_
 #define _LIBM__MATH_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 extern double  pow(double x, double y);
+extern double  exp(double x);
+extern double  log(double val);
+
+#ifdef __cplusplus
+}
+#endif
 
 #endif
index f35d7c2..d968ca8 100644 (file)
@@ -16,3 +16,17 @@ double pow(double x, double y)
                return 1.0f;
        return __builtin_pow(x,y);
 }
+
+double exp(double y)
+{
+       if( y == 0.0f )
+               return 1.0f;
+       return __builtin_exp(y);
+}
+
+double log(double n)
+{
+       if(n == 1.0f)
+               return 0.0f;
+       return __builtin_log(n);
+}
index ca566cd..dcbf8f5 100644 (file)
@@ -11,7 +11,7 @@ LDFLAGS  += -soname libposix.so -Map map.txt -lc
 OBJ  = main.o unistd.o dirent.o stat.o utmpx.o termios.o\r
 OBJ += pwd.o syslog.o sys_time.o sys_ioctl.o sys_resource.o\r
 OBJ += fcntl.o clocks.o sys_wait.o unistd_crypt.o\r
-OBJ += grp.o pty.o\r
+OBJ += grp.o pty.o mktemp.o utime.o\r
 DEPFILES := $(OBJ:%.o=%.d)\r
 BIN = libposix.so\r
 \r
index 747d7ea..8eec42a 100644 (file)
 
 #include "sys/stat.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define NAME_MAX       255
 
 struct dirent
@@ -28,5 +32,9 @@ extern void   rewinddir(DIR *);
 extern void    seekdir(DIR *, long int);
 extern long int        telldir(DIR *);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
 
diff --git a/Usermode/Libraries/libposix.so_src/include_exp/libposix_stdlib.h b/Usermode/Libraries/libposix.so_src/include_exp/libposix_stdlib.h
new file mode 100644 (file)
index 0000000..c5f8c8e
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+ * Acess2 POSIX Emulation
+ * - By John Hodge (thePowersGang)
+ *
+ * stdlib.h (libposix version)
+ * - Misc functions
+ *
+ * NOTE: Included by libc's stdlib.h
+ */
+#ifndef _LIBPOSIX__STDLIB_H_
+#define _LIBPOSIX__STDLIB_H_
+
+extern int     mkstemp(char *_template);
+
+
+#endif
+
diff --git a/Usermode/Libraries/libposix.so_src/include_exp/sys/mman.h b/Usermode/Libraries/libposix.so_src/include_exp/sys/mman.h
new file mode 100644 (file)
index 0000000..7fbb9a5
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * Acess2 POSIX Emulation Layer
+ * - By John Hodge
+ * 
+ * sys/mman.h
+ * - Memory Management (mmap and friends)
+ */
+#ifndef _LIBPOSIX__SYS_MMAN_H_
+#define _LIBPOSIX__SYS_MMAN_H_
+
+extern void    *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset);
+extern int     munmap(void *addr, size_t length);
+
+
+#endif
+
index 0340a9f..faac6c1 100644 (file)
 #include <stdint.h>
 #include "sys/types.h" // off_t
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef void   *dev_t; /* TODO: How to identify a device with Acess */
 typedef uint64_t       ino_t;
 typedef unsigned int   blksize_t;
@@ -27,6 +31,9 @@ typedef uint32_t      mode_t;
 #define                S_IFSOCK        0140000 /* socket */
 #define                S_IFIFO 0010000 /* fifo */
 
+#define S_ISDIR(mode)  (((mode) & S_IFMT) == S_IFDIR)
+#define S_ISREG(mode)  (((mode) & S_IFMT) == S_IFREG)
+#define S_ISCHR(mode)  (((mode) & S_IFMT) == S_IFCHR)
 
 struct stat
 {
@@ -50,4 +57,8 @@ extern int lstat(const char *path, struct stat *buf);
 extern int fstat(int fd, struct stat *buf);
 extern int mkdir(const char *pathname, mode_t mode);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
index 79e4013..cef859b 100644 (file)
 
 #include <time.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef unsigned long  suseconds_t;
 
 struct timeval
@@ -55,5 +59,9 @@ extern int    gettimeofday(struct timeval *tv, struct timezone *tz);
 // select
 extern int     utimes(const char *, const struct timeval [2]);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
 
index 1223857..c94a65a 100644 (file)
@@ -5,10 +5,14 @@
 
 #include <stddef.h>
 
+#define __USE_BSD      1
+
 //typedef signed int   ssize_t;
-//#ifdef  __USE_BSD
+
+#ifdef  __USE_BSD
+typedef unsigned long  u_long;
 typedef unsigned int   u_int;
-//#endif
+#endif
 
 typedef struct stat    t_fstat;
 
index f24011a..6519b3b 100644 (file)
 
 #include <stddef.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 //! \brief flags for open(2)
 #define O_WRONLY       0x01
 #define O_RDONLY       0x02
@@ -65,6 +69,10 @@ extern int   chown(const char *path, uid_t owner, gid_t group);
 #define S_IXOTH        00001
 extern int     chmod(const char *path, mode_t mode);
 
+extern int     unlink(const char *pathname);
+
+extern int     access(const char *pathname, int mode);
+
 extern pid_t   setsid(void);
 
 extern uid_t   getuid(void);
@@ -79,6 +87,7 @@ typedef uint32_t      useconds_t;
 
 extern unsigned int    sleep(unsigned int seconds);
 extern int     usleep(useconds_t usec);
+extern unsigned int    alarm(unsigned int seconds);
 
 // - crypt.c
 extern char    *crypt(const char *key, const char *salt);
@@ -97,5 +106,9 @@ extern int   rmdir(const char *pathname);
 #define PASS_MAX       63
 extern char *getpass(const char *prompt);
 
+#if __cplusplus
+}
+#endif
+
 #endif
 
diff --git a/Usermode/Libraries/libposix.so_src/include_exp/utime.h b/Usermode/Libraries/libposix.so_src/include_exp/utime.h
new file mode 100644 (file)
index 0000000..dcc43c7
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Acess2 POSIX Emulation Layer
+ * - By John Hodge
+ * 
+ * utime.h
+ * - 
+ */
+#ifndef _LIBPOSIX__UTIME_H_
+#define _LIBPOSIX__UTIME_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <sys/types.h> // time_t
+
+struct utimbuf {
+       time_t  actime;         // access time
+       time_t  modtime;        // modifcation time
+};
+
+extern int     utime(const char *filename, const struct utimbuf *times);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/Usermode/Libraries/libposix.so_src/mktemp.c b/Usermode/Libraries/libposix.so_src/mktemp.c
new file mode 100644 (file)
index 0000000..863b925
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Acess2 POSIX Emulation Layer
+ * - By John Hodge
+ * 
+ * mkstemp.c
+ * - mkstemp/mktemp
+ */
+#include <unistd.h>    // mktemp
+#include <stdlib.h>    // mkstemp
+#include <string.h>    // str*
+#include <errno.h>
+
+// === CODE ===
+int mkstemp(char *template)
+{
+       size_t  tpl_len = strlen(template);
+       if( tpl_len < 6 ) {
+               errno = EINVAL;
+               return -1;
+       }
+       if( strcmp(template+tpl_len-6, "XXXXXX") != 0 ) {
+               errno = EINVAL;
+               return -1;
+       }
+       
+       for( int i = 0; i < 1000000; i ++ )
+       {
+               sprintf(template+tpl_len-6, "%06d", i);
+               int fd = open(template, O_EXCL|O_CREAT, 0600);
+               if(fd == -1)    continue ;
+       
+               return fd;
+       }
+       
+       errno = EEXIST;
+       template[0] = '\0';
+       return -1;
+}
+
+char *mktemp(char *template)
+{
+        int fd = mkstemp(template);
+       if( fd == -1 )
+               return NULL;
+       close(fd);
+       return template;
+}
+
+
index a2f4eb7..3af7bcb 100644 (file)
@@ -50,6 +50,12 @@ int open(const char *path, int openmode, ...)
        return ret;
 }
 
+int access(const char *path, int openmode)
+{
+       errno = EINVAL;
+       return -1;
+}
+
 int creat(const char *path, mode_t mode)
 {
        // TODO: Make native call to do this cheaper
@@ -183,6 +189,17 @@ int usleep(useconds_t usec)
        return 0;
 }
 
+unsigned int alarm(unsigned int seconds)
+{
+       static int64_t  alarm_time;
+       if( seconds > 0 )
+       {
+               alarm_time = _SysTimestamp() + seconds * 1000;
+               // TODO: Schedule SIGALRM
+       }
+       return (alarm_time - _SysTimestamp()) / 1000;
+}
+
 int kill(pid_t pid, int signal)
 {
        // TODO: Need special handling?
diff --git a/Usermode/Libraries/libposix.so_src/utime.c b/Usermode/Libraries/libposix.so_src/utime.c
new file mode 100644 (file)
index 0000000..de9483a
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * Acess2 POSIX Emulation Layer
+ * - By John Hodge
+ * 
+ * utime.h
+ * - 
+ */
+#include <utime.h>
+#include <acess/sys.h>
+
+// === CODE ===
+int utime(const char *filename, const struct utimbuf *times)
+{
+       _SysDebug("TODO: libposix utime('%s', {%lli,%lli})",
+               filename, times->actime, times->modtime
+               );
+       return 0;
+}
+
index bd7f38d..0ad326e 100644 (file)
@@ -6,7 +6,7 @@ CPPFLAGS +=
 CFLAGS   += -Wall
 LDFLAGS  += -lc -soname libpsocket.so -lnet
 
-OBJ = main.o getaddrinfo.o socket.o pton.o
+OBJ = main.o getaddrinfo.o socket.o pton.o byteordering.o
 BIN = libpsocket.so
 
 include ../Makefile.tpl
diff --git a/Usermode/Libraries/libpsocket.so_src/byteordering.c b/Usermode/Libraries/libpsocket.so_src/byteordering.c
new file mode 100644 (file)
index 0000000..0c8b99d
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Acess2 POSIX Sockets Library
+ * - By John Hodge (thePowersGang)
+ *
+ * byteordering.c
+ * - hton/ntoh
+ */
+#include <arpa/inet.h>
+
+// === CODE ===
+static uint32_t Flip32(uint32_t val)
+{
+       return (((val >> 24) & 0xFF) << 0)
+               | (((val >> 16) & 0xFF) << 8)
+               | (((val >> 8) & 0xFF) << 16)
+               | (((val >> 0) & 0xFF) << 24)
+               ;
+}
+
+static uint16_t Flip16(uint16_t val)
+{
+       return (val >> 8) | (val << 8);
+}
+
+uint32_t htonl(uint32_t hostlong)
+{
+       #if BIG_ENDIAN
+       return hostlong;
+       #else
+       return Flip32(hostlong);
+       #endif
+}
+uint16_t htons(uint16_t hostshort)
+{
+       #if BIG_ENDIAN
+       return hostshort;
+       #else
+       return Flip16(hostshort);
+       #endif
+}
+uint32_t ntohl(uint32_t netlong)
+{
+       #if BIG_ENDIAN
+       return netlong;
+       #else
+       return Flip32(netlong);
+       #endif
+}
+uint16_t ntohs(uint16_t netshort)
+{
+       #if BIG_ENDIAN
+       return netshort;
+       #else
+       return Flip16(netshort);
+       #endif
+}
+
+
index bd50f91..cb361f9 100644 (file)
@@ -235,3 +235,8 @@ const char *gai_strerror(int errnum)
        }
 }
 
+struct hostent *gethostbyname(const char *name)
+{
+       return NULL;
+}
+
index effc288..ea303dd 100644 (file)
 #include <netinet/in.h>
 #include <stdint.h>    // Should be inttypes.h?
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 extern uint32_t htonl(uint32_t hostlong);
 extern uint16_t htons(uint16_t hostshort);
 extern uint32_t ntohl(uint32_t netlong);
@@ -23,5 +27,9 @@ extern in_addr_t      inet_netof(struct in_addr in);
 extern in_addr_t       inet_network(const char *cp);
 extern char    *inet_ntoa(struct in_addr in);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
 
index 95f6f2e..943d514 100644 (file)
@@ -3,6 +3,11 @@
 
 #include <sys/socket.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
 struct hostent
 {
        char    *h_name;
@@ -11,6 +16,7 @@ struct hostent
         int    h_length;
        char    **h_addr_list;
 };
+#define h_addr h_addr_list[0]  // backwards compataibility
 
 struct netent
 {
@@ -96,9 +102,16 @@ const char  *gai_strerror(int errorcode);
 extern struct servent  *getservbyname(const char *name, const char *proto);
 extern struct servent  *getservbyport(int port, const char *proto);
 
+extern struct hostent  *gethostbyname(const char *name);
+extern struct hostent  *gethostbyaddr(const void *addr, socklen_t len, int type);
+
 extern void    setservent(int stayopen);
 extern struct servent  *getservent(void);
 extern void    enservent(void);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
 
index d69ce86..0f4e887 100644 (file)
@@ -58,5 +58,7 @@ struct sockaddr_in6
        uint32_t        sin6_scope_id;
 };
 
+#include <arpa/inet.h> // for hton*/ntoh* (bochs)
+
 #endif
 
index deb1f51..9c3e3bd 100644 (file)
 #endif
 #include <stdint.h>    // uint32_t
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef uint32_t       socklen_t;
 
-typedef enum
+enum
 {
        AF_UNSPEC       = 0,
        AF_PACKET       = 1,
        AF_LOCAL        = 2,
        AF_INET         = 4,
        AF_INET6        = 6,
-} sa_family_t;
+};
 #define AF_UNIX        AF_LOCAL
+typedef uint8_t        sa_family_t;    // I would use an enum, but cast issues
 
 struct sockaddr
 {
@@ -141,6 +146,8 @@ extern int  connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen);
  */
 extern int     listen(int sockfd, int backlog);
 
+#define SOMAXCONN      128     // Maximum size of backlog (actually far higher)
+
 /**
  * \brief Accept an incoming connection
  */
@@ -164,5 +171,9 @@ extern void herror(const char *s);
 extern const char      *hstrerror(int err);
 extern struct hostent *gethostent(void);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
 
index 32cde27..ded0068 100644 (file)
@@ -36,3 +36,8 @@ const char *inet_ntop(int af, const void *src, char *dest, size_t len)
        return dest;
 }
 
+char *inet_ntoa(struct in_addr in)
+{
+       return Net_PrintAddress(4, &in.s_addr);
+}
+

UCC git Repository :: git.ucc.asn.au