]> Devi Nivas Git - cs3210-lab1.git/commitdiff
thanks tyfkda
authorFrans Kaashoek <kaashoek@mit.edu>
Fri, 31 Aug 2018 13:21:19 +0000 (09:21 -0400)
committerFrans Kaashoek <kaashoek@mit.edu>
Fri, 31 Aug 2018 13:21:19 +0000 (09:21 -0400)
forktest.c
printf.c
ulib.c
user.h

index 73f2fe8e76cf6bc5bdbea8e765380f31765fb685..8bc984d3097a7b159e3bc7187f26281a0861db56 100644 (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));
 }
index 9972b45647b01b0e68811ce8ad4eace6939afb2b..b3298aaedda3dffdf7432d4a6adacca05ea9b049 100644 (file)
--- 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 51a9e74d0b87c463c7614e439436e992b050ef40..8e1e1a24c77eb1b2945167c0c5c9e7cd59f9c5f3 100644 (file)
--- 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 f45b8d5a03119716f847c5ea99a3bd6b2027d13c..4f99c52ba6c2380d64453462fb276382351a9157 100644 (file)
--- 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*);