ref: b455d411d48d803903d2c1bca8c6af4bd264f300
parent: 61d8ab34d1ccd7ffdc3fd0e3fe73bf1a87bf0af6
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Fri Jan 24 04:22:56 EST 2020
libc: Add placeholder for ppc32 This is only a placeholder and it does not contain actual code.
--- /dev/null
+++ b/config/conf/ppc32-linux.mk
@@ -1,0 +1,3 @@
+include $(PROJECTDIR)/config/conf/ppc32-posix.mk
+
+SYS = linux
--- /dev/null
+++ b/config/conf/ppc32-posix.mk
@@ -1,0 +1,3 @@
+ABI = ppc32-posix
+ARCH = ppc32
+O = q
--- /dev/null
+++ b/include/bits/ppc32/arch/limits.h
@@ -1,0 +1,18 @@
+#define CHAR_BIT 8
+#define SCHAR_MAX 0x7F
+#define SCHAR_MIN (-SCHAR_MAX - 1)
+#define CHAR_MAX 0x7F
+#define CHAR_MIN (-CHAR_MAX - 1)
+#define UCHAR_MAX 0xFF
+#define SHRT_MAX 0x7FFF
+#define SHRT_MIN (-SHRT_MAX - 1)
+#define USHRT_MAX 0xFFFF
+#define INT_MAX 0x7FFFFFFF
+#define INT_MIN (-INT_MAX - 1)
+#define UINT_MAX 0xFFFFFFFF
+#define LONG_MAX 0x7FFFFFFF
+#define LONG_MIN (-LONG_MAX - 1)
+#define ULONG_MAX 0xFFFFFFFF
+#define LLONG_MAX 0x7FFFFFFFFFFFFFFF
+#define LLONG_MIN (-LLONG_MAX - 1)
+#define ULLONG_MAX 0xFFFFFFFFFFFFFFFF
--- /dev/null
+++ b/include/bits/ppc32/arch/stddef.h
@@ -1,0 +1,9 @@
+#ifndef SIZET_
+typedef unsigned int size_t;
+#define SIZET_
+#endif
+
+#ifndef _PTRDIFF_T
+typedef long ptrdiff_t;
+#define _PTRDIFF_T
+#endif
--- /dev/null
+++ b/include/bits/ppc32/arch/stdint.h
@@ -1,0 +1,96 @@
+#define INT8_MAX 0x7F
+#define INT8_MIN (-INT8_MAX - 1)
+#define UINT8_MAX 0xFF
+
+#define INT16_MAX 0x7FFF
+#define INT16_MIN (-INT16_MAX - 1)
+#define UINT16_MAX 0xFFFF
+
+#define INT32_MAX 0x7FFFFFFF
+#define INT32_MIN (-INT32_MAX - 1)
+#define UINT32_MAX 0xFFFFFFFF
+
+#define INT64_MAX 0x7FFFFFFFFFFFFFFF
+#define INT64_MIN (-INT64_MAX - 1)
+#define UINT64_MAX 0xFFFFFFFFFFFFFFFF
+
+#define INT_LEAST8_MIN INT8_MIN
+#define INT_LEAST8_MAX INT8_MAX
+#define UINT_LEAST8_MAX UINT8_MAX
+
+#define INT_LEAST16_MIN INT16_MIN
+#define INT_LEAST16_MAX INT16_MAX
+#define UINT_LEAST16_MAX UINT16_MAX
+
+#define INT_LEAST32_MIN INT32_MIN
+#define INT_LEAST32_MAX INT32_MAX
+#define UINT_LEAST32_MAX UINT32_MAX
+
+#define INT_LEAST64_MIN INT64_MIN
+#define INT_LEAST64_MAX INT64_MAX
+#define UINT_LEAST64_MAX UINT64_MAX
+
+#define INT_FAST8_MIN INT32_MIN
+#define INT_FAST8_MAX INT32_MAX
+#define UINT_FAST8_MAX UINT32_MAX
+
+#define INT_FAST16_MIN INT32_MIN
+#define INT_FAST16_MAX INT32_MAX
+#define UINT_FAST16_MAX UINT32_MAX
+
+#define INT_FAST32_MIN INT32_MIN
+#define INT_FAST32_MAX INT32_MAX
+#define UINT_FAST32_MAX UINT32_MAX
+
+#define INT_FAST64_MIN INT64_MIN
+#define INT_FAST64_MAX INT64_MAX
+#define UINT_FAST64_MAX UINT64_MAX
+
+#define INTPTR_MIN INT32_MIN
+#define INTPTR_MAX INT32_MAX
+#define UINTPTR_MAX UINT32_MAX
+
+#define INTMAX_MIN INT64_MIN
+#define INTMAX_MAX INT64_MAX
+#define UINTMAX_MAX UINT64_MAX
+
+#define PTRDIFF_MIN INT32_MIN
+#define PTRDIFF_MAX INT32_MAX
+
+#define SIZE_MAX UINT32_MAX
+
+typedef signed char int8_t;
+typedef short int16_t;
+typedef int int32_t;
+typedef long long int64_t;
+
+typedef unsigned char uint8_t;
+typedef unsigned short uint16_t;
+typedef unsigned int uint32_t;
+typedef unsigned long long uint64_t;
+
+typedef signed char int8_least_t;
+typedef short int16_least_t;
+typedef int int32_least_t;
+typedef long long int64_least_t;
+
+typedef unsigned char uint8_least_t;
+typedef unsigned short uint16_least_t;
+typedef unsigned int uint32_least_t;
+typedef unsigned long long uint64_least_t;
+
+typedef int int8_fast_t;
+typedef int int16_fast_t;
+typedef int int32_fast_t;
+typedef long long int64_fast_t;
+
+typedef unsigned int uint8_fast_t;
+typedef unsigned int uint16_fast_t;
+typedef unsigned int uint32_fast_t;
+typedef unsigned long long uint64_fast_t;
+
+typedef long intptr_t;
+typedef unsigned long uintptr_t;
+
+typedef long long intmax_t;
+typedef unsigned long long uintmax_t;
--- /dev/null
+++ b/include/bits/ppc32/arch/stdio.h
@@ -1,0 +1,15 @@
+#ifndef _SIZET
+typedef unsigned int size_t;
+#define _SIZET
+#endif
+
+#define BUFSIZ 512
+#define FILENAME_MAX 256
+#define FOPEN_MAX 16
+
+#define TMP_MAX 25
+#define L_tmpnam 256
+
+#define _TMPNAME "/tmp/tmp.0000000"
+
+typedef int fpos_t;
--- /dev/null
+++ b/include/bits/ppc32/arch/stdlib.h
@@ -1,0 +1,14 @@
+#ifndef SIZET_
+typedef unsigned int size_t;
+#define SIZET_
+#endif
+
+#define EXIT_FAILURE 1
+#define EXIT_SUCCESS 0
+
+#ifndef _WCHAR_T
+typedef int wchar_t; // TODO
+#define _WCHAR_T
+#endif
+
+#define _ALIGNTYPE long double
--- /dev/null
+++ b/include/bits/ppc32/arch/string.h
@@ -1,0 +1,6 @@
+#ifndef SIZET_
+typedef unsigned int size_t;
+#define SIZET_
+#endif
+
+#define __NUMCHARS 128
--- /dev/null
+++ b/include/bits/ppc32/arch/time.h
@@ -1,0 +1,8 @@
+#ifndef _SIZET
+typedef unsigned int size_t;
+#define _SIZET
+#endif
+
+#define _MAXYEAR 9999
+
+typedef long int time_t;
--- a/scripts/libc-proto
+++ b/scripts/libc-proto
@@ -3,6 +3,7 @@
libexec/scc
lib
lib/scc
+lib/scc/ppc32-linux
lib/scc/i386-linux
lib/scc/arm32-linux
lib/scc/arm64-linux
--- a/scripts/proto
+++ b/scripts/proto
@@ -26,6 +26,10 @@
f 644 lib/scc/amd64-linux/libc.a
f 644 lib/scc/amd64-linux/crt.o
f 644 lib/scc/amd64-linux/libcrt.a
+d 755 lib/scc/ppc32-linux
+f 644 lib/scc/ppc32-linux/libc.a
+f 644 lib/scc/ppc32-linux/crt.o
+f 644 lib/scc/ppc32-linux/libcrt.a
d 755 bin
f 755 bin/ld
f 755 bin/cpp
@@ -101,6 +105,16 @@
f 644 include/bits/arm32/arch/setjmp.h
f 644 include/bits/arm32/arch/time.h
f 644 include/bits/arm32/arch/stdint.h
+d 755 include/bits/ppc32
+d 755 include/bits/ppc32/arch
+f 644 include/bits/ppc32/arch/string.h
+f 644 include/bits/ppc32/arch/limits.h
+f 644 include/bits/ppc32/arch/stdlib.h
+f 644 include/bits/ppc32/arch/stdio.h
+f 644 include/bits/ppc32/arch/stddef.h
+f 644 include/bits/ppc32/arch/setjmp.h
+f 644 include/bits/ppc32/arch/time.h
+f 644 include/bits/ppc32/arch/stdint.h
d 755 include/bits/z80
d 755 include/bits/z80/arch
f 644 include/bits/z80/arch/string.h
--- a/src/libc/.gitignore
+++ b/src/libc/.gitignore
@@ -2,4 +2,5 @@
*.7
*.8
*.z
+*.q
libc.lst
--- a/src/libc/arch/Makefile
+++ b/src/libc/arch/Makefile
@@ -3,7 +3,12 @@
include $(PROJECTDIR)/scripts/rules.mk
include ../rules.mk
-DIRS = amd64 arm32 arm64 i386
+DIRS =\
+ amd64\
+ arm32\
+ arm64\
+ i386\
+ ppc32\
all:
+@cd $(ARCH) && $(MAKE)
--- /dev/null
+++ b/src/libc/arch/ppc32/Makefile
@@ -1,0 +1,30 @@
+.POSIX:
+PROJECTDIR =../../../..
+include $(PROJECTDIR)/scripts/rules.mk
+include ../../rules.mk
+
+OBJS =\
+ longjmp.$O\
+ setjmp.$O\
+ memchr.$O\
+ memcmp.$O\
+ memcpy.$O\
+ memmove.$O\
+ memset.$O\
+
+DIRS = linux
+
+all: $(LIBC) $(SYS)
+
+$(LIBC): $(OBJS)
+ $(MKLST)
+
+$(SYS): FORCE
+ +@cd $@ && $(MAKE)
+
+dep: inc-dep
+
+dep clean:
+ $(FORALL)
+
+include deps.mk
--- /dev/null
+++ b/src/libc/arch/ppc32/deps.mk
@@ -1,0 +1,1 @@
+#deps
--- /dev/null
+++ b/src/libc/arch/ppc32/linux/Makefile
@@ -1,0 +1,30 @@
+.POSIX:
+PROJECTDIR =../../../../..
+include $(PROJECTDIR)/scripts/rules.mk
+include ../../../rules.mk
+
+GENOBJS =
+
+GENSRC = $(GENOBJS:.$O=.s)
+
+OBJS = \
+ $(GENOBJS)\
+
+# Rules
+
+all: $(LIBC) $(CRT)
+
+$(LIBC): $(OBJS)
+ $(MKLST)
+
+crt.$O: ../crt-posix.s
+
+$(GENSRC): syscall.lst
+ gensys.sh $(@:.s=)
+
+dep: inc-dep
+
+clean:
+ rm -f $(GENSRC)
+
+include deps.mk
--- /dev/null
+++ b/src/libc/arch/ppc32/linux/crt.s
@@ -1,0 +1,1 @@
+ .include "../crt-posix.s"
--- /dev/null
+++ b/src/libc/arch/ppc32/linux/deps.mk
@@ -1,0 +1,1 @@
+#deps
--- /dev/null
+++ b/src/libc/arch/ppc32/memchr.c
@@ -1,0 +1,1 @@
+#include "../../string/memchr.c"
--- /dev/null
+++ b/src/libc/arch/ppc32/memcmp.c
@@ -1,0 +1,1 @@
+#include "../../string/memcmp.c"
--- /dev/null
+++ b/src/libc/arch/ppc32/memcpy.c
@@ -1,0 +1,1 @@
+#include "../../string/memcpy.c"
--- /dev/null
+++ b/src/libc/arch/ppc32/memmove.c
@@ -1,0 +1,1 @@
+#include "../../string/memmove.c"
--- /dev/null
+++ b/src/libc/arch/ppc32/memset.c
@@ -1,0 +1,1 @@
+#include "../../string/memset.c"
--- a/src/libc/rules.mk
+++ b/src/libc/rules.mk
@@ -17,7 +17,7 @@
# Rules
-.SUFFIXES: .6 .7 .8 .z
+.SUFFIXES: .6 .7 .8 .z .q
_sys_errlist.c: $(SYSERRNO)
../../mkerrstr $(SYSERRNO)
@@ -28,7 +28,7 @@
clean: clean-libc
clean-libc: FORCE
- rm -f *.6 *.7 *.8 *.z
+ rm -f *.6 *.7 *.8 *.z *.q
# amd64-posix objects
.c.6:
@@ -63,4 +63,11 @@
$(CC) $(SCC_CFLAGS) -o $@ -c $<
.s.z:
+ $(AS) $(SCC_ASFLAGS) $< -o $@
+
+# ppc32 objects
+.c.q:
+ $(CC) $(SCC_CFLAGS) -o $@ -c $<
+
+.s.q:
$(AS) $(SCC_ASFLAGS) $< -o $@