Mercurial > pub > dyncall > dyncall
annotate test/call_suite/globals.c @ 430:8e22b70d3ee4
- simplified test/call_suite further
author | Tassilo Philipp |
---|---|
date | Mon, 17 Jan 2022 15:46:38 +0100 |
parents | 2b708397bba1 |
children | 23b12c7ad462 |
rev | line source |
---|---|
0 | 1 /* |
2 | |
3 Package: dyncall | |
4 Library: test | |
5 File: test/call_suite/globals.c | |
6 Description: | |
7 License: | |
8 | |
281 | 9 Copyright (c) 2011-2018 Daniel Adler <dadler@uni-goettingen.de>, |
0 | 10 Tassilo Philipp <tphilipp@potion-studios.com> |
11 | |
12 Permission to use, copy, modify, and distribute this software for any | |
13 purpose with or without fee is hereby granted, provided that the above | |
14 copyright notice and this permission notice appear in all copies. | |
15 | |
16 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
17 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
18 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
19 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
20 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
21 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
22 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
23 | |
24 */ | |
25 | |
26 #include <stdlib.h> | |
27 #include "globals.h" | |
28 #include <float.h> | |
29 | |
429
2b708397bba1
- simplified and decluttered test/call_suite
Tassilo Philipp
parents:
281
diff
changeset
|
30 #define X(CH,T) T *V_##CH; T *K_##CH; |
0 | 31 DEF_TYPES |
32 #undef X | |
33 | |
34 double rand_d() { return ( ( (double) rand() ) / ( (double) RAND_MAX ) ); } | |
35 | |
36 void init_K() | |
37 { | |
38 int i; | |
429
2b708397bba1
- simplified and decluttered test/call_suite
Tassilo Philipp
parents:
281
diff
changeset
|
39 #define X(CH,T) V_##CH = (T*) malloc(sizeof(T)*(G_maxargs+1)); K_##CH = (T*) malloc(sizeof(T)*(G_maxargs+1)); |
0 | 40 DEF_TYPES |
41 #undef X | |
48
dc0bcee2c847
bugfix: value and control-group arrays need to be max-arg size + 1 (... futher cleanup is needed as index 0 in array is not used at all ;-/ )
Daniel Adler <dadler@dyncall.org>
parents:
0
diff
changeset
|
42 for(i=0;i<G_maxargs+1;++i) { |
0 | 43 K_c[i] = (char) (((rand_d()-0.5)*2) * (1<<7)); |
44 K_s[i] = (short) (((rand_d()-0.5)*2) * (1<<(sizeof(short)*8-1))); | |
45 K_i[i] = (int) (((rand_d()-0.5)*2) * (1<<(sizeof(int)*8-2))); | |
46 K_j[i] = (long) (((rand_d()-0.5)*2) * (1L<<(sizeof(long)*8-2))); | |
47 K_l[i] = (long long) (((rand_d()-0.5)*2) * (1LL<<(sizeof(long long)*8-2))); | |
48 K_p[i] = (void*) (long) (((rand_d()-0.5)*2) * (1LL<<(sizeof(void*)*8-1))); | |
429
2b708397bba1
- simplified and decluttered test/call_suite
Tassilo Philipp
parents:
281
diff
changeset
|
49 K_f[i] = (float) (rand_d() * FLT_MAX); |
0 | 50 K_d[i] = (double) (((rand_d()-0.5)*2) * 1.7976931348623157E+308/*__DBL_MAX__*/); /* Plan9 doesn't know the macro. */ |
51 } | |
52 } | |
53 | |
54 void clear_V() | |
55 { | |
56 int i; | |
48
dc0bcee2c847
bugfix: value and control-group arrays need to be max-arg size + 1 (... futher cleanup is needed as index 0 in array is not used at all ;-/ )
Daniel Adler <dadler@dyncall.org>
parents:
0
diff
changeset
|
57 for(i=0;i<G_maxargs+1;++i) { |
429
2b708397bba1
- simplified and decluttered test/call_suite
Tassilo Philipp
parents:
281
diff
changeset
|
58 #define X(CH,T) V_##CH[i] = (T) 0; |
0 | 59 DEF_TYPES |
60 #undef X | |
61 } | |
62 } | |
63 |