comparison dyncall/dyncall_callvm_x86.c @ 466:ddfb9577a00e

introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed for upcoming aggregate support (until now only x86 platforms allowed for specifically selecting thiscall mode, given the different conventions on the same platform); also added respective DC_SIGCHAR_CC_THISCALL ('*')
author Tassilo Philipp
date Wed, 02 Feb 2022 18:30:44 +0100
parents e2899b4ff713
children 71c884e610f0
comparison
equal deleted inserted replaced
465:e2899b4ff713 466:ddfb9577a00e
4 Library: dyncall 4 Library: dyncall
5 File: dyncall/dyncall_callvm_x86.c 5 File: dyncall/dyncall_callvm_x86.c
6 Description: Call VM for x86 architecture implementation 6 Description: Call VM for x86 architecture implementation
7 License: 7 License:
8 8
9 Copyright (c) 2007-2020 Daniel Adler <dadler@uni-goettingen.de>, 9 Copyright (c) 2007-2020 Daniel Adler <dadler@uni-goettingen.de>,
10 Tassilo Philipp <tphilipp@potion-studios.com> 10 Tassilo Philipp <tphilipp@potion-studios.com>
11 11
12 Permission to use, copy, modify, and distribute this software for any 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 13 purpose with or without fee is hereby granted, provided that the above
14 copyright notice and this permission notice appear in all copies. 14 copyright notice and this permission notice appear in all copies.
27 27
28 #include "dyncall_callvm_x86.h" 28 #include "dyncall_callvm_x86.h"
29 #include "dyncall_alloc.h" 29 #include "dyncall_alloc.h"
30 30
31 31
32 /* 32 /*
33 ** x86 calling convention calls 33 ** x86 calling convention calls
34 ** 34 **
35 ** - hybrid return-type call (bool ... pointer) 35 ** - hybrid return-type call (bool ... pointer)
36 ** 36 **
37 */ 37 */
38 38
169 &dc_callvm_free_x86 169 &dc_callvm_free_x86
170 , &dc_callvm_reset_x86 170 , &dc_callvm_reset_x86
171 , &dc_callvm_mode_x86 171 , &dc_callvm_mode_x86
172 , &dc_callvm_argBool_x86 172 , &dc_callvm_argBool_x86
173 , &dc_callvm_argChar_x86 173 , &dc_callvm_argChar_x86
174 , &dc_callvm_argShort_x86 174 , &dc_callvm_argShort_x86
175 , &dc_callvm_argInt_x86 175 , &dc_callvm_argInt_x86
176 , &dc_callvm_argLong_x86 176 , &dc_callvm_argLong_x86
177 , &dc_callvm_argLongLong_x86 177 , &dc_callvm_argLongLong_x86
178 , &dc_callvm_argFloat_x86 178 , &dc_callvm_argFloat_x86
179 , &dc_callvm_argDouble_x86 179 , &dc_callvm_argDouble_x86
209 &dc_callvm_free_x86 209 &dc_callvm_free_x86
210 , &dc_callvm_reset_x86 210 , &dc_callvm_reset_x86
211 , &dc_callvm_mode_x86 211 , &dc_callvm_mode_x86
212 , &dc_callvm_argBool_x86 212 , &dc_callvm_argBool_x86
213 , &dc_callvm_argChar_x86 213 , &dc_callvm_argChar_x86
214 , &dc_callvm_argShort_x86 214 , &dc_callvm_argShort_x86
215 , &dc_callvm_argInt_x86 215 , &dc_callvm_argInt_x86
216 , &dc_callvm_argLong_x86 216 , &dc_callvm_argLong_x86
217 , &dc_callvm_argLongLong_x86 217 , &dc_callvm_argLongLong_x86
218 , &dc_callvm_argFloat_x86 218 , &dc_callvm_argFloat_x86
219 , &dc_callvm_argDouble_x86 219 , &dc_callvm_argDouble_x86
597 DCCallVM_x86* self = (DCCallVM_x86*)in_self; 597 DCCallVM_x86* self = (DCCallVM_x86*)in_self;
598 DCCallVM_vt* vt; 598 DCCallVM_vt* vt;
599 599
600 switch(mode) { 600 switch(mode) {
601 case DC_CALL_C_DEFAULT: 601 case DC_CALL_C_DEFAULT:
602 #if !defined(DC__C_MSVC)
603 case DC_CALL_C_DEFAULT_THIS:
604 #endif
602 case DC_CALL_C_ELLIPSIS: 605 case DC_CALL_C_ELLIPSIS:
603 case DC_CALL_C_ELLIPSIS_VARARGS: 606 case DC_CALL_C_ELLIPSIS_VARARGS:
604 /* Plan9 (and forks) have their own calling convention (and no support for foreign ones). */ 607 /* Plan9 (and forks) have their own calling convention (and no support for foreign ones). */
605 #if defined(DC_PLAN9) 608 #if defined(DC_PLAN9)
606 case DC_CALL_C_X86_PLAN9: vt = &gVT_x86_plan9; break; 609 case DC_CALL_C_X86_PLAN9: vt = &gVT_x86_plan9; break;
607 #else 610 #else
608 case DC_CALL_C_X86_CDECL: vt = &gVT_x86_cdecl; break; /* also handles DC_CALL_C_X86_WIN32_THIS_GNU */ 611 case DC_CALL_C_X86_CDECL: vt = &gVT_x86_cdecl; break; /* also handles DC_CALL_C_X86_WIN32_THIS_GNU */
609 case DC_CALL_C_X86_WIN32_STD: vt = &gVT_x86_win32_std; break; 612 case DC_CALL_C_X86_WIN32_STD: vt = &gVT_x86_win32_std; break;
610 case DC_CALL_C_X86_WIN32_FAST_MS: vt = &gVT_x86_win32_fast_ms; break; 613 case DC_CALL_C_X86_WIN32_FAST_MS: vt = &gVT_x86_win32_fast_ms; break;
614 #if defined(DC__C_MSVC)
615 case DC_CALL_C_DEFAULT_THIS:
616 #endif
611 case DC_CALL_C_X86_WIN32_THIS_MS: vt = &gVT_x86_win32_this_ms; break; 617 case DC_CALL_C_X86_WIN32_THIS_MS: vt = &gVT_x86_win32_this_ms; break;
612 case DC_CALL_C_X86_WIN32_FAST_GNU: vt = &gVT_x86_win32_fast_gnu; break; 618 case DC_CALL_C_X86_WIN32_FAST_GNU: vt = &gVT_x86_win32_fast_gnu; break;
613 case DC_CALL_SYS_DEFAULT: 619 case DC_CALL_SYS_DEFAULT:
614 # if defined DC_UNIX 620 # if defined DC_UNIX
615 # if defined DC__OS_Linux 621 # if defined DC__OS_Linux
621 self->mInterface.mError = DC_ERROR_UNSUPPORTED_MODE; return; 627 self->mInterface.mError = DC_ERROR_UNSUPPORTED_MODE; return;
622 # endif 628 # endif
623 case DC_CALL_SYS_X86_INT80H_LINUX: vt = &gVT_x86_syscall_int80h_linux; break; 629 case DC_CALL_SYS_X86_INT80H_LINUX: vt = &gVT_x86_syscall_int80h_linux; break;
624 case DC_CALL_SYS_X86_INT80H_BSD: vt = &gVT_x86_syscall_int80h_bsd; break; 630 case DC_CALL_SYS_X86_INT80H_BSD: vt = &gVT_x86_syscall_int80h_bsd; break;
625 #endif 631 #endif
626 default: 632 default:
627 self->mInterface.mError = DC_ERROR_UNSUPPORTED_MODE; 633 self->mInterface.mError = DC_ERROR_UNSUPPORTED_MODE;
628 return; 634 return;
629 } 635 }
630 dc_callvm_base_init(&self->mInterface, vt); 636 dc_callvm_base_init(&self->mInterface, vt);
631 } 637 }