bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: tempname.c vs. mingw


From: Eric Blake
Subject: Re: tempname.c vs. mingw
Date: Thu, 29 Jun 2006 22:15:41 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

Paul Eggert <eggert <at> CS.UCLA.EDU> writes:

> > +#if ! HAVE_DECL_MKDIR
> > +# if HAVE_IO_H
> > +#  include <io.h>
> > +# endif
> > +# define mkdir ((int (*)()) _mkdir)
> > +#endif
> 
> Surely this won't work if ! HAVE_DECL_MKDIR && ! HAVE_IO_H, since
> _mkdir will be undefined in that case.

Agreed; and I used your proposed rewrite of the tighter condition.

>  Also, older Unix systems lack
> a mkdir declaration, but have mkdir (it may not fit the prototype,
> though, so you shouldn't declare it without checking).

Is that even worth bothering with, for modern portability targets?  I figure we 
can improve the module later if another host is found where it is worthwhile to 
add a workaround in sys/stat.  And when it comes to module dependencies, for 
now only mkstemp depends on the new sys_stat; we can add the dependency to 
other modules as the need arises when porting them to mingw.

>  Also the
> "#define" gives me the heebie-jeebies, since it relies on undefined
> behavior (passing the wrong number of arguments to a C function).

Well, it was the suggestion from Bruno as seen in functions.texi, and has the 
benefit that &mkdir is still a valid function pointer to the OS's exported 
function (with a static replacement function, you no longer can guarantee that 
the function pointer is the same across .o files).  But I went with your idea 
of a static method as a cleaner solution.  Besides, how often does code take 
the address of mkdir?

> 
> Other than that, it looks good to me; thanks.
> 

Checked in with the above changes.  Thanks for the review.

-- 
Eric Blake






reply via email to

[Prev in Thread] Current Thread [Next in Thread]