summaryrefslogtreecommitdiff
path: root/exec/priv.h
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2000-03-13 22:31:24 +0000
committerRoland McGrath <roland@gnu.org>2000-03-13 22:31:24 +0000
commit61f43e7530fd22c9381a6a4e18c2d38431ebb72d (patch)
treeda6e8f5e791985d72611254092e3a2f72bc8bad4 /exec/priv.h
parent9802bc89324cbe38aa57640a3836fe2de308057e (diff)
2000-03-13 Roland McGrath <roland@baalperazim.frob.com>
* priv.h (EXECDATA_STREAM): New macro, always defined for now. (struct execdata) [! EXECDATA_STREAM]: Add members map_buffer, map_bsize, map_fsize, map_filepos in place of stream. (map_buffer, map_filepos, map_set_fsize): New macros for accessing those or stream. [! EXECDATA_STREAM] (map_fsize, map_vsize): Define using new members. * exec.c (map): Rewritten purely using those accessor macros. (input_room): Set the __target, __bufp, __error, and __eof members, which are no longer set by map. [! EXECDATA_STREAM] (prepare_stream, prepare_in_memory): Make no-ops. (input_room, close_exec_stream, fake_seek, prepare_stream, prepare_in_memory): Conditionalize these defns on [EXECDATA_STREAM]. (load_section): Always use map instead of stdio. Replace bcopy with memcpy. (check_gzip: zipread): Rewrite using map instead of stdio. (check_bzip2: zipread): Likewise.
Diffstat (limited to 'exec/priv.h')
-rw-r--r--exec/priv.h34
1 files changed, 31 insertions, 3 deletions
diff --git a/exec/priv.h b/exec/priv.h
index 75a350f1..1e836c55 100644
--- a/exec/priv.h
+++ b/exec/priv.h
@@ -72,10 +72,15 @@ typedef struct trivfs_protid *trivfs_protid_t; /* For MiG. */
extern mach_port_t procserver; /* Our proc port. */
-#ifndef BFD
+#define EXECDATA_STREAM /* XXX */
+
+#ifdef BFD
+#define EXECDATA_STREAM /* BFD uses stdio to access the executable. */
+#else
typedef void asection;
#endif
+
/* Data shared between check, check_section,
load, load_section, and finish. */
struct execdata
@@ -87,11 +92,34 @@ struct execdata
vm_address_t entry;
file_t file;
+#ifndef EXECDATA_STREAM
+
+ /* Note that if `file_data' (below) is set, then these just point
+ into that and should not be deallocated (file_data is malloc'd). */
+ char *map_buffer; /* Our mapping window or read buffer. */
+ size_t map_vsize; /* Page-aligned size allocated there. */
+ size_t map_fsize; /* Bytes from there to end of mapped data. */
+ off_t map_filepos; /* Position `map_buffer' maps to. */
+#define map_buffer(e) ((e)->map_buffer)
+#define map_fsize(e) ((e)->map_fsize)
+#define map_vsize(e) ((e)->map_vsize)
+#define map_filepos(e) ((e)->map_filepos)
+#define map_set_fsize(e, fsize) ((e)->map_fsize = (fsize))
+
+#else
+
#ifdef _STDIO_USES_IOSTREAM
+# error implement me for libio!
#else
FILE stream;
+#define map_buffer(e) ((e)->stream.__buffer)
#define map_fsize(e) ((e)->stream.__get_limit - (e)->stream.__buffer)
#define map_vsize(e) ((e)->stream.__bufsize)
+#define map_filepos(e) ((e)->stream.__offset)
+#define map_set_fsize(e, fsize) \
+ ((e)->stream.__get_limit = (e)->stream.__buffer + (fsize))
+#endif
+
#endif
#ifdef BFD
@@ -136,11 +164,11 @@ error_t elf_machine_matches_host (Elf32_Half e_machine);
void finish (struct execdata *, int dealloc_file_port);
/* Make sure our mapping window (or read buffer) covers
- LEN bytes of the file starting at POSN. */
+ LEN bytes of the file starting at POSN, and return
+ a pointer into the window corresponding to POSN. */
void *map (struct execdata *e, off_t posn, size_t len);
-
void check_hashbang (struct execdata *e,
file_t file,
task_t oldtask,