[Top][All Lists]

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

tempname.c vs. mingw

From: Eric Blake
Subject: tempname.c vs. mingw
Date: Wed, 28 Jun 2006 15:36:14 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

CVS m4 is using the mkstemp module, which includes tempname.c.  But there are a 
couple of compatibility problems preventing a clean compile on mingw32.

First is the fact that on Windows, mkdir only takes one argument (as noted in 
doc/functions.texi).  Mingw declares mkdir (and _mkdir) in <io.h> rather than 
<sys/stat.h>, but <fcntl.h> includes <io.h>, leading to other problems if I 
redefine mkdir inside my config.h.  Would it be worth augmenting the mkdir 
module to add lib/mkdir.h which neutralizes mingw mkdir, then making all 
modules which use mkdir (mkdir-p, openat, mkdtemp, mkstemp) depend on the mkdir 
module and include "mkdir.h" so that they can work on mingw?

For that matter, why are mkstemp and mkdtemp not sharing tempname.c?  In the 
case of mkstemp, maybe it would be easier to strip the (unused) mkdir out of 
tempname.c, since only mkdtemp really needs to call mkdir.  And mkdtemp already 
contains mingw mkdir neutralization code.

I'm thinking something like this for a new lib/mkdir.h:

#ifndef _gl_MKDIR_H
#define _gl_MKDIR_H

/* Get mkdir from compliant headers.  */
#include <sys/stat.h>

/* On mingw32, mkdir is declared in <io.h> with only one argument.  */
# include <io.h>

# define mkdir(file, mode) mkdir(file)

#endif /* _gl_MKDIR_H */

Second is the fact that since mingw does not support symlinks, it does not have 
lstat.  This portability pitfall is not mentioned in doc/functions.texi yet.  
The workaround is as simple as:
# define lstat stat

Would it be worth augmenting the lstat module to check for this case, then make 
all modules that use lstat (canonicalize, error, fts, fts-lgpl, getcwd, glob, 
lchown, mkdir-p, mkstemp, mountlist, openat, readlink, utimecmp) also depend on 
the lstat module?

Eric Blake

reply via email to

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