Alexandre Julliard : tools: Move some portability defines out of port.h.

Alexandre Julliard julliard at winehq.org
Wed Oct 6 15:51:37 CDT 2021


Module: wine
Branch: master
Commit: 207068c48ce80d35badbe79a253b8a735c70fc52
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=207068c48ce80d35badbe79a253b8a735c70fc52

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Wed Oct  6 10:16:59 2021 +0200

tools: Move some portability defines out of port.h.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 include/wine/port.h     | 49 -------------------------------------------------
 tools/makedep.c         |  9 +--------
 tools/tools.h           | 25 +++++++++++++++++++++++++
 tools/widl/typelib.c    |  2 +-
 tools/widl/widl.c       |  2 +-
 tools/winedump/output.c |  4 ++--
 tools/winedump/pdb.c    |  4 ++--
 tools/winedump/pe.c     |  2 +-
 tools/wmc/mcl.c         |  2 +-
 tools/wmc/mcy.y         |  2 +-
 tools/wmc/utils.c       |  3 +--
 tools/wmc/utils.h       |  1 -
 tools/wmc/wmc.h         |  1 +
 13 files changed, 37 insertions(+), 69 deletions(-)

diff --git a/include/wine/port.h b/include/wine/port.h
index b7f537bec86..3bb13275c32 100644
--- a/include/wine/port.h
+++ b/include/wine/port.h
@@ -53,17 +53,12 @@
 #include <io.h>
 #include <process.h>
 
-#define mkdir(path,mode) mkdir(path)
-
 static inline void *dlopen(const char *name, int flags) { return NULL; }
 static inline void *dlsym(void *handle, const char *name) { return NULL; }
 static inline int dlclose(void *handle) { return 0; }
 static inline const char *dlerror(void) { return "No dlopen support on Windows"; }
 
 #ifdef _MSC_VER
-
-#define popen _popen
-#define pclose _pclose
 /* The UCRT headers in the Windows SDK #error out if we #define snprintf.
  * The C headers that came with previous Visual Studio versions do not have
  * snprintf. Check for VS 2015, which appears to be the first version to
@@ -71,25 +66,6 @@ static inline const char *dlerror(void) { return "No dlopen support on Windows";
 #if _MSC_VER < 1900
 # define snprintf _snprintf
 #endif
-#define strtoll _strtoi64
-#define strtoull _strtoui64
-#define strncasecmp _strnicmp
-#define strcasecmp _stricmp
-
-typedef long off_t;
-typedef int pid_t;
-typedef int ssize_t;
-
-#endif /* _MSC_VER */
-
-#else  /* _WIN32 */
-
-#ifndef __int64
-#  if defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__) || defined(_WIN64)
-#    define __int64 long
-#  else
-#    define __int64 long long
-#  endif
 #endif
 
 #endif  /* _WIN32 */
@@ -106,36 +82,11 @@ typedef int ssize_t;
 #define RTLD_GLOBAL  0x100
 #endif
 
-#ifndef S_ISLNK
-# define S_ISLNK(mod) (0)
-#endif
-
-#ifndef S_ISDIR
-# define S_ISDIR(mod) (((mod) & _S_IFMT) == _S_IFDIR)
-#endif
-
-#ifndef S_ISCHR
-# define S_ISCHR(mod) (((mod) & _S_IFMT) == _S_IFCHR)
-#endif
-
-#ifndef S_ISREG
-# define S_ISREG(mod) (((mod) & _S_IFMT) == _S_IFREG)
-#endif
-
 /* So we open files in 64 bit access mode on Linux */
 #ifndef O_LARGEFILE
 # define O_LARGEFILE 0
 #endif
 
-#ifndef O_NONBLOCK
-# define O_NONBLOCK 0
-#endif
-
-#ifndef O_BINARY
-# define O_BINARY 0
-#endif
-
-
 /****************************************************************
  * Constants
  */
diff --git a/tools/makedep.c b/tools/makedep.c
index 121fd4f3565..15939edfb78 100644
--- a/tools/makedep.c
+++ b/tools/makedep.c
@@ -31,14 +31,7 @@
 #include <string.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-#if defined(_WIN32) && !defined(__CYGWIN__)
-#include <direct.h>
-#include <io.h>
-#define mkdir(path,mode) mkdir(path)
-#endif
+
 #include "tools.h"
 #include "wine/list.h"
 
diff --git a/tools/tools.h b/tools/tools.h
index f013bf7a510..cd87e20c163 100644
--- a/tools/tools.h
+++ b/tools/tools.h
@@ -26,6 +26,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <sys/types.h>
+#include <sys/stat.h>
 #include <fcntl.h>
 #include <time.h>
 #include <errno.h>
@@ -34,10 +35,34 @@
 #endif
 
 #if defined(_WIN32) && !defined(__CYGWIN__)
+# include <direct.h>
+# include <io.h>
 # include <process.h>
+# define mkdir(path,mode) mkdir(path)
+# ifndef S_ISREG
+#  define S_ISREG(mod) (((mod) & _S_IFMT) == _S_IFREG)
+# endif
+# ifdef _MSC_VER
+#  define popen _popen
+#  define pclose _pclose
+#  define strtoll _strtoi64
+#  define strtoull _strtoui64
+#  define strncasecmp _strnicmp
+#  define strcasecmp _stricmp
+# endif
 #else
 # include <sys/wait.h>
 # include <unistd.h>
+# ifndef O_BINARY
+#  define O_BINARY 0
+# endif
+# ifndef __int64
+#   if defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__)
+#     define __int64 long
+#   else
+#     define __int64 long long
+#   endif
+# endif
 #endif
 
 #if !defined(__GNUC__) && !defined(__attribute__)
diff --git a/tools/widl/typelib.c b/tools/widl/typelib.c
index 1d7e21da937..7f34aa4efcf 100644
--- a/tools/widl/typelib.c
+++ b/tools/widl/typelib.c
@@ -250,7 +250,7 @@ static void tlb_read(int fd, void *buf, int count)
         error("error while reading importlib.\n");
 }
 
-static void tlb_lseek(int fd, off_t offset)
+static void tlb_lseek(int fd, int offset)
 {
     if(lseek(fd, offset, SEEK_SET) == -1)
         error("lseek failed\n");
diff --git a/tools/widl/widl.c b/tools/widl/widl.c
index 5c11f6285ea..97a26743cf3 100644
--- a/tools/widl/widl.c
+++ b/tools/widl/widl.c
@@ -287,7 +287,7 @@ static void add_widl_version_define(void)
     if (p)
         version += atoi(p + 1);
 
-    snprintf(version_str, sizeof(version_str), "__WIDL__=0x%x", version);
+    sprintf(version_str, "__WIDL__=0x%x", version);
     wpp_add_cmdline_define(version_str);
 }
 
diff --git a/tools/winedump/output.c b/tools/winedump/output.c
index 5911f22f6c8..ad3a70c3b0f 100644
--- a/tools/winedump/output.c
+++ b/tools/winedump/output.c
@@ -68,7 +68,7 @@ void  output_spec_symbol (const parsed_symbol *sym)
   assert (sym && sym->symbol);
 
   if (sym->ordinal >= 0)
-    snprintf(ord_spec, 12, "%d", sym->ordinal);
+    sprintf(ord_spec, "%d", sym->ordinal);
   else
   {
     ord_spec[0] = '@';
@@ -485,7 +485,7 @@ void  output_c_banner (const parsed_symbol *sym)
   size_t i;
 
   if (sym->ordinal >= 0)
-    snprintf(ord_spec, sizeof (ord_spec), "%d", sym->ordinal);
+    sprintf(ord_spec, "%d", sym->ordinal);
   else
   {
     ord_spec[0] = '@';
diff --git a/tools/winedump/pdb.c b/tools/winedump/pdb.c
index 9057a544065..30001d224da 100644
--- a/tools/winedump/pdb.c
+++ b/tools/winedump/pdb.c
@@ -279,9 +279,9 @@ static void pdb_dump_symbols(struct pdb_reader* reader, PDB_STREAM_INDEXES* sidx
         printf("-Unknown symbol info version %d\n", symbols->version);
     }
     if (symbols->flags & 0x8000) /* new */
-        snprintf(tcver, sizeof(tcver), "%u.%u", (symbols->flags >> 8) & 0x7f, symbols->flags & 0xff);
+        sprintf(tcver, "%u.%u", (symbols->flags >> 8) & 0x7f, symbols->flags & 0xff);
     else
-        snprintf(tcver, sizeof(tcver), "old-%x", symbols->flags);
+        sprintf(tcver, "old-%x", symbols->flags);
     printf("Symbols:\n"
            "\tsignature:       %08x\n"
            "\tversion:         %u\n"
diff --git a/tools/winedump/pe.c b/tools/winedump/pe.c
index e21084ad4cf..4455ab61bd0 100644
--- a/tools/winedump/pe.c
+++ b/tools/winedump/pe.c
@@ -2442,7 +2442,7 @@ static	void	do_grab_sym( void )
 	{
 	    char ordinal_text[256];
 	    /* Ordinal only entry */
-            snprintf (ordinal_text, sizeof(ordinal_text), "%s_%u",
+            sprintf (ordinal_text, "%s_%u",
 		      globals.forward_dll ? globals.forward_dll : OUTPUT_UC_DLL_NAME,
 		      exportDir->Base + i);
 	    str_toupper(ordinal_text);
diff --git a/tools/wmc/mcl.c b/tools/wmc/mcl.c
index 93e666fed74..c0ca4eeba5c 100644
--- a/tools/wmc/mcl.c
+++ b/tools/wmc/mcl.c
@@ -26,8 +26,8 @@
 #include <assert.h>
 #include <string.h>
 
-#include "utils.h"
 #include "wmc.h"
+#include "utils.h"
 #include "lang.h"
 
 #include "mcy.tab.h"
diff --git a/tools/wmc/mcy.y b/tools/wmc/mcy.y
index 2ed8f72813a..879c46ffc77 100644
--- a/tools/wmc/mcy.y
+++ b/tools/wmc/mcy.y
@@ -44,8 +44,8 @@
 #include <stdlib.h>
 #include <assert.h>
 
-#include "utils.h"
 #include "wmc.h"
+#include "utils.h"
 #include "lang.h"
 
 static const char err_syntax[]	= "Syntax error\n";
diff --git a/tools/wmc/utils.c b/tools/wmc/utils.c
index a1286f8da30..5a91d420cb4 100644
--- a/tools/wmc/utils.c
+++ b/tools/wmc/utils.c
@@ -28,10 +28,9 @@
 #include <assert.h>
 #include <ctype.h>
 
-#include "wmctypes.h"
+#include "wmc.h"
 #include "winnls.h"
 #include "utils.h"
-#include "wmc.h"
 
 #define SUPPRESS_YACC_ERROR_MESSAGE
 
diff --git a/tools/wmc/utils.h b/tools/wmc/utils.h
index 39db674d4c9..3a8010d77cc 100644
--- a/tools/wmc/utils.h
+++ b/tools/wmc/utils.h
@@ -21,7 +21,6 @@
 #ifndef __WMC_UTILS_H
 #define __WMC_UTILS_H
 
-#include "../tools.h"
 #include "wmctypes.h"
 
 int mcy_error(const char *s, ...) __attribute__((format (printf, 1, 2)));
diff --git a/tools/wmc/wmc.h b/tools/wmc/wmc.h
index 438a645ebfc..913c2a9443e 100644
--- a/tools/wmc/wmc.h
+++ b/tools/wmc/wmc.h
@@ -21,6 +21,7 @@
 #ifndef __WMC_WMC_H
 #define __WMC_WMC_H
 
+#include "../tools.h"
 #include "wmctypes.h"
 
 /*




More information about the wine-cvs mailing list