gcc's cc1 runs!
authorbrian <brian@brianweb.net>
Wed, 5 May 2004 04:30:13 +0000 (21:30 -0700)
committerbrian <brian@brianweb.net>
Wed, 5 May 2004 04:30:13 +0000 (21:30 -0700)
darcs-hash:20040505043013-24bed-11faded04b8600f697fa484fe96fce51adc01908.gz

src/org/ibex/nestedvm/Runtime.java
src/org/ibex/nestedvm/RuntimeCompiler.java
src/org/ibex/nestedvm/UnixRuntime.java

index b790374..9ba3dd0 100644 (file)
@@ -693,10 +693,14 @@ public abstract class Runtime implements UsermodeConstants,Registers,Cloneable {
     public static final int O_APPEND = 0x0008;
     public static final int O_TRUNC = 0x0400;
     public static final int O_NONBLOCK = 0x4000;
     public static final int O_APPEND = 0x0008;
     public static final int O_TRUNC = 0x0400;
     public static final int O_NONBLOCK = 0x4000;
+    public static final int O_NOCTTY = 0x8000;
+    
     
     FD hostFSOpen(final File f, int flags, int mode, final Object data) throws ErrnoException {
         if((flags & ~(3|O_CREAT|O_EXCL|O_APPEND|O_TRUNC)) != 0) {
     
     FD hostFSOpen(final File f, int flags, int mode, final Object data) throws ErrnoException {
         if((flags & ~(3|O_CREAT|O_EXCL|O_APPEND|O_TRUNC)) != 0) {
-            if(STDERR_DIAG) System.err.println("WARNING: Unsupported flags passed to open(): " + toHex(flags & ~(3|O_CREAT|O_EXCL|O_APPEND|O_TRUNC)));
+            if(STDERR_DIAG)
+                System.err.println("WARNING: Unsupported flags passed to open(\"" + f + "\"): " + toHex(flags & ~(3|O_CREAT|O_EXCL|O_APPEND|O_TRUNC)));
+           
             throw new ErrnoException(ENOTSUP);
         }
         boolean write = (flags&3) != RD_ONLY;
             throw new ErrnoException(ENOTSUP);
         }
         boolean write = (flags&3) != RD_ONLY;
@@ -737,6 +741,7 @@ public abstract class Runtime implements UsermodeConstants,Registers,Cloneable {
     
     /** The open syscall */
     private int sys_open(int addr, int flags, int mode) throws ErrnoException, FaultException {
     
     /** The open syscall */
     private int sys_open(int addr, int flags, int mode) throws ErrnoException, FaultException {
+        flags &= ~O_NOCTTY; // this is meaningless under nestedvm
         FD fd = _open(cstring(addr),flags,mode);
         if(fd == null) return -ENOENT;
         int fdn = addFD(fd);
         FD fd = _open(cstring(addr),flags,mode);
         if(fd == null) return -ENOENT;
         int fdn = addFD(fd);
@@ -869,6 +874,8 @@ public abstract class Runtime implements UsermodeConstants,Registers,Cloneable {
     private int sys_sysconf(int n) {
         switch(n) {
             case _SC_CLK_TCK: return 1000;
     private int sys_sysconf(int n) {
         switch(n) {
             case _SC_CLK_TCK: return 1000;
+            case _SC_PAGESIZE: return  writePages.length == 1 ? 4096 : (1<<pageShift);
+            case _SC_PHYS_PAGES: return writePages.length == 1 ? (1<<pageShift)/4096 : writePages.length;
             default:
                 if(STDERR_DIAG) System.err.println("WARNING: Attempted to use unknown sysconf key: " + n);
                 return -EINVAL;
             default:
                 if(STDERR_DIAG) System.err.println("WARNING: Attempted to use unknown sysconf key: " + n);
                 return -EINVAL;
index 78b4e9a..a722d9c 100644 (file)
@@ -18,7 +18,7 @@ public class RuntimeCompiler {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ClassFileCompiler c = new ClassFileCompiler(data,className,baos);
         // FEATURE: make this Optional, pass options on compile arguments
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ClassFileCompiler c = new ClassFileCompiler(data,className,baos);
         // FEATURE: make this Optional, pass options on compile arguments
-        c.parseOptions("unixruntime");
+        c.parseOptions("unixruntime,nosupportcall");
         c.go();
         baos.close();
         byte[] bytecode = baos.toByteArray();
         c.go();
         baos.close();
         byte[] bytecode = baos.toByteArray();
index a6847ee..9b9a8cf 100644 (file)
@@ -33,7 +33,9 @@ public abstract class UnixRuntime extends Runtime implements Cloneable {
                 
         // FEATURE: Do the proper mangling for non-unix hosts
         String userdir = getSystemProperty("user.dir");
                 
         // FEATURE: Do the proper mangling for non-unix hosts
         String userdir = getSystemProperty("user.dir");
-        cwd = userdir != null && userdir.startsWith("/") && File.separatorChar == '/'  ? userdir.substring(1) : "";
+        cwd = 
+            userdir != null && userdir.startsWith("/") && File.separatorChar == '/' && HostFS.hostRootDir().getParent() == null  
+            ? userdir.substring(1) : "";
     }
     
     // NOTE: getDisplayName() is a Java2 function
     }
     
     // NOTE: getDisplayName() is a Java2 function
@@ -794,8 +796,14 @@ public abstract class UnixRuntime extends Runtime implements Cloneable {
         public File getRoot() { return root; }
         
         private static File hostRootDir() {
         public File getRoot() { return root; }
         
         private static File hostRootDir() {
+            if(getSystemProperty("nestedvm.root") != null) {
+                File f = new File(getSystemProperty("nestedvm.root"));
+                if(f.isDirectory()) return f;
+                // fall through to case below
+            }
             String cwd = getSystemProperty("user.dir");
             File f = new File(cwd != null ? cwd : ".");
             String cwd = getSystemProperty("user.dir");
             File f = new File(cwd != null ? cwd : ".");
+            if(!f.exists()) throw new Error("Couldn't get File for cwd");
             f = new File(f.getAbsolutePath());
             while(f.getParent() != null) f = new File(f.getParent());
             return f;
             f = new File(f.getAbsolutePath());
             while(f.getParent() != null) f = new File(f.getParent());
             return f;