Mercurial > pub > dyncall > dyncall
comparison dyncall/dyncall_callvm_ppc32.c @ 84:67961454902b
- bigger cleanup in callvm code
* changed init of most callvms to reuse code and for consistency
* removed unused functions
* general changes for consistency
* added some missing cconv defines do mode calls
- fixed potential buffer overrun on arm64
- fixed sparc and x64 mode setting (only one mode, but wasn't (pointlessly) resettable)
- error code handling (dcGetError) changes, flag is now cleared (work still underway)
- Changelog update
author | cslag |
---|---|
date | Wed, 06 Apr 2016 00:21:51 +0200 |
parents | 3e629dc19168 |
children | f44808587a3c |
comparison
equal
deleted
inserted
replaced
83:54930a037e8a | 84:67961454902b |
---|---|
49 #include "dyncall_utils.h" | 49 #include "dyncall_utils.h" |
50 | 50 |
51 /* Support for Mac OS X (Darwin) and Systen V ABI for Power PC 32-bit */ | 51 /* Support for Mac OS X (Darwin) and Systen V ABI for Power PC 32-bit */ |
52 | 52 |
53 #if defined(DC__OS_Darwin) | 53 #if defined(DC__OS_Darwin) |
54 #define DC__ABI_Darwin | 54 # define DC__ABI_Darwin |
55 #elif defined(DC__OS_Linux) || defined(DC__OS_FreeBSD) || defined(DC__OS_OpenBSD) || defined(DC__OS_NetBSD) || defined(DC__OS_DragonFlyBSD) || defined(DC__OS_SunOS) | 55 #elif defined(DC__OS_Linux) || defined(DC__OS_FreeBSD) || defined(DC__OS_OpenBSD) || defined(DC__OS_NetBSD) || defined(DC__OS_DragonFlyBSD) || defined(DC__OS_SunOS) |
56 #define DC__ABI_SysV | 56 # define DC__ABI_SysV |
57 #else | 57 #else |
58 #error Unsupported OS for ppc32 architecture. | 58 # error Unsupported OS for ppc32 architecture. |
59 #endif | 59 #endif |
60 | 60 |
61 static void dc_callvm_free_ppc32(DCCallVM* in_self) | 61 static void dc_callvm_free_ppc32(DCCallVM* in_self) |
62 { | 62 { |
63 dcFreeMem(in_self); | 63 dcFreeMem(in_self); |
362 }; | 362 }; |
363 | 363 |
364 | 364 |
365 void dc_callvm_mode_ppc32(DCCallVM* in_self, DCint mode) | 365 void dc_callvm_mode_ppc32(DCCallVM* in_self, DCint mode) |
366 { | 366 { |
367 DCCallVM_ppc32* self = (DCCallVM_ppc32*) in_self; | 367 DCCallVM_ppc32* self = (DCCallVM_ppc32*)in_self; |
368 DCCallVM_vt* vt; | 368 DCCallVM_vt* vt; |
369 | |
369 switch(mode) { | 370 switch(mode) { |
370 | |
371 case DC_CALL_C_PPC32_OSX: | |
372 | 371 |
373 #if defined(DC__ABI_Darwin) | 372 #if defined(DC__ABI_Darwin) |
374 case DC_CALL_C_DEFAULT: | 373 case DC_CALL_C_DEFAULT: |
375 case DC_CALL_C_ELLIPSIS: | 374 case DC_CALL_C_ELLIPSIS: |
376 case DC_CALL_C_ELLIPSIS_VARARGS: | 375 case DC_CALL_C_ELLIPSIS_VARARGS: |
377 #endif | 376 #endif |
378 | 377 case DC_CALL_C_PPC32_OSX: |
379 vt = &gVT_ppc32_darwin; | 378 vt = &gVT_ppc32_darwin; |
380 break; | 379 break; |
381 | |
382 case DC_CALL_C_PPC32_SYSV: | |
383 | 380 |
384 #if defined(DC__ABI_SysV) | 381 #if defined(DC__ABI_SysV) |
385 case DC_CALL_C_DEFAULT: | 382 case DC_CALL_C_DEFAULT: |
386 case DC_CALL_C_ELLIPSIS: | 383 case DC_CALL_C_ELLIPSIS: |
387 case DC_CALL_C_ELLIPSIS_VARARGS: | 384 case DC_CALL_C_ELLIPSIS_VARARGS: |
388 #endif | 385 #endif |
389 | 386 case DC_CALL_C_PPC32_SYSV: |
390 vt = &gVT_ppc32_sysv; | 387 vt = &gVT_ppc32_sysv; |
391 break; | 388 break; |
392 | 389 |
393 case DC_CALL_SYS_DEFAULT: | 390 case DC_CALL_SYS_DEFAULT: |
394 case DC_CALL_SYS_PPC32: | 391 case DC_CALL_SYS_PPC32: |
397 | 394 |
398 default: | 395 default: |
399 self->mInterface.mError = DC_ERROR_UNSUPPORTED_MODE; | 396 self->mInterface.mError = DC_ERROR_UNSUPPORTED_MODE; |
400 return; | 397 return; |
401 } | 398 } |
402 | 399 |
403 dc_callvm_base_init(&self->mInterface, vt); | 400 dc_callvm_base_init(&self->mInterface, vt); |
404 } | 401 } |
405 | 402 |
403 /* Public API. */ | |
406 DCCallVM* dcNewCallVM(DCsize size) | 404 DCCallVM* dcNewCallVM(DCsize size) |
407 { | 405 { |
408 DCCallVM_ppc32* self = (DCCallVM_ppc32*)dcAllocMem(sizeof(DCCallVM_ppc32)+size); | 406 DCCallVM_ppc32* p = (DCCallVM_ppc32*)dcAllocMem(sizeof(DCCallVM_ppc32)+size); |
409 dcVecInit(&self->mVecHead, size); | 407 |
410 self->mIntRegs = 0; | 408 dc_callvm_mode_ppc32((DCCallVM*)p, DC_CALL_C_DEFAULT); |
411 self->mFloatRegs = 0; | 409 |
412 dc_callvm_mode_ppc32( (DCCallVM*) self, DC_CALL_C_DEFAULT ); | 410 dcVecInit(&p->mVecHead, size); |
413 return (DCCallVM*)self; | 411 dc_callvm_reset_ppc32((DCCallVM*)p); |
414 } | 412 |
415 | 413 return (DCCallVM*)p; |
414 } | |
415 |