Add support for FreeBSD

Port the OpenMP runtime to FreeBSD along with associated build system changes.

Also begin to generalize affinity capabilities so they aren't tied explicitly
to Windows and Linux.

The port builds with stock clang and gmake and has no additional runtime
dependencies.

All but a handful of the validation suite tests are now passing on FreeBSD 10
x86_64.

llvm-svn: 202478
This commit is contained in:
Alp Toker 2014-02-28 09:42:41 +00:00
parent 6c6af852f9
commit 763b93965c
17 changed files with 141 additions and 88 deletions

View File

@ -78,6 +78,7 @@ Intel(R) Many Integrated Core Architecture
| icc/icl | gcc | clang |
--------------|---------------|--------------------------|
| Linux* OS | Yes(1,5) | Yes(2,4) | Yes(4,6,7) |
| FreeBSD* | No | No | Yes(4,6,7) |
| OS X* | Yes(1,3,4) | No | Yes(4,6,7) |
| Windows* OS | Yes(1,4) | No | No |
----------------------------------------------------------

View File

@ -88,7 +88,7 @@
#include "kmp_lock.h"
#include "kmp_i18n.h"
#define KMP_HANDLE_SIGNALS (KMP_OS_LINUX || KMP_OS_WINDOWS || KMP_OS_DARWIN)
#define KMP_HANDLE_SIGNALS (KMP_OS_LINUX || KMP_OS_FREEBSD || KMP_OS_WINDOWS || KMP_OS_DARWIN)
#ifdef KMP_SETVERSION
/* from factory/Include, to get VERSION_STRING embedded for 'what' */
@ -460,6 +460,15 @@ typedef int PACKED_REDUCTION_METHOD_T;
* Only Linux* OS and Windows* OS support thread affinity.
*/
#if KMP_OS_LINUX || KMP_OS_WINDOWS
# define KMP_AFFINITY_SUPPORTED 1
#elif KMP_OS_DARWIN || KMP_OS_FREEBSD
// affinity not supported
# define KMP_AFFINITY_SUPPORTED 0
#else
# error "Unknown or unsupported OS"
#endif
#if KMP_AFFINITY_SUPPORTED
extern size_t __kmp_affin_mask_size;
# define KMP_AFFINITY_CAPABLE() (__kmp_affin_mask_size > 0)
@ -719,11 +728,7 @@ extern kmp_affin_mask_t *__kmp_affinity_get_fullMask();
# endif /* KMP_OS_LINUX */
extern char const * __kmp_cpuinfo_file;
#elif KMP_OS_DARWIN
// affinity not supported
#else
#error "Unknown or unsupported OS"
#endif /* KMP_OS_LINUX || KMP_OS_WINDOWS */
#endif /* KMP_AFFINITY_SUPPORTED */
#if OMP_40_ENABLED
@ -944,10 +949,12 @@ extern unsigned int __kmp_place_core_offset;
#elif KMP_OS_LINUX
# define KMP_INIT_WAIT 1024U /* initial number of spin-tests */
# define KMP_NEXT_WAIT 512U /* susequent number of spin-tests */
#elif KMP_OS_DARWIN
/* TODO: tune for KMP_OS_DARWIN */
#elif KMP_OS_DARWIN || KMP_OS_FREEBSD
/* TODO: tune for OS */
# define KMP_INIT_WAIT 1024U /* initial number of spin-tests */
# define KMP_NEXT_WAIT 512U /* susequent number of spin-tests */
#else
# error "Unknown or unsupported OS"
#endif
#if KMP_ARCH_X86 || KMP_ARCH_X86_64
@ -2971,7 +2978,7 @@ extern void __kmp_initialize_system_tick( void ); /* Initialize timer tick valu
extern void __kmp_runtime_initialize( void ); /* machine specific initialization */
extern void __kmp_runtime_destroy( void );
#if KMP_OS_LINUX || KMP_OS_WINDOWS
#if KMP_AFFINITY_SUPPORTED
extern char *__kmp_affinity_print_mask(char *buf, int buf_len, kmp_affin_mask_t *mask);
extern void __kmp_affinity_initialize(void);
extern void __kmp_affinity_uninitialize(void);
@ -2989,7 +2996,7 @@ extern int __kmp_aux_unset_affinity_mask_proc(int proc, void **mask);
extern int __kmp_aux_get_affinity_mask_proc(int proc, void **mask);
extern void __kmp_balanced_affinity( int tid, int team_size );
#endif /* KMP_OS_LINUX || KMP_OS_WINDOWS */
#endif /* KMP_AFFINITY_SUPPORTED */
#if KMP_OS_LINUX && (KMP_ARCH_X86 || KMP_ARCH_X86_64 || KMP_ARCH_ARM)

View File

@ -21,7 +21,7 @@
#include "kmp_str.h"
#if KMP_OS_WINDOWS || KMP_OS_LINUX
#if KMP_AFFINITY_SUPPORTED
//
// Print the affinity mask to the character array in a pretty format.
@ -4543,9 +4543,4 @@ void __kmp_balanced_affinity( int tid, int nthreads )
# endif /* KMP_MIC */
#elif KMP_OS_DARWIN
// affinity not supported
#else
#error "Unknown or unsupported OS"
#endif // KMP_OS_WINDOWS || KMP_OS_LINUX
#endif // KMP_AFFINITY_SUPPORTED

View File

@ -66,7 +66,7 @@
#if KMP_OS_UNIX
#include <stdlib.h> // getenv, setenv, unsetenv.
#include <string.h> // strlen, strcpy.
#if KMP_OS_LINUX
#if KMP_OS_LINUX || KMP_OS_FREEBSD
extern char * * environ;
#elif KMP_OS_DARWIN
#include <crt_externs.h>

View File

@ -222,7 +222,7 @@ FTN_GET_LIBRARY (void)
int FTN_STDCALL
FTN_SET_AFFINITY( void **mask )
{
#if defined(KMP_STUB) || !(KMP_OS_WINDOWS || KMP_OS_LINUX)
#if defined(KMP_STUB) || !KMP_AFFINITY_SUPPORTED
return -1;
#else
if ( ! TCR_4(__kmp_init_middle) ) {
@ -235,7 +235,7 @@ FTN_SET_AFFINITY( void **mask )
int FTN_STDCALL
FTN_GET_AFFINITY( void **mask )
{
#if defined(KMP_STUB) || !(KMP_OS_WINDOWS || KMP_OS_LINUX)
#if defined(KMP_STUB) || !KMP_AFFINITY_SUPPORTED
return -1;
#else
if ( ! TCR_4(__kmp_init_middle) ) {
@ -248,7 +248,7 @@ FTN_GET_AFFINITY( void **mask )
int FTN_STDCALL
FTN_GET_AFFINITY_MAX_PROC( void )
{
#if defined(KMP_STUB) || !(KMP_OS_WINDOWS || KMP_OS_LINUX)
#if defined(KMP_STUB) || !KMP_AFFINITY_SUPPORTED
return 0;
#else
//
@ -273,7 +273,7 @@ FTN_GET_AFFINITY_MAX_PROC( void )
void FTN_STDCALL
FTN_CREATE_AFFINITY_MASK( void **mask )
{
#if defined(KMP_STUB) || !(KMP_OS_WINDOWS || KMP_OS_LINUX)
#if defined(KMP_STUB) || !KMP_AFFINITY_SUPPORTED
*mask = NULL;
#else
//
@ -290,7 +290,7 @@ FTN_CREATE_AFFINITY_MASK( void **mask )
void FTN_STDCALL
FTN_DESTROY_AFFINITY_MASK( void **mask )
{
#if defined(KMP_STUB) || !(KMP_OS_WINDOWS || KMP_OS_LINUX)
#if defined(KMP_STUB) || !KMP_AFFINITY_SUPPORTED
// Nothing
#else
//
@ -312,7 +312,7 @@ FTN_DESTROY_AFFINITY_MASK( void **mask )
int FTN_STDCALL
FTN_SET_AFFINITY_MASK_PROC( int KMP_DEREF proc, void **mask )
{
#if defined(KMP_STUB) || !(KMP_OS_WINDOWS || KMP_OS_LINUX)
#if defined(KMP_STUB) || !KMP_AFFINITY_SUPPORTED
return -1;
#else
if ( ! TCR_4(__kmp_init_middle) ) {
@ -325,7 +325,7 @@ FTN_SET_AFFINITY_MASK_PROC( int KMP_DEREF proc, void **mask )
int FTN_STDCALL
FTN_UNSET_AFFINITY_MASK_PROC( int KMP_DEREF proc, void **mask )
{
#if defined(KMP_STUB) || !(KMP_OS_WINDOWS || KMP_OS_LINUX)
#if defined(KMP_STUB) || !KMP_AFFINITY_SUPPORTED
return -1;
#else
if ( ! TCR_4(__kmp_init_middle) ) {
@ -338,7 +338,7 @@ FTN_UNSET_AFFINITY_MASK_PROC( int KMP_DEREF proc, void **mask )
int FTN_STDCALL
FTN_GET_AFFINITY_MASK_PROC( int KMP_DEREF proc, void **mask )
{
#if defined(KMP_STUB) || !(KMP_OS_WINDOWS || KMP_OS_LINUX)
#if defined(KMP_STUB) || !KMP_AFFINITY_SUPPORTED
return -1;
#else
if ( ! TCR_4(__kmp_init_middle) ) {
@ -408,7 +408,7 @@ xexpand(FTN_GET_THREAD_NUM)( void )
#else
int gtid;
#if KMP_OS_DARWIN
#if KMP_OS_DARWIN || KMP_OS_FREEBSD
gtid = __kmp_entry_gtid();
#elif KMP_OS_WINDOWS
if (!__kmp_init_parallel ||

View File

@ -815,7 +815,7 @@ sys_error(
// not issue warning if strerror_r() returns `int' instead of expected `char *'.
message = __kmp_str_format( "%s", err_msg );
#else // OS X*
#else // OS X*, FreeBSD etc.
// XSI version of strerror_r.

View File

@ -63,9 +63,10 @@
/* ---------------------- Operating system recognition ------------------- */
#define KMP_OS_LINUX 0
#define KMP_OS_FREEBSD 0
#define KMP_OS_DARWIN 0
#define KMP_OS_WINDOWS 0
#define KMP_OS_UNIX 0 /* disjunction of KMP_OS_LINUX with KMP_OS_DARWIN */
#define KMP_OS_UNIX 0 /* disjunction of KMP_OS_LINUX, KMP_OS_DARWIN etc. */
#define KMP_ARCH_X86 0
#define KMP_ARCH_X86_64 0
@ -85,11 +86,16 @@
# define KMP_OS_LINUX 1
#endif
#if (1 != KMP_OS_LINUX + KMP_OS_DARWIN + KMP_OS_WINDOWS)
#if ( defined __FreeBSD__ )
# undef KMP_OS_FREEBSD
# define KMP_OS_FREEBSD 1
#endif
#if (1 != KMP_OS_LINUX + KMP_OS_FREEBSD + KMP_OS_DARWIN + KMP_OS_WINDOWS)
# error Unknown OS
#endif
#if KMP_OS_LINUX || KMP_OS_DARWIN
#if KMP_OS_LINUX || KMP_OS_FREEBSD || KMP_OS_DARWIN
# undef KMP_OS_UNIX
# define KMP_OS_UNIX 1
#endif
@ -498,7 +504,7 @@ extern kmp_real64 __kmp_xchg_real64( volatile kmp_real64 *p, kmp_real64 v );
# define KMP_XCHG_REAL64(p, v) __kmp_xchg_real64( (p), (v) );
#elif (KMP_ASM_INTRINS && (KMP_OS_LINUX || KMP_OS_DARWIN)) || !(KMP_ARCH_X86 || KMP_ARCH_X86_64)
#elif (KMP_ASM_INTRINS && (KMP_OS_LINUX || KMP_OS_FREEBSD || KMP_OS_DARWIN)) || !(KMP_ARCH_X86 || KMP_ARCH_X86_64)
/* cast p to correct type so that proper intrinsic will be used */
# define KMP_TEST_THEN_INC32(p) __sync_fetch_and_add( (kmp_int32 *)(p), 1 )
@ -780,7 +786,7 @@ typedef void (*microtask_t)( int *gtid, int *npr, ... );
// Warning levels
enum kmp_warnings_level {
kmp_warnings_off = 0, /* No warnings */
kmp_warnings_low, /* Minimal warmings (default) */
kmp_warnings_low, /* Minimal warnings (default) */
kmp_warnings_explicit = 6, /* Explicitly set to ON - more warnings */
kmp_warnings_verbose /* reserved */
};

View File

@ -4558,11 +4558,11 @@ __kmp_register_root( int initial_thread )
KMP_DEBUG_ASSERT( root->r.r_hot_team->t.t_bar[ bs_forkjoin_barrier ].b_arrived == KMP_INIT_BARRIER_STATE );
#if KMP_OS_WINDOWS || KMP_OS_LINUX
#if KMP_AFFINITY_SUPPORTED
if ( TCR_4(__kmp_init_middle) ) {
__kmp_affinity_set_init_mask( gtid, TRUE );
}
#endif /* KMP_OS_WINDOWS || KMP_OS_LINUX */
#endif /* KMP_AFFINITY_SUPPORTED */
__kmp_root_counter ++;
@ -8150,9 +8150,9 @@ __kmp_cleanup( void )
}
if (TCR_4(__kmp_init_middle)) {
#if KMP_OS_WINDOWS || KMP_OS_LINUX
#if KMP_AFFINITY_SUPPORTED
__kmp_affinity_uninitialize();
#endif /* KMP_OS_WINDOWS || KMP_OS_LINUX */
#endif /* KMP_AFFINITY_SUPPORTED */
TCW_4(__kmp_init_middle, FALSE);
}
@ -8452,7 +8452,7 @@ __kmp_determine_reduction_method( ident_t *loc, kmp_int32 global_tid,
#if KMP_ARCH_X86_64
#if KMP_OS_LINUX || KMP_OS_WINDOWS || KMP_OS_DARWIN
#if KMP_OS_LINUX || KMP_OS_FREEBSD || KMP_OS_WINDOWS || KMP_OS_DARWIN
#if KMP_MIC
#define REDUCTION_TEAMSIZE_CUTOFF 8
#else // KMP_MIC
@ -8471,7 +8471,7 @@ __kmp_determine_reduction_method( ident_t *loc, kmp_int32 global_tid,
}
#else
#error "Unknown or unsupported OS"
#endif // KMP_OS_LINUX || KMP_OS_WINDOWS || KMP_OS_DARWIN
#endif // KMP_OS_LINUX || KMP_OS_FREEBSD || KMP_OS_WINDOWS || KMP_OS_DARWIN
#elif KMP_ARCH_X86 || KMP_ARCH_ARM

View File

@ -1579,7 +1579,7 @@ __kmp_stg_parse_cpuinfo_file( char const * name, char const * value, void * data
#if KMP_OS_LINUX || KMP_OS_WINDOWS
__kmp_stg_parse_str( name, value, & __kmp_cpuinfo_file );
K_DIAG( 1, ( "__kmp_cpuinfo_file == %s\n", __kmp_cpuinfo_file ) );
#elif KMP_OS_DARWIN
#elif !KMP_AFFINITY_SUPPORTED
// affinity not supported
#else
#error "Unknown or unsupported OS"
@ -3068,7 +3068,7 @@ __kmp_stg_print_topology_method( kmp_str_buf_t * buffer, char const * name,
# endif /* KMP_DEBUG */
} // __kmp_stg_print_topology_method
#elif KMP_OS_DARWIN
#elif !KMP_AFFINITY_SUPPORTED
// affinity not supported
#else
#error "Unknown or unsupported OS"
@ -4429,7 +4429,7 @@ static kmp_setting_t __kmp_stg_table[] = {
{ "KMP_TOPOLOGY_METHOD", __kmp_stg_parse_topology_method, __kmp_stg_print_topology_method, NULL, 0, 0 },
#elif KMP_OS_DARWIN
#elif !KMP_AFFINITY_SUPPORTED
//
// KMP_AFFINITY is not supported on OS X*, nor is OMP_PLACES.
@ -4686,7 +4686,7 @@ __kmp_stg_init( void
rivals[ i ++ ] = NULL;
}
#elif KMP_OS_DARWIN
#elif !KMP_AFFINITY_SUPPORTED
// KMP_AFFINITY not supported, so OMP_PROC_BIND has no rivals.
// OMP_PLACES not supported yet.
#else
@ -4768,7 +4768,7 @@ __kmp_stg_check_rivals( // 0 -- Ok, 1 -- errors found.
for ( ; strcmp( rivals[ i ]->name, name ) != 0; i++ ) {
KMP_DEBUG_ASSERT( rivals[ i ] != NULL );
#if KMP_OS_LINUX || KMP_OS_WINDOWS
#if KMP_AFFINITY_SUPPORTED
if ( rivals[ i ] == __kmp_affinity_notype ) {
//
// If KMP_AFFINITY is specified without a type name,
@ -4885,7 +4885,7 @@ __kmp_env_initialize( char const * string ) {
__kmp_stg_parse( name, value );
}; // if
#if KMP_OS_LINUX || KMP_OS_WINDOWS
#if KMP_AFFINITY_SUPPORTED
//
// Special case. KMP_AFFINITY is not a rival to other affinity env vars
// if no affinity type is specified. We want to allow
@ -4928,7 +4928,7 @@ __kmp_env_initialize( char const * string ) {
}
# undef FIND
}
#endif /* KMP_OS_LINUX || KMP_OS_WINDOWS */
#endif /* KMP_AFFINITY_SUPPORTED */
#if OMP_40_ENABLED
//
@ -4967,7 +4967,7 @@ __kmp_env_initialize( char const * string ) {
KMP_DEBUG_ASSERT( __kmp_user_lock_kind != lk_default );
}
#if KMP_OS_LINUX || KMP_OS_WINDOWS
#if KMP_AFFINITY_SUPPORTED
if ( ! TCR_4(__kmp_init_middle) ) {
//
// Determine if the machine/OS is actually capable of supporting
@ -4999,10 +4999,10 @@ __kmp_env_initialize( char const * string ) {
}
else if ( __kmp_nested_proc_bind.bind_types[0] == proc_bind_default ) {
//
// On Windows* OS & Linux* OS, the default is to use the KMP_AFFINITY
// mechanism. On OS X*, it is none.
// Where supported the default is to use the KMP_AFFINITY
// mechanism. On OS X* etc. it is none.
//
# if KMP_OS_WINDOWS || KMP_OS_LINUX
# if KMP_AFFINITY_SUPPORTED
__kmp_nested_proc_bind.bind_types[0] = proc_bind_intel;
# else
__kmp_nested_proc_bind.bind_types[0] = proc_bind_false;
@ -5136,11 +5136,7 @@ __kmp_env_initialize( char const * string ) {
# endif
}
#elif KMP_OS_DARWIN
// affinity not supported
#else
#error "Unknown or unsupported OS"
#endif /* KMP_OS_LINUX || KMP_OS_WINDOWS */
#endif /* KMP_AFFINITY_SUPPORTED */
if ( __kmp_version ) {
__kmp_print_version_1();

View File

@ -169,7 +169,7 @@ __kmp_print_version_1( void )
& buffer,
"%sthread affinity support: %s\n",
KMP_VERSION_PREF_STR,
#if KMP_OS_WINDOWS || KMP_OS_LINUX
#if KMP_AFFINITY_SUPPORTED
(
KMP_AFFINITY_CAPABLE()
?

View File

@ -105,6 +105,8 @@
#if KMP_OS_WINDOWS
#include <malloc.h> // Windows* OS: _alloca() declared in "malloc.h".
#define alloca _alloca // Allow to use alloca() with no underscore.
#elif KMP_OS_FREEBSD
// Declared in "stdlib.h".
#elif KMP_OS_UNIX
#include <alloca.h> // Linux* OS and OS X*: alloc() declared in "alloca".
#else

View File

@ -355,10 +355,14 @@ ifeq "$(os)" "lin"
# to remove dependency on libgcc_s:
ifeq "$(c)" "gcc"
ld-flags-dll += -static-libgcc
ld-flags-extra += -Wl,-ldl
ifneq "$(omp_os)" "freebsd"
ld-flags-extra += -Wl,-ldl
endif
endif
ifeq "$(c)" "clang"
ld-flags-extra += -Wl,-ldl
ifneq "$(omp_os)" "freebsd"
ld-flags-extra += -Wl,-ldl
endif
endif
ifeq "$(arch)" "32"
ifeq "$(filter gcc clang,$(c))" ""
@ -1247,7 +1251,7 @@ ifneq "$(os)" "lrb"
# On Linux* OS and OS X* the test is good enough because GNU compiler knows nothing
# about libirc and Intel compiler private lib directories, but we will grep verbose linker
# output just in case.
tt-c = gcc
tt-c = cc
ifeq "$(os)" "lin" # GCC on OS X* does not recognize -pthread.
tt-c-flags += -pthread
endif
@ -1261,12 +1265,12 @@ ifneq "$(os)" "lrb"
# Explicitly add dl library to avoid failure.
tt-ld-flags += -ldl
endif
ifeq "$(os)" "lin"
tt-ld-flags-v += -Wl,--verbose
tt-env += LD_LIBRARY_PATH=".:$(LD_LIBRARY_PATH)"
else # mac
ifeq "$(os)" "mac"
tt-ld-flags-v += -Wl,-t
tt-env += DYLD_LIBRARY_PATH=".:$(DYLD_LIBRARY_PATH)"
else # lin
tt-ld-flags-v += -Wl,--verbose
tt-env += LD_LIBRARY_PATH=".:$(LD_LIBRARY_PATH)"
endif
endif
tt-c-flags += $(tt-c-flags-rt)
@ -1430,6 +1434,12 @@ ifneq "$(filter %-dyna win-%,$(os)-$(LINK_TYPE))" ""
td_exp += uuid
endif
endif
ifeq "$(omp_os)" "freebsd"
td_exp =
td_exp += libc.so.7
td_exp += libthr.so.3
td_exp += libunwind.so.5
endif
test-deps/.test : $(lib_file) $(tools_dir)check-depends.pl test-deps/.dir .rebuild
$(target)

View File

@ -22,7 +22,9 @@
#include "kmp_i18n.h"
#include "kmp_io.h"
#include <alloca.h>
#if !KMP_OS_FREEBSD
# include <alloca.h>
#endif
#include <unistd.h>
#include <math.h> // HUGE_VAL.
#include <sys/time.h>
@ -48,6 +50,9 @@
#elif KMP_OS_DARWIN
# include <sys/sysctl.h>
# include <mach/mach.h>
#elif KMP_OS_FREEBSD
# include <sys/sysctl.h>
# include <pthread_np.h>
#endif
@ -596,7 +601,7 @@ static kmp_int32
__kmp_set_stack_info( int gtid, kmp_info_t *th )
{
int stack_data;
#if KMP_OS_LINUX
#if KMP_OS_LINUX || KMP_OS_FREEBSD
/* Linux* OS only -- no pthread_getattr_np support on OS X* */
pthread_attr_t attr;
int status;
@ -611,8 +616,13 @@ __kmp_set_stack_info( int gtid, kmp_info_t *th )
/* Fetch the real thread attributes */
status = pthread_attr_init( &attr );
KMP_CHECK_SYSFAIL( "pthread_attr_init", status );
#if KMP_OS_FREEBSD
status = pthread_attr_get_np( pthread_self(), &attr );
KMP_CHECK_SYSFAIL( "pthread_attr_get_np", status );
#else
status = pthread_getattr_np( pthread_self(), &attr );
KMP_CHECK_SYSFAIL( "pthread_getattr_np", status );
#endif
status = pthread_attr_getstack( &attr, &addr, &size );
KMP_CHECK_SYSFAIL( "pthread_attr_getstack", status );
KA_TRACE( 60, ( "__kmp_set_stack_info: T#%d pthread_attr_getstack returned size: %lu, "
@ -629,16 +639,14 @@ __kmp_set_stack_info( int gtid, kmp_info_t *th )
TCW_PTR(th->th.th_info.ds.ds_stacksize, size);
TCW_4(th->th.th_info.ds.ds_stackgrow, FALSE);
return TRUE;
} else {
#endif /* KMP_OS_LINUX */
/* Use incremental refinement starting from initial conservative estimate */
TCW_PTR(th->th.th_info.ds.ds_stacksize, 0);
TCW_PTR(th -> th.th_info.ds.ds_stackbase, &stack_data);
TCW_4(th->th.th_info.ds.ds_stackgrow, TRUE);
return FALSE;
#if KMP_OS_LINUX
}
#endif /* KMP_OS_LINUX */
#endif /* KMP_OS_LINUX || KMP_OS_FREEBSD */
/* Use incremental refinement starting from initial conservative estimate */
TCW_PTR(th->th.th_info.ds.ds_stacksize, 0);
TCW_PTR(th -> th.th_info.ds.ds_stackbase, &stack_data);
TCW_4(th->th.th_info.ds.ds_stackgrow, TRUE);
return FALSE;
}
static void*
@ -663,12 +671,8 @@ __kmp_launch_worker( void *thr )
__kmp_itt_thread_name( gtid );
#endif /* USE_ITT_BUILD */
#if KMP_OS_LINUX
#if KMP_AFFINITY_SUPPORTED
__kmp_affinity_set_init_mask( gtid, FALSE );
#elif KMP_OS_DARWIN
// affinity not supported
#else
#error "Unknown or unsupported OS"
#endif
#ifdef KMP_CANCEL_THREADS
@ -696,7 +700,7 @@ __kmp_launch_worker( void *thr )
KMP_CHECK_SYSFAIL( "pthread_sigmask", status );
#endif /* KMP_BLOCK_SIGNALS */
#if KMP_OS_LINUX
#if KMP_OS_LINUX || KMP_OS_FREEBSD
if ( __kmp_stkoffset > 0 && gtid > 0 ) {
padding = alloca( gtid * __kmp_stkoffset );
}
@ -2000,6 +2004,16 @@ __kmp_get_xproc( void ) {
KMP_INFORM( AssumedNumCPU );
}; // if
#elif KMP_OS_FREEBSD
int mib[] = { CTL_HW, HW_NCPU };
size_t len = sizeof( r );
if ( sysctl( mib, 2, &r, &len, NULL, 0 ) < 0 ) {
r = 0;
KMP_WARNING( CantGetNumAvailCPU );
KMP_INFORM( AssumedNumCPU );
}
#else
#error "Unknown or unsupported OS."
@ -2121,12 +2135,8 @@ __kmp_runtime_destroy( void )
if ( status != 0 && status != EBUSY ) {
KMP_SYSFAIL( "pthread_cond_destroy", status );
}
#if KMP_OS_LINUX
#if KMP_AFFINITY_SUPPORTED
__kmp_affinity_uninitialize();
#elif KMP_OS_DARWIN
// affinity not supported
#else
#error "Unknown or unsupported OS"
#endif
__kmp_init_runtime = FALSE;
@ -2243,6 +2253,11 @@ __kmp_is_address_mapped( void * addr ) {
found = 1;
}; // if
#elif KMP_OS_FREEBSD
// FIXME(FreeBSD): Implement this.
found = 1;
#else
#error "Unknown or unsupported OS"

View File

@ -26,6 +26,9 @@ ifndef omp_os
ifeq ($(OS), Linux)
export omp_os=linux
endif
ifeq ($(OS), FreeBSD)
export omp_os=freebsd
endif
ifeq ($(OS), Darwin)
export omp_os=macos
endif

View File

@ -0,0 +1,13 @@
#
#//===----------------------------------------------------------------------===//
#//
#// The LLVM Compiler Infrastructure
#//
#// This file is dual licensed under the MIT and the University of Illinois Open
#// Source Licenses. See LICENSE.txt for details.
#//
#//===----------------------------------------------------------------------===//
#
include tools/linux.inc

View File

@ -170,6 +170,9 @@ sub target_options() {
if ( 0 ) {
} elsif ( $operating_system eq "GNU/Linux" ) {
$_host_os = "lin";
} elsif ( $operating_system eq "FreeBSD" ) {
# Host OS resembles Linux.
$_host_os = "lin";
} elsif ( $operating_system eq "Darwin" ) {
$_host_os = "mac";
} elsif ( $operating_system eq "MS Windows" ) {

View File

@ -139,11 +139,11 @@ $values{ processor } = $values{ machine };
# hardware_platform.
if ( 0 ) {
} elsif ( $^O eq "linux" ) {
} elsif ( $^O eq "linux" or $^O eq "freebsd" ) {
if ( 0 ) {
} elsif ( $values{ machine } =~ m{\Ai[3456]86\z} ) {
$values{ hardware_platform } = "i386";
} elsif ( $values{ machine } =~ m{\Ax86_64\z} ) {
} elsif ( $values{ machine } =~ m{\A(x86_64|amd64)\z} ) {
$values{ hardware_platform } = "x86_64";
} elsif ( $values{ machine } =~ m{\Aarmv7\D*\z} ) {
$values{ hardware_platform } = "arm";
@ -370,8 +370,10 @@ if ( 0 ) {
# $values{ operating_system_update } = $os_name[ 1 ];
} elsif ( $values{ kernel_name } =~ m{\ACYGWIN_NT-} ) {
$values{ operating_system } = "MS Windows";
} elsif ( $values{ kernel_name } =~ m{\AFreeBSD} ) {
$values{ operating_system } = "FreeBSD";
} else {
die "Unsuppoprted kernel_name (\"$values{ kernel_name }\") returned by POSIX::uname(); stopped";
die "Unsupported kernel_name (\"$values{ kernel_name }\") returned by POSIX::uname(); stopped";
}; # if
# host_name and domain_name