[Xorp-cvs] XORP cvs commit: xorp/rtrmgr

Bruce M Simpson bms@spc.org
Tue, 11 Oct 2005 23:41:44 +0100


On Sun, Oct 02, 2005 at 10:10:23PM +0000, Pavlin Radoslavov wrote:
> 	* Regenerate lex.opcmd.cc
> 	  Note that this regeneration removes manually added Windows-related
> 	  modifications like the following, so this may break the Windows
> 	  compilation:
> 	
> 	#ifdef HOST_OS_WINDOWS
> 	#define isatty(x) _isatty(x)
> 	#define fileno(x) _fileno(x)
> 	#endif
> 	
> 	  It is impossible to maintain such modifications in auto-generated
> 	  files, and they should be added somewhere else (e.g., somewhere
> 	  in libxorp).
%%%

This is ugly.

We need to decide what we're more comfortable with -- the cost of possibly
misusing emulation functions, or making lexer regens slightly more complex.

We could remove -D_NO_OLDNAMES from Windows compilation, but this creates a
situation where MSVCRT.DLL library functions which imitate UNIX syscalls may
be used without explicit reference, perhaps in error.

During the porting process I made a deliberate decision to use -D_NO_OLDNAMES,
to weed out cases where we might be doing things the UNIX way, when they
needed to be done the Windows way.

On the other hand, we could use modified lex templates when regenerating
the lexer, but this has additional maintenance cost.

These particular two functions have very specific actions, and fileno()'s
use is quite different from the UNIX world because of the 3-tier
file descriptor dance which is happening in MSVCRT.DLL (stdio,
'file descriptor', and underlying Win32 file handle).

isatty() in the Windows case actually ends up calling into the console
mode subsystem to determine if a given file handle points to a
console window.

BMS