thanks tyfkda

This commit is contained in:
Frans Kaashoek 2018-08-31 09:21:19 -04:00
parent 343255189e
commit 308a3b88c9
4 changed files with 20 additions and 19 deletions

View file

@ -8,7 +8,7 @@
#define N 1000
void
printf(int fd, char *s, ...)
printf(int fd, const char *s, ...)
{
write(fd, s, strlen(s));
}

View file

@ -37,7 +37,7 @@ printint(int fd, int xx, int base, int sgn)
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
printf(int fd, const char *fmt, ...)
{
char *s;
int c, i, state;

11
ulib.c
View file

@ -5,7 +5,7 @@
#include "x86.h"
char*
strcpy(char *s, char *t)
strcpy(char *s, const char *t)
{
char *os;
@ -24,7 +24,7 @@ strcmp(const char *p, const char *q)
}
uint
strlen(char *s)
strlen(const char *s)
{
int n;
@ -68,7 +68,7 @@ gets(char *buf, int max)
}
int
stat(char *n, struct stat *st)
stat(const char *n, struct stat *st)
{
int fd;
int r;
@ -93,9 +93,10 @@ atoi(const char *s)
}
void*
memmove(void *vdst, void *vsrc, int n)
memmove(void *vdst, const void *vsrc, int n)
{
char *dst, *src;
char *dst;
const char *src;
dst = vdst;
src = vsrc;

24
user.h
View file

@ -6,18 +6,18 @@ int fork(void);
int exit(void) __attribute__((noreturn));
int wait(void);
int pipe(int*);
int write(int, void*, int);
int write(int, const void*, int);
int read(int, void*, int);
int close(int);
int kill(int);
int exec(char*, char**);
int open(char*, int);
int mknod(char*, short, short);
int unlink(char*);
int open(const char*, int);
int mknod(const char*, short, short);
int unlink(const char*);
int fstat(int fd, struct stat*);
int link(char*, char*);
int mkdir(char*);
int chdir(char*);
int link(const char*, const char*);
int mkdir(const char*);
int chdir(const char*);
int dup(int);
int getpid(void);
char* sbrk(int);
@ -25,14 +25,14 @@ int sleep(int);
int uptime(void);
// ulib.c
int stat(char*, struct stat*);
char* strcpy(char*, char*);
void *memmove(void*, void*, int);
int stat(const char*, struct stat*);
char* strcpy(char*, const char*);
void *memmove(void*, const void*, int);
char* strchr(const char*, char c);
int strcmp(const char*, const char*);
void printf(int, char*, ...);
void printf(int, const char*, ...);
char* gets(char*, int max);
uint strlen(char*);
uint strlen(const char*);
void* memset(void*, int, uint);
void* malloc(uint);
void free(void*);