Cleanup eglib config handling on Windows (#52855)
authorAlexander Köplinger <alex.koeplinger@outlook.com>
Tue, 18 May 2021 12:05:38 +0000 (14:05 +0200)
committerGitHub <noreply@github.com>
Tue, 18 May 2021 12:05:38 +0000 (14:05 +0200)
We were using a hardcoded checked-in version of the config file on Windows, replace it with the CMake-generated one.

src/mono/CMakeLists.txt
src/mono/cmake/eglib-config.h.cmake.in
src/mono/mono/eglib/CMakeLists.txt
src/mono/mono/eglib/eglib-config.h.in [deleted file]
src/mono/mono/eglib/eglib-config.hw [deleted file]
src/mono/mono/eglib/glib.h

index 9142cbcee104eded7b3b9c556987e025bd499e6b..e4f4d0d5f01a8650a7962b1f1e8678ff3bf51047 100644 (file)
@@ -127,6 +127,14 @@ set(HAVE_MOVING_COLLECTOR 1)
 set(HAVE_CONC_GC_AS_DEFAULT 1)
 set(MONO_INSIDE_RUNTIME 1)
 
+TEST_BIG_ENDIAN(IS_BIG_ENDIAN)
+
+if(IS_BIG_ENDIAN)
+  set(TARGET_BYTE_ORDER G_BIG_ENDIAN)
+else()
+  set(TARGET_BYTE_ORDER G_LITTLE_ENDIAN)
+endif()
+
 ######################################
 # AOT CROSS COMPILER SUPPORT
 ######################################
@@ -600,48 +608,39 @@ endif()
 # EGLIB CHECKS
 ######################################
 
-set(GNUC_PRETTY)
-set(GNUC_UNUSED)
-set(BREAKPOINT "G_STMT_START { raise(SIGTRAP); } G_STMT_END")
-if(GCC)
-  set(GNUC_UNUSED "__attribute__((__unused__))")
-  set(GNUC_NORETURN "__attribute__((__noreturn__))")
-  if(HOST_AMD64 OR HOST_X86)
-    set(BREAKPOINT "G_STMT_START { __asm__(\"int \$03\"); } G_STMT_END")
-  endif()
-endif()
-
-TEST_BIG_ENDIAN(IS_BIG_ENDIAN)
-
-if(IS_BIG_ENDIAN)
-  set(TARGET_BYTE_ORDER G_BIG_ENDIAN)
-else()
-  set(TARGET_BYTE_ORDER G_LITTLE_ENDIAN)
-endif()
-
-if(IS_BIG_ENDIAN)
-  set(ORDER G_BIG_ENDIAN)
-else()
-  set(ORDER G_LITTLE_ENDIAN)
-endif()
+set(EGLIB_GNUC_PRETTY)
+set(EGLIB_GNUC_UNUSED)
 
 if(HOST_WIN32)
-  set(PATHSEP "\\")
-  set(SEARCHSEP ";")
-  set(OS "WIN32")
-  set(PIDTYPE "void *")
+  set(EGLIB_GNUC_PRETTY "__FUNCTION__")
+  set(EGLIB_BREAKPOINT "__debugbreak()")
+  set(EGLIB_PATHSEP "\\\\")
+  set(EGLIB_SEARCHSEP ";")
+  set(EGLIB_OS "WIN32")
+  set(EGLIB_PIDTYPE "void *")
+  if(HOST_AMD64 OR HOST_ARM64)
+    set(EGLIB_GSIZE_FORMAT "\"Iu\"")
+  else()
+    set(EGLIB_GSIZE_FORMAT "\"u\"")
+  endif()
 else()
-  set(PATHSEP "/")
-  set(SEARCHSEP ":")
-  set(OS "UNIX")
-  set(PIDTYPE "int")
+  set(EGLIB_BREAKPOINT "G_STMT_START { raise(SIGTRAP); } G_STMT_END")
+  if(GCC)
+    set(EGLIB_GNUC_UNUSED "__attribute__((__unused__))")
+    set(EGLIB_GNUC_NORETURN "__attribute__((__noreturn__))")
+    if(HOST_AMD64 OR HOST_X86)
+      set(EGLIB_BREAKPOINT "G_STMT_START { __asm__(\"int \$03\"); } G_STMT_END")
+    endif()
+  endif()
+  set(EGLIB_PATHSEP "/")
+  set(EGLIB_SEARCHSEP ":")
+  set(EGLIB_OS "UNIX")
+  set(EGLIB_PIDTYPE "int")
+  set(EGLIB_GSIZE_FORMAT "\"lu\"")
 endif()
 
-# FIXME:
-set(GSIZE_FORMAT "\"lu\"")
-
-set(GSIZE "size_t")
-set(GSSIZE "ptrdiff_t")
+set(EGLIB_GSIZE "size_t")
+set(EGLIB_GSSIZE "ptrdiff_t")
 
 #
 # END OF EGLIB CHECKS
@@ -752,4 +751,4 @@ if (ENABLE_MSCORDBI AND NOT TARGET_ARCH STREQUAL "arm64"  AND NOT CMAKE_CROSSCOM
 endif()
 
 configure_file(cmake/config.h.in config.h)
-configure_file(cmake/eglib-config.h.cmake.in mono/eglib/eglib-config.h)  # TODO: eglib-config.h is not needed, we're using hardcoded eglib-config.hw
+configure_file(cmake/eglib-config.h.cmake.in mono/eglib/eglib-config.h)
index ebd5aaeee739a9895a7a62a6be5d827339e614e7..9f1394e134b53e72405c9c774a09e674e00916e1 100644 (file)
@@ -1,19 +1,37 @@
 #ifndef __EGLIB_CONFIG_H
 #define __EGLIB_CONFIG_H
 
-/*
- * System-dependent settings
- */
-#define G_GNUC_PRETTY_FUNCTION   @GNUC_PRETTY@
-#define G_GNUC_UNUSED            @GNUC_UNUSED@
-#define G_BYTE_ORDER             @ORDER@
-#define G_GNUC_NORETURN          @GNUC_NORETURN@
-#define G_SEARCHPATH_SEPARATOR_S "@SEARCHSEP@"
-#define G_SEARCHPATH_SEPARATOR   '@SEARCHSEP@'
-#define G_DIR_SEPARATOR          '@PATHSEP@'
-#define G_DIR_SEPARATOR_S        "@PATHSEP@"
-#define G_BREAKPOINT()           @BREAKPOINT@
-#define G_OS_@OS@
+#ifdef _MSC_VER
+
+#include <io.h>
+#include <stddef.h>
+
+#define MAXPATHLEN 242
+
+#define STDOUT_FILENO (1)
+#define STDERR_FILENO (2)
+
+/* FIXME: what should this be ?*/
+#define X_OK 4 /* This is really read */
+#define WNOHANG 1
+#define F_SETFD 1
+#define FD_CLOEXEC 1
+
+#ifndef __cplusplus
+#undef inline
+#define inline __inline
+#endif
+
+#define strtok_r strtok_s
+
+#undef G_HAVE_UNISTD_H
+#undef G_HAVE_SYS_TIME_H
+#undef G_HAVE_SYS_WAIT_H
+#undef G_HAVE_PWD_H
+#undef G_HAVE_STRNDUP
+#define G_HAVE_GETOPT_H 1
+
+#else
 
 #if @HAVE_ALLOCA_H@ == 1
 #define G_HAVE_ALLOCA_H
 #define G_HAVE_UNISTD_H
 #endif
 
-typedef @GSIZE@ gsize;
-typedef @GSSIZE@ gssize;
+#endif
 
-#define G_GSIZE_FORMAT   @GSIZE_FORMAT@
+/*
+ * System-dependent settings
+ */
+#define G_GNUC_PRETTY_FUNCTION   @EGLIB_GNUC_PRETTY@
+#define G_GNUC_UNUSED            @EGLIB_GNUC_UNUSED@
+#define G_BYTE_ORDER             @TARGET_BYTE_ORDER@
+#define G_GNUC_NORETURN          @EGLIB_GNUC_NORETURN@
+#define G_SEARCHPATH_SEPARATOR_S "@EGLIB_SEARCHSEP@"
+#define G_SEARCHPATH_SEPARATOR   '@EGLIB_SEARCHSEP@'
+#define G_DIR_SEPARATOR          '@EGLIB_PATHSEP@'
+#define G_DIR_SEPARATOR_S        "@EGLIB_PATHSEP@"
+#define G_BREAKPOINT()           @EGLIB_BREAKPOINT@
+#define G_OS_@EGLIB_OS@          1
+#define G_GSIZE_FORMAT           @EGLIB_GSIZE_FORMAT@
 
 #if defined (HOST_WATCHOS)
 #undef G_BREAKPOINT
@@ -38,6 +68,12 @@ typedef @GSSIZE@ gssize;
 #define G_BREAKPOINT() do { printf ("MONO: BREAKPOINT\n"); abort (); } while (0)
 #endif
 
-typedef @PIDTYPE@ GPid;
+typedef @EGLIB_GSIZE@ gsize;
+typedef @EGLIB_GSSIZE@ gssize;
+typedef @EGLIB_PIDTYPE@ GPid;
+
+#ifdef _MSC_VER
+typedef int pid_t;
+#endif
 
 #endif
index d8b7d01a1e4bf759cf64a77135afcdd56d5623ac..1325ee6c1126ce0c701e630f3540ffc1fd9dc549 100644 (file)
@@ -1,6 +1,5 @@
 
 set(eglib_win32_sources
-    eglib-config.hw
     gdate-win32.c gdir-win32.c gfile-win32.c gmisc-win32.c
     gmodule-win32.c gtimer-win32.c gunicode-win32.c)
 
diff --git a/src/mono/mono/eglib/eglib-config.h.in b/src/mono/mono/eglib/eglib-config.h.in
deleted file mode 100644 (file)
index ebd5aae..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-#ifndef __EGLIB_CONFIG_H
-#define __EGLIB_CONFIG_H
-
-/*
- * System-dependent settings
- */
-#define G_GNUC_PRETTY_FUNCTION   @GNUC_PRETTY@
-#define G_GNUC_UNUSED            @GNUC_UNUSED@
-#define G_BYTE_ORDER             @ORDER@
-#define G_GNUC_NORETURN          @GNUC_NORETURN@
-#define G_SEARCHPATH_SEPARATOR_S "@SEARCHSEP@"
-#define G_SEARCHPATH_SEPARATOR   '@SEARCHSEP@'
-#define G_DIR_SEPARATOR          '@PATHSEP@'
-#define G_DIR_SEPARATOR_S        "@PATHSEP@"
-#define G_BREAKPOINT()           @BREAKPOINT@
-#define G_OS_@OS@
-
-#if @HAVE_ALLOCA_H@ == 1
-#define G_HAVE_ALLOCA_H
-#endif
-
-#if @HAVE_UNISTD_H@ == 1
-#define G_HAVE_UNISTD_H
-#endif
-
-typedef @GSIZE@ gsize;
-typedef @GSSIZE@ gssize;
-
-#define G_GSIZE_FORMAT   @GSIZE_FORMAT@
-
-#if defined (HOST_WATCHOS)
-#undef G_BREAKPOINT
-#define G_BREAKPOINT()
-#endif
-
-#if defined (HOST_WASM)
-#undef G_BREAKPOINT
-#define G_BREAKPOINT() do { printf ("MONO: BREAKPOINT\n"); abort (); } while (0)
-#endif
-
-typedef @PIDTYPE@ GPid;
-
-#endif
diff --git a/src/mono/mono/eglib/eglib-config.hw b/src/mono/mono/eglib/eglib-config.hw
deleted file mode 100644 (file)
index 6ab297f..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-#ifndef __EGLIB_CONFIG_H
-#define __EGLIB_CONFIG_H
-
-/*
- * System-dependent settings
- */
-#define G_OS_WIN32 1
-
-#ifdef _MSC_VER
-
-#include <io.h>
-#include <stddef.h>
-
-#define G_GNUC_PRETTY_FUNCTION   __FUNCTION__
-#define G_GNUC_UNUSED            
-#define G_BYTE_ORDER             1234
-#define G_GNUC_NORETURN          
-#define G_BREAKPOINT()           __debugbreak()
-#define MAXPATHLEN 242
-
-typedef size_t gsize;
-typedef ptrdiff_t gssize;
-typedef int pid_t;
-
-#define G_DIR_SEPARATOR          '\\'
-#define G_DIR_SEPARATOR_S        "\\"
-#define G_SEARCHPATH_SEPARATOR_S ";"
-#define G_SEARCHPATH_SEPARATOR   ';'
-
-#ifdef _WIN64
-// Correct for Win32 and Win64 since circa 2000.
-#define G_GSIZE_FORMAT   "Iu"
-#else
-// Correct for Win32 since circa 1992.
-#define G_GSIZE_FORMAT   "u"
-#endif
-
-// https://msdn.microsoft.com/en-us/library/40bbyw78.aspx
-#define STDOUT_FILENO (1)
-#define STDERR_FILENO (2)
-
-/* FIXME: what should this be ?*/
-#define X_OK 4 /* This is really read */
-#define WNOHANG 1
-#define F_SETFD 1
-#define FD_CLOEXEC 1
-
-#ifndef __cplusplus
-#undef inline
-#define inline __inline
-#endif
-
-#define strtok_r strtok_s
-
-#undef G_HAVE_UNISTD_H
-#undef G_HAVE_SYS_TIME_H
-#undef G_HAVE_SYS_WAIT_H
-#undef G_HAVE_PWD_H
-#undef G_HAVE_STRNDUP
-#define G_HAVE_GETOPT_H 1
-
-/* disable the following warnings 
- * C4100: The formal parameter is not referenced in the body of the function. The unreferenced parameter is ignored. 
- * C4127: conditional expression is constant
-*/
-#pragma warning(disable:4100 4127)
-#endif
-
-typedef void * GPid;
-#endif
index 6ed8fa0bd0aedc53a8288e830eda6bf1c30e2245..5a454a037202f583b479847552632907eee64d4c 100644 (file)
 #include <limits.h>
 #include <stdint.h>
 #include <inttypes.h>
-#ifdef _MSC_VER
-#include <eglib-config.hw>
-#else
 #include <eglib-config.h>
-#endif
 
 // - Pointers should only be converted to or from pointer-sized integers.
 // - Any size integer can be converted to any other size integer.