This commit was generated by cvs2svn to track changes on a CVS vendor
[deliverable/binutils-gdb.git] / sim / common / syscall.c
index 1556ece24f79f5e82da8f2df56a64af0adde70df..e0a3b880b84c26a061b8e3a2400ce6c5f78cda49 100644 (file)
@@ -1,5 +1,5 @@
 /* Remote target system call support.
-   Copyright 1997 Free Software Foundation, Inc.
+   Copyright 1997, 1998 Free Software Foundation, Inc.
    Contributed by Cygnus Solutions.
 
    This file is part of GDB.
@@ -123,8 +123,6 @@ get_path (cb, sc, addr, bufp)
 }
 
 /* Perform a system call on behalf of the target.  */
-/* FIXME: TODO: Add magic number to CB_SYSCALL, macro to initialize it,
-   and test for the magic number here.  */
 
 CB_RC
 cb_syscall (cb, sc)
@@ -281,6 +279,8 @@ cb_syscall (cb, sc)
                                           ? count : FILE_XFR_SIZE));
            if (result == -1)
              goto ErrorFinish;
+           if (result == 0)    /* EOF */
+             break;
            bytes_written = (*sc->write_mem) (cb, sc, addr, buf, result);
            if (bytes_written != result)
              {
@@ -291,6 +291,9 @@ cb_syscall (cb, sc)
            bytes_read += result;
            count -= result;
            addr += result;
+           /* If this is a short read, don't go back for more */
+           if (result != FILE_XFR_SIZE)
+             break;
          }
        result = bytes_read;
       }
@@ -320,9 +323,15 @@ cb_syscall (cb, sc)
                goto FinishSyscall;
              }
            if (fd == 1)
-             result = (int) (*cb->write_stdout) (cb, buf, bytes_read);
-           if (fd == 2)
-             result = (int) (*cb->write_stderr) (cb, buf, bytes_read);
+             {
+               result = (int) (*cb->write_stdout) (cb, buf, bytes_read);
+               (*cb->flush_stdout) (cb);
+             }
+           else if (fd == 2)
+             {
+               result = (int) (*cb->write_stderr) (cb, buf, bytes_read);
+               (*cb->flush_stderr) (cb);
+             }
            else
              result = (int) (*cb->write) (cb, fd, buf, bytes_read);
            if (result == -1)
This page took 0.023822 seconds and 4 git commands to generate.