www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/03/09/15:22:11

From: idr AT cs DOT pdx DOT edu (Ian D Romanick)
Message-Id: <199603092018.MAA29469@sirius.cs.pdx.edu>
Subject: Re: Using DXEs for notrivial tasks?
To: sandmann AT clio DOT rice DOT edu
Date: Sat, 9 Mar 1996 12:18:56 -0800 (PST)
Cc: djgpp AT delorie DOT com
In-Reply-To: <3141c18f.sandmann@clio.rice.edu> from "Charles Sandmann" at Mar 9, 96 11:36:15 am
MIME-Version: 1.0

>  2) Pass the address of the routines you can't directly link into the DXE
>     after loading it (so you can call them in the main image).  This last
>     fix isn't that hard if you have a relatively limited number of these
>     special routines and use some creative #define macros.

I've been thinking about this last option.  Now, on the Amiga, functions
in the shared system libraries are called through a table of pointers. 
When you open the library, all that you get is a pointer to this
structure.  How hard would it be to modify, for example, the stdio
library to use this mechanism.  You could then make a set of inline
functions like this:

inline size_t fwrite( const void * ptr, size_t size, size_t num, FILE * f )
{
   return( stdioBase->fwrite( ptr, size, num, f ) );
}

That way you would only need to pass a single pointer around.  This
would also make is so that stdio could have all the benefits of being a
shared library.

Now, there's no reason that the global variables that are part would
stdio would have to disappear.  They would just become fields in the
structure that had the function pointers in it.  Doing this, however,
would mean that a more complex (read: Amiga like) system would need to
be used.  When you opened a library, the pointer you got wasn't exacly a
pointer to the function table.  It was more like this:


        function n
        ...
        function 2
        function 1
lib ->  (start of library data here)

So what we might have for stdio would be:

struct StdioFunctions
{
    size_t (*fwrite)();
    size_t (*fread)();
    FILE * (*fopen)();
    ...
}

struct StdioData
{
    FILE * stdout;
    FILE * stdin;
    ...
}

struct StdioBase
{
    struct StdioFunctions func;
    struct StdioData      data;
};

Then the DXE init function would return a pointer to the "data" part of
the StdioBase structure.  The reason for doing it like this is so that
if you update the stdio DXE, code that was compiled for the older
versions will still work.

-- 
He asks a girl if they can both sit in a chair,
but he doen't get nervous: she's not really there!

http://www.cs.pdx.edu/~idr is the home of the Dancing Fool

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019