From a544e9810ef34b8eb39f7856f500f25fce1cd207 Mon Sep 17 00:00:00 2001 From: NightRa Date: Sat, 18 Jul 2015 22:52:08 +0300 Subject: Fix windows support --- packages/base/src/Internal/C/windows_random_r.h | 39 +++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 packages/base/src/Internal/C/windows_random_r.h (limited to 'packages/base/src/Internal/C/windows_random_r.h') diff --git a/packages/base/src/Internal/C/windows_random_r.h b/packages/base/src/Internal/C/windows_random_r.h new file mode 100644 index 0000000..c05caa7 --- /dev/null +++ b/packages/base/src/Internal/C/windows_random_r.h @@ -0,0 +1,39 @@ +#if defined(_WIN32) || defined(WIN32) + +#ifndef MYRANDOM_H +#define MYRANDOM_H + +#include + +#define NULL 0 + +#define EINVAL 23 + +typedef int int32_t; + +struct random_data +{ + int32_t *fptr; /* Front pointer. */ + int32_t *rptr; /* Rear pointer. */ + int32_t *state; /* Array of state values. */ + int rand_type; /* Type of random number generator. */ + int rand_deg; /* Degree of random number generator. */ + int rand_sep; /* Distance between front and rear. */ + int32_t *end_ptr; /* Pointer behind state table. */ +}; + + +#define errno my_errno +extern int my_errno; + +static inline void __set_errno(int err) { my_errno = err; }; + +int random_r (struct random_data *buf, int32_t *result); + +int initstate_r (unsigned int seed, + char *arg_state, + /*unsigned long*/ size_t n, + struct random_data *buf); + +#endif +#endif \ No newline at end of file -- cgit v1.2.3 From 456f54adfbb8a91bce994ba2ee9045f94d46bf77 Mon Sep 17 00:00:00 2001 From: NightRa Date: Sat, 18 Jul 2015 23:47:08 +0300 Subject: Correct paths to C sources --- packages/base/hmatrix.cabal | 6 +++--- packages/base/src/Internal/C/windows_random_r.c | 4 ++-- packages/base/src/Internal/C/windows_random_r.h | 20 ++++++++------------ 3 files changed, 13 insertions(+), 17 deletions(-) (limited to 'packages/base/src/Internal/C/windows_random_r.h') diff --git a/packages/base/hmatrix.cabal b/packages/base/hmatrix.cabal index 5e4f3ce..93ca3d7 100644 --- a/packages/base/hmatrix.cabal +++ b/packages/base/hmatrix.cabal @@ -25,7 +25,7 @@ build-type: Simple extra-source-files: THANKS.md CHANGELOG extra-source-files: src/Internal/C/lapack-aux.h - src/C/windows_random_r.h + src/Internal/C/windows_random_r.h flag openblas description: Link with OpenBLAS (https://github.com/xianyi/OpenBLAS) optimized libraries. @@ -75,10 +75,10 @@ library Internal.Util Internal.Modular Internal.Static - + C-sources: src/Internal/C/lapack-aux.c src/Internal/C/vector-aux.c - src/C/windows_random_r.c + src/Internal/C/windows_random_r.c extensions: ForeignFunctionInterface, diff --git a/packages/base/src/Internal/C/windows_random_r.c b/packages/base/src/Internal/C/windows_random_r.c index c16d96f..872cb2e 100644 --- a/packages/base/src/Internal/C/windows_random_r.c +++ b/packages/base/src/Internal/C/windows_random_r.c @@ -53,7 +53,7 @@ * Rewritten to be reentrant by Ulrich Drepper, 1995 */ -#include "myrandom.h" +#include "windows_random_r.h" /* An improved random number generation package. In addition to the standard rand()/srand() like interface, this package also has a special state info @@ -388,5 +388,5 @@ int random_r (struct random_data *buf, int32_t *result) return -1; } -int my_errno; +int windows_random_r; #endif \ No newline at end of file diff --git a/packages/base/src/Internal/C/windows_random_r.h b/packages/base/src/Internal/C/windows_random_r.h index c05caa7..4f4d32f 100644 --- a/packages/base/src/Internal/C/windows_random_r.h +++ b/packages/base/src/Internal/C/windows_random_r.h @@ -1,32 +1,28 @@ #if defined(_WIN32) || defined(WIN32) -#ifndef MYRANDOM_H -#define MYRANDOM_H +#ifndef WINDOWS_RANDOM_R_H +#define WINDOWS_RANDOM_R_H #include -#define NULL 0 - #define EINVAL 23 typedef int int32_t; struct random_data { - int32_t *fptr; /* Front pointer. */ - int32_t *rptr; /* Rear pointer. */ - int32_t *state; /* Array of state values. */ + int *fptr; /* Front pointer. */ + int *rptr; /* Rear pointer. */ + int *state; /* Array of state values. */ int rand_type; /* Type of random number generator. */ int rand_deg; /* Degree of random number generator. */ int rand_sep; /* Distance between front and rear. */ - int32_t *end_ptr; /* Pointer behind state table. */ + int *end_ptr; /* Pointer behind state table. */ }; +extern int windows_random_r_errno; -#define errno my_errno -extern int my_errno; - -static inline void __set_errno(int err) { my_errno = err; }; +static inline void __set_errno(int err) { windows_random_r_errno = err; }; int random_r (struct random_data *buf, int32_t *result); -- cgit v1.2.3