comparison test/sign/sign.c @ 465:e2899b4ff713

- // -> /* */, mainly for consistency (but also for a few obscure compilers)
author Tassilo Philipp
date Wed, 02 Feb 2022 12:55:23 +0100
parents 7608e34098b0
children
comparison
equal deleted inserted replaced
464:bd65767c0534 465:e2899b4ff713
24 */ 24 */
25 25
26 26
27 #include "dyncall.h" 27 #include "dyncall.h"
28 28
29 // This program demonstrates the need for 'unsigned' integers and the 29 /* This program demonstrates the need for 'unsigned' integers and the */
30 // ability to implement zero/sign extensions for small integers. 30 /* ability to implement zero/sign extensions for small integers. */
31 // This test program indicates failure on powerpc 32-bit with 31 /* This test program indicates failure on powerpc 32-bit with */
32 // compiler optimizations enabled (e.g. '-O2' compilation flags). 32 /* compiler optimizations enabled (e.g. '-O2' compilation flags). */
33 // 33 /* */
34 // A fix to be incorporated in the API is also given. 34 /* A fix to be incorporated in the API is also given. */
35 //
36 35
37 int add1s(unsigned short x) { return x + 1; } 36 int add1s(unsigned short x) { return x + 1; }
38 37
39 // API BUGFIX: 38 /* API BUGFIX: */
40 #define dcArgUShort(vm,x) dcArgInt(vm,(int)(unsigned int)(x)) 39 #define dcArgUShort(vm,x) dcArgInt(vm,(int)(unsigned int)(x))
41 40
42 // OLD TEST: int add1(unsigned char x) { return x + 1; } 41 /* OLD TEST: int add1(unsigned char x) { return x + 1; } */
43 42
44 int main(int argc, char* argv[]) 43 int main(int argc, char* argv[])
45 { 44 {
46 DCCallVM* vm; 45 DCCallVM* vm;
47 int result; 46 int result;
53 result = dcCallInt( vm, &add1s ); 52 result = dcCallInt( vm, &add1s );
54 total = (result == 0x10000); 53 total = (result == 0x10000);
55 printf("result: sign: %d\n", total); 54 printf("result: sign: %d\n", total);
56 55
57 if (!total) { 56 if (!total) {
58 // 57
59 // TEST BUGFIX: use instead.. 58 /* TEST BUGFIX: use instead.. */
60 //
61 dcReset(vm); 59 dcReset(vm);
62 dcArgUShort( vm, 0xFFFF ); 60 dcArgUShort( vm, 0xFFFF );
63 result = dcCallInt( vm, &add1s ); 61 result = dcCallInt( vm, &add1s );
64 total = (result == 0x10000); 62 total = (result == 0x10000);
65 printf("result: sign (bugfix): %d\n", total); 63 printf("result: sign (bugfix): %d\n", total);
66 } 64 }
67 65
68 // result = dcCallInt( vm, &add1s ); 66 /*result = dcCallInt( vm, &add1s );
69 // total = (result == 0x10000); 67 total = (result == 0x10000);*/
70 68
71 // OLD TEST: updated to using 'short' 69 /*OLD TEST: updated to using 'short'
72 // dcArgChar( vm, (char) 255 ); 70 dcArgChar( vm, (char) 255 );
73 // result = dcCallInt( vm, &add1 ); 71 result = dcCallInt( vm, &add1 );
74 // total = (result == 256); 72 total = (result == 256);*/
75 73
76 // printf("result: sign: %d\n", total); 74 /*printf("result: sign: %d\n", total); */
77 return 0; 75 return 0;
78 } 76 }
77