update copyright dates
[deliverable/binutils-gdb.git] / bfd / bfdio.c
index 16bbf03a6970b619ed3d57dcb008f120a98c399c..bedebba87254116cd7d3dd7f905a67cad02d36dd 100644 (file)
@@ -1,7 +1,7 @@
 /* Low-level I/O routines for BFDs.
 
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
    Free Software Foundation, Inc.
 
    Written by Cygnus Support.
@@ -158,6 +158,9 @@ DESCRIPTION
 .  int (*bclose) (struct bfd *abfd);
 .  int (*bflush) (struct bfd *abfd);
 .  int (*bstat) (struct bfd *abfd, struct stat *sb);
+.  {* Just like mmap: (void*)-1 on failure, mmapped address on success.  *}
+.  void *(*bmmap) (struct bfd *abfd, void *addr, bfd_size_type len,
+.                  int prot, int flags, file_ptr offset);
 .};
 
 */
@@ -511,3 +514,31 @@ bfd_get_size (bfd *abfd)
 
   return buf.st_size;
 }
+
+
+/*
+FUNCTION
+       bfd_mmap
+
+SYNOPSIS
+       void *bfd_mmap (bfd *abfd, void *addr, bfd_size_type len,
+                       int prot, int flags, file_ptr offset);
+
+DESCRIPTION
+       Return mmap()ed region of the file, if possible and implemented.
+
+*/
+
+void *
+bfd_mmap (bfd *abfd, void *addr, bfd_size_type len,
+         int prot, int flags, file_ptr offset)
+{
+  void *ret = (void *)-1;
+  if ((abfd->flags & BFD_IN_MEMORY) != 0)
+    return ret;
+
+  if (abfd->iovec == NULL)
+    return ret;
+
+  return abfd->iovec->bmmap (abfd, addr, len, prot, flags, offset);
+}
This page took 0.023366 seconds and 4 git commands to generate.