bug-gnulib
[Top][All Lists]
Advanced

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

[PATCH gnulib 4/4] RFC stat: x86_64 mingw64 #define stat as _stat64.


From: Marc-André Lureau
Subject: [PATCH gnulib 4/4] RFC stat: x86_64 mingw64 #define stat as _stat64.
Date: Wed, 25 Jan 2012 19:35:09 +0100

* lib/sys_stat.in.h: in order to keep mingw64 stat type, add a
orig_strut_stat typedef.  A bunch of "struct stat" need to be
replaced to use that original type, because stat() is defined by
rpl_stat() instead.
* lib/canonicalize-lgpl.c (__realpath): use orig_struct_stat.
* lib/readlink.c (readlink): Likewise.
* lib/stat.c (rpl_stat): Likewise.
* lib/tempname.c (struct_stat64): Likewise.

WARNING: this solution isn't elegant.. the caller is supposed to
decalre the "struct stat" with "orig_struct_stat".

Also the patch isn't complete, it probably needs to touch other parts
of gnulib code using stat().
---
 ChangeLog               |   12 ++++++++++++
 lib/canonicalize-lgpl.c |    2 +-
 lib/readlink.c          |    2 +-
 lib/stat.c              |    2 +-
 lib/sys_stat.in.h       |    3 ++-
 lib/tempname.c          |    2 +-
 6 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index dc7cdc1..f541345 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
 2012-01-25  Marc-André Lureau  <address@hidden>
 
+       stat: x86_64 mingw64 #define stat as _stat64.
+       * lib/sys_stat.in.h: in order to keep mingw64 stat type, add a
+       orig_strut_stat typedef.  A bunch of "struct stat" need to be
+       replaced to use that original type, because stat() is defined by
+       rpl_stat() instead.
+       * lib/canonicalize-lgpl.c (__realpath): use orig_struct_stat.
+       * lib/readlink.c (readlink): Likewise.
+       * lib/stat.c (rpl_stat): Likewise.
+       * lib/tempname.c (struct_stat64): Likewise.
+
+2012-01-25  Marc-André Lureau  <address@hidden>
+
        select, poll, isatty: Avoid warnings on x86_64 mingw64.
        * lib/select.c (IsConsoleHandle): Use intptr_t to convert handle
        pointer to an integer. Fix warnings with MinGW64 x64.
diff --git a/lib/canonicalize-lgpl.c b/lib/canonicalize-lgpl.c
index 2fd79dc..b866cb8 100644
--- a/lib/canonicalize-lgpl.c
+++ b/lib/canonicalize-lgpl.c
@@ -165,7 +165,7 @@ __realpath (const char *name, char *resolved)
 #ifdef _LIBC
       struct stat64 st;
 #else
-      struct stat st;
+      orig_struct_stat st;
 #endif
       int n;
 
diff --git a/lib/readlink.c b/lib/readlink.c
index baac132..b01f4cc 100644
--- a/lib/readlink.c
+++ b/lib/readlink.c
@@ -32,7 +32,7 @@ ssize_t
 readlink (const char *name, char *buf _GL_UNUSED,
           size_t bufsize _GL_UNUSED)
 {
-  struct stat statbuf;
+  orig_struct_stat statbuf;
 
   /* In general we should use lstat() here, not stat().  But on platforms
      without symbolic links, lstat() - if it exists - would be equivalent to
diff --git a/lib/stat.c b/lib/stat.c
index 9ea53c1..10594b0 100644
--- a/lib/stat.c
+++ b/lib/stat.c
@@ -62,7 +62,7 @@ orig_stat (const char *filename, struct stat *buf)
    correctly.  */
 
 int
-rpl_stat (char const *name, struct stat *st)
+rpl_stat (char const *name, orig_struct_stat *st)
 {
   int result = orig_stat (name, st);
 #if REPLACE_FUNC_STAT_FILE
diff --git a/lib/sys_stat.in.h b/lib/sys_stat.in.h
index 005ad2d..df515a3 100644
--- a/lib/sys_stat.in.h
+++ b/lib/sys_stat.in.h
@@ -616,6 +616,7 @@ _GL_WARN_ON_USE (mknodat, "mknodat is not portable - "
 /* We can't use the object-like #define stat rpl_stat, because of
    struct stat.  This means that rpl_stat will not be used if the user
    does (stat)(a,b).  Oh well.  */
+typedef struct stat orig_struct_stat;
 #  undef stat
 #  ifdef _LARGE_FILES
     /* With _LARGE_FILES defined, AIX (only) defines stat to stat64,
@@ -626,7 +627,7 @@ _GL_WARN_ON_USE (mknodat, "mknodat is not portable - "
 #  else /* !_LARGE_FILES */
 #   define stat(name, st) rpl_stat (name, st)
 #  endif /* !_LARGE_FILES */
-_GL_EXTERN_C int stat (const char *name, struct stat *buf)
+_GL_EXTERN_C int stat (const char *name, orig_struct_stat *buf)
                       _GL_ARG_NONNULL ((1, 2));
 # endif
 #elif defined GNULIB_POSIXCHECK
diff --git a/lib/tempname.c b/lib/tempname.c
index de0474d..f82caa2 100644
--- a/lib/tempname.c
+++ b/lib/tempname.c
@@ -61,7 +61,7 @@
 #if _LIBC
 # define struct_stat64 struct stat64
 #else
-# define struct_stat64 struct stat
+# define struct_stat64 orig_struct_stat
 # define __gen_tempname gen_tempname
 # define __getpid getpid
 # define __gettimeofday gettimeofday
-- 
1.7.7.5




reply via email to

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