Mercurial > pub > dyncall > dyncall
comparison dyncall/dyncall_aggregate.h @ 533:71c884e610f0
- integration of patches from Raphael Luba, Thekla, Inc.:
* integration of aggregate-by-value (struct, union) support patch for x64 (win and sysv)
* windows/x64 asm additions to specify how stack unwinds (help for debuggers, exception handling, etc.)
* see Changelog for details
- new calling convention modes for thiscalls (platform agnostic, was specific before)
* new signature character for platform agnostic thiscalls ('*' / DC_SIGCHAR_CC_THISCALL)
- dcCallF(), dcVCallF(), dcArgF() and dcVArgF():
* added support for aggregates-by-value (wasn't part of patch)
* change that those functions don't implicitly call dcReset() anymore, which was unflexible (breaking change)
- added macros to feature test implementation for aggregate-by-value and syscall support
- changed libdyncall_s.lib and libdyncallback_s.lib order in callback test makefiles, as some toolchains are picky about order
- doc:
* man page updates to describe aggregate interface
* manual overview changes to highlight platforms with aggregate-by-value support
- test/plain: replaced tests w/ old/stale sctruct interface with new aggregate one
author | Tassilo Philipp |
---|---|
date | Thu, 21 Apr 2022 13:35:47 +0200 |
parents | |
children | ba70fb631bea |
comparison
equal
deleted
inserted
replaced
532:d4bf63ab9164 | 533:71c884e610f0 |
---|---|
1 /* | |
2 | |
3 Package: dyncall | |
4 Library: dyncall | |
5 File: dyncall/dyncall_aggregate.h | |
6 Description: C interface to compute struct size | |
7 License: | |
8 | |
9 Copyright (c) 2021-2022 Tassilo Philipp <tphilipp@potion-studios.com> | |
10 | |
11 Permission to use, copy, modify, and distribute this software for any | |
12 purpose with or without fee is hereby granted, provided that the above | |
13 copyright notice and this permission notice appear in all copies. | |
14 | |
15 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
16 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
17 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
18 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
19 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
20 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
21 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
22 | |
23 */ | |
24 | |
25 | |
26 #ifndef DYNCALL_STRUCT_H | |
27 #define DYNCALL_STRUCT_H | |
28 | |
29 #include "dyncall.h" | |
30 | |
31 #ifdef __cplusplus | |
32 extern "C" { | |
33 #endif | |
34 | |
35 #if defined(DC_UNIX) && defined(DC__Arch_AMD64) | |
36 | |
37 /* x64 param classification - only used for aggregates, so comments might be aggregate specific */ | |
38 # define DC_SYSV_MAX_NUM_CLASSES 8 /* max num of aggregate qwords to be classified; constant defined by call conv */ | |
39 # define SYSVC_NONE 0 /* end of classification !code relies on this being 0! */ | |
40 # define SYSVC_INTEGER (1<<0) /* (signed and unsigned) _Bool/bool, char, short, int, long, long long and pointers (also __int128, but treated as two longs) */ | |
41 # define SYSVC_SSE (1<<1) /* float, double and __m64, as well as least significant half of __float128 and __m128 (also complex float/double, but treated as two float/double) */ | |
42 # define SYSVC_SSEUP (1<<2) /* @@@AGGR currently unsupported/unused: most significant half of __float128 and __m128, most significant parts of __m256 and __m512 */ | |
43 # define SYSVC_X87 (1<<3) /* @@@AGGR currently unsupported/unused: 64bit mantissa of type long double (80bit x87 extended precision format) */ | |
44 # define SYSVC_X87UP (1<<4) /* @@@AGGR currently unsupported/unused: 16bit exponent plus 6 bytes of padding of type long double (80bit x87 extended precision format) */ | |
45 # define SYSVC_COMPLEX_X87 (1<<5) /* @@@AGGR currently unsupported/unused: complex long double */ | |
46 # define SYSVC_MEMORY (1<<6) /* for everything not fitting or allowed in regs given call conv (if class[0] == SYSVC_MEMORY, shortcut to pass entire aggregate via memory) */ | |
47 | |
48 #endif | |
49 | |
50 | |
51 typedef struct DCfield_ { | |
52 DCsize offset, size, array_len; | |
53 DCsigchar type; | |
54 const DCaggr* sub_aggr; | |
55 } DCfield; | |
56 | |
57 struct DCaggr_ { | |
58 DCsize size, n_fields; | |
59 #if defined(DC_UNIX) && defined(DC__Arch_AMD64) | |
60 DCuchar sysv_classes[DC_SYSV_MAX_NUM_CLASSES]; /* !code relies on this to be 64 bits! */ | |
61 #endif | |
62 DCfield fields[]; | |
63 }; | |
64 | |
65 | |
66 | |
67 #ifdef __cplusplus | |
68 } | |
69 #endif | |
70 | |
71 #endif /* DYNCALL_H */ | |
72 |