diff options
author | Dale Rahn <drahn@cvs.openbsd.org> | 2004-05-17 20:42:11 +0000 |
---|---|---|
committer | Dale Rahn <drahn@cvs.openbsd.org> | 2004-05-17 20:42:11 +0000 |
commit | 210747ce9cbbde21fd37218d73b1cb1aaa552e98 (patch) | |
tree | 5628f23f3b9b8b5892ac32e956c863fda2560269 /gnu | |
parent | 1578a2b4f012af571e3bf23eb83fded78757942a (diff) |
import binutils 2.14 (excluding testsuites, .info files, and .po files)
Diffstat (limited to 'gnu')
-rw-r--r-- | gnu/usr.bin/binutils/bfd/bfdio.c | 94 |
1 files changed, 44 insertions, 50 deletions
diff --git a/gnu/usr.bin/binutils/bfd/bfdio.c b/gnu/usr.bin/binutils/bfd/bfdio.c index a90cb33ea5f..32293162367 100644 --- a/gnu/usr.bin/binutils/bfd/bfdio.c +++ b/gnu/usr.bin/binutils/bfd/bfdio.c @@ -1,8 +1,6 @@ /* Low-level I/O routines for BFDs. - - Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, - 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. - + Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, + 2000, 2001, 2002 Free Software Foundation, Inc. Written by Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -38,30 +36,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #define S_IXOTH 0001 /* Execute by others. */ #endif -file_ptr -real_ftell (FILE *file) -{ -#if defined (HAVE_FTELLO64) - return ftello64 (file); -#elif defined (HAVE_FTELLO) - return ftello (file); -#else - return ftell (file); -#endif -} - -int -real_fseek (FILE *file, file_ptr offset, int whence) -{ -#if defined (HAVE_FSEEKO64) - return fseeko64 (file, offset, whence); -#elif defined (HAVE_FSEEKO) - return fseeko (file, offset, whence); -#else - return fseek (file, offset, whence); -#endif -} - /* Note that archive entries don't have streams; they share their parent's. This allows someone to play with the iostream behind BFD's back. @@ -69,8 +43,13 @@ real_fseek (FILE *file, file_ptr offset, int whence) contents (0 for non-archive elements). For archive entries this is the first octet in the file, NOT the beginning of the archive header. */ +static size_t real_read PARAMS ((PTR where, size_t a, size_t b, FILE *file)); static size_t -real_read (void *where, size_t a, size_t b, FILE *file) +real_read (where, a, b, file) + PTR where; + size_t a; + size_t b; + FILE *file; { /* FIXME - this looks like an optimization, but it's really to cover up for a feature of some OSs (not solaris - sigh) that @@ -97,7 +76,10 @@ real_read (void *where, size_t a, size_t b, FILE *file) /* Return value is amount read. */ bfd_size_type -bfd_bread (void *ptr, bfd_size_type size, bfd *abfd) +bfd_bread (ptr, size, abfd) + PTR ptr; + bfd_size_type size; + bfd *abfd; { size_t nread; @@ -106,7 +88,7 @@ bfd_bread (void *ptr, bfd_size_type size, bfd *abfd) struct bfd_in_memory *bim; bfd_size_type get; - bim = abfd->iostream; + bim = (struct bfd_in_memory *) abfd->iostream; get = size; if (abfd->where + get > bim->size) { @@ -144,13 +126,16 @@ bfd_bread (void *ptr, bfd_size_type size, bfd *abfd) } bfd_size_type -bfd_bwrite (const void *ptr, bfd_size_type size, bfd *abfd) +bfd_bwrite (ptr, size, abfd) + const PTR ptr; + bfd_size_type size; + bfd *abfd; { size_t nwrote; if ((abfd->flags & BFD_IN_MEMORY) != 0) { - struct bfd_in_memory *bim = abfd->iostream; + struct bfd_in_memory *bim = (struct bfd_in_memory *) (abfd->iostream); size = (size_t) size; if (abfd->where + size > bim->size) { @@ -162,7 +147,7 @@ bfd_bwrite (const void *ptr, bfd_size_type size, bfd *abfd) newsize = (bim->size + 127) & ~(bfd_size_type) 127; if (newsize > oldsize) { - bim->buffer = bfd_realloc (bim->buffer, newsize); + bim->buffer = (bfd_byte *) bfd_realloc (bim->buffer, newsize); if (bim->buffer == 0) { bim->size = 0; @@ -188,15 +173,16 @@ bfd_bwrite (const void *ptr, bfd_size_type size, bfd *abfd) return nwrote; } -file_ptr -bfd_tell (bfd *abfd) +bfd_vma +bfd_tell (abfd) + bfd *abfd; { file_ptr ptr; if ((abfd->flags & BFD_IN_MEMORY) != 0) return abfd->where; - ptr = real_ftell (bfd_cache_lookup (abfd)); + ptr = ftell (bfd_cache_lookup (abfd)); if (abfd->my_archive) ptr -= abfd->origin; @@ -205,7 +191,8 @@ bfd_tell (bfd *abfd) } int -bfd_flush (bfd *abfd) +bfd_flush (abfd) + bfd *abfd; { if ((abfd->flags & BFD_IN_MEMORY) != 0) return 0; @@ -215,7 +202,9 @@ bfd_flush (bfd *abfd) /* Returns 0 for success, negative value for failure (in which case bfd_get_error can retrieve the error code). */ int -bfd_stat (bfd *abfd, struct stat *statbuf) +bfd_stat (abfd, statbuf) + bfd *abfd; + struct stat *statbuf; { FILE *f; int result; @@ -239,11 +228,14 @@ bfd_stat (bfd *abfd, struct stat *statbuf) can retrieve the error code). */ int -bfd_seek (bfd *abfd, file_ptr position, int direction) +bfd_seek (abfd, position, direction) + bfd *abfd; + file_ptr position; + int direction; { int result; FILE *f; - file_ptr file_position; + long file_position; /* For the time being, a BFD may not seek to it's end. The problem is that we don't easily have a way to recognize the end of an element in an archive. */ @@ -257,7 +249,7 @@ bfd_seek (bfd *abfd, file_ptr position, int direction) { struct bfd_in_memory *bim; - bim = abfd->iostream; + bim = (struct bfd_in_memory *) abfd->iostream; if (direction == SEEK_SET) abfd->where = position; @@ -276,7 +268,7 @@ bfd_seek (bfd *abfd, file_ptr position, int direction) newsize = (bim->size + 127) & ~(bfd_size_type) 127; if (newsize > oldsize) { - bim->buffer = bfd_realloc (bim->buffer, newsize); + bim->buffer = (bfd_byte *) bfd_realloc (bim->buffer, newsize); if (bim->buffer == 0) { bim->size = 0; @@ -304,7 +296,7 @@ bfd_seek (bfd *abfd, file_ptr position, int direction) tripping the abort, we can probably safely disable this code, so that the real optimizations happen. */ file_ptr where_am_i_now; - where_am_i_now = real_ftell (bfd_cache_lookup (abfd)); + where_am_i_now = ftell (bfd_cache_lookup (abfd)); if (abfd->my_archive) where_am_i_now -= abfd->origin; if (where_am_i_now != abfd->where) @@ -333,7 +325,7 @@ bfd_seek (bfd *abfd, file_ptr position, int direction) if (direction == SEEK_SET && abfd->my_archive != NULL) file_position += abfd->origin; - result = real_fseek (f, file_position, direction); + result = fseek (f, file_position, direction); if (result != 0) { int hold_errno = errno; @@ -367,7 +359,7 @@ FUNCTION bfd_get_mtime SYNOPSIS - long bfd_get_mtime (bfd *abfd); + long bfd_get_mtime(bfd *abfd); DESCRIPTION Return the file modification time (as read from the file system, or @@ -376,7 +368,8 @@ DESCRIPTION */ long -bfd_get_mtime (bfd *abfd) +bfd_get_mtime (abfd) + bfd *abfd; { FILE *fp; struct stat buf; @@ -397,7 +390,7 @@ FUNCTION bfd_get_size SYNOPSIS - long bfd_get_size (bfd *abfd); + long bfd_get_size(bfd *abfd); DESCRIPTION Return the file size (as read from file system) for the file @@ -421,12 +414,13 @@ DESCRIPTION error when it tries to read the table, or a "virtual memory exhausted" error when it tries to allocate 15 bazillon bytes of space for the 15 bazillon byte table it is about to read. - This function at least allows us to answer the question, "is the + This function at least allows us to answer the quesion, "is the size reasonable?". */ long -bfd_get_size (bfd *abfd) +bfd_get_size (abfd) + bfd *abfd; { FILE *fp; struct stat buf; |