#if !defined(_MSC_VER)
#include <unistd.h>
+#elif _MSC_VER < 1900
+#define snprintf _snprintf
#endif
#include <time.h>
#endif
#endif
+#ifdef OS_HAIKU
+#define NO_SYSV_IPC
+#endif
+
#ifdef OS_WINDOWS
#ifdef ATOM
#define GOTO_ATOM ATOM
#include <time.h>
#include <unistd.h>
#include <math.h>
-#ifdef SMP
+#if defined(SMP) || defined(USE_LOCKING)
#include <pthread.h>
#endif
#endif
#define ALLOCA_ALIGN 63UL
-#define NUM_BUFFERS (MAX_CPU_NUMBER * 2 * MAX_PARALLEL_NUMBER)
+#define NUM_BUFFERS MAX(50,(MAX_CPU_NUMBER * 2 * MAX_PARALLEL_NUMBER))
#ifdef NEEDBUNDERSCORE
#define BLASFUNC(FUNC) FUNC##_
#error "You can't specify both LOCK operation!"
#endif
-#ifdef SMP
+#if defined(SMP) || defined(USE_LOCKING)
#define USE_PTHREAD_LOCK
#undef USE_PTHREAD_SPINLOCK
#endif
#ifdef USE64BITINT
typedef BLASLONG blasint;
+#if defined(OS_WINDOWS) && defined(__64BIT__)
+#define blasabs(x) llabs(x)
+#else
+#define blasabs(x) labs(x)
+#endif
#else
typedef int blasint;
+#define blasabs(x) abs(x)
#endif
#else
#ifdef USE64BITINT
#endif
#endif
+#ifdef POWER9
+#ifndef YIELDING
+#define YIELDING __asm__ __volatile__ ("nop;nop;nop;nop;nop;nop;nop;nop;\n");
+#endif
+#endif
/*
#ifdef PILEDRIVER
typedef char env_var_t[MAX_PATH];
#define readenv(p, n) 0
#else
-#ifdef OS_WINDOWS
+#if defined(OS_WINDOWS) && !defined(OS_CYGWIN_NT)
typedef char env_var_t[MAX_PATH];
#define readenv(p, n) GetEnvironmentVariable((LPCTSTR)(n), (LPTSTR)(p), sizeof(p))
#else
void gotoblas_profile_quit(void);
#ifdef USE_OPENMP
+
#ifndef C_MSVC
int omp_in_parallel(void);
int omp_get_num_procs(void);
__declspec(dllimport) int __cdecl omp_in_parallel(void);
__declspec(dllimport) int __cdecl omp_get_num_procs(void);
#endif
+
+#if (__STDC_VERSION__ >= 201112L)
+#if defined(C_GCC) && ( __GNUC__ < 7)
+// workaround for GCC bug 65467
+#ifndef _Atomic
+#define _Atomic volatile
+#endif
+#endif
+#include <stdatomic.h>
+#else
+#ifndef _Atomic
+#define _Atomic volatile
+#endif
+#endif
+
#else
#ifdef __ELF__
int omp_in_parallel (void) __attribute__ ((weak));