all: remove $OBJTYPE from build

Now that we assume pthreads, the only assembly
left is in libmp and libsec.
We only ever added assembly for 386.
The portable C code is fine for plan9port.
This commit is contained in:
Russ Cox 2020-12-30 07:39:16 -05:00
parent 0bd1478342
commit 99dee78c2d
56 changed files with 41 additions and 1291 deletions

30
INSTALL
View file

@ -71,18 +71,15 @@ if [ `uname` = SunOS ]; then
echo "* Running on Solaris: checking architecture..."
case "$(isainfo -n)" in
*amd64*)
echo " x86-64 found."
echo "OBJTYPE=x86_64" >>$PLAN9/config
echo " x86-64 found; using gcc."
echo "CC9=gcc" >>$PLAN9/config # defaults to gcc on Solaris/amd64
;;
*i386*)
echo " i386 found."
echo "OBJTYPE=386" >>$PLAN9/config
echo " i386 found; using gcc."
echo "CC9=gcc" >>$PLAN9/config # defaults to gcc on Solaris/i386
;;
*sparc*)
echo " Sparc found."
echo "OBJTYPE=sparc" >>$PLAN9/config
;;
esac
fi
@ -90,28 +87,15 @@ fi
if [ `uname` = Darwin ]; then
export NPROC=$(sysctl hw.ncpu | sed 's/hw.ncpu: //')
# On Darwin, uname -m -p cannot be trusted.
echo "* Running on Darwin: checking architecture..."
echo "* Running on Darwin..."
rm -f ./a.out
if ! gcc lib/darwin-main.c >/dev/null 2>&1; then
echo "Cannot find gcc. You may need to install the command-line tools using Xcode." >&2
if ! xcrun --sdk macosx clang lib/darwin-main.c >/dev/null 2>&1; then
echo "Cannot find 'xcrun --sdk macosx clang'." >&2
echo "You may need to install the command-line tools using Xcode." >&2
echo "See http://swtch.com/go/xcodegcc for details." >&2
exit 1
fi
case "$(file ./a.out 2>/dev/null)" in
*x86_64*)
echo " x86-64 found."
echo "OBJTYPE=x86_64" >>$PLAN9/config
echo "CC9='xcrun --sdk macosx clang'" >>$PLAN9/config
;;
*i386*)
echo " i386 found."
echo "OBJTYPE=386" >>$PLAN9/config
;;
*ppc*)
echo " power found."
echo "OBJTYPE=power" >>$PLAN9/config
;;
esac
echo "CC9='xcrun --sdk macosx clang'" >>$PLAN9/config
rm -f ./a.out
fi

21
bin/9a
View file

@ -1,21 +0,0 @@
#!/bin/sh
if [ $# != 1 ]; then
echo 'usage: 9a file.s' 1>&2
exit 1
fi
test -f $PLAN9/config && . $PLAN9/config
aflags=""
case "`uname`-${OBJTYPE:-`uname -m`}" in
Darwin-*386*)
aflags="-arch i386"
;;
Darwin-*x86_64*)
aflags="-arch x86_64"
;;
esac
out=`echo $1 | sed 's/\.s$//;s/$/.o/'`
exec as $aflags -o $out $1

14
bin/9c
View file

@ -112,24 +112,14 @@ usexlc()
cflags="$cflags $CC9FLAGS"
}
tag="${SYSNAME:-`uname`}-${OBJTYPE:-`uname -m`}-${CC9:-cc}"
tag="${SYSNAME:-`uname`}-${CC9:-cc}"
case "$tag" in
*DragonFly*gcc*|*BSD*gcc*) usegcc ;;
*DragonFly*clang|*BSD*clang*) useclang ;;
*Darwin-x86_64*)
*Darwin*)
useclang
cflags="$cflags -g3 -m64"
;;
*Darwin-arm64*)
useclang
cflags="$cflags -g3 -m64"
;;
*Darwin*clang*)
useclang
cflags="$cflags -g3 -m32"
;;
*Darwin*) usegcc
cflags="$cflags -g3 -no-cpp-precomp -m32" ;;
*HP-UX*) cc=${CC9:-cc}; cflags="-g -O -c -Ae" ;;
*Linux*) usegcc
case "${CC9:-gcc}" in

12
bin/9l
View file

@ -9,7 +9,7 @@ verbose=false
nmflags=""
extralibs="-lm"
tag="${SYSNAME:-`uname`}-${OBJTYPE:-`uname -m`}"
tag="${SYSNAME:-`uname`}"
case "$tag" in
*DragonFly*|*BSD*)
ld="${CC9:-gcc} $CC9FLAGS"
@ -27,14 +27,8 @@ case "$tag" in
userpath=true
extralibs="$extralibs -lutil -lresolv -lpthread"
;;
*Darwin*x86_64*)
ld="${CC9:-gcc} -m64 $CC9FLAGS"
;;
*Darwin-arm64*)
ld="${CC9:-gcc} -m64 $CC9FLAGS"
;;
*Darwin*)
ld="${CC9:-gcc} -m32 $CC9FLAGS"
ld="${CC9:-gcc} -m64 $CC9FLAGS"
;;
*SunOS*)
ld="${CC9:-cc} -g $CC9FLAGS"
@ -255,7 +249,7 @@ then
fi
# Don't say -L with a non-existent directory: Xcode complains.
# x86_64 seems to put its 64-bit libraries in lib64.
if [ "${OBJTYPE:-`uname -m`}" = "x86_64" -a -d "$X11/lib64" ]
if [ "`uname -m`" = "x86_64" -a -d "$X11/lib64" ]
then
libsl="$libsl -L$X11/lib64"
fi

2
dist/buildmk vendored
View file

@ -2,5 +2,5 @@
# run this in the src directory
. ../src/mkenv
export SYSNAME OBJTYPE INSTALL
export SYSNAME INSTALL
sh -x mkmk.sh

View file

@ -1,15 +0,0 @@
<$PLAN9/src/mkhdr
LIB=libmp.a
UNAME=`uname`
A=`[ $UNAME = Darwin ] && echo -Darwin`
OFILES=\
mpdigdiv$A.$O\
mpvecadd$A.$O\
mpvecdigmuladd$A.$O\
mpvecdigmulsub$A.$O\
mpvecsub$A.$O\
HFILES=$PLAN9/include/mp.h ../port/dat.h
<$PLAN9/src/mksyslib

View file

@ -1,33 +0,0 @@
.text
.globl _mpdigdiv
_mpdigdiv:
/* Prelude */
pushl %ebp /* save on stack */
pushl %ebx
leal 12(%esp), %ebp /* %ebp = FP for now */
movl 0(%ebp), %ebx /* dividend */
movl 0(%ebx), %eax
movl 4(%ebx), %edx
movl 4(%ebp), %ebx /* divisor */
movl 8(%ebp), %ebp /* quotient */
xorl %ecx, %ecx
cmpl %ebx, %edx /* dividend >= 2^32 * divisor */
jae 2f
cmpl %ecx, %ebx /* divisor == 1 */
je 2f
divl %ebx /* AX = DX:AX/BX */
movl %eax, (%ebp)
1:
/* Postlude */
popl %ebx
popl %ebp
ret
/* return all 1's */
2:
notl %ecx
movl %ecx, (%ebp)
jmp 1b

View file

@ -1,33 +0,0 @@
.text
.p2align 2,0x90
.globl mpdigdiv
mpdigdiv:
/* Prelude */
pushl %ebp /* save on stack */
pushl %ebx
leal 12(%esp), %ebp /* %ebp = FP for now */
movl 0(%ebp), %ebx /* dividend */
movl 0(%ebx), %eax
movl 4(%ebx), %edx
movl 4(%ebp), %ebx /* divisor */
movl 8(%ebp), %ebp /* quotient */
xorl %ecx, %ecx
cmpl %ebx, %edx /* dividend >= 2^32 * divisor */
jae divovfl
cmpl %ecx, %ebx /* divisor == 1 */
je divovfl
divl %ebx /* AX = DX:AX/BX */
movl %eax, (%ebp)
done:
/* Postlude */
popl %ebx
popl %ebp
ret
/* return all 1's */
divovfl:
notl %ecx
movl %ecx, (%ebp)
jmp done

View file

@ -1,70 +0,0 @@
/* mpvecadd(mpdigit *a, int alen, mpdigit *b, int blen, mpdigit *sum) */
/* sum[0:alen] = a[0:alen-1] + b[0:blen-1] */
/* prereq: alen >= blen, sum has room for alen+1 digits */
/* (very old gnu assembler doesn't allow multiline comments) */
.text
.p2align 2,0x90
.globl _mpvecadd
_mpvecadd:
/* Prelude */
pushl %ebp /* save on stack */
pushl %ebx
pushl %esi
pushl %edi
leal 20(%esp), %ebp /* %ebp = FP for now */
movl 4(%ebp), %edx /* alen */
movl 12(%ebp), %ecx /* blen */
movl 0(%ebp), %esi /* a */
movl 8(%ebp), %ebx /* b */
subl %ecx, %edx
movl 16(%ebp), %edi /* sum */
xorl %ebp, %ebp /* this also sets carry to 0 */
/* skip addition if b is zero */
testl %ecx,%ecx
je 2f
/* sum[0:blen-1],carry = a[0:blen-1] + b[0:blen-1] */
1:
movl (%esi, %ebp, 4), %eax
adcl (%ebx, %ebp, 4), %eax
movl %eax, (%edi, %ebp, 4)
incl %ebp
loop 1b
2:
/* jump if alen > blen */
incl %edx
movl %edx, %ecx
loop 5f
/* sum[alen] = carry */
3:
jb 4f
movl $0, (%edi, %ebp, 4)
jmp 6f
4:
movl $1, (%edi, %ebp, 4)
jmp 6f
/* sum[blen:alen-1],carry = a[blen:alen-1] + 0 */
5:
movl (%esi, %ebp, 4),%eax
adcl $0, %eax
movl %eax, (%edi, %ebp, 4)
incl %ebp
loop 5b
jmp 3b
6:
/* Postlude */
popl %edi
popl %esi
popl %ebx
popl %ebp
ret

View file

@ -1,70 +0,0 @@
/* mpvecadd(mpdigit *a, int alen, mpdigit *b, int blen, mpdigit *sum) */
/* sum[0:alen] = a[0:alen-1] + b[0:blen-1] */
/* prereq: alen >= blen, sum has room for alen+1 digits */
/* (very old gnu assembler doesn't allow multiline comments) */
.text
.p2align 2,0x90
.globl mpvecadd
mpvecadd:
/* Prelude */
pushl %ebp /* save on stack */
pushl %ebx
pushl %esi
pushl %edi
leal 20(%esp), %ebp /* %ebp = FP for now */
movl 4(%ebp), %edx /* alen */
movl 12(%ebp), %ecx /* blen */
movl 0(%ebp), %esi /* a */
movl 8(%ebp), %ebx /* b */
subl %ecx, %edx
movl 16(%ebp), %edi /* sum */
xorl %ebp, %ebp /* this also sets carry to 0 */
/* skip addition if b is zero */
testl %ecx,%ecx
je _add1
/* sum[0:blen-1],carry = a[0:blen-1] + b[0:blen-1] */
_addloop1:
movl (%esi, %ebp, 4), %eax
adcl (%ebx, %ebp, 4), %eax
movl %eax, (%edi, %ebp, 4)
incl %ebp
loop _addloop1
_add1:
/* jump if alen > blen */
incl %edx
movl %edx, %ecx
loop _addloop2
/* sum[alen] = carry */
_addend:
jb _addcarry
movl $0, (%edi, %ebp, 4)
jmp done
_addcarry:
movl $1, (%edi, %ebp, 4)
jmp done
/* sum[blen:alen-1],carry = a[blen:alen-1] + 0 */
_addloop2:
movl (%esi, %ebp, 4),%eax
adcl $0, %eax
movl %eax, (%edi, %ebp, 4)
incl %ebp
loop _addloop2
jmp _addend
done:
/* Postlude */
popl %edi
popl %esi
popl %ebx
popl %ebp
ret

View file

@ -1,68 +0,0 @@
/*
* mpvecdigmul(mpdigit *b, int n, mpdigit m, mpdigit *p)
*
* p += b*m
*
* each step look like:
* hi,lo = m*b[i]
* lo += oldhi + carry
* hi += carry
* p[i] += lo
* oldhi = hi
*
* the registers are:
* hi = DX - constrained by hardware
* lo = AX - constrained by hardware
* b+n = SI - can't be BP
* p+n = DI - can't be BP
* i-n = BP
* m = BX
* oldhi = CX
*
*/
.text
.globl _mpvecdigmuladd
_mpvecdigmuladd:
/* Prelude */
pushl %ebp /* save on stack */
pushl %ebx
pushl %esi
pushl %edi
leal 20(%esp), %ebp /* %ebp = FP for now */
movl 0(%ebp), %esi /* b */
movl 4(%ebp), %ecx /* n */
movl 8(%ebp), %ebx /* m */
movl 12(%ebp), %edi /* p */
movl %ecx, %ebp
negl %ebp /* BP = -n */
shll $2, %ecx
addl %ecx, %esi /* SI = b + n */
addl %ecx, %edi /* DI = p + n */
xorl %ecx, %ecx
1:
movl (%esi, %ebp, 4), %eax /* lo = b[i] */
mull %ebx /* hi, lo = b[i] * m */
addl %ecx,%eax /* lo += oldhi */
jae 2f
incl %edx /* hi += carry */
2:
addl %eax, (%edi, %ebp, 4) /* p[i] += lo */
jae 3f
incl %edx /* hi += carry */
3:
movl %edx, %ecx /* oldhi = hi */
incl %ebp /* i++ */
jnz 1b
xorl %eax, %eax
addl %ecx, (%edi, %ebp, 4) /* p[n] + oldhi */
adcl %eax, %eax /* return carry out of p[n] */
/* Postlude */
popl %edi
popl %esi
popl %ebx
popl %ebp
ret

View file

@ -1,69 +0,0 @@
#
# mpvecdigmul(mpdigit *b, int n, mpdigit m, mpdigit *p)
#
# p += b*m
#
# each step look like:
# hi,lo = m*b[i]
# lo += oldhi + carry
# hi += carry
# p[i] += lo
# oldhi = hi
#
# the registers are:
# hi = DX - constrained by hardware
# lo = AX - constrained by hardware
# b+n = SI - can't be BP
# p+n = DI - can't be BP
# i-n = BP
# m = BX
# oldhi = CX
#
.text
.p2align 2,0x90
.globl mpvecdigmuladd
mpvecdigmuladd:
# Prelude
pushl %ebp # save on stack
pushl %ebx
pushl %esi
pushl %edi
leal 20(%esp), %ebp # %ebp = FP for now
movl 0(%ebp), %esi # b
movl 4(%ebp), %ecx # n
movl 8(%ebp), %ebx # m
movl 12(%ebp), %edi # p
movl %ecx, %ebp
negl %ebp # BP = -n
shll $2, %ecx
addl %ecx, %esi # SI = b + n
addl %ecx, %edi # DI = p + n
xorl %ecx, %ecx
_muladdloop:
movl (%esi, %ebp, 4), %eax # lo = b[i]
mull %ebx # hi, lo = b[i] * m
addl %ecx,%eax # lo += oldhi
jae _muladdnocarry1
incl %edx # hi += carry
_muladdnocarry1:
addl %eax, (%edi, %ebp, 4) # p[i] += lo
jae _muladdnocarry2
incl %edx # hi += carry
_muladdnocarry2:
movl %edx, %ecx # oldhi = hi
incl %ebp # i++
jnz _muladdloop
xorl %eax, %eax
addl %ecx, (%edi, %ebp, 4) # p[n] + oldhi
adcl %eax, %eax # return carry out of p[n]
# Postlude
popl %edi
popl %esi
popl %ebx
popl %ebp
ret

View file

@ -1,69 +0,0 @@
/*
* mpvecdigmulsub(mpdigit *b, int n, mpdigit m, mpdigit *p)
*
* p -= b*m
*
* each step look like:
* hi,lo = m*b[i]
* lo += oldhi + carry
* hi += carry
* p[i] += lo
* oldhi = hi
*
* the registers are:
* hi = DX - constrained by hardware
* lo = AX - constrained by hardware
* b = SI - can't be BP
* p = DI - can't be BP
* i = BP
* n = CX - constrained by LOOP instr
* m = BX
* oldhi = EX
*
*/
.text
.globl _mpvecdigmulsub
_mpvecdigmulsub:
/* Prelude */
pushl %ebp /* save on stack */
pushl %ebx
pushl %esi
pushl %edi
leal 20(%esp), %ebp /* %ebp = FP for now */
movl 0(%ebp), %esi /* b */
movl 4(%ebp), %ecx /* n */
movl 8(%ebp), %ebx /* m */
movl 12(%ebp), %edi /* p */
xorl %ebp, %ebp
pushl %ebp
1:
movl (%esi, %ebp, 4),%eax /* lo = b[i] */
mull %ebx /* hi, lo = b[i] * m */
addl 0(%esp), %eax /* lo += oldhi */
jae 2f
incl %edx /* hi += carry */
2:
subl %eax, (%edi, %ebp, 4)
jae 3f
incl %edx /* hi += carry */
3:
movl %edx, 0(%esp)
incl %ebp
loop 1b
popl %eax
subl %eax, (%edi, %ebp, 4)
jae 4f
movl $-1, %eax
jmp 5f
4:
movl $1, %eax
5:
/* Postlude */
popl %edi
popl %esi
popl %ebx
popl %ebp
ret

View file

@ -1,70 +0,0 @@
#
# mpvecdigmulsub(mpdigit *b, int n, mpdigit m, mpdigit *p)
#
# p -= b*m
#
# each step look like:
# hi,lo = m*b[i]
# lo += oldhi + carry
# hi += carry
# p[i] += lo
# oldhi = hi
#
# the registers are:
# hi = DX - constrained by hardware
# lo = AX - constrained by hardware
# b = SI - can't be BP
# p = DI - can't be BP
# i = BP
# n = CX - constrained by LOOP instr
# m = BX
# oldhi = EX
#
.text
.p2align 2,0x90
.globl mpvecdigmulsub
mpvecdigmulsub:
# Prelude
pushl %ebp # save on stack
pushl %ebx
pushl %esi
pushl %edi
leal 20(%esp), %ebp # %ebp = FP for now
movl 0(%ebp), %esi # b
movl 4(%ebp), %ecx # n
movl 8(%ebp), %ebx # m
movl 12(%ebp), %edi # p
xorl %ebp, %ebp
pushl %ebp
_mulsubloop:
movl (%esi, %ebp, 4),%eax # lo = b[i]
mull %ebx # hi, lo = b[i] * m
addl 0(%esp), %eax # lo += oldhi
jae _mulsubnocarry1
incl %edx # hi += carry
_mulsubnocarry1:
subl %eax, (%edi, %ebp, 4)
jae _mulsubnocarry2
incl %edx # hi += carry
_mulsubnocarry2:
movl %edx, 0(%esp)
incl %ebp
loop _mulsubloop
popl %eax
subl %eax, (%edi, %ebp, 4)
jae _mulsubnocarry3
movl $-1, %eax
jmp done
_mulsubnocarry3:
movl $1, %eax
done:
# Postlude
popl %edi
popl %esi
popl %ebx
popl %ebp
ret

View file

@ -1,60 +0,0 @@
/* mpvecsub(mpdigit *a, int alen, mpdigit *b, int blen, mpdigit *diff) */
/* diff[0:alen-1] = a[0:alen-1] - b[0:blen-1] */
/* prereq: alen >= blen, diff has room for alen digits */
/* (very old gnu assembler doesn't allow multiline comments) */
.text
.p2align 2,0x90
.globl _mpvecsub
_mpvecsub:
/* Prelude */
pushl %ebp /* save on stack */
pushl %ebx
pushl %esi
pushl %edi
leal 20(%esp), %ebp /* %ebp = FP for now */
movl 0(%ebp), %esi /* a */
movl 8(%ebp), %ebx /* b */
movl 4(%ebp), %edx /* alen */
movl 12(%ebp), %ecx /* blen */
movl 16(%ebp), %edi /* diff */
subl %ecx,%edx
xorl %ebp,%ebp /* this also sets carry to 0 */
/* skip subraction if b is zero */
testl %ecx,%ecx
jz 2f
/* diff[0:blen-1],borrow = a[0:blen-1] - b[0:blen-1] */
1:
movl (%esi, %ebp, 4), %eax
sbbl (%ebx, %ebp, 4), %eax
movl %eax, (%edi, %ebp, 4)
incl %ebp
loop 1b
2:
incl %edx
movl %edx,%ecx
loop 3f
jmp 4f
/* diff[blen:alen-1] = a[blen:alen-1] - 0 */
3:
movl (%esi, %ebp, 4), %eax
sbbl $0, %eax
movl %eax, (%edi, %ebp, 4)
incl %ebp
loop 3b
4:
/* Postlude */
popl %edi
popl %esi
popl %ebx
popl %ebp
ret

View file

@ -1,60 +0,0 @@
/* mpvecsub(mpdigit *a, int alen, mpdigit *b, int blen, mpdigit *diff) */
/* diff[0:alen-1] = a[0:alen-1] - b[0:blen-1] */
/* prereq: alen >= blen, diff has room for alen digits */
/* (very old gnu assembler doesn't allow multiline comments) */
.text
.p2align 2,0x90
.globl mpvecsub
mpvecsub:
/* Prelude */
pushl %ebp /* save on stack */
pushl %ebx
pushl %esi
pushl %edi
leal 20(%esp), %ebp /* %ebp = FP for now */
movl 0(%ebp), %esi /* a */
movl 8(%ebp), %ebx /* b */
movl 4(%ebp), %edx /* alen */
movl 12(%ebp), %ecx /* blen */
movl 16(%ebp), %edi /* diff */
subl %ecx,%edx
xorl %ebp,%ebp /* this also sets carry to 0 */
/* skip subraction if b is zero */
testl %ecx,%ecx
jz _sub1
/* diff[0:blen-1],borrow = a[0:blen-1] - b[0:blen-1] */
_subloop1:
movl (%esi, %ebp, 4), %eax
sbbl (%ebx, %ebp, 4), %eax
movl %eax, (%edi, %ebp, 4)
incl %ebp
loop _subloop1
_sub1:
incl %edx
movl %edx,%ecx
loop _subloop2
jmp done
/* diff[blen:alen-1] = a[blen:alen-1] - 0 */
_subloop2:
movl (%esi, %ebp, 4), %eax
sbbl $0, %eax
movl %eax, (%edi, %ebp, 4)
incl %ebp
loop _subloop2
done:
/* Postlude */
popl %edi
popl %esi
popl %ebx
popl %ebp
ret

View file

@ -1,4 +0,0 @@
all:
%:V:
# nothing to see here

View file

@ -1,4 +0,0 @@
all:
%:V:
# nothing to see here

View file

@ -1,4 +0,0 @@
all:
%:V:
# nothing to see here

View file

@ -1,4 +0,0 @@
all:
%:V:
# nothing to see here

View file

@ -2,6 +2,6 @@
DIRS=\
port\
$OBJTYPE\
# $OBJTYPE\
<$PLAN9/src/mkdirs

View file

@ -34,8 +34,9 @@ FILES=\
mptouv\
ALLOFILES=${FILES:%=%.$O}
# cull things in the per-machine directories from this list
OFILES= `{sh ./reduce $O $OBJTYPE $ALLOFILES}
# # cull things in the per-machine directories from this list
# OFILES= `{sh ./reduce $O $ALLOFILES}
OFILES=$ALLOFILES
HFILES=\
$PLAN9/include/lib9.h\

View file

@ -1,4 +0,0 @@
all:
%:V:
# nothing to see here

View file

@ -1,4 +0,0 @@
all:
%:V:
# nothing to see here

View file

@ -1,4 +0,0 @@
all:
%:V:
# nothing to see here

View file

@ -1,4 +0,0 @@
all:
%:V:
# nothing to see here

View file

@ -1,248 +0,0 @@
/*
* rfc1321 requires that I include this. The code is new. The constants
* all come from the rfc (hence the copyright). We trade a table for the
* macros in rfc. The total size is a lot less. -- presotto
*
* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
* rights reserved.
*
* License to copy and use this software is granted provided that it
* is identified as the "RSA Data Security, Inc. MD5 Message-Digest
* Algorithm" in all material mentioning or referencing this software
* or this function.
*
* License is also granted to make and use derivative works provided
* that such works are identified as "derived from the RSA Data
* Security, Inc. MD5 Message-Digest Algorithm" in all material
* mentioning or referencing the derived work.
*
* RSA Data Security, Inc. makes no representations concerning either
* the merchantability of this software or the suitability of this
* software forany particular purpose. It is provided "as is"
* without express or implied warranty of any kind.
* These notices must be retained in any copies of any part of this
* documentation and/or software.
*/
#define S11 7
#define S12 12
#define S13 17
#define S14 22
#define S21 5
#define S22 9
#define S23 14
#define S24 20
#define S31 4
#define S32 11
#define S33 16
#define S34 23
#define S41 6
#define S42 10
#define S43 15
#define S44 21
#define PAYME(x) $##x
/*
* SI is data
* a += FN(B,C,D);
* a += x[sh] + t[sh];
* a = (a << S11) | (a >> (32 - S11));
* a += b;
*/
#define BODY1(off,V,FN,SH,A,B,C,D)\
FN(B,C,D)\
leal V(A, %edi, 1), A;\
addl off(%ebp), A;\
roll PAYME(SH), A;\
addl B, A;\
#define BODY(off,V,FN,SH,A,B,C,D)\
FN(B,C,D)\
leal V(A, %edi, 1), A;\
addl (off)(%ebp), A;\
roll PAYME(SH), A;\
addl B,A;\
/*
* fn1 = ((c ^ d) & b) ^ d
*/
#define FN1(B,C,D)\
movl C, %edi;\
xorl D, %edi;\
andl B, %edi;\
xorl D, %edi;\
/*
* fn2 = ((b ^ c) & d) ^ c;
*/
#define FN2(B,C,D)\
movl B, %edi;\
xorl C, %edi;\
andl D, %edi;\
xorl C, %edi;\
/*
* fn3 = b ^ c ^ d;
*/
#define FN3(B,C,D)\
movl B, %edi;\
xorl C, %edi;\
xorl D, %edi;\
/*
* fn4 = c ^ (b | ~d);
*/
#define FN4(B,C,D)\
movl D, %edi;\
xorl $-1, %edi;\
orl B, %edi;\
xorl C, %edi;\
#define STACKSIZE 20
#define DATA (STACKSIZE+8)
#define LEN (STACKSIZE+12)
#define STATE (STACKSIZE+16)
#define EDATA (STACKSIZE-4)
#define OLDEBX (STACKSIZE-8)
#define OLDESI (STACKSIZE-12)
#define OLDEDI (STACKSIZE-16)
.text
.p2align 2,0x90
#ifdef __Darwin__
.globl __md5block
__md5block:
#else
.globl _md5block
_md5block:
#endif
/* Prelude */
pushl %ebp
subl $(STACKSIZE), %esp
movl %ebx, OLDEBX(%esp)
movl %esi, OLDESI(%esp)
movl %edi, OLDEDI(%esp)
movl DATA(%esp), %eax
addl LEN(%esp), %eax
movl %eax, EDATA(%esp)
movl DATA(%esp), %ebp
0:
movl STATE(%esp), %esi
movl (%esi), %eax
movl 4(%esi), %ebx
movl 8(%esi), %ecx
movl 12(%esi), %edx
BODY1( 0*4,0xd76aa478,FN1,S11,%eax,%ebx,%ecx,%edx)
BODY1( 1*4,0xe8c7b756,FN1,S12,%edx,%eax,%ebx,%ecx)
BODY1( 2*4,0x242070db,FN1,S13,%ecx,%edx,%eax,%ebx)
BODY1( 3*4,0xc1bdceee,FN1,S14,%ebx,%ecx,%edx,%eax)
BODY1( 4*4,0xf57c0faf,FN1,S11,%eax,%ebx,%ecx,%edx)
BODY1( 5*4,0x4787c62a,FN1,S12,%edx,%eax,%ebx,%ecx)
BODY1( 6*4,0xa8304613,FN1,S13,%ecx,%edx,%eax,%ebx)
BODY1( 7*4,0xfd469501,FN1,S14,%ebx,%ecx,%edx,%eax)
BODY1( 8*4,0x698098d8,FN1,S11,%eax,%ebx,%ecx,%edx)
BODY1( 9*4,0x8b44f7af,FN1,S12,%edx,%eax,%ebx,%ecx)
BODY1(10*4,0xffff5bb1,FN1,S13,%ecx,%edx,%eax,%ebx)
BODY1(11*4,0x895cd7be,FN1,S14,%ebx,%ecx,%edx,%eax)
BODY1(12*4,0x6b901122,FN1,S11,%eax,%ebx,%ecx,%edx)
BODY1(13*4,0xfd987193,FN1,S12,%edx,%eax,%ebx,%ecx)
BODY1(14*4,0xa679438e,FN1,S13,%ecx,%edx,%eax,%ebx)
BODY1(15*4,0x49b40821,FN1,S14,%ebx,%ecx,%edx,%eax)
BODY( 1*4,0xf61e2562,FN2,S21,%eax,%ebx,%ecx,%edx)
BODY( 6*4,0xc040b340,FN2,S22,%edx,%eax,%ebx,%ecx)
BODY(11*4,0x265e5a51,FN2,S23,%ecx,%edx,%eax,%ebx)
BODY( 0*4,0xe9b6c7aa,FN2,S24,%ebx,%ecx,%edx,%eax)
BODY( 5*4,0xd62f105d,FN2,S21,%eax,%ebx,%ecx,%edx)
BODY(10*4,0x02441453,FN2,S22,%edx,%eax,%ebx,%ecx)
BODY(15*4,0xd8a1e681,FN2,S23,%ecx,%edx,%eax,%ebx)
BODY( 4*4,0xe7d3fbc8,FN2,S24,%ebx,%ecx,%edx,%eax)
BODY( 9*4,0x21e1cde6,FN2,S21,%eax,%ebx,%ecx,%edx)
BODY(14*4,0xc33707d6,FN2,S22,%edx,%eax,%ebx,%ecx)
BODY( 3*4,0xf4d50d87,FN2,S23,%ecx,%edx,%eax,%ebx)
BODY( 8*4,0x455a14ed,FN2,S24,%ebx,%ecx,%edx,%eax)
BODY(13*4,0xa9e3e905,FN2,S21,%eax,%ebx,%ecx,%edx)
BODY( 2*4,0xfcefa3f8,FN2,S22,%edx,%eax,%ebx,%ecx)
BODY( 7*4,0x676f02d9,FN2,S23,%ecx,%edx,%eax,%ebx)
BODY(12*4,0x8d2a4c8a,FN2,S24,%ebx,%ecx,%edx,%eax)
BODY( 5*4,0xfffa3942,FN3,S31,%eax,%ebx,%ecx,%edx)
BODY( 8*4,0x8771f681,FN3,S32,%edx,%eax,%ebx,%ecx)
BODY(11*4,0x6d9d6122,FN3,S33,%ecx,%edx,%eax,%ebx)
BODY(14*4,0xfde5380c,FN3,S34,%ebx,%ecx,%edx,%eax)
BODY( 1*4,0xa4beea44,FN3,S31,%eax,%ebx,%ecx,%edx)
BODY( 4*4,0x4bdecfa9,FN3,S32,%edx,%eax,%ebx,%ecx)
BODY( 7*4,0xf6bb4b60,FN3,S33,%ecx,%edx,%eax,%ebx)
BODY(10*4,0xbebfbc70,FN3,S34,%ebx,%ecx,%edx,%eax)
BODY(13*4,0x289b7ec6,FN3,S31,%eax,%ebx,%ecx,%edx)
BODY( 0*4,0xeaa127fa,FN3,S32,%edx,%eax,%ebx,%ecx)
BODY( 3*4,0xd4ef3085,FN3,S33,%ecx,%edx,%eax,%ebx)
BODY( 6*4,0x04881d05,FN3,S34,%ebx,%ecx,%edx,%eax)
BODY( 9*4,0xd9d4d039,FN3,S31,%eax,%ebx,%ecx,%edx)
BODY(12*4,0xe6db99e5,FN3,S32,%edx,%eax,%ebx,%ecx)
BODY(15*4,0x1fa27cf8,FN3,S33,%ecx,%edx,%eax,%ebx)
BODY( 2*4,0xc4ac5665,FN3,S34,%ebx,%ecx,%edx,%eax)
BODY( 0*4,0xf4292244,FN4,S41,%eax,%ebx,%ecx,%edx)
BODY( 7*4,0x432aff97,FN4,S42,%edx,%eax,%ebx,%ecx)
BODY(14*4,0xab9423a7,FN4,S43,%ecx,%edx,%eax,%ebx)
BODY( 5*4,0xfc93a039,FN4,S44,%ebx,%ecx,%edx,%eax)
BODY(12*4,0x655b59c3,FN4,S41,%eax,%ebx,%ecx,%edx)
BODY( 3*4,0x8f0ccc92,FN4,S42,%edx,%eax,%ebx,%ecx)
BODY(10*4,0xffeff47d,FN4,S43,%ecx,%edx,%eax,%ebx)
BODY( 1*4,0x85845dd1,FN4,S44,%ebx,%ecx,%edx,%eax)
BODY( 8*4,0x6fa87e4f,FN4,S41,%eax,%ebx,%ecx,%edx)
BODY(15*4,0xfe2ce6e0,FN4,S42,%edx,%eax,%ebx,%ecx)
BODY( 6*4,0xa3014314,FN4,S43,%ecx,%edx,%eax,%ebx)
BODY(13*4,0x4e0811a1,FN4,S44,%ebx,%ecx,%edx,%eax)
BODY( 4*4,0xf7537e82,FN4,S41,%eax,%ebx,%ecx,%edx)
BODY(11*4,0xbd3af235,FN4,S42,%edx,%eax,%ebx,%ecx)
BODY( 2*4,0x2ad7d2bb,FN4,S43,%ecx,%edx,%eax,%ebx)
BODY( 9*4,0xeb86d391,FN4,S44,%ebx,%ecx,%edx,%eax)
addl $(16*4), %ebp
movl STATE(%esp), %edi
addl %eax,0(%edi)
addl %ebx,4(%edi)
addl %ecx,8(%edi)
addl %edx,12(%edi)
movl EDATA(%esp), %edi
cmpl %edi, %ebp
jb 0b
/* Postlude */
movl OLDEBX(%esp), %ebx
movl OLDESI(%esp), %esi
movl OLDEDI(%esp), %edi
addl $(STACKSIZE), %esp
popl %ebp
ret

View file

@ -1,26 +0,0 @@
<$PLAN9/src/mkhdr
LIB=libsec.a
SFILES=\
md5block.s\
sha1block.s\
HFILES=$PLAN9/include/libsec.h
OFILES=${SFILES:%.s=%.$O}
UPDATE=mkfile\
$HFILES\
$SFILES\
<$PLAN9/src/mksyslib
%.s: %.spp
if [ `uname` = OpenBSD ] || [ `uname` = Darwin ]
then
gcc -xc -D__`uname`__ -E $stem.spp >$stem.s
else
cpp $stem.spp >$stem.s
fi
CLEANFILES=md5block.s sha1block.s

View file

@ -1,221 +0,0 @@
.text
.p2align 2,0x90
#ifdef __Darwin__
.globl __sha1block
__sha1block:
#else
.globl _sha1block
_sha1block:
#endif
/* x = (wp[off-f] ^ wp[off-8] ^ wp[off-14] ^ wp[off-16]) <<< 1;
* wp[off] = x;
* x += A <<< 5;
* E += 0xca62c1d6 + x;
* x = FN(B,C,D);
* E += x;
* B >>> 2
*/
#define BSWAPDI BYTE $0x0f; BYTE $0xcf;
#define BODY(off,FN,V,A,B,C,D,E)\
movl (off-64)(%ebp), %edi;\
xorl (off-56)(%ebp), %edi;\
xorl (off-32)(%ebp), %edi;\
xorl (off-12)(%ebp), %edi;\
roll $1, %edi;\
movl %edi, off(%ebp);\
leal V(%edi, E, 1), E;\
movl A, %edi;\
roll $5, %edi;\
addl %edi, E;\
FN(B,C,D)\
addl %edi, E;\
rorl $2, B;\
#define BODY0(off,FN,V,A,B,C,D,E)\
movl off(%ebx), %edi;\
bswap %edi;\
movl %edi, off(%ebp);\
leal V(%edi,E,1), E;\
movl A, %edi;\
roll $5,%edi;\
addl %edi,E;\
FN(B,C,D)\
addl %edi,E;\
rorl $2,B;\
/*
* fn1 = (((C^D)&B)^D);
*/
#define FN1(B,C,D)\
movl C, %edi;\
xorl D, %edi;\
andl B, %edi;\
xorl D, %edi;\
/*
* fn24 = B ^ C ^ D
*/
#define FN24(B,C,D)\
movl B, %edi;\
xorl C, %edi;\
xorl D, %edi;\
/*
* fn3 = ((B ^ C) & (D ^= B)) ^ B
* D ^= B to restore D
*/
#define FN3(B,C,D)\
movl B, %edi;\
xorl C, %edi;\
xorl B, D;\
andl D, %edi;\
xorl B, %edi;\
xorl B, D;\
/*
* stack offsets
* void sha1block(uchar *DATA, int LEN, ulong *STATE)
*/
#define STACKSIZE (48+80*4)
#define DATA (STACKSIZE+8)
#define LEN (STACKSIZE+12)
#define STATE (STACKSIZE+16)
/*
* stack offsets for locals
* ulong w[80];
* uchar *edata;
* ulong *w15, *w40, *w60, *w80;
* register local
* ulong *wp = %ebp
* ulong a = eax, b = ebx, c = ecx, d = edx, e = esi
* ulong tmp = edi
*/
#define WARRAY (STACKSIZE-4-(80*4))
#define TMP1 (STACKSIZE-8-(80*4))
#define TMP2 (STACKSIZE-12-(80*4))
#define W15 (STACKSIZE-16-(80*4))
#define W40 (STACKSIZE-20-(80*4))
#define W60 (STACKSIZE-24-(80*4))
#define W80 (STACKSIZE-28-(80*4))
#define EDATA (STACKSIZE-32-(80*4))
#define OLDEBX (STACKSIZE-36-(80*4))
#define OLDESI (STACKSIZE-40-(80*4))
#define OLDEDI (STACKSIZE-44-(80*4))
/* Prelude */
pushl %ebp
subl $(STACKSIZE), %esp
mov %ebx, OLDEBX(%esp)
mov %esi, OLDESI(%esp)
mov %edi, OLDEDI(%esp)
movl DATA(%esp), %eax
addl LEN(%esp), %eax
movl %eax, EDATA(%esp)
leal (WARRAY+15*4)(%esp), %edi /* aw15 */
movl %edi, W15(%esp)
leal (WARRAY+40*4)(%esp), %edx /* aw40 */
movl %edx, W40(%esp)
leal (WARRAY+60*4)(%esp), %ecx /* aw60 */
movl %ecx, W60(%esp)
leal (WARRAY+80*4)(%esp), %edi /* aw80 */
movl %edi, W80(%esp)
0:
leal WARRAY(%esp), %ebp /* warray */
movl STATE(%esp), %edi /* state */
movl (%edi),%eax
movl 4(%edi),%ebx
movl %ebx, TMP1(%esp) /* tmp1 */
movl 8(%edi), %ecx
movl 12(%edi), %edx
movl 16(%edi), %esi
movl DATA(%esp), %ebx /* data */
1:
BODY0(0,FN1,0x5a827999,%eax,TMP1(%esp),%ecx,%edx,%esi)
movl %esi,TMP2(%esp)
BODY0(4,FN1,0x5a827999,%esi,%eax,TMP1(%esp),%ecx,%edx)
movl TMP1(%esp),%esi
BODY0(8,FN1,0x5a827999,%edx,TMP2(%esp),%eax,%esi,%ecx)
BODY0(12,FN1,0x5a827999,%ecx,%edx,TMP2(%esp),%eax,%esi)
movl %esi,TMP1(%esp)
BODY0(16,FN1,0x5a827999,%esi,%ecx,%edx,TMP2(%esp),%eax)
movl TMP2(%esp),%esi
addl $20, %ebx
addl $20, %ebp
cmpl W15(%esp), %ebp /* w15 */
jb 1b
BODY0(0,FN1,0x5a827999,%eax,TMP1(%esp),%ecx,%edx,%esi)
addl $4, %ebx
movl %ebx, DATA(%esp) /* data */
movl TMP1(%esp),%ebx
BODY(4,FN1,0x5a827999,%esi,%eax,%ebx,%ecx,%edx)
BODY(8,FN1,0x5a827999,%edx,%esi,%eax,%ebx,%ecx)
BODY(12,FN1,0x5a827999,%ecx,%edx,%esi,%eax,%ebx)
BODY(16,FN1,0x5a827999,%ebx,%ecx,%edx,%esi,%eax)
addl $20, %ebp
2:
BODY(0,FN24,0x6ed9eba1,%eax,%ebx,%ecx,%edx,%esi)
BODY(4,FN24,0x6ed9eba1,%esi,%eax,%ebx,%ecx,%edx)
BODY(8,FN24,0x6ed9eba1,%edx,%esi,%eax,%ebx,%ecx)
BODY(12,FN24,0x6ed9eba1,%ecx,%edx,%esi,%eax,%ebx)
BODY(16,FN24,0x6ed9eba1,%ebx,%ecx,%edx,%esi,%eax)
addl $20,%ebp
cmpl W40(%esp), %ebp
jb 2b
3:
BODY(0,FN3,0x8f1bbcdc,%eax,%ebx,%ecx,%edx,%esi)
BODY(4,FN3,0x8f1bbcdc,%esi,%eax,%ebx,%ecx,%edx)
BODY(8,FN3,0x8f1bbcdc,%edx,%esi,%eax,%ebx,%ecx)
BODY(12,FN3,0x8f1bbcdc,%ecx,%edx,%esi,%eax,%ebx)
BODY(16,FN3,0x8f1bbcdc,%ebx,%ecx,%edx,%esi,%eax)
addl $20, %ebp
cmpl W60(%esp), %ebp /* w60 */
jb 3b
4:
BODY(0,FN24,0xca62c1d6,%eax,%ebx,%ecx,%edx,%esi)
BODY(4,FN24,0xca62c1d6,%esi,%eax,%ebx,%ecx,%edx)
BODY(8,FN24,0xca62c1d6,%edx,%esi,%eax,%ebx,%ecx)
BODY(12,FN24,0xca62c1d6,%ecx,%edx,%esi,%eax,%ebx)
BODY(16,FN24,0xca62c1d6,%ebx,%ecx,%edx,%esi,%eax)
addl $20, %ebp
cmpl W80(%esp), %ebp /* w80 */
jb 4b
movl STATE(%esp), %edi /* state */
addl %eax, 0(%edi)
addl %ebx, 4(%edi)
addl %ecx, 8(%edi)
addl %edx, 12(%edi)
addl %esi, 16(%edi)
movl EDATA(%esp), %edi /* edata */
cmpl %edi, DATA(%esp) /* data */
jb 0b
/* Postlude */
mov OLDEBX(%esp), %ebx
mov OLDESI(%esp), %esi
mov OLDEDI(%esp), %edi
addl $(STACKSIZE), %esp
popl %ebp
ret

View file

@ -1,4 +0,0 @@
all:
%:V:
# nothing to see here

View file

@ -1,4 +0,0 @@
all:
%:V:
# nothing to see here

View file

@ -1,4 +0,0 @@
all:
%:V:
# nothing to see here

View file

@ -1,4 +0,0 @@
all:
%:V:
# nothing to see here

View file

@ -2,6 +2,6 @@
DIRS=\
port\
$OBJTYPE\
# $OBJTYPE\
<$PLAN9/src/mkdirs

View file

@ -54,7 +54,8 @@ ALLOFILES=\
tlshand.$O\
x509.$O\
OFILES=`{sh ./reduce $O $OBJTYPE $ALLOFILES}
# OFILES=`{sh ./reduce $O $OBJTYPE $ALLOFILES}
OFILES=$ALLOFILES
HFILES=$PLAN9/include/libsec.h
<$PLAN9/src/mksyslib

View file

@ -1,4 +0,0 @@
all:
%:V:
# nothing to see here

View file

@ -1,4 +0,0 @@
all:
%:V:
# nothing to see here

View file

@ -1,4 +0,0 @@
all:
%:V:
# nothing to see here

View file

@ -1,4 +0,0 @@
all:
%:V:
# nothing to see here

View file

@ -2,22 +2,22 @@
# and also valid shell input for ../dist/buildmk
SYSNAME=`uname`
OBJTYPE=`(uname -m -p 2>/dev/null || uname -m) | sed '
s;.*i[3-6]86.*;386;;
s;.*i86pc.*;386;;
s;.*amd64.*;x86_64;;
s;.*x86_64.*;x86_64;;
s;.*armv.*;arm;g;
s;.*powerpc.*;power;g;
s;.*PowerMacintosh.*;power;g;
s;.*Power.Macintosh.*;power;g;
s;.*macppc.*;power;g;
s;.*mips.*;mips;g;
s;.*ppc64.*;power;g;
s;.*ppc.*;power;g;
s;.*alpha.*;alpha;g;
s;.*sun4u.*;sun4u;g;
s;.*aarch64.*;arm64;
s;.*arm64.*;arm64;
'`
# OBJTYPE=`(uname -m -p 2>/dev/null || uname -m) | sed '
# s;.*i[3-6]86.*;386;;
# s;.*i86pc.*;386;;
# s;.*amd64.*;x86_64;;
# s;.*x86_64.*;x86_64;;
# s;.*armv.*;arm;g;
# s;.*powerpc.*;power;g;
# s;.*PowerMacintosh.*;power;g;
# s;.*Power.Macintosh.*;power;g;
# s;.*macppc.*;power;g;
# s;.*mips.*;mips;g;
# s;.*ppc64.*;power;g;
# s;.*ppc.*;power;g;
# s;.*alpha.*;alpha;g;
# s;.*sun4u.*;sun4u;g;
# s;.*aarch64.*;arm64;
# s;.*arm64.*;arm64;
# '`
INSTALL=`[ $(uname) = AIX ] && echo installbsd || echo install`

View file

@ -37,9 +37,7 @@ mkmk.sh:VD:
) | sed '
s/'$INSTALL'/$INSTALL/g
s/'$SYSNAME'/$SYSNAME/g
s/'$OBJTYPE'/$OBJTYPE/g
s;'$PLAN9';$PLAN9;g
s/^9[ac] *tas-.*/9a tas-$OBJTYPE.s || 9c tas-$OBJTYPE.c/
' >$target
testmkmk:V:

View file

@ -1,7 +0,0 @@
CC=gcc
CFLAGS+=-Wall -Wno-missing-braces -Wno-parentheses -Wno-switch -O2 -g -c -I. -I${PREFIX}/include
O=o
AR=ar
ARFLAGS=rvc
NAN=nan64.$O
RANLIB=ranlib

View file

@ -1,6 +0,0 @@
CC=gcc
CFLAGS+=-Wall -Wno-missing-braces -Wno-parentheses -Wno-switch -O2 -g -c -I.
O=o
AR=ar
ARFLAGS=rvc
NAN=nan64.$O

View file

@ -1,6 +0,0 @@
CC=gcc
CFLAGS+=-Wall -Wno-missing-braces -Wno-parentheses -Wno-switch -O2 -g -c -I.
O=o
AR=ar
ARFLAGS=rvc
NAN=nan64.$O

2
unix/make/Make.SunOS Normal file
View file

@ -0,0 +1,2 @@
include Make.SunOS-$(CC)
NAN=nan64.$O

View file

@ -1,2 +0,0 @@
include Make.SunOS-sun4u-$(CC)
NAN=nan64.$O

View file

@ -1,18 +1,16 @@
# this works in gnu make
SYSNAME:=${shell uname}
OBJTYPE:=${shell uname -m | sed 's;i.86;386;; s;/.*;;; s; ;;g'}
# this works in bsd make
SYSNAME!=uname
OBJTYPE!=uname -m | sed 's;i.86;386;; s;amd64;x864_64;; s;/.*;;; s; ;;g'
# the gnu rules will mess up bsd but not vice versa,
# hence the gnu rules come first.
RANLIB=true
include Make.$(SYSNAME)-$(OBJTYPE)
include Make.$(SYSNAME)
PREFIX=/usr/local