Skip to content

Commit

Permalink
Cleanup eglib config handling on Windows (dotnet#52855)
Browse files Browse the repository at this point in the history
We were using a hardcoded checked-in version of the config file on Windows, replace it with the CMake-generated one.
  • Loading branch information
akoeplinger authored May 18, 2021
1 parent 4cb86f7 commit 0d6fcd5
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 173 deletions.
75 changes: 37 additions & 38 deletions src/mono/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
######################################
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
70 changes: 53 additions & 17 deletions src/mono/cmake/eglib-config.h.cmake.in
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -23,10 +41,22 @@
#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
Expand All @@ -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
1 change: 0 additions & 1 deletion src/mono/mono/eglib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
43 changes: 0 additions & 43 deletions src/mono/mono/eglib/eglib-config.h.in

This file was deleted.

70 changes: 0 additions & 70 deletions src/mono/mono/eglib/eglib-config.hw

This file was deleted.

4 changes: 0 additions & 4 deletions src/mono/mono/eglib/glib.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@
#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.
Expand Down

0 comments on commit 0d6fcd5

Please sign in to comment.