aboutsummaryrefslogtreecommitdiffstats
path: root/community/dsfmt/0001-dSFMT.patch
blob: 8048ab2565a62843d9e524d673814865391f749f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
From: Jakub Jirutka <jakub@jirutka.cz>
Date: Wed, 08 Jun 2016 20:49:00 +0200
Subject: [PATCH] Port patches from Julia

Patches copied from the Julia Language:

* https://github.com/JuliaLang/julia/blob/615f7ca7965fec2b57dddca88e3ba518384b18db/deps/patches/dSFMT.c.patch
* https://github.com/JuliaLang/julia/blob/615f7ca7965fec2b57dddca88e3ba518384b18db/deps/patches/dSFMT.h.patch

--- a/dSFMT.c	2012-06-29 03:24:27.000000000 -0400
+++ b/dSFMT.c	2012-12-20 12:45:45.000000000 -0500
@@ -32,13 +32,13 @@
 inline static uint32_t ini_func1(uint32_t x);
 inline static uint32_t ini_func2(uint32_t x);
 inline static void gen_rand_array_c1o2(dsfmt_t *dsfmt, w128_t *array,
-				       int size);
+				       ptrdiff_t size);
 inline static void gen_rand_array_c0o1(dsfmt_t *dsfmt, w128_t *array,
-				       int size);
+				       ptrdiff_t size);
 inline static void gen_rand_array_o0c1(dsfmt_t *dsfmt, w128_t *array,
-				       int size);
+				       ptrdiff_t size);
 inline static void gen_rand_array_o0o1(dsfmt_t *dsfmt, w128_t *array,
-				       int size);
+				       ptrdiff_t size);
 inline static int idxof(int i);
 static void initial_mask(dsfmt_t *dsfmt);
 static void period_certification(dsfmt_t *dsfmt);
@@ -142,8 +142,8 @@
  * @param size number of 128-bit pseudorandom numbers to be generated.
  */
 inline static void gen_rand_array_c1o2(dsfmt_t *dsfmt, w128_t *array,
-				       int size) {
-    int i, j;
+				       ptrdiff_t size) {
+    ptrdiff_t i, j;
     w128_t lung;
 
     lung = dsfmt->status[DSFMT_N];
@@ -180,8 +180,8 @@
  * @param size number of 128-bit pseudorandom numbers to be generated.
  */
 inline static void gen_rand_array_c0o1(dsfmt_t *dsfmt, w128_t *array,
-				       int size) {
-    int i, j;
+				       ptrdiff_t size) {
+    ptrdiff_t i, j;
     w128_t lung;
 
     lung = dsfmt->status[DSFMT_N];
@@ -223,8 +223,8 @@
  * @param size number of 128-bit pseudorandom numbers to be generated.
  */
 inline static void gen_rand_array_o0o1(dsfmt_t *dsfmt, w128_t *array,
-				       int size) {
-    int i, j;
+				       ptrdiff_t size) {
+    ptrdiff_t i, j;
     w128_t lung;
 
     lung = dsfmt->status[DSFMT_N];
@@ -266,8 +266,8 @@
  * @param size number of 128-bit pseudorandom numbers to be generated.
  */
 inline static void gen_rand_array_o0c1(dsfmt_t *dsfmt, w128_t *array,
-				       int size) {
-    int i, j;
+				       ptrdiff_t size) {
+    ptrdiff_t i, j;
     w128_t lung;
 
     lung = dsfmt->status[DSFMT_N];
@@ -453,7 +453,7 @@
  * memory. Mac OSX doesn't have these functions, but \b malloc of OSX
  * returns the pointer to the aligned memory block.
  */
-void dsfmt_fill_array_close1_open2(dsfmt_t *dsfmt, double array[], int size) {
+void dsfmt_fill_array_close1_open2(dsfmt_t *dsfmt, double array[], ptrdiff_t size) {
     assert(size % 2 == 0);
     assert(size >= DSFMT_N64);
     gen_rand_array_c1o2(dsfmt, (w128_t *)array, size / 2);
@@ -471,7 +471,7 @@
  * @param size the number of pseudorandom numbers to be generated.
  * see also \sa fill_array_close1_open2()
  */
-void dsfmt_fill_array_open_close(dsfmt_t *dsfmt, double array[], int size) {
+void dsfmt_fill_array_open_close(dsfmt_t *dsfmt, double array[], ptrdiff_t size) {
     assert(size % 2 == 0);
     assert(size >= DSFMT_N64);
     gen_rand_array_o0c1(dsfmt, (w128_t *)array, size / 2);
@@ -489,7 +489,7 @@
  * @param size the number of pseudorandom numbers to be generated.
  * see also \sa fill_array_close1_open2()
  */
-void dsfmt_fill_array_close_open(dsfmt_t *dsfmt, double array[], int size) {
+void dsfmt_fill_array_close_open(dsfmt_t *dsfmt, double array[], ptrdiff_t size) {
     assert(size % 2 == 0);
     assert(size >= DSFMT_N64);
     gen_rand_array_c0o1(dsfmt, (w128_t *)array, size / 2);
@@ -507,7 +507,7 @@
  * @param size the number of pseudorandom numbers to be generated.
  * see also \sa fill_array_close1_open2()
  */
-void dsfmt_fill_array_open_open(dsfmt_t *dsfmt, double array[], int size) {
+void dsfmt_fill_array_open_open(dsfmt_t *dsfmt, double array[], ptrdiff_t size) {
     assert(size % 2 == 0);
     assert(size >= DSFMT_N64);
     gen_rand_array_o0o1(dsfmt, (w128_t *)array, size / 2);
--- a/dSFMT.h	2012-06-29 03:24:27.000000000 -0400
+++ b/dSFMT.h	2012-12-20 12:35:44.000000000 -0500
@@ -40,6 +40,7 @@
 
 #include <stdio.h>
 #include <assert.h>
+#include <stddef.h>
 
 #if !defined(DSFMT_MEXP)
 #ifdef __GNUC__
@@ -178,16 +179,17 @@
 extern const int dsfmt_global_mexp;
 
 void dsfmt_gen_rand_all(dsfmt_t *dsfmt);
-void dsfmt_fill_array_open_close(dsfmt_t *dsfmt, double array[], int size);
-void dsfmt_fill_array_close_open(dsfmt_t *dsfmt, double array[], int size);
-void dsfmt_fill_array_open_open(dsfmt_t *dsfmt, double array[], int size);
-void dsfmt_fill_array_close1_open2(dsfmt_t *dsfmt, double array[], int size);
+void dsfmt_fill_array_open_close(dsfmt_t *dsfmt, double array[], ptrdiff_t size);
+void dsfmt_fill_array_close_open(dsfmt_t *dsfmt, double array[], ptrdiff_t size);
+void dsfmt_fill_array_open_open(dsfmt_t *dsfmt, double array[], ptrdiff_t size);
+void dsfmt_fill_array_close1_open2(dsfmt_t *dsfmt, double array[], ptrdiff_t size);
 void dsfmt_chk_init_gen_rand(dsfmt_t *dsfmt, uint32_t seed, int mexp);
 void dsfmt_chk_init_by_array(dsfmt_t *dsfmt, uint32_t init_key[],
                              int key_length, int mexp);
 const char *dsfmt_get_idstring(void);
 int dsfmt_get_min_array_size(void);
 
+/*
 #if defined(__GNUC__)
 #  define DSFMT_PRE_INLINE inline static
 #  define DSFMT_PST_INLINE __attribute__((always_inline))
@@ -198,6 +200,10 @@
 #  define DSFMT_PRE_INLINE inline static
 #  define DSFMT_PST_INLINE
 #endif
+*/
+#define DSFMT_PRE_INLINE
+#define DSFMT_PST_INLINE
+
 DSFMT_PRE_INLINE uint32_t dsfmt_genrand_uint32(dsfmt_t *dsfmt) DSFMT_PST_INLINE;
 DSFMT_PRE_INLINE double dsfmt_genrand_close1_open2(dsfmt_t *dsfmt)
     DSFMT_PST_INLINE;
@@ -212,13 +218,13 @@
 DSFMT_PRE_INLINE double dsfmt_gv_genrand_close_open(void) DSFMT_PST_INLINE;
 DSFMT_PRE_INLINE double dsfmt_gv_genrand_open_close(void) DSFMT_PST_INLINE;
 DSFMT_PRE_INLINE double dsfmt_gv_genrand_open_open(void) DSFMT_PST_INLINE;
-DSFMT_PRE_INLINE void dsfmt_gv_fill_array_open_close(double array[], int size)
+DSFMT_PRE_INLINE void dsfmt_gv_fill_array_open_close(double array[], ptrdiff_t size)
     DSFMT_PST_INLINE;
-DSFMT_PRE_INLINE void dsfmt_gv_fill_array_close_open(double array[], int size)
+DSFMT_PRE_INLINE void dsfmt_gv_fill_array_close_open(double array[], ptrdiff_t size)
     DSFMT_PST_INLINE;
-DSFMT_PRE_INLINE void dsfmt_gv_fill_array_open_open(double array[], int size)
+DSFMT_PRE_INLINE void dsfmt_gv_fill_array_open_open(double array[], ptrdiff_t size)
     DSFMT_PST_INLINE;
-DSFMT_PRE_INLINE void dsfmt_gv_fill_array_close1_open2(double array[], int size)
+DSFMT_PRE_INLINE void dsfmt_gv_fill_array_close1_open2(double array[], ptrdiff_t size)
     DSFMT_PST_INLINE;
 DSFMT_PRE_INLINE void dsfmt_gv_init_gen_rand(uint32_t seed) DSFMT_PST_INLINE;
 DSFMT_PRE_INLINE void dsfmt_gv_init_by_array(uint32_t init_key[],
@@ -236,7 +242,7 @@
  * @param dsfmt dsfmt internal state date
  * @return double precision floating point pseudorandom number
  */
-inline static uint32_t dsfmt_genrand_uint32(dsfmt_t *dsfmt) {
+uint32_t dsfmt_genrand_uint32(dsfmt_t *dsfmt) {
     uint32_t r;
     uint64_t *psfmt64 = &dsfmt->status[0].u[0];
 
@@ -257,7 +263,7 @@
  * @param dsfmt dsfmt internal state date
  * @return double precision floating point pseudorandom number
  */
-inline static double dsfmt_genrand_close1_open2(dsfmt_t *dsfmt) {
+double dsfmt_genrand_close1_open2(dsfmt_t *dsfmt) {
     double r;
     double *psfmt64 = &dsfmt->status[0].d[0];
 
@@ -276,7 +282,7 @@
  * before this function.  This function uses \b global variables.
  * @return double precision floating point pseudorandom number
  */
-inline static uint32_t dsfmt_gv_genrand_uint32(void) {
+uint32_t dsfmt_gv_genrand_uint32(void) {
     return dsfmt_genrand_uint32(&dsfmt_global_data);
 }
 
@@ -287,7 +293,7 @@
  * before this function. This function uses \b global variables.
  * @return double precision floating point pseudorandom number
  */
-inline static double dsfmt_gv_genrand_close1_open2(void) {
+double dsfmt_gv_genrand_close1_open2(void) {
     return dsfmt_genrand_close1_open2(&dsfmt_global_data);
 }
 
@@ -299,7 +305,7 @@
  * @param dsfmt dsfmt internal state date
  * @return double precision floating point pseudorandom number
  */
-inline static double dsfmt_genrand_close_open(dsfmt_t *dsfmt) {
+double dsfmt_genrand_close_open(dsfmt_t *dsfmt) {
     return dsfmt_genrand_close1_open2(dsfmt) - 1.0;
 }
 
@@ -310,7 +316,7 @@
  * before this function. This function uses \b global variables.
  * @return double precision floating point pseudorandom number
  */
-inline static double dsfmt_gv_genrand_close_open(void) {
+double dsfmt_gv_genrand_close_open(void) {
     return dsfmt_gv_genrand_close1_open2() - 1.0;
 }
 
@@ -322,7 +328,7 @@
  * @param dsfmt dsfmt internal state date
  * @return double precision floating point pseudorandom number
  */
-inline static double dsfmt_genrand_open_close(dsfmt_t *dsfmt) {
+double dsfmt_genrand_open_close(dsfmt_t *dsfmt) {
     return 2.0 - dsfmt_genrand_close1_open2(dsfmt);
 }
 
@@ -333,7 +339,7 @@
  * before this function. This function uses \b global variables.
  * @return double precision floating point pseudorandom number
  */
-inline static double dsfmt_gv_genrand_open_close(void) {
+double dsfmt_gv_genrand_open_close(void) {
     return 2.0 - dsfmt_gv_genrand_close1_open2();
 }
 
@@ -345,7 +351,7 @@
  * @param dsfmt dsfmt internal state date
  * @return double precision floating point pseudorandom number
  */
-inline static double dsfmt_genrand_open_open(dsfmt_t *dsfmt) {
+double dsfmt_genrand_open_open(dsfmt_t *dsfmt) {
     double *dsfmt64 = &dsfmt->status[0].d[0];
     union {
         double d;
@@ -368,7 +374,7 @@
  * before this function. This function uses \b global variables.
  * @return double precision floating point pseudorandom number
  */
-inline static double dsfmt_gv_genrand_open_open(void) {
+double dsfmt_gv_genrand_open_open(void) {
     return dsfmt_genrand_open_open(&dsfmt_global_data);
 }
 
@@ -383,7 +389,7 @@
  * @param size the number of pseudorandom numbers to be generated.
  * see also \sa dsfmt_fill_array_close1_open2()
  */
-inline static void dsfmt_gv_fill_array_close1_open2(double array[], int size) {
+void dsfmt_gv_fill_array_close1_open2(double array[], ptrdiff_t size) {
     dsfmt_fill_array_close1_open2(&dsfmt_global_data, array, size);
 }
 
@@ -399,7 +405,7 @@
  * see also \sa dsfmt_fill_array_close1_open2() and \sa
  * dsfmt_gv_fill_array_close1_open2()
  */
-inline static void dsfmt_gv_fill_array_open_close(double array[], int size) {
+void dsfmt_gv_fill_array_open_close(double array[], ptrdiff_t size) {
     dsfmt_fill_array_open_close(&dsfmt_global_data, array, size);
 }
 
@@ -415,7 +421,7 @@
  * see also \sa dsfmt_fill_array_close1_open2() \sa
  * dsfmt_gv_fill_array_close1_open2()
  */
-inline static void dsfmt_gv_fill_array_close_open(double array[], int size) {
+void dsfmt_gv_fill_array_close_open(double array[], ptrdiff_t size) {
     dsfmt_fill_array_close_open(&dsfmt_global_data, array, size);
 }
 
@@ -431,7 +437,7 @@
  * see also \sa dsfmt_fill_array_close1_open2() \sa
  * dsfmt_gv_fill_array_close1_open2()
  */
-inline static void dsfmt_gv_fill_array_open_open(double array[], int size) {
+void dsfmt_gv_fill_array_open_open(double array[], ptrdiff_t size) {
     dsfmt_fill_array_open_open(&dsfmt_global_data, array, size);
 }
 
@@ -441,7 +447,7 @@
  * @param dsfmt dsfmt state vector.
  * @param seed a 32-bit integer used as the seed.
  */
-inline static void dsfmt_init_gen_rand(dsfmt_t *dsfmt, uint32_t seed) {
+void dsfmt_init_gen_rand(dsfmt_t *dsfmt, uint32_t seed) {
     dsfmt_chk_init_gen_rand(dsfmt, seed, DSFMT_MEXP);
 }
 
@@ -451,7 +457,7 @@
  * @param seed a 32-bit integer used as the seed.
  * see also \sa dsfmt_init_gen_rand()
  */
-inline static void dsfmt_gv_init_gen_rand(uint32_t seed) {
+void dsfmt_gv_init_gen_rand(uint32_t seed) {
     dsfmt_init_gen_rand(&dsfmt_global_data, seed);
 }
 
@@ -462,7 +468,7 @@
  * @param init_key the array of 32-bit integers, used as a seed.
  * @param key_length the length of init_key.
  */
-inline static void dsfmt_init_by_array(dsfmt_t *dsfmt, uint32_t init_key[],
+void dsfmt_init_by_array(dsfmt_t *dsfmt, uint32_t init_key[],
                                        int key_length) {
     dsfmt_chk_init_by_array(dsfmt, init_key, key_length, DSFMT_MEXP);
 }
@@ -475,7 +481,7 @@
  * @param key_length the length of init_key.
  * see also \sa dsfmt_init_by_array()
  */
-inline static void dsfmt_gv_init_by_array(uint32_t init_key[], int key_length) {
+void dsfmt_gv_init_by_array(uint32_t init_key[], int key_length) {
     dsfmt_init_by_array(&dsfmt_global_data, init_key, key_length);
 }
 
@@ -489,13 +495,13 @@
 DSFMT_PRE_INLINE double genrand_close_open(void) DSFMT_PST_INLINE;
 DSFMT_PRE_INLINE double genrand_open_close(void) DSFMT_PST_INLINE;
 DSFMT_PRE_INLINE double genrand_open_open(void) DSFMT_PST_INLINE;
-DSFMT_PRE_INLINE void fill_array_open_close(double array[], int size)
+DSFMT_PRE_INLINE void fill_array_open_close(double array[], ptrdiff_t size)
     DSFMT_PST_INLINE;
-DSFMT_PRE_INLINE void fill_array_close_open(double array[], int size)
+DSFMT_PRE_INLINE void fill_array_close_open(double array[], ptrdiff_t size)
     DSFMT_PST_INLINE;
-DSFMT_PRE_INLINE void fill_array_open_open(double array[], int size)
+DSFMT_PRE_INLINE void fill_array_open_open(double array[], ptrdiff_t size)
     DSFMT_PST_INLINE;
-DSFMT_PRE_INLINE void fill_array_close1_open2(double array[], int size)
+DSFMT_PRE_INLINE void fill_array_close1_open2(double array[], ptrdiff_t size)
     DSFMT_PST_INLINE;
 
 /**
@@ -503,7 +509,7 @@
  * @return id string.
  * see also \sa dsfmt_get_idstring()
  */
-inline static const char *get_idstring(void) {
+const char *get_idstring(void) {
     return dsfmt_get_idstring();
 }
 
@@ -512,7 +518,7 @@
  * @return minimum size of array used for fill_array functions.
  * see also \sa dsfmt_get_min_array_size()
  */
-inline static int get_min_array_size(void) {
+int get_min_array_size(void) {
     return dsfmt_get_min_array_size();
 }
 
@@ -521,7 +527,7 @@
  * @param seed a 32-bit integer used as the seed.
  * see also \sa dsfmt_gv_init_gen_rand(), \sa dsfmt_init_gen_rand().
  */
-inline static void init_gen_rand(uint32_t seed) {
+void init_gen_rand(uint32_t seed) {
     dsfmt_gv_init_gen_rand(seed);
 }
 
@@ -531,7 +537,7 @@
  * @param key_length the length of init_key.
  * see also \sa dsfmt_gv_init_by_array(), \sa dsfmt_init_by_array().
  */
-inline static void init_by_array(uint32_t init_key[], int key_length) {
+void init_by_array(uint32_t init_key[], int key_length) {
     dsfmt_gv_init_by_array(init_key, key_length);
 }
 
@@ -541,7 +547,7 @@
  * see also \sa dsfmt_genrand_close1_open2() \sa
  * dsfmt_gv_genrand_close1_open2()
  */
-inline static double genrand_close1_open2(void) {
+double genrand_close1_open2(void) {
     return dsfmt_gv_genrand_close1_open2();
 }
 
@@ -551,7 +557,7 @@
  * see also \sa dsfmt_genrand_close_open() \sa
  * dsfmt_gv_genrand_close_open()
  */
-inline static double genrand_close_open(void) {
+double genrand_close_open(void) {
     return dsfmt_gv_genrand_close_open();
 }
 
@@ -561,7 +567,7 @@
  * see also \sa dsfmt_genrand_open_close() \sa
  * dsfmt_gv_genrand_open_close()
  */
-inline static double genrand_open_close(void) {
+double genrand_open_close(void) {
     return dsfmt_gv_genrand_open_close();
 }
 
@@ -571,7 +577,7 @@
  * see also \sa dsfmt_genrand_open_open() \sa
  * dsfmt_gv_genrand_open_open()
  */
-inline static double genrand_open_open(void) {
+double genrand_open_open(void) {
     return dsfmt_gv_genrand_open_open();
 }
 
@@ -584,7 +590,7 @@
  * dsfmt_fill_array_close1_open2(), \sa
  * dsfmt_gv_fill_array_close1_open2()
  */
-inline static void fill_array_open_close(double array[], int size) {
+void fill_array_open_close(double array[], ptrdiff_t size) {
     dsfmt_gv_fill_array_open_close(array, size);
 }
 
@@ -597,7 +603,7 @@
  * dsfmt_fill_array_close1_open2(), \sa
  * dsfmt_gv_fill_array_close1_open2()
  */
-inline static void fill_array_close_open(double array[], int size) {
+void fill_array_close_open(double array[], ptrdiff_t size) {
     dsfmt_gv_fill_array_close_open(array, size);
 }
 
@@ -610,7 +616,7 @@
  * dsfmt_fill_array_close1_open2(), \sa
  * dsfmt_gv_fill_array_close1_open2()
  */
-inline static void fill_array_open_open(double array[], int size) {
+void fill_array_open_open(double array[], ptrdiff_t size) {
     dsfmt_gv_fill_array_open_open(array, size);
 }
 
@@ -622,7 +628,7 @@
  * see also \sa dsfmt_fill_array_close1_open2(), \sa
  * dsfmt_gv_fill_array_close1_open2()
  */
-inline static void fill_array_close1_open2(double array[], int size) {
+void fill_array_close1_open2(double array[], ptrdiff_t size) {
     dsfmt_gv_fill_array_close1_open2(array, size);
 }
 #endif /* DSFMT_DO_NOT_USE_OLD_NAMES */