1 /***************************************************************************
5 * Purpose: Test functions in C for UFFI library
6 * Programer: Kevin M. Rosenberg
7 * Date Started: Mar 2002
9 * This file, part of UFFI, is Copyright (c) 2002-2010 by Kevin M. Rosenberg
11 * These variables are correct for GCC
12 * you'll need to modify these for other compilers
13 ***************************************************************************/
15 #if defined(WIN32)||defined(WIN64)
18 BOOL WINAPI DllEntryPoint(HINSTANCE hinstdll,
25 #define DLLEXPORT __declspec(dllexport)
36 DLLEXPORT unsigned char uchar_13 = 13;
37 DLLEXPORT signed char schar_neg_120 = -120;
38 DLLEXPORT unsigned short uword_257 = 257;
39 DLLEXPORT signed short sword_neg_321 = -321;
40 DLLEXPORT unsigned int uint_1234567 = 1234567;
41 DLLEXPORT signed int sint_neg_123456 = -123456;
42 DLLEXPORT double double_3_1 = 3.1;
43 DLLEXPORT float float_neg_4_5 = -4.5;
45 /* Test of constant input string */
48 cs_count_upper (char* psz)
63 /* Test of input and output of a string */
66 cs_to_upper (char* psz)
70 *psz = toupper (*psz);
76 /* Test of an output only string */
79 cs_make_random (int size, char* buffer)
82 for (i = 0; i < size; i++)
83 buffer[i] = 'A' + (rand() % 26);
87 /* Test of input/output vector */
90 half_double_vector (int size, double* vec)
93 for (i = 0; i < size; i++)
102 int *x = (int *) malloc(sizeof(int));
111 double *y = (double *) malloc(sizeof(double));
118 return_long_negative_one ()
125 return_int_negative_one ()
132 return_short_negative_one ()
137 DLLEXPORT int fvar_addend = 3;
144 fvar_struct_type fvar_struct = {42, 3.2};
147 int fvar_struct_int () {
148 return (fvar_addend + fvar_struct.i);
152 double fvar_struct_double () {
153 return fvar_struct.d;