Skip to content

Commit

Permalink
Fix build and use System.Native on FreeBSD (#12921)
Browse files Browse the repository at this point in the history
* Required includes for system headers to behave on FreeBSD

* System.Native on FreeBSD
  • Loading branch information
NattyNarwhal authored and marek-safar committed Feb 10, 2019
1 parent b98780c commit b2f590b
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 1 deletion.
17 changes: 17 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -6140,6 +6140,22 @@ elif case $host_os in aix*|os400*) true;; *) false;; esac; then
AC_MSG_RESULT(aix)

MONO_NATIVE_PLATFORM_TYPE="MONO_NATIVE_PLATFORM_TYPE_AIX"
elif case $host_os in freebsd*) true;; *) false;; esac; then
mono_native_text="FreeBSD"
MONO_NATIVE_CC=$CC
MONO_NATIVE_CXX=$CXX
MONO_NATIVE_CPPFLAGS=$CPPFLAGS
MONO_NATIVE_CXXFLAGS=$CXXFLAGS
MONO_NATIVE_CFLAGS=$CFLAGS
MONO_NATIVE_LDFLAGS=$LDFLAGS

mono_native=yes
mono_native_compat=no
MONO_NATIVE_PLATFORM=freebsd
AC_MSG_CHECKING([Mono.Native support])
AC_MSG_RESULT(freebsd)

MONO_NATIVE_PLATFORM_TYPE="MONO_NATIVE_PLATFORM_TYPE_FREEBSD"
elif test x$platform_android = xyes; then
mono_native_text="Android"
MONO_NATIVE_CC=$CC
Expand Down Expand Up @@ -6194,6 +6210,7 @@ AM_CONDITIONAL(MONO_NATIVE_PLATFORM_IOS, test x$MONO_NATIVE_PLATFORM = xios)
AM_CONDITIONAL(MONO_NATIVE_PLATFORM_LINUX, test x$MONO_NATIVE_PLATFORM = xlinux)
AM_CONDITIONAL(MONO_NATIVE_PLATFORM_AIX, test x$MONO_NATIVE_PLATFORM = xaix)
AM_CONDITIONAL(MONO_NATIVE_PLATFORM_ANDROID, test x$MONO_NATIVE_PLATFORM = xandroid)
AM_CONDITIONAL(MONO_NATIVE_PLATFORM_FREEBSD, test x$MONO_NATIVE_PLATFORM = xfreebsd)

MONO_NATIVE_PLATFORM_TYPE_COMPAT="$MONO_NATIVE_PLATFORM_TYPE | MONO_NATIVE_PLATFORM_TYPE_COMPAT"
MONO_NATIVE_PLATFORM_TYPE_UNIFIED="$MONO_NATIVE_PLATFORM_TYPE | MONO_NATIVE_PLATFORM_TYPE_UNIFIED"
Expand Down
2 changes: 2 additions & 0 deletions mcs/class/corlib/Test/Mono/MonoNativePlatformType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ enum MonoNativePlatformType
MONO_NATIVE_PLATFORM_TYPE_IOS = 2,
MONO_NATIVE_PLATFORM_TYPE_LINUX = 3,
MONO_NATIVE_PLATFORM_TYPE_AIX = 4,
MONO_NATIVE_PLATFORM_TYPE_ANDROID = 5,
MONO_NATIVE_PLATFORM_TYPE_FREEBSD = 6,

MONO_NATIVE_PLATFORM_TYPE_IPHONE = 0x100,
MONO_NATIVE_PLATFORM_TYPE_TV = 0x200,
Expand Down
1 change: 1 addition & 0 deletions mono/metadata/mono-route.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#if defined(HOST_DARWIN) || defined(HOST_BSD)

#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h> /* in_addr_t */

Expand Down
8 changes: 7 additions & 1 deletion mono/native/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ linux_sources = $(unix_sources)

aix_sources = $(unix_sources)

freebsd_sources = $(unix_sources)

android_sources = \
pal-android.h \
pal-android.c \
Expand Down Expand Up @@ -108,7 +110,7 @@ macos_sources += $(gss_sources)
ios_sources += $(gss_sources)
endif

EXTRA_libmono_native_la_SOURCES = $(common_sources) $(macos_sources) $(ios_sources) $(linux_sources) $(aix_sources) $(unix_sources) $(gss_sources)
EXTRA_libmono_native_la_SOURCES = $(common_sources) $(macos_sources) $(ios_sources) $(linux_sources) $(aix_sources) $(freebsd) $(unix_sources) $(gss_sources)

if MONO_NATIVE_PLATFORM_MACOS
platform_sources = $(macos_sources)
Expand All @@ -124,6 +126,10 @@ platform_sources = $(aix_sources)
else
if MONO_NATIVE_PLATFORM_ANDROID
platform_sources = $(android_sources)
else
if MONO_NATIVE_PLATFORM_FREEBSD
platform_sources = $(freebsd_sources)
endif
endif
endif
endif
Expand Down
1 change: 1 addition & 0 deletions mono/native/mono-native-platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ typedef enum {
MONO_NATIVE_PLATFORM_TYPE_LINUX = 3,
MONO_NATIVE_PLATFORM_TYPE_AIX = 4,
MONO_NATIVE_PLATFORM_TYPE_ANDROID = 5,
MONO_NATIVE_PLATFORM_TYPE_FREEBSD = 6,

MONO_NATIVE_PLATFORM_TYPE_IPHONE = 0x100,
MONO_NATIVE_PLATFORM_TYPE_TV = 0x200,
Expand Down
3 changes: 3 additions & 0 deletions mono/utils/mono-state.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@

#include <sys/param.h>
#include <fcntl.h>
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
#include <utils/mono-threads-debug.h>

extern GCStats mono_gc_stats;
Expand Down

0 comments on commit b2f590b

Please sign in to comment.