libc: change usize to 64-bit for amd64 and arm64, make memory(2) functions use usize

This commit is contained in:
cinap_lenrek 2021-07-25 15:54:22 +00:00
parent 8a8329ad95
commit e4b5f170cf
19 changed files with 57 additions and 59 deletions

View file

@ -8,7 +8,7 @@ typedef long long vlong;
typedef unsigned long long uvlong;
typedef long long intptr;
typedef unsigned long long uintptr;
typedef unsigned long usize;
typedef unsigned long long usize;
typedef uint Rune;
typedef union FPdbleword FPdbleword;
typedef uintptr jmp_buf[2];

View file

@ -9,7 +9,7 @@ typedef long long vlong;
typedef unsigned long long uvlong;
typedef vlong intptr;
typedef uvlong uintptr;
typedef unsigned long usize;
typedef unsigned long long usize;
typedef uint Rune;
typedef union FPdbleword FPdbleword;
typedef uintptr jmp_buf[2];

View file

@ -8,12 +8,12 @@
/*
* mem routines
*/
extern void* memccpy(void*, void*, int, ulong);
extern void* memset(void*, int, ulong);
extern int memcmp(void*, void*, ulong);
extern void* memcpy(void*, void*, ulong);
extern void* memmove(void*, void*, ulong);
extern void* memchr(void*, int, ulong);
extern void* memccpy(void*, void*, int, usize);
extern void* memset(void*, int, usize);
extern int memcmp(void*, void*, usize);
extern void* memcpy(void*, void*, usize);
extern void* memmove(void*, void*, usize);
extern void* memchr(void*, int, usize);
/*
* string routines

View file

@ -8,22 +8,22 @@ memccpy, memchr, memcmp, memcpy, memmove, memset, tsmemcmp \- memory operations
.PP
.ta \w'\fLvoid* 'u
.B
void* memccpy(void *s1, void *s2, int c, ulong n)
void* memccpy(void *s1, void *s2, int c, usize n)
.PP
.B
void* memchr(void *s, int c, ulong n)
void* memchr(void *s, int c, usize n)
.PP
.B
int memcmp(void *s1, void *s2, ulong n)
int memcmp(void *s1, void *s2, usize n)
.PP
.B
void* memcpy(void *s1, void *s2, ulong n)
void* memcpy(void *s1, void *s2, usize n)
.PP
.B
void* memmove(void *s1, void *s2, ulong n)
void* memmove(void *s1, void *s2, usize n)
.PP
.B
void* memset(void *s, int c, ulong n)
void* memset(void *s, int c, usize n)
.PP
.B #include <libsec.h>
.PP

View file

@ -8,11 +8,11 @@
/*
* mem routines
*/
extern void* memccpy(void*, void*, int, ulong);
extern void* memset(void*, int, ulong);
extern int memcmp(void*, void*, ulong);
extern void* memmove(void*, void*, ulong);
extern void* memchr(void*, int, ulong);
extern void* memccpy(void*, void*, int, usize);
extern void* memset(void*, int, usize);
extern int memcmp(void*, void*, usize);
extern void* memmove(void*, void*, usize);
extern void* memchr(void*, int, usize);
/*
* string routines

View file

@ -349,13 +349,13 @@ Have:
}
void*
evommem(void *a, void *b, ulong n)
evommem(void *a, void *b, usize n)
{
return memmove(b, a, n);
}
int
isnonzero(void *v, ulong n)
isnonzero(void *v, usize n)
{
uchar *a, *ea;
@ -375,7 +375,7 @@ rdwrpart(Req *r)
vlong offset;
long count, tot, n, o;
uchar *blk, *dat;
void *(*move)(void*, void*, ulong);
void *(*move)(void*, void*, usize);
q = r->fid->qid.path-Qpart;
if(q < 0 || q > nelem(tab) || !tab[q].inuse || tab[q].vers != r->fid->qid.vers){

View file

@ -1,7 +1,7 @@
TEXT memccpy(SB),$0
MOVL n+24(FP), CX
CMPL CX, $0
MOVQ n+24(FP), CX
CMPQ CX, $0
JEQ none
MOVQ p2+8(FP), DI
MOVBLZX c+16(FP), AX
@ -18,7 +18,7 @@
*/
none:
MOVL $0, AX
MOVL n+24(FP), BX
MOVQ n+24(FP), BX
JMP memcpy
/*
@ -44,7 +44,7 @@ memcpy:
ORQ SI, DX
ANDL $3, DX
JNE c3
MOVL BX, CX
MOVQ BX, CX
SHRQ $2, CX
REP; MOVSL
/*
@ -52,7 +52,7 @@ memcpy:
*/
ANDL $3, BX
c3:
MOVL BX, CX
MOVQ BX, CX
REP; MOVSB
RET

View file

@ -1,7 +1,7 @@
TEXT memchr(SB),$0
MOVL n+16(FP), CX
CMPL CX, $0
MOVQ n+16(FP), CX
CMPQ CX, $0
JEQ none
MOVQ RARG, DI
MOVBLZX c+8(FP), AX

View file

@ -1,7 +1,7 @@
TEXT memcmp(SB),$0
MOVL n+16(FP), BX
CMPL BX, $0
MOVQ n+16(FP), BX
CMPQ BX, $0
JEQ none
MOVQ RARG, DI
MOVQ p2+8(FP), SI
@ -14,7 +14,7 @@
* first by longs
*/
MOVL BX, CX
MOVQ BX, CX
SHRQ $2, CX
REP; CMPSL
@ -25,7 +25,7 @@
*/
ANDL $3, BX
c3:
MOVL BX, CX
MOVQ BX, CX
REP; CMPSB
JNE found1

View file

@ -2,8 +2,8 @@ TEXT memcpy(SB), $0
MOVQ RARG, DI
MOVQ DI, AX /* return value */
MOVQ p2+8(FP), SI
MOVL n+16(FP), BX
CMPL BX, $0
MOVQ n+16(FP), BX
CMPQ BX, $0
JGT _ok
JEQ _return /* nothing to do if n == 0 */
MOVL $0, SI /* fault if n < 0 */
@ -40,7 +40,7 @@ _forward:
*/
JEQ _return /* flags set by above ANDL */
c3f:
MOVL BX, CX
MOVQ BX, CX
REP; MOVSB
RET
@ -62,7 +62,7 @@ _back:
ORQ SI, DX
ANDL $3, DX
JNE c3b
MOVL BX, CX
MOVQ BX, CX
SHRQ $2, CX
ANDL $3, BX
REP; MOVSL
@ -74,7 +74,7 @@ _back:
c3b:
ADDQ $3, DI
ADDQ $3, SI
MOVL BX, CX
MOVQ BX, CX
REP; MOVSB
_return:

View file

@ -2,8 +2,8 @@ TEXT memmove(SB), $0
MOVQ RARG, DI
MOVQ DI, AX /* return value */
MOVQ p2+8(FP), SI
MOVL n+16(FP), BX
CMPL BX, $0
MOVQ n+16(FP), BX
CMPQ BX, $0
JGT _ok
JEQ _return /* nothing to do if n == 0 */
MOVL $0, SI /* fault if n < 0 */
@ -40,7 +40,7 @@ _forward:
*/
JEQ _return /* flags set by above ANDL */
c3f:
MOVL BX, CX
MOVQ BX, CX
REP; MOVSB
RET
@ -62,7 +62,7 @@ _back:
ORQ SI, DX
ANDL $3, DX
JNE c3b
MOVL BX, CX
MOVQ BX, CX
SHRQ $2, CX
ANDL $3, BX
REP; MOVSL
@ -74,7 +74,7 @@ _back:
c3b:
ADDQ $3, DI
ADDQ $3, SI
MOVL BX, CX
MOVQ BX, CX
REP; MOVSB
_return:

View file

@ -3,11 +3,11 @@
CLD
MOVQ RARG, DI
MOVBLZX c+8(FP), AX
MOVL n+16(FP), BX
MOVQ n+16(FP), BX
/*
* if not enough bytes, just set bytes
*/
CMPL BX, $9
CMPQ BX, $9
JLS c3
/*
* if not aligned, just set bytes

View file

@ -1,7 +1,7 @@
TEXT memcpy(SB), $-4
TEXT memmove(SB), $-4
MOV from+8(FP), R1
MOVWU n+16(FP), R2
MOV n+16(FP), R2
CMP R0, R1
BEQ _done

View file

@ -1,6 +1,6 @@
TEXT memset(SB), $-4
MOVBU c+8(FP), R1
MOVWU n+16(FP), R2
MOV n+16(FP), R2
MOV R0, R5
ADD R0, R2, R3

View file

@ -2,7 +2,7 @@
#include <libc.h>
void*
memccpy(void *a1, void *a2, int c, ulong n)
memccpy(void *a1, void *a2, int c, usize n)
{
uchar *s1, *s2;

View file

@ -2,7 +2,7 @@
#include <libc.h>
void*
memchr(void *ap, int c, ulong n)
memchr(void *ap, int c, usize n)
{
uchar *sp;

View file

@ -2,7 +2,7 @@
#include <libc.h>
int
memcmp(void *a1, void *a2, ulong n)
memcmp(void *a1, void *a2, usize n)
{
uchar *s1, *s2;
uint c1, c2;

View file

@ -2,12 +2,10 @@
#include <libc.h>
void*
memmove(void *a1, void *a2, ulong n)
memmove(void *a1, void *a2, usize n)
{
char *s1, *s2;
if((long)n < 0)
abort();
s1 = a1;
s2 = a2;
if((s2 < s1) && (s2+n > s1))
@ -29,7 +27,7 @@ back:
}
void*
memcpy(void *a1, void *a2, ulong n)
memcpy(void *a1, void *a2, usize n)
{
return memmove(a1, a2, n);
}

View file

@ -2,7 +2,7 @@
#include <libc.h>
void*
memset(void *ap, int c, ulong n)
memset(void *ap, int c, usize n)
{
char *p;