www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1993/06/29/16:11:56

From: gsw AT aloft DOT att DOT com
Date: Tue, 29 Jun 93 08:33:57 EDT
Original-From: aloft!gsw (gerald.s.williams)
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: Re: getcwd()

I figured the DOS libraries (getcwd) problem would have been resolved
much quicker than this.

Oh well, since it hasn't, I might as well throw in my two cents:

If you really have DOS and UNIX library functions that you may want
to switch between on the same platform (eg. use UNIX getcwd() under
DOS), then you need to have two differently-named functions.

I would also contend that the "normal" DOS user is going to want to
use the DOS versions of the programs.  Face it, you're using a DOS
machine.

To that end, I would suggest putting the DOS versions of the library
functions in libc.a and adding a libunix.a which can be linked in if
the user wants UNIX library functions by default.  Furthermore, all
library functions duplicated in libunix.a would have an additional
"wrapper" function in libc.a called _dos_function().

Assuming the linker works as linkers are supposed to, _dos_function()
will call the function in libc.a even if the user specified -lunix on
the command line.  Sure there is a small bit of overhead, but that's
what you get for doing weird things.  Note you would only need to use
the wrapper functions if you were calling both DOS-like and UNIX-like
library functions in the same program.  If you're really worried about
overhead, don't use wrappers -- simply duplicate the library functions
in libc.a (at a cost in library size).

Note that the only functions that should be duplicated in libunix.a
are those that a user might reasonably want to use both versions of.
Also, if you want any library functions with variable arguments in
libunix.a, the functions will need some modifications.

If you want to make DOS-like library function calls the default, but
allow for occassional UNIX-like calls, then either add a lib_unix.a
library just like libunix.a except that each function is renamed
_unix_function(), or, modify DJGPP to allow you to specify libunix.a
either before or after libc.a and put wrapper functions in both
libraries.

--------------------

Quick recap of the solutions to the getcwd() problem:

1) Have dos-like and unix-like getcwd functions in libc.a and use
   #define's to select correct one.

2) Have libdos.a which includes DOS-like functions only, then link
   libdos.a to get DOS-like functions.

3) Have libunix.a which include UNIX-like functions only, and add
   wrapper functions to libc.a.

--------------------

,-----------------.
|Gerald S Williams|
|gsw AT aloft DOT att DOT com|
|  (215)439-7237  |
`-----------------'

      _  |     ____/    _  |
     /   /    /        /   /      /                         /
    /   /  ____ |     ____/   _  _/     __ |     __ |      /       ____/
   /   /        /    /          /      /   /    /   /     /     ____
______/  ______/  __/         ___/   _____/   _____/    ___/   ______/


- Raw text -


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