[Mirmince-commits] {mirmince} branch master updated. 925ed2e6a6a2ee89e51ab358d93d8aeb424aa9b3

tg at freewrt.org tg at freewrt.org
Thu Jan 10 23:59:50 UTC 2013


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Main git repository for FreeWRT project mirmince".

The branch, master has been updated
       via  925ed2e6a6a2ee89e51ab358d93d8aeb424aa9b3 (commit)
       via  f6578e7a51c8a37bf5501cae4a9bf79debe1107c (commit)
       via  77c37fb1a6efc572a67417424ebe45fb769a3592 (commit)
       via  6a3e8a3e756f36d81dc8a23544298858837727dc (commit)
       via  f9176bd1091aee07d274c2d4753d58e49a0aeaf9 (commit)
       via  34915d1c91584d9c37c36466a3f763caa7239b64 (commit)
       via  13f1737eb65437efb66f26afd450a6f8f6fd2ff5 (commit)
       via  ab7760bb3158675fc5c88b494104d51d6fa123bb (commit)
       via  bfdb7dc15c43e515cc879d9d748946d6d8b7499a (commit)
       via  691394c33d3cd6e6e9674af1b4e98d48ff269a8b (commit)
       via  a5a1c1abad91f68eb674a2420492c6a0f0fc7a80 (commit)
      from  cedc94f7b201f05b0970173c401fe396f53fb318 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 925ed2e6a6a2ee89e51ab358d93d8aeb424aa9b3
Author: Thorsten Glaser <tg at mirbsd.org>
Date:   Thu Jan 10 23:59:14 2013 +0000

    add strlen(3)

commit f6578e7a51c8a37bf5501cae4a9bf79debe1107c
Author: Thorsten Glaser <tg at mirbsd.org>
Date:   Thu Jan 10 23:50:07 2013 +0000

    switch i386 to -mregparm=3 -mrtd by default

commit 77c37fb1a6efc572a67417424ebe45fb769a3592
Author: Thorsten Glaser <tg at mirbsd.org>
Date:   Thu Jan 10 23:49:52 2013 +0000

    GCC is a weird beast

commit 6a3e8a3e756f36d81dc8a23544298858837727dc
Author: Thorsten Glaser <tg at mirbsd.org>
Date:   Thu Jan 10 23:38:29 2013 +0000

    make cc_cdecl reset regparm, too

commit f9176bd1091aee07d274c2d4753d58e49a0aeaf9
Author: Thorsten Glaser <tg at mirbsd.org>
Date:   Thu Jan 10 23:38:08 2013 +0000

    make objcopy binary overridable (for cross-builds)

commit 34915d1c91584d9c37c36466a3f763caa7239b64
Author: Thorsten Glaser <tg at mirbsd.org>
Date:   Thu Jan 10 23:29:34 2013 +0000

    MirBSD/i386 syscall ABI docs
    
    from reading the kernel source; correct me if I’m wrong

commit 13f1737eb65437efb66f26afd450a6f8f6fd2ff5
Author: Thorsten Glaser <tg at mirbsd.org>
Date:   Thu Jan 10 23:15:31 2013 +0000

    to every function their calling convention

commit ab7760bb3158675fc5c88b494104d51d6fa123bb
Author: Thorsten Glaser <tg at mirbsd.org>
Date:   Thu Jan 10 23:10:45 2013 +0000

    begin issuing calling conventions for syscalls and functions

commit bfdb7dc15c43e515cc879d9d748946d6d8b7499a
Author: Thorsten Glaser <tg at mirbsd.org>
Date:   Thu Jan 10 22:44:45 2013 +0000

    unify syscall parsing code; validate lots

commit 691394c33d3cd6e6e9674af1b4e98d48ff269a8b
Author: Thorsten Glaser <tg at mirbsd.org>
Date:   Thu Jan 10 22:36:02 2013 +0000

    begin code for having different calling conventions

commit a5a1c1abad91f68eb674a2420492c6a0f0fc7a80
Author: Thorsten Glaser <tg at mirbsd.org>
Date:   Thu Jan 10 22:25:39 2013 +0000

    add macro (overridable) for syscall-userspace-fn calling convention
    
    I guess almost all would want to use cdecl, but I imagine some
    could use regparm possibly…

-----------------------------------------------------------------------

Summary of changes:
 Makefile                          |   19 +++----
 cvsyscls                          |  104 +++++++++++++++++++++++++++++++++++++
 do-install                        |    2 +-
 include/fcntl.h                   |    3 +-
 include/mirmince/c.h              |   12 +++--
 include/stdlib.h                  |    4 +-
 include/{sys/types.h => string.h} |   10 ++--
 include/unistd.h                  |    9 ++--
 md/i386/Makefile.inc              |   10 ++++
 md/i386/README                    |   14 +++++
 md/i386/c.h                       |    3 ++
 mi/Makefile.inc                   |    2 +
 mi/exit.c                         |    4 +-
 mi/mincebeg_mi.c                  |    2 +-
 mi/{exit.c => strlen.c}           |   14 ++---
 mkmkfg                            |   26 ----------
 mksysch                           |   26 ----------
 osdep/mirbsd/syscalls             |    2 +-
 18 files changed, 182 insertions(+), 84 deletions(-)
 create mode 100644 cvsyscls
 copy include/{sys/types.h => string.h} (51%)
 create mode 100644 md/i386/README
 copy mi/{exit.c => strlen.c} (88%)
 delete mode 100644 mkmkfg
 delete mode 100644 mksysch

diff --git a/Makefile b/Makefile
index de36218..f68ce2e 100644
--- a/Makefile
+++ b/Makefile
@@ -21,6 +21,8 @@
 # settings (will change later)
 CC?=		mgcc
 LD?=		ld
+STRIP?=		strip
+OBJCOPY?=	objcopy
 DST=		/opt/mirmince
 TG_ARCH=	i386
 TG_OS=		mirbsd
@@ -93,26 +95,21 @@ LINK.c:=	${CC} ${CPPFLAGS} ${CFLAGS} ${LDFLAGS}
 all: ${GENHDRS}
 all: mincebeg.o
 
+# un-nice: despite localising, _mince_csu_run is not discarded
 mincebeg.o: mincebeg_os.o mincebeg_md.o mincebeg_mi.o
 	${LD} -X -r -o $@.o $>
-	objcopy -G _mince_csu_init -x $@.o $@
+	${OBJCOPY} -G _mince_csu_init -x $@.o $@
 	@rm -f $@.o
 
-GENHDRS+=	syscall.h
+GENHDRS+=	syscall.h syscallc.h
 
 ${_CONF}:
 	@:>$@
 
-DCLEANFILES+=	syscall.h
+DCLEANFILES+=	syscall.h syscallc.h Makefile.gen
 
-syscall.h: ${_CONF} mksysch
-	${SHELL} ${LIBCDIR:Q}/mksysch \
-	    ${LIBCDIR:Q}/osdep/${TG_OS}/syscalls
-
-DCLEANFILES+=	Makefile.gen
-
-Makefile.gen: ${_CONF} mkmkfg
-	${SHELL} ${LIBCDIR:Q}/mkmkfg \
+syscall.h syscallc.h Makefile.gen: ${_CONF} cvsyscls ${LIBCDIR}/osdep/${TG_OS}/syscalls
+	${SHELL} ${LIBCDIR:Q}/cvsyscls $@ \
 	    ${LIBCDIR:Q}/osdep/${TG_OS}/syscalls
 
 SYSCALLS+=${SYSCALLS_${TG_ARCH}}
diff --git a/cvsyscls b/cvsyscls
new file mode 100644
index 0000000..f767ad0
--- /dev/null
+++ b/cvsyscls
@@ -0,0 +1,104 @@
+# Copyright © 2013
+#	Thorsten Glaser <tg at mirbsd.org>
+#
+# Provided that these terms and disclaimer and all copyright notices
+# are retained or reproduced in an accompanying document, permission
+# is granted to deal in this work without restriction, including un‐
+# limited rights to use, publicly perform, distribute, sell, modify,
+# merge, give away, or sublicence.
+#
+# This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to
+# the utmost extent permitted by applicable law, neither express nor
+# implied; without malicious intent or gross negligence. In no event
+# may a licensor, author or contributor be held liable for indirect,
+# direct, other damage, loss, or other issues arising in any way out
+# of dealing in the work, even if advised of the possibility of such
+# damage or existence of a defect, except proven that it results out
+# of said person’s immediate fault when using the work as intended.
+
+whattodo=$1
+syscalls=$2
+
+case $whattodo {
+(Makefile.gen)
+	function doit {
+		mv=SYSCALLS_$arch
+		[[ $arch = '*' ]] && mv=SYSCALLS
+		print -r "${mv}+=	$name $kname $args"
+	}
+	;;
+(syscall.h)
+	function doit {
+		[[ $arch = '*' ]] || print "#ifdef __mirmincE_arch_$arch"
+		print "#define SYS_$kname $num"
+		[[ $arch = '*' ]] || print "#endif"
+	}
+	;;
+(syscallc.h)
+	function doit {
+		[[ $arch = '*' ]] || print "#ifdef __mirmincE_arch_$arch"
+		print "#define mirmincE_cc_$kname mirmince_cc_$cconv"
+		[[ $name = "$kname" ]] || print \
+		    "#define mirmincE_cc_$name mirmince_cc_$kcconv /* $kname */"
+		[[ $arch = '*' ]] || print "#endif"
+	}
+	;;
+(*)
+	print -u2 "E: Syntax error"
+	exit 2
+	;;
+}
+
+if [[ -z $syscalls || ! -s $syscalls ]]; then
+	print -u2 "E: syscalls file '$syscalls' illegible"
+	exit 2
+fi
+
+set -A numseen
+while read arch num args name kname cconv kcconv rest; do
+	[[ -z $arch || $arch = '#' ]] && continue
+	if [[ $num != +([0-9]) ]]; then
+		print -ru2 "E: syscall '$name' syscall number '$num' invalid"
+		exit 1
+	fi
+	if [[ $args != [0-6V] ]]; then
+		print -ru2 "E: syscall $num number of arguments '$args' invalid"
+		exit 1
+	fi
+	if [[ $arch != '*' && $arch != [a-z_]*([a-z_0-9]) ]]; then
+		print -ru2 "E: syscall $num architecture '$arch' invalid"
+		exit 1
+	fi
+	if [[ $name != [a-z_]*([a-z_0-9]) ]]; then
+		print -ru2 "E: syscall $num name '$name' invalid"
+		exit 1
+	fi
+	if [[ $kname = ?(-) ]]; then
+		kname=$name
+	elif [[ $kname != [a-z_]*([a-z_0-9]) ]]; then
+		print -ru2 "E: syscall $num kernel name '$kname' invalid"
+		exit 1
+	fi
+	if [[ -n ${numseen[num]} ]]; then
+		print -ru2 "E: syscall $num (${numseen[num]}) duplicate $kname"
+		exit 1
+	fi
+	numseen[num]=$kname
+	if [[ $cconv = ?(-) ]]; then
+		if [[ $name = "$kname" ]]; then
+			# direct syscall function
+			cconv=syscall
+		else
+			# syscall wrapper
+			cconv=userspc
+		fi
+	elif [[ $cconv != [a-z]*([a-z_0-9()]) ]]; then
+		print -ru2 "E: syscall $num calling convention '$cconv' invalid"
+	fi
+	if [[ $kcconv = ?(-) ]]; then
+		kcconv=syscall
+	elif [[ $kcconv != [a-z]*([a-z_0-9()]) ]]; then
+		print -ru2 "E: syscall $num calling convention '$kcconv' invalid"
+	fi
+	doit
+done <"$syscalls" >$whattodo
diff --git a/do-install b/do-install
index 34cf201..1765e71 100644
--- a/do-install
+++ b/do-install
@@ -76,7 +76,7 @@ find include -name \*.h -print0 | pax -rw -0 "$dst"/
     pax -rw -0 "$dst"/include/mirmince/md/)
 (cd osdep/"$os" && find . -name \*.h -print0 | \
     pax -rw -0 "$dst"/include/mirmince/osdep/)
-cp obj/syscall.h "$dst"/include/mirmince/
+cp obj/syscall.h obj/syscallc.h "$dst"/include/mirmince/
 (( full )) || exit 0
 for f in obj/mince{beg,end}.o obj/*.a; do
 	[[ -s $f ]] || continue
diff --git a/include/fcntl.h b/include/fcntl.h
index 7ee8585..f2324d8 100644
--- a/include/fcntl.h
+++ b/include/fcntl.h
@@ -41,7 +41,8 @@
 #endif /* OS:MirBSD */
 
 __BEGIN_DECLS
-int open(const char *path, int oflag, ...);
+int open(const char *path, int oflag, ...)
+	mirmincE_cc_open;
 __END_DECLS
 
 #endif
diff --git a/include/mirmince/c.h b/include/mirmince/c.h
index ba22016..6eb14f0 100644
--- a/include/mirmince/c.h
+++ b/include/mirmince/c.h
@@ -14,7 +14,7 @@
 
 #ifdef __GNUC__
 #define mirmince_bss		__attribute__((__section__ (".bss")))
-#define mirmince_cc_cdecl	__attribute__((__cdecl__))
+#define mirmince_cc_cdecl	__attribute__((__regparm__ (0), __cdecl__))
 #define mirmince_cc_regparm(x)	__attribute__((__regparm__ (x)))
 #define mirmince_dead		__attribute__((__noreturn__))
 #define mirmince_printf(x)	__attribute__((__printf__ x))
@@ -28,10 +28,16 @@
 #define mirmince_unused
 #endif
 
-#ifndef mirmince_cc_fast
-#define mirmince_cc_fast	mirmince_cc_cdecl
+#ifndef mirmince_cc_userspc
+#define mirmince_cc_userspc	mirmince_cc_cdecl
 #endif
 
+#ifndef mirmince_cc_syscall
+#define mirmince_cc_syscall	mirmince_cc_cdecl
+#endif
+
+#include <mirmince/syscallc.h>
+
 #define NULL			((void *)0)
 
 #endif
diff --git a/include/stdlib.h b/include/stdlib.h
index 9ac85a0..50bfcc9 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -6,7 +6,9 @@
 #endif
 
 __BEGIN_DECLS
-void exit(int status) mirmince_dead;
+void exit(int status)
+	mirmince_dead
+	mirmincE_cc_exit;
 __END_DECLS
 
 #endif
diff --git a/include/sys/types.h b/include/string.h
similarity index 51%
copy from include/sys/types.h
copy to include/string.h
index 8d38699..904e90b 100644
--- a/include/sys/types.h
+++ b/include/string.h
@@ -1,12 +1,16 @@
-#ifndef SYS_TYPES_H
-#define SYS_TYPES_H
+#ifndef STRING_H
+#define STRING_H
 
 #ifndef MIRMINCE_C_H
 #include <mirmince/c.h>
 #endif
 
-/* incomplete list */
 #define MIRMINCE_NT_SIZE_T
 #include <mirmince/types.h>
 
+__BEGIN_DECLS
+size_t strlen(const char *s)
+	mirmince_cc_userspc;
+__END_DECLS
+
 #endif
diff --git a/include/unistd.h b/include/unistd.h
index 2604e5e..ddc36e5 100644
--- a/include/unistd.h
+++ b/include/unistd.h
@@ -19,9 +19,12 @@
 #define STDERR_FILENO		2
 
 __BEGIN_DECLS
-int close(int fd);
-ssize_t read(int fd, void *buf, size_t nbytes);
-ssize_t write(int fd, const void *buf, size_t nbytes);
+int close(int fd)
+	mirmincE_cc_close;
+ssize_t read(int fd, void *buf, size_t nbytes)
+	mirmincE_cc_read;
+ssize_t write(int fd, const void *buf, size_t nbytes)
+	mirmincE_cc_write;
 __END_DECLS
 
 #endif
diff --git a/md/i386/Makefile.inc b/md/i386/Makefile.inc
index e69de29..acf40f0 100644
--- a/md/i386/Makefile.inc
+++ b/md/i386/Makefile.inc
@@ -0,0 +1,10 @@
+MD_USE_REGPARM?=	Yes
+MD_USE_RTD?=		Yes
+
+.if ${MD_USE_REGPARM:L} == "yes"
+TG_CFLAGS+=		-mregparm=3 -D__mirmincE_use_regparm__=3
+.endif
+
+.if ${MD_USE_RTD:L} == "yes"
+TG_CFLAGS+=		-mrtd -D__mirmincE_use_rtd__
+.endif
diff --git a/md/i386/README b/md/i386/README
new file mode 100644
index 0000000..a0717f9
--- /dev/null
+++ b/md/i386/README
@@ -0,0 +1,14 @@
+syscall ABI
+===========
+
+MirBSD/i386
+-----------
+
+Arguments are pushed on the stack (cdecl),
+then another argument (call), then int 80h
+is run.
+
+Normal:	CF clear (NC), EDX:EAX = return value
+Error:	CF set (CY), EAX = errno
+
+All registers other than EAX, EDX, EFLAGS are preserved.
diff --git a/md/i386/c.h b/md/i386/c.h
index e69de29..6e818ff 100644
--- a/md/i386/c.h
+++ b/md/i386/c.h
@@ -0,0 +1,3 @@
+#ifdef __mirmincE_use_regparm__
+#define mirmince_cc_userspc	mirmince_cc_regparm(__mirmincE_use_regparm__)
+#endif
diff --git a/mi/Makefile.inc b/mi/Makefile.inc
index 26fd8e6..fbf9400 100644
--- a/mi/Makefile.inc
+++ b/mi/Makefile.inc
@@ -1,3 +1,5 @@
 SRCS+=		vars.c
 
 SRCS+=		exit.c
+
+SRCS+=		strlen.c
diff --git a/mi/exit.c b/mi/exit.c
index 648d4ec..99b7bc0 100644
--- a/mi/exit.c
+++ b/mi/exit.c
@@ -20,7 +20,9 @@
 
 #include <stdlib.h>
 
-extern int _exit__(int status) mirmince_dead;
+extern int _exit__(int status)
+	mirmince_dead
+	mirmincE_cc__exit__;
 
 void
 exit(int status)
diff --git a/mi/mincebeg_mi.c b/mi/mincebeg_mi.c
index cbc600c..4fe33a4 100644
--- a/mi/mincebeg_mi.c
+++ b/mi/mincebeg_mi.c
@@ -28,7 +28,7 @@ extern int main(int argc, char *argv[], char *envp[]);
 
 extern char **environ;
 
-void
+mirmince_dead mirmince_cc_cdecl void
 _mince_csu_run(int argc, char *argv[], char *envp[])
 {
 	/* we will want __progname later */
diff --git a/mi/exit.c b/mi/strlen.c
similarity index 88%
copy from mi/exit.c
copy to mi/strlen.c
index 648d4ec..160b7fb 100644
--- a/mi/exit.c
+++ b/mi/strlen.c
@@ -18,12 +18,14 @@
  * of said person’s immediate fault when using the work as intended.
  */
 
-#include <stdlib.h>
+#include <string.h>
 
-extern int _exit__(int status) mirmince_dead;
-
-void
-exit(int status)
+size_t
+strlen(const char *s)
 {
-	_exit__(status);
+	register const char *cp = s;
+
+	while (*cp++)
+		/* loop */;
+	return (--cp - s);
 }
diff --git a/mkmkfg b/mkmkfg
deleted file mode 100644
index 43af505..0000000
--- a/mkmkfg
+++ /dev/null
@@ -1,26 +0,0 @@
-# Copyright © 2013
-#	Thorsten Glaser <tg at mirbsd.org>
-#
-# Provided that these terms and disclaimer and all copyright notices
-# are retained or reproduced in an accompanying document, permission
-# is granted to deal in this work without restriction, including un‐
-# limited rights to use, publicly perform, distribute, sell, modify,
-# merge, give away, or sublicence.
-#
-# This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to
-# the utmost extent permitted by applicable law, neither express nor
-# implied; without malicious intent or gross negligence. In no event
-# may a licensor, author or contributor be held liable for indirect,
-# direct, other damage, loss, or other issues arising in any way out
-# of dealing in the work, even if advised of the possibility of such
-# damage or existence of a defect, except proven that it results out
-# of said person’s immediate fault when using the work as intended.
-
-syscalls=$1
-
-while read arch num args name kname rest; do
-	[[ -z $arch || $arch = '#' ]] && continue
-	mv=SYSCALLS_$arch
-	[[ $arch = '*' ]] && mv=SYSCALLS
-	print -r "${mv}+=	${name:-!} ${kname:-${name:-!}} ${args:-!}"
-done <"$syscalls" >Makefile.gen
diff --git a/mksysch b/mksysch
deleted file mode 100644
index b3bf7b5..0000000
--- a/mksysch
+++ /dev/null
@@ -1,26 +0,0 @@
-# Copyright © 2013
-#	Thorsten Glaser <tg at mirbsd.org>
-#
-# Provided that these terms and disclaimer and all copyright notices
-# are retained or reproduced in an accompanying document, permission
-# is granted to deal in this work without restriction, including un‐
-# limited rights to use, publicly perform, distribute, sell, modify,
-# merge, give away, or sublicence.
-#
-# This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to
-# the utmost extent permitted by applicable law, neither express nor
-# implied; without malicious intent or gross negligence. In no event
-# may a licensor, author or contributor be held liable for indirect,
-# direct, other damage, loss, or other issues arising in any way out
-# of dealing in the work, even if advised of the possibility of such
-# damage or existence of a defect, except proven that it results out
-# of said person’s immediate fault when using the work as intended.
-
-syscalls=$1
-
-while read arch num args name kname rest; do
-	[[ -z $arch || $arch = '#' ]] && continue
-	[[ $arch = '*' ]] || print "#ifdef __mirmincE_arch_$arch"
-	print "#define SYS_${kname:-${name:-!}} $num"
-	[[ $arch = '*' ]] || print "#endif"
-done <"$syscalls" >syscall.h
diff --git a/osdep/mirbsd/syscalls b/osdep/mirbsd/syscalls
index 1a1a6ef..37ce142 100644
--- a/osdep/mirbsd/syscalls
+++ b/osdep/mirbsd/syscalls
@@ -1,4 +1,4 @@
-# arch	num	args	name		kname
+# arch	num	args	name		kname		cconv	kcconv
 *	0	V	syscall
 *	1	1	_exit__		exit
 *	3	3	read


hooks/post-receive
-- 
Main git repository for FreeWRT project mirmince
(FreeWRT project mirmince repository mirmince)


More information about the Mirmince-commits mailing list