summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrans Kaashoek <[email protected]>2018-08-31 09:21:19 -0400
committerFrans Kaashoek <[email protected]>2018-08-31 09:21:19 -0400
commit308a3b88c9e59b9065f1af9cdd2e0369cdfd0823 (patch)
tree561d5cc95964191b8b16fe61b16406aeadaf3ad0
parent343255189e3b5dac4bcd132ecc0cb28158657aa6 (diff)
downloadxv6-labs-308a3b88c9e59b9065f1af9cdd2e0369cdfd0823.tar.gz
xv6-labs-308a3b88c9e59b9065f1af9cdd2e0369cdfd0823.tar.bz2
xv6-labs-308a3b88c9e59b9065f1af9cdd2e0369cdfd0823.zip
thanks tyfkda
-rw-r--r--forktest.c2
-rw-r--r--printf.c2
-rw-r--r--ulib.c11
-rw-r--r--user.h24
4 files changed, 20 insertions, 19 deletions
diff --git a/forktest.c b/forktest.c
index 73f2fe8..8bc984d 100644
--- a/forktest.c
+++ b/forktest.c
@@ -8,7 +8,7 @@
#define N 1000
void
-printf(int fd, char *s, ...)
+printf(int fd, const char *s, ...)
{
write(fd, s, strlen(s));
}
diff --git a/printf.c b/printf.c
index 9972b45..b3298aa 100644
--- a/printf.c
+++ b/printf.c
@@ -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;
diff --git a/ulib.c b/ulib.c
index 51a9e74..8e1e1a2 100644
--- a/ulib.c
+++ b/ulib.c
@@ -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;
diff --git a/user.h b/user.h
index f45b8d5..4f99c52 100644
--- a/user.h
+++ b/user.h
@@ -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*);