gas/
[deliverable/binutils-gdb.git] / sim / ppc / emul_netbsd.c
index 13897face2dfeb9ad8db8e1149f8e561810008d2..6bef3707a3e7c154c0670385f414e247acf5cd25 100644 (file)
@@ -4,7 +4,7 @@
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
+    the Free Software Foundation; either version 3 of the License, or
     (at your option) any later version.
 
     This program is distributed in the hope that it will be useful,
@@ -13,8 +13,7 @@
     GNU General Public License for more details.
 
     You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+    along with this program; if not, see <http://www.gnu.org/licenses/>.
 
     */
 
@@ -43,7 +42,6 @@
 #include <signal.h>
 #include <fcntl.h>
 #include <errno.h>
-#include <sys/errno.h>
 #include <sys/param.h>
 #include <sys/time.h>
 
@@ -94,6 +92,14 @@ int getrusage();
 #include <sys/sysctl.h>
 #include <sys/mount.h>
 extern int getdirentries(int fd, char *buf, int nbytes, long *basep);
+
+/* NetBSD post 2.0 has the statfs system call (if COMPAT_20), but does
+   not have struct statfs.  In this case don't implement fstatfs.
+   FIXME: Should implement fstatvfs.  */
+#ifndef HAVE_STRUCT_STATFS
+#undef HAVE_FSTATFS
+#endif
+
 #else
 
 /* If this is not netbsd, don't allow fstatfs or getdirentries at this time */
@@ -216,7 +222,7 @@ write_timeval(unsigned_word addr,
   emul_write_buffer(&t, addr, sizeof(t), processor, cia);
 }
 
-
+#ifdef HAVE_GETTIMEOFDAY
 STATIC_INLINE_EMUL_NETBSD void
 write_timezone(unsigned_word addr,
               struct timezone tz,
@@ -227,7 +233,7 @@ write_timezone(unsigned_word addr,
   H2T(tz.tz_dsttime);
   emul_write_buffer(&tz, addr, sizeof(tz), processor, cia);
 }
-
+#endif
 
 #ifdef HAVE_GETDIRENTRIES
 STATIC_INLINE_EMUL_NETBSD void
@@ -251,7 +257,7 @@ write_direntries(unsigned_word addr,
     nbytes -= in->d_reclen;
     addr += in->d_reclen;
     buf += in->d_reclen;
-    zfree(out);
+    free(out);
   }
 }
 #endif
@@ -339,7 +345,7 @@ do_read(os_emul_data *emul,
   if (status > 0)
     emul_write_buffer(scratch_buffer, buf, status, processor, cia);
 
-  zfree(scratch_buffer);
+  free(scratch_buffer);
 }
 
 
@@ -370,7 +376,7 @@ do_write(os_emul_data *emul,
   /* write */
   status = write(d, scratch_buffer, nbytes);
   emul_write_status(processor, status, errno);
-  zfree(scratch_buffer);
+  free(scratch_buffer);
 
   flush_stdoutput();
 }
@@ -909,7 +915,7 @@ do_getdirentries(os_emul_data *emul,
   if (status > 0)
     write_direntries(buf_addr, buf, status, processor, cia);
   if (buf != NULL)
-    zfree(buf);
+    free(buf);
 }
 #endif
 
@@ -1376,6 +1382,7 @@ emul_netbsd_create(device *root,
   int elf_binary;
   os_emul_data *bsd_data;
   device *vm;
+  char *filename;
 
   /* check that this emulation is really for us */
   if (name != NULL && strcmp(name, "netbsd") != 0)
@@ -1410,8 +1417,10 @@ emul_netbsd_create(device *root,
             (unsigned long)(top_of_stack - stack_size));
   tree_parse(vm, "./nr-bytes 0x%x", stack_size);
 
+  filename = tree_quote_property (bfd_get_filename(image));
   tree_parse(root, "/openprom/vm/map-binary/file-name %s",
-            bfd_get_filename(image));
+            filename);
+  free (filename);
 
   /* finish the init */
   tree_parse(root, "/openprom/init/register/pc 0x%lx",
@@ -1466,4 +1475,4 @@ const os_emul emul_netbsd = {
   0 /*data*/
 };
 
-#endif _EMUL_NETBSD_C_
+#endif /* _EMUL_NETBSD_C_ */
This page took 0.027117 seconds and 4 git commands to generate.