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 #define N 1000
void void
printf(int fd, char *s, ...) printf(int fd, const char *s, ...)
{ {
write(fd, s, strlen(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. // Print to the given fd. Only understands %d, %x, %p, %s.
void void
printf(int fd, char *fmt, ...) printf(int fd, const char *fmt, ...)
{ {
char *s; char *s;
int c, i, state; int c, i, state;

11
ulib.c
View file

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

24
user.h
View file

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