diff options
-rw-r--r-- | sys/conf/Makefile.alpha | 6 | ||||
-rw-r--r-- | sys/conf/Makefile.i386 | 6 | ||||
-rw-r--r-- | sys/conf/Makefile.pc98 | 6 | ||||
-rw-r--r-- | sys/conf/Makefile.powerpc | 6 | ||||
-rw-r--r-- | sys/conf/files.i386 | 8 | ||||
-rw-r--r-- | sys/conf/files.pc98 | 8 | ||||
-rw-r--r-- | sys/kern/genassym.sh | 53 | ||||
-rw-r--r-- | sys/sys/assym.h | 18 |
8 files changed, 80 insertions, 31 deletions
diff --git a/sys/conf/Makefile.alpha b/sys/conf/Makefile.alpha index 066bf40..f73f864 100644 --- a/sys/conf/Makefile.alpha +++ b/sys/conf/Makefile.alpha @@ -138,7 +138,7 @@ ${mfile:T:S/.m$/.h/}: ${mfile} .endfor kernel-clean: - rm -f *.o *.so *.So *.ko *.s eddep errs genassym \ + rm -f *.o *.so *.So *.ko *.s eddep errs \ ${FULLKERNEL} ${KERNEL} linterrs makelinks param.c \ setdef[01].c setdefs.h tags \ vers.c vnode_if.c vnode_if.h \ @@ -176,8 +176,8 @@ setdef0.c setdef1.c setdefs.h: ${OBJS} param.o # this rule stops ./assym.s in .depend from causing problems ./assym.s: assym.s -assym.s: genassym.o - genassym genassym.o >assym.s +assym.s: $S/kern/genassym.sh genassym.o + sh $S/kern/genassym.sh genassym.o > ${.TARGET} genassym.o: $S/$M/$M/genassym.c ${CC} -c ${CFLAGS} $S/$M/$M/genassym.c diff --git a/sys/conf/Makefile.i386 b/sys/conf/Makefile.i386 index 9517a54..8d0dcf8 100644 --- a/sys/conf/Makefile.i386 +++ b/sys/conf/Makefile.i386 @@ -138,7 +138,7 @@ ${mfile:T:S/.m$/.h/}: ${mfile} .endfor kernel-clean: - rm -f *.o *.so *.So *.ko *.s eddep errs genassym \ + rm -f *.o *.so *.So *.ko *.s eddep errs \ ${FULLKERNEL} ${KERNEL} linterrs makelinks param.c \ setdef[01].c setdefs.h tags \ vers.c vnode_if.c vnode_if.h \ @@ -176,8 +176,8 @@ setdef0.c setdef1.c setdefs.h: ${OBJS} param.o # this rule stops ./assym.s in .depend from causing problems ./assym.s: assym.s -assym.s: genassym.o - genassym genassym.o >assym.s +assym.s: $S/kern/genassym.sh genassym.o + sh $S/kern/genassym.sh genassym.o > ${.TARGET} genassym.o: $S/$M/$M/genassym.c ${CC} -c ${CFLAGS} $S/$M/$M/genassym.c diff --git a/sys/conf/Makefile.pc98 b/sys/conf/Makefile.pc98 index b656e2c..7ee45aa 100644 --- a/sys/conf/Makefile.pc98 +++ b/sys/conf/Makefile.pc98 @@ -142,7 +142,7 @@ ${mfile:T:S/.m$/.h/}: ${mfile} .endfor clean: - rm -f *.o *.so *.So *.ko *.s eddep errs genassym \ + rm -f *.o *.so *.So *.ko *.s eddep errs \ ${FULLKERNEL} ${KERNEL} linterrs makelinks param.c \ setdef[01].c setdefs.h tags \ vers.c vnode_if.c vnode_if.h \ @@ -183,8 +183,8 @@ setdef0.c setdef1.c setdefs.h: ${OBJS} param.o # this rule stops ./assym.s in .depend from causing problems ./assym.s: assym.s -assym.s: genassym.o - genassym genassym.o >assym.s +assym.s: $S/kern/genassym.sh genassym.o + sh $S/kern/genassym.sh genassym.o > ${.TARGET} genassym.o: $S/$M/$M/genassym.c rm -f ./machine ; ln -s $S/$M/include ./machine diff --git a/sys/conf/Makefile.powerpc b/sys/conf/Makefile.powerpc index 9517a54..8d0dcf8 100644 --- a/sys/conf/Makefile.powerpc +++ b/sys/conf/Makefile.powerpc @@ -138,7 +138,7 @@ ${mfile:T:S/.m$/.h/}: ${mfile} .endfor kernel-clean: - rm -f *.o *.so *.So *.ko *.s eddep errs genassym \ + rm -f *.o *.so *.So *.ko *.s eddep errs \ ${FULLKERNEL} ${KERNEL} linterrs makelinks param.c \ setdef[01].c setdefs.h tags \ vers.c vnode_if.c vnode_if.h \ @@ -176,8 +176,8 @@ setdef0.c setdef1.c setdefs.h: ${OBJS} param.o # this rule stops ./assym.s in .depend from causing problems ./assym.s: assym.s -assym.s: genassym.o - genassym genassym.o >assym.s +assym.s: $S/kern/genassym.sh genassym.o + sh $S/kern/genassym.sh genassym.o > ${.TARGET} genassym.o: $S/$M/$M/genassym.c ${CC} -c ${CFLAGS} $S/$M/$M/genassym.c diff --git a/sys/conf/files.i386 b/sys/conf/files.i386 index 58ba714..540083a 100644 --- a/sys/conf/files.i386 +++ b/sys/conf/files.i386 @@ -20,14 +20,14 @@ svr4_genassym.o optional compat_svr4 \ clean "svr4_genassym.o" # linux_assym.h optional compat_linux \ - dependency "linux_genassym.o" \ - compile-with "genassym linux_genassym.o > ${.TARGET}" \ + dependency "$S/kern/genassym.sh linux_genassym.o" \ + compile-with "sh $S/kern/genassym.sh linux_genassym.o > ${.TARGET}" \ no-obj no-implicit-rule before-depend \ clean "linux_assym.h" # svr4_assym.h optional compat_svr4 \ - dependency "svr4_genassym.o" \ - compile-with "genassym svr4_genassym.o > ${.TARGET}" \ + dependency "$S/kern/genassym.sh svr4_genassym.o" \ + compile-with "sh $S/kern/genassym.sh svr4_genassym.o > ${.TARGET}" \ no-obj no-implicit-rule before-depend \ clean "svr4_assym.h" # diff --git a/sys/conf/files.pc98 b/sys/conf/files.pc98 index 6d40d16..6d8e589 100644 --- a/sys/conf/files.pc98 +++ b/sys/conf/files.pc98 @@ -22,14 +22,14 @@ svr4_genassym.o optional compat_svr4 \ clean "svr4_genassym.o" # linux_assym.h optional compat_linux \ - dependency "linux_genassym.o" \ - compile-with "genassym linux_genassym.o > ${.TARGET}" \ + dependency "$S/kern/genassym.sh linux_genassym.o" \ + compile-with "sh $S/kern/genassym.sh linux_genassym.o > ${.TARGET}" \ no-obj no-implicit-rule before-depend \ clean "linux_assym.h" # svr4_assym.h optional compat_svr4 \ - dependency "svr4_genassym.o" \ - compile-with "genassym svr4_genassym.o > ${.TARGET}" \ + dependency "$S/kern/genassym.sh svr4_genassym.o" \ + compile-with "sh $S/kern/genassym.sh svr4_genassym.o > ${.TARGET}" \ no-obj no-implicit-rule before-depend \ clean "svr4_assym.h" # diff --git a/sys/kern/genassym.sh b/sys/kern/genassym.sh new file mode 100644 index 0000000..071ddb0 --- /dev/null +++ b/sys/kern/genassym.sh @@ -0,0 +1,53 @@ +#!/bin/sh +# $FreeBSD$ + +# Grrr, this should use stdin and stdout, but is encrufted for compatibility. + +usage() { + echo "usage: genassym [-o outfile] objfile" + exit 1 +} + +outfile=/dev/stdout +while getopts "o:" option +do + case "$option" in + o) outfile="$OPTARG";; + *) usage;; + esac +done +shift $(($OPTIND - 1)) +case $# in +1) ;; +*) usage;; +esac + +nm "$1" | awk ' +/ C .*sign$/ { + sign = substr($1, length($1) - 3, 4) + sub("^0*", "", sign) + if (sign != "") + sign = "-" +} +/ C .*w0$/ { + w0 = substr($1, length($1) - 3, 4) +} +/ C .*w1$/ { + w1 = substr($1, length($1) - 3, 4) +} +/ C .*w2$/ { + w2 = substr($1, length($1) - 3, 4) +} +/ C .*w3$/ { + w3 = substr($1, length($1) - 3, 4) + w = w3 w2 w1 w0 + sub("^0*", "", w) + if (w == "") + w = "0" + sub("w3$", "", $3) + # This still has minor problems representing INT_MIN, etc. E.g., + # with 32-bit 2''s complement ints, this prints -0x80000000, which + # has the wrong type (unsigned int). + printf("#define\t%s\t%s0x%s\n", $3, sign, w) +} +' 3>"$outfile" >&3 3>&- diff --git a/sys/sys/assym.h b/sys/sys/assym.h index 4350316..d3c8291 100644 --- a/sys/sys/assym.h +++ b/sys/sys/assym.h @@ -31,17 +31,13 @@ #ifndef _SYS_ASSYM_H_ #define _SYS_ASSYM_H_ -#ifndef offsetof -#define offsetof(t, m) (&((t *)0)->m) -#endif +#define ASSYM_ABS(value) ((value) < 0 ? -((value) + 1) + 1ULL : (value)) -#ifndef __assym -#define __assym(sym, v) unsigned long sym = (unsigned long)v -#endif - -#define ASSYM(sym, v) __assym(assym_##sym, v) - -#define ASSYM_SELF(sym) ASSYM(sym, sym) -#define ASSYM_OFFSET(sym, s, m) ASSYM(sym, offsetof(s, m)) +#define ASSYM(name, value) \ +char name ## sign[(value) < 0 ? 1 : 0]; \ +char name ## w0[ASSYM_ABS(value) & 0xFFFFU]; \ +char name ## w1[(ASSYM_ABS(value) & 0xFFFF0000UL) >> 16]; \ +char name ## w2[(ASSYM_ABS(value) & 0xFFFF00000000ULL) >> 32]; \ +char name ## w3[(ASSYM_ABS(value) & 0xFFFF000000000000ULL) >> 48] #endif /* !_SYS_ASSYM_H_ */ |