ref: a6517fb4984458d6f5ce4864a408c5057d15306d
parent: cc066d813083789d76169720edbf7a3104538117
author: aiju <devnull@localhost>
date: Tue Dec 11 04:17:44 EST 2018
kernel: change peek to return number of characters left rather than 0/-1
--- a/sys/src/9/pc/l.s
+++ b/sys/src/9/pc/l.s
@@ -513,7 +513,6 @@
/* fault-proof memcpy */
TEXT peek(SB), $0
- MOVL $0, AX /* AX set to -1 if traped */
MOVL src+0(FP), SI
MOVL dst+4(FP), DI
MOVL cnt+8(FP), CX
@@ -520,6 +519,7 @@
CLD
TEXT _peekinst(SB), $0
REP; MOVSB
+ MOVL CX, AX
RET
/*
--- a/sys/src/9/pc/trap.c
+++ b/sys/src/9/pc/trap.c
@@ -481,7 +481,6 @@
}
} else if(pc == _peekinst){
if(vno == VectorGPF){
- ureg->ax = -1;
ureg->pc += 2;
return;
}
@@ -722,7 +721,6 @@
{
extern void _peekinst(void);
if((void(*)(void))ureg->pc == _peekinst){
- ureg->ax = -1;
ureg->pc += 2;
return;
}
--- a/sys/src/9/pc64/l.s
+++ b/sys/src/9/pc64/l.s
@@ -451,7 +451,6 @@
/* fault-proof memcpy */
TEXT peek(SB), 1, $-4
- MOVQ $0, AX
MOVQ RARG, SI
MOVQ dst+8(FP), DI
MOVL cnt+16(FP), CX
@@ -458,6 +457,7 @@
CLD
TEXT _peekinst(SB), $0
REP; MOVSB
+ MOVL CX, AX
RET
--- a/sys/src/9/pc64/trap.c
+++ b/sys/src/9/pc64/trap.c
@@ -451,7 +451,6 @@
}
} else if(pc == _peekinst){
if(vno == VectorGPF){
- ureg->ax = -1;
ureg->pc += 2;
return;
}
@@ -683,7 +682,6 @@
extern void _peekinst(void);
if((void(*)(void))ureg->pc == _peekinst){
- ureg->ax = -1;
ureg->pc += 2;
return;
}
--- a/sys/src/9/port/devdtracy.c
+++ b/sys/src/9/port/devdtracy.c
@@ -529,5 +529,5 @@
if(len == 0) return 0;
if(a != addr || a > -(uintptr)len || len < 0) return -1;
if(up == nil || up->privatemem || a >= KZERO) return -1;
- return peek((void *)a, buf, len);
+ return peek((void *)a, buf, len) > 0 ? -1 : 0;
}