-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
286 additions
and
315 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
#ifndef _RANDOMDGEN__CONFIG_H_ | ||
#define _RANDOMDGEN__CONFIG_H_ | ||
|
||
#include <math.h> | ||
#include <stddef.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
|
||
#if defined(_WIN32) && defined(_MSC_VER) | ||
|
||
/* windows msvc */ | ||
|
||
#ifndef MSVCFORCEINLINE | ||
#ifndef _DEBUG | ||
#define MSVCFORCEINLINE __forceinline | ||
#else | ||
#define MSVCFORCEINLINE | ||
#endif | ||
#endif | ||
|
||
#ifndef inline | ||
#if _MSC_VER < 1600 | ||
/* msvs 2008 and earlier */ | ||
#define inline _inline MSVCFORCEINLINE | ||
#else | ||
/* msvs 2010 and later */ | ||
#define inline __inline MSVCFORCEINLINE | ||
#endif | ||
#define INLINE inline | ||
#else | ||
#define INLINE __inline MSVCFORCEINLINE | ||
#endif | ||
|
||
#if _MSC_VER < 1600 | ||
|
||
/* msvs 2008 and earlier */ | ||
#include "inttypes.h" | ||
#include "stdbool.h" | ||
#include "stdint.h" | ||
|
||
#elif _MSC_VER < 1800 | ||
|
||
/* msvs 2010-2012 */ | ||
#include "inttypes.h" | ||
#include "stdbool.h" | ||
#include <stdint.h> | ||
|
||
#else | ||
|
||
/* msvs 2013 and later */ | ||
#include <inttypes.h> | ||
#include <stdbool.h> | ||
#include <stdint.h> | ||
|
||
#endif | ||
|
||
#define ALIGN_WINDOWS __declspec(align(16)) | ||
#define ALIGN_GCC_CLANG | ||
|
||
#else | ||
|
||
#include <inttypes.h> | ||
#include <stdbool.h> | ||
#include <stdint.h> | ||
|
||
#define INLINE inline | ||
|
||
#define ALIGN_WINDOWS | ||
#define ALIGN_GCC_CLANG __attribute__((aligned(16))) | ||
|
||
#endif | ||
|
||
#if defined(__MINGW32__) | ||
#include <x86intrin.h> | ||
#endif | ||
|
||
#ifdef _WIN32 | ||
#define UNLIKELY(x) ((x)) | ||
#else | ||
#define UNLIKELY(x) (__builtin_expect((x), 0)) | ||
#endif | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#ifndef _RANDOMDGEN__CONFIG_NUMPY_H_ | ||
#define _RANDOMDGEN__CONFIG_NUMPY_H_ | ||
|
||
#ifndef RANDOMGEN_STANDALONE | ||
|
||
#include "Python.h" | ||
#include "numpy/npy_common.h" | ||
#include "numpy/npy_math.h" | ||
|
||
#else | ||
|
||
#include "standalone/aligned_malloc.h" | ||
#include "standalone/npy_common.h" | ||
#include "standalone/npy_math.h" | ||
#include "standalone/python.h" | ||
|
||
#endif | ||
|
||
#ifndef NPY_MEMALIGN | ||
|
||
#define NPY_MEMALIGN 64 /* 16 for SSE2, 32 for AVX, 64 for Xeon Phi */ | ||
|
||
#endif | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#ifndef _RANDOMGEN__IMMINTRIN_H_ | ||
#define _RANDOMGEN__IMMINTRIN_H_ | ||
|
||
#undef HAVE_IMMINTRIN | ||
#if defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || defined(_M_IX86) | ||
#if defined(_MSC_VER) && defined(_WIN32) | ||
#if _MSC_VER >= 1900 | ||
#include <immintrin.h> | ||
#define HAVE_IMMINTRIN 1 | ||
#endif | ||
#else | ||
#include <immintrin.h> | ||
#define HAVE_IMMINTRIN 1 | ||
#endif | ||
#endif | ||
|
||
#endif /* _RANDOMGEN__IMMINTRIN_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#ifndef Py_PYTHON_H | ||
#define Py_PYTHON_H | ||
|
||
#include <inttypes.h> | ||
|
||
typedef uintptr_t Py_uintptr_t; | ||
typedef intptr_t Py_intptr_t; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#ifndef _RANDOMDGEN__ALIGNED_MALLOC_H_ | ||
#define _RANDOMDGEN__ALIGNED_MALLOC_H_ | ||
|
||
#include <stdlib.h> | ||
#include <malloc.h> | ||
#include <string.h> | ||
|
||
static inline void *_aligned_calloc(size_t n, size_t size, size_t alignment) { | ||
|
||
void *p = 0; | ||
|
||
size_t asize = n * size; | ||
|
||
p = _aligned_malloc(asize, alignment); | ||
|
||
if (p) { | ||
memset(p, 0, asize); | ||
} | ||
|
||
return p; | ||
|
||
} | ||
|
||
#define malloc_aligned(a) _aligned_calloc(1,(a),NPY_MEMALIGN) | ||
#define calloc_aligned(a, b) _aligned_calloc((a),(b),NPY_MEMALIGN) | ||
#define free_aligned(a) _aligned_free(a) | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#ifndef _NPY_COMMON_H_ | ||
#define _NPY_COMMON_H_ | ||
|
||
#include "Python.h" | ||
|
||
#if defined(_MSC_VER) | ||
#define NPY_INLINE __inline | ||
#elif defined(__GNUC__) | ||
#if defined(__STRICT_ANSI__) | ||
#define NPY_INLINE __inline__ | ||
#else | ||
#define NPY_INLINE inline | ||
#endif | ||
#else | ||
#define NPY_INLINE | ||
#endif | ||
|
||
#define NPY_SIZEOF_LONG SIZEOF_LONG | ||
|
||
typedef double npy_double; | ||
|
||
typedef unsigned long npy_uint32; | ||
|
||
typedef unsigned char npy_bool; | ||
#define NPY_FALSE 0 | ||
#define NPY_TRUE 1 | ||
|
||
typedef Py_intptr_t npy_intp; | ||
typedef Py_uintptr_t npy_uintp; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#ifndef __NPY_MATH_C99_H_ | ||
#define __NPY_MATH_C99_H_ | ||
|
||
#include <math.h> | ||
|
||
#include "npy_common.h" | ||
|
||
#if defined(_MSC_VER) && (_MSC_VER < 1900) | ||
#define npy_isnan(x) _isnan((x)) | ||
#else | ||
#define npy_isnan(x) isnan(x) | ||
#endif | ||
|
||
NPY_INLINE static float __npy_nanf(void) | ||
{ | ||
const union { npy_uint32 __i; float __f;} __bint = {0x7fc00000UL}; | ||
return __bint.__f; | ||
} | ||
|
||
#define NPY_NANF __npy_nanf() | ||
|
||
#define NPY_NAN ((npy_double)NPY_NANF) | ||
|
||
#endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#ifndef _RANDOMDGEN__STDBOOL_H | ||
#define _RANDOMDGEN__STDBOOL_H | ||
|
||
#if defined(_WIN32) && defined(_MSC_VER) | ||
#ifndef __bool_true_false_are_defined | ||
#define __bool_true_false_are_defined | ||
typedef int bool; | ||
#define false 0 | ||
#define true 1 | ||
#endif | ||
#endif | ||
|
||
#endif |
Oops, something went wrong.