Subject: Re: Should libc's toplevel Makefile add -DNLS to CFLAGS?
To: T. William Wells <bill@twwells.com>
From: J.T. Conklin <jconklin@netcom.com>
List: tech-userlevel
Date: 10/04/1994 22:32:02
> Weak references, of the kind I'm familiar with, aren't a solution
> either. How would yours solve the problem?

I was under the impression that using weak references is one of the most 
common ways of making a C library ANSI compliant.

For example, the remove() function calls the syscall unlink().  We can't 
do that in an ANSI compliant library, because unlink() is in the user's 
namespace.  But we have to provide unlink() because it is part of the 
UNIX/POSIX API.  How can this contradiction be resolved?

So we rename all our syscalls so that they have two leading underscores, 
(which puts them in the system's namespace) and change the library so 
that it calls them with the new names.  

To provide the traditional UNIX API, we can either create functions that
call the renamed functions:

	int unlink(const char *path)
	{
		return __unlink(path);
	}

Or we can use a weak reference to equate unlink() with __unlink().  In 
either case, the user can create his own global function unlink() and it 
will not effect the operation of the C library.  And, if the user doesn't
define his own unlink(), he'll get the one in the C library.  Thus with
this method we can supply both an ANSI and a POSIX compliant library.

	--jtc