Type names (uint32 -> u32, e.t.c.)
This commit is contained in:
parent
f5b93ef12f
commit
362d5adeb2
39 changed files with 485 additions and 489 deletions
|
@ -53,7 +53,7 @@ go(int which_child)
|
|||
int fd = -1;
|
||||
static char buf[999];
|
||||
char *break0 = sbrk(0);
|
||||
uint64 iters = 0;
|
||||
u64 iters = 0;
|
||||
|
||||
mkdir("grindir");
|
||||
if(chdir("grindir") != 0){
|
||||
|
|
|
@ -17,7 +17,7 @@ printint(int fd, int xx, int base, int sgn)
|
|||
{
|
||||
char buf[16];
|
||||
int i, neg;
|
||||
uint x;
|
||||
u32 x;
|
||||
|
||||
neg = 0;
|
||||
if(sgn && xx < 0){
|
||||
|
@ -39,12 +39,12 @@ printint(int fd, int xx, int base, int sgn)
|
|||
}
|
||||
|
||||
static void
|
||||
printptr(int fd, uint64 x) {
|
||||
printptr(int fd, u64 x) {
|
||||
int i;
|
||||
putc(fd, '0');
|
||||
putc(fd, 'x');
|
||||
for (i = 0; i < (sizeof(uint64) * 2); i++, x <<= 4)
|
||||
putc(fd, digits[x >> (sizeof(uint64) * 8 - 4)]);
|
||||
for (i = 0; i < (sizeof(u64) * 2); i++, x <<= 4)
|
||||
putc(fd, digits[x >> (sizeof(u64) * 8 - 4)]);
|
||||
}
|
||||
|
||||
// Print to the given fd. Only understands %d, %x, %p, %s.
|
||||
|
@ -67,11 +67,11 @@ vprintf(int fd, const char *fmt, va_list ap)
|
|||
if(c == 'd'){
|
||||
printint(fd, va_arg(ap, int), 10, 1);
|
||||
} else if(c == 'l') {
|
||||
printint(fd, va_arg(ap, uint64), 10, 0);
|
||||
printint(fd, va_arg(ap, u64), 10, 0);
|
||||
} else if(c == 'x') {
|
||||
printint(fd, va_arg(ap, int), 16, 0);
|
||||
} else if(c == 'p') {
|
||||
printptr(fd, va_arg(ap, uint64));
|
||||
printptr(fd, va_arg(ap, u64));
|
||||
} else if(c == 's'){
|
||||
s = va_arg(ap, char*);
|
||||
if(s == 0)
|
||||
|
@ -81,7 +81,7 @@ vprintf(int fd, const char *fmt, va_list ap)
|
|||
s++;
|
||||
}
|
||||
} else if(c == 'c'){
|
||||
putc(fd, va_arg(ap, uint));
|
||||
putc(fd, va_arg(ap, u32));
|
||||
} else if(c == '%'){
|
||||
putc(fd, c);
|
||||
} else {
|
||||
|
|
10
user/ulib.c
10
user/ulib.c
|
@ -30,10 +30,10 @@ strcmp(const char *p, const char *q)
|
|||
{
|
||||
while(*p && *p == *q)
|
||||
p++, q++;
|
||||
return (uchar)*p - (uchar)*q;
|
||||
return (u8)*p - (u8)*q;
|
||||
}
|
||||
|
||||
uint
|
||||
u32
|
||||
strlen(const char *s)
|
||||
{
|
||||
int n;
|
||||
|
@ -44,7 +44,7 @@ strlen(const char *s)
|
|||
}
|
||||
|
||||
void*
|
||||
memset(void *dst, int c, uint n)
|
||||
memset(void *dst, int c, u32 n)
|
||||
{
|
||||
char *cdst = (char *) dst;
|
||||
int i;
|
||||
|
@ -127,7 +127,7 @@ memmove(void *vdst, const void *vsrc, int n)
|
|||
}
|
||||
|
||||
int
|
||||
memcmp(const void *s1, const void *s2, uint n)
|
||||
memcmp(const void *s1, const void *s2, u32 n)
|
||||
{
|
||||
const char *p1 = s1, *p2 = s2;
|
||||
while (n-- > 0) {
|
||||
|
@ -141,7 +141,7 @@ memcmp(const void *s1, const void *s2, uint n)
|
|||
}
|
||||
|
||||
void *
|
||||
memcpy(void *dst, const void *src, uint n)
|
||||
memcpy(void *dst, const void *src, u32 n)
|
||||
{
|
||||
return memmove(dst, src, n);
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ typedef long Align;
|
|||
union header {
|
||||
struct {
|
||||
union header *ptr;
|
||||
uint size;
|
||||
u32 size;
|
||||
} s;
|
||||
Align x;
|
||||
};
|
||||
|
@ -44,7 +44,7 @@ free(void *ap)
|
|||
}
|
||||
|
||||
static Header*
|
||||
morecore(uint nu)
|
||||
morecore(u32 nu)
|
||||
{
|
||||
char *p;
|
||||
Header *hp;
|
||||
|
@ -61,10 +61,10 @@ morecore(uint nu)
|
|||
}
|
||||
|
||||
void*
|
||||
malloc(uint nbytes)
|
||||
malloc(u32 nbytes)
|
||||
{
|
||||
Header *p, *prevp;
|
||||
uint nunits;
|
||||
u32 nunits;
|
||||
|
||||
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
|
||||
if((prevp = freep) == 0){
|
||||
|
|
10
user/user.h
10
user/user.h
|
@ -32,10 +32,10 @@ int strcmp(const char*, const char*);
|
|||
void fprintf(int, const char*, ...);
|
||||
void printf(const char*, ...);
|
||||
char* gets(char*, int max);
|
||||
uint strlen(const char*);
|
||||
void* memset(void*, int, uint);
|
||||
void* malloc(uint);
|
||||
u32 strlen(const char*);
|
||||
void* memset(void*, int, u32);
|
||||
void* malloc(u32);
|
||||
void free(void*);
|
||||
int atoi(const char*);
|
||||
int memcmp(const void *, const void *, uint);
|
||||
void *memcpy(void *, const void *, uint);
|
||||
int memcmp(const void *, const void *, u32);
|
||||
void *memcpy(void *, const void *, u32);
|
||||
|
|
|
@ -32,10 +32,10 @@ char buf[BUFSZ];
|
|||
void
|
||||
copyin(char *s)
|
||||
{
|
||||
uint64 addrs[] = { 0x80000000LL, 0xffffffffffffffff };
|
||||
u64 addrs[] = { 0x80000000LL, 0xffffffffffffffff };
|
||||
|
||||
for(int ai = 0; ai < 2; ai++){
|
||||
uint64 addr = addrs[ai];
|
||||
u64 addr = addrs[ai];
|
||||
|
||||
int fd = open("copyin1", O_CREATE|O_WRONLY);
|
||||
if(fd < 0){
|
||||
|
@ -76,10 +76,10 @@ copyin(char *s)
|
|||
void
|
||||
copyout(char *s)
|
||||
{
|
||||
uint64 addrs[] = { 0x80000000LL, 0xffffffffffffffff };
|
||||
u64 addrs[] = { 0x80000000LL, 0xffffffffffffffff };
|
||||
|
||||
for(int ai = 0; ai < 2; ai++){
|
||||
uint64 addr = addrs[ai];
|
||||
u64 addr = addrs[ai];
|
||||
|
||||
int fd = open("README", 0);
|
||||
if(fd < 0){
|
||||
|
@ -117,10 +117,10 @@ copyout(char *s)
|
|||
void
|
||||
copyinstr1(char *s)
|
||||
{
|
||||
uint64 addrs[] = { 0x80000000LL, 0xffffffffffffffff };
|
||||
u64 addrs[] = { 0x80000000LL, 0xffffffffffffffff };
|
||||
|
||||
for(int ai = 0; ai < 2; ai++){
|
||||
uint64 addr = addrs[ai];
|
||||
u64 addr = addrs[ai];
|
||||
|
||||
int fd = open((char *)addr, O_CREATE|O_WRONLY);
|
||||
if(fd >= 0){
|
||||
|
@ -199,11 +199,11 @@ void
|
|||
copyinstr3(char *s)
|
||||
{
|
||||
sbrk(8192);
|
||||
uint64 top = (uint64) sbrk(0);
|
||||
u64 top = (u64) sbrk(0);
|
||||
if((top % PGSIZE) != 0){
|
||||
sbrk(PGSIZE - (top % PGSIZE));
|
||||
}
|
||||
top = (uint64) sbrk(0);
|
||||
top = (u64) sbrk(0);
|
||||
if(top % PGSIZE){
|
||||
printf("oops\n");
|
||||
exit(1);
|
||||
|
@ -245,14 +245,14 @@ rwsbrk()
|
|||
{
|
||||
int fd, n;
|
||||
|
||||
uint64 a = (uint64) sbrk(8192);
|
||||
u64 a = (u64) sbrk(8192);
|
||||
|
||||
if(a == 0xffffffffffffffffLL) {
|
||||
printf("sbrk(rwsbrk) failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ((uint64) sbrk(-8192) == 0xffffffffffffffffLL) {
|
||||
if ((u64) sbrk(-8192) == 0xffffffffffffffffLL) {
|
||||
printf("sbrk(rwsbrk) shrink failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
@ -1397,7 +1397,7 @@ concreate(char *s)
|
|||
int i, pid, n, fd;
|
||||
char fa[N];
|
||||
struct {
|
||||
ushort inum;
|
||||
u16 inum;
|
||||
char name[DIRSIZ];
|
||||
} de;
|
||||
|
||||
|
@ -2062,13 +2062,13 @@ sbrkmuch(char *s)
|
|||
{
|
||||
enum { BIG=100*1024*1024 };
|
||||
char *c, *oldbrk, *a, *lastaddr, *p;
|
||||
uint64 amt;
|
||||
u64 amt;
|
||||
|
||||
oldbrk = sbrk(0);
|
||||
|
||||
// can one grow address space to something big?
|
||||
a = sbrk(0);
|
||||
amt = BIG - (uint64)a;
|
||||
amt = BIG - (u64)a;
|
||||
p = sbrk(amt);
|
||||
if (p != a) {
|
||||
printf("%s: sbrk test failed to grow big address space; enough phys mem?\n", s);
|
||||
|
@ -2145,7 +2145,7 @@ kernmem(char *s)
|
|||
void
|
||||
MAXVAplus(char *s)
|
||||
{
|
||||
volatile uint64 a = MAXVA;
|
||||
volatile u64 a = MAXVA;
|
||||
for( ; a != 0; a <<= 1){
|
||||
int pid;
|
||||
pid = fork();
|
||||
|
@ -2185,7 +2185,7 @@ sbrkfail(char *s)
|
|||
for(i = 0; i < sizeof(pids)/sizeof(pids[0]); i++){
|
||||
if((pids[i] = fork()) == 0){
|
||||
// allocate a lot of memory
|
||||
sbrk(BIG - (uint64)sbrk(0));
|
||||
sbrk(BIG - (u64)sbrk(0));
|
||||
write(fds[1], "x", 1);
|
||||
// sit around until killed
|
||||
for(;;) sleep(1000);
|
||||
|
@ -2267,10 +2267,10 @@ void
|
|||
validatetest(char *s)
|
||||
{
|
||||
int hi;
|
||||
uint64 p;
|
||||
u64 p;
|
||||
|
||||
hi = 1100*1024;
|
||||
for(p = 0; p <= (uint)hi; p += PGSIZE){
|
||||
for(p = 0; p <= (u32)hi; p += PGSIZE){
|
||||
// try to crash the kernel by passing in a bad string pointer
|
||||
if(link("nosuchfile", (char*)p) != -1){
|
||||
printf("%s: link should not succeed\n", s);
|
||||
|
@ -2445,7 +2445,7 @@ textwrite(char *s)
|
|||
}
|
||||
|
||||
// regression test. copyin(), copyout(), and copyinstr() used to cast
|
||||
// the virtual page address to uint, which (with certain wild system
|
||||
// the virtual page address to u32, which (with certain wild system
|
||||
// call arguments) resulted in a kernel page faults.
|
||||
void *big = (void*) 0xeaeb0b5b00002f5e;
|
||||
void
|
||||
|
@ -2471,7 +2471,7 @@ sbrkbugs(char *s)
|
|||
exit(1);
|
||||
}
|
||||
if(pid == 0){
|
||||
int sz = (uint64) sbrk(0);
|
||||
int sz = (u64) sbrk(0);
|
||||
// free all user memory; there used to be a bug that
|
||||
// would not adjust p->sz correctly in this case,
|
||||
// causing exit() to panic.
|
||||
|
@ -2487,7 +2487,7 @@ sbrkbugs(char *s)
|
|||
exit(1);
|
||||
}
|
||||
if(pid == 0){
|
||||
int sz = (uint64) sbrk(0);
|
||||
int sz = (u64) sbrk(0);
|
||||
// set the break to somewhere in the very first
|
||||
// page; there used to be a bug that would incorrectly
|
||||
// free the first page.
|
||||
|
@ -2503,7 +2503,7 @@ sbrkbugs(char *s)
|
|||
}
|
||||
if(pid == 0){
|
||||
// set the break in the middle of a page.
|
||||
sbrk((10*4096 + 2048) - (uint64)sbrk(0));
|
||||
sbrk((10*4096 + 2048) - (u64)sbrk(0));
|
||||
|
||||
// reduce the break a bit, but not enough to
|
||||
// cause a page to be freed. this used to cause
|
||||
|
@ -2523,13 +2523,13 @@ sbrkbugs(char *s)
|
|||
void
|
||||
sbrklast(char *s)
|
||||
{
|
||||
uint64 top = (uint64) sbrk(0);
|
||||
u64 top = (u64) sbrk(0);
|
||||
if((top % 4096) != 0)
|
||||
sbrk(4096 - (top % 4096));
|
||||
sbrk(4096);
|
||||
sbrk(10);
|
||||
sbrk(-20);
|
||||
top = (uint64) sbrk(0);
|
||||
top = (u64) sbrk(0);
|
||||
char *p = (char *) (top - 64);
|
||||
p[0] = 'x';
|
||||
p[1] = '\0';
|
||||
|
@ -2789,7 +2789,7 @@ execout(char *s)
|
|||
} else if(pid == 0){
|
||||
// allocate all of memory.
|
||||
while(1){
|
||||
uint64 a = (uint64) sbrk(4096);
|
||||
u64 a = (u64) sbrk(4096);
|
||||
if(a == 0xffffffffffffffffLL)
|
||||
break;
|
||||
*(char*)(a + 4096 - 1) = 1;
|
||||
|
@ -3005,7 +3005,7 @@ countfree()
|
|||
close(fds[0]);
|
||||
|
||||
while(1){
|
||||
uint64 a = (uint64) sbrk(4096);
|
||||
u64 a = (u64) sbrk(4096);
|
||||
if(a == 0xffffffffffffffff){
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue