Get rid of unnecessary barrier. Improve comment.
[pintos-anon] / grading / vm / child-sort.c
index 5ce8da45ab45b04c778743c148a435d03d9adb62..56161b9b77ca32b57036707a71a7e5fd8666c75d 100644 (file)
@@ -2,26 +2,21 @@
 #ifdef PINTOS
 #include <syscall.h>
 #else
-#include <unistd.h>
-#include <fcntl.h>
+#include "posix-compat.h"
 #endif
 
 unsigned char buf[65536];
 size_t histogram[256];
 
 int
-main (void
+main (int argc __attribute__ ((unused)), char *argv[]
 {
   int fd;
   unsigned char *p;
   size_t size;
   size_t i;
-  
-#ifdef PINTOS
-  fd = open ("buffer");
-#else
-  fd = open ("buffer", O_RDWR);
-#endif
+
+  fd = open (argv[1]);
   if (fd < 0) 
     {
       printf ("(child-sort) open() failed\n");
@@ -38,13 +33,9 @@ main (void)
       while (j-- > 0)
         *p++ = i;
     }
-#ifdef PINTOS
   seek (fd, 0);
-#else
-  lseek (fd, 0, SEEK_SET);
-#endif
   write (fd, buf, size);
   close (fd);
   
-  return 0x123;
+  return 123;
 }