1 /*
2 
3  Package: dyncall
4  Library: dyncall
5  File: dyncall/dyncall_value.h
6  Description: Value variant type
7  License:
8 
9    Copyright (c) 2007-2018 Daniel Adler <dadler@uni-goettingen.de>,
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 
27 /*
28 
29   dyncall value variant
30 
31   a value variant union-type that carries all supported dyncall types.
32 
33   REVISION
34   2007/12/11 initial
35 
36 */
37 
38 #ifndef DYNCALL_VALUE_H
39 #define DYNCALL_VALUE_H
40 
41 #include "dyncall_types.h"
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
47 typedef union DCValue_ DCValue;
48 
49 union DCValue_
50 {
51 /* dyncallback assembly pulls value directly from DCValue structs, without   */
52 /* knowledge about types used, so lay it out as needed at compile time, here */
53 #if defined(DC__Endian_BIG) && (defined(DC__Arch_PPC32) || defined(DC__Arch_MIPS) || defined(DC__Arch_Sparc))
54   DCbool      B;
55   struct { DCchar  c_pad[3]; DCchar  c; };
56   struct { DCuchar C_pad[3]; DCuchar C; };
57   struct { DCshort s_pad;    DCshort s; };
58   struct { DCshort S_pad;    DCshort S; };
59   DCint       i;
60   DCuint      I;
61 #elif defined(DC__Endian_BIG) && (defined(DC__Arch_PPC64) || defined(DC__Arch_MIPS64) || defined(DC__Arch_Sparc64))
62   struct { DCbool  B_pad;    DCbool  B; };
63   struct { DCchar  c_pad[7]; DCchar  c; };
64   struct { DCuchar C_pad[7]; DCuchar C; };
65   struct { DCshort s_pad[3]; DCshort s; };
66   struct { DCshort S_pad[3]; DCshort S; };
67   struct { DCint   i_pad;    DCint   i; };
68   struct { DCint   I_pad;    DCuint  I; };
69 #else
70   DCbool      B;
71   DCchar      c;
72   DCuchar     C;
73   DCshort     s;
74   DCushort    S;
75   DCint       i;
76   DCuint      I;
77 #endif
78   DClong      j;
79   DCulong     J;
80   DClonglong  l;
81   DCulonglong L;
82 /* floats on mips are right justified in fp-registers on big endian targets, as they aren't promoted */
83 #if defined(DC__Endian_BIG) && (defined(DC__Arch_MIPS) || defined(DC__Arch_MIPS64))
84   struct { DCfloat f_pad; DCfloat f; };
85 #else
86   DCfloat     f;
87 #endif
88   DCdouble    d;
89   DCpointer   p;
90   DCstring    Z;
91 };
92 
93 #ifdef __cplusplus
94 }
95 #endif
96 
97 #endif /* DYNCALL_VALUE_H */
98 
99