[t][TT #1119] Convert t/op/bitwise.t to PIR
[parrot.git] / src / nci_test.c
blob0ff9cf3b45083b5dbc65356913a6e099de478272
1 /*
2 Copyright (C) 2001-2007, Parrot Foundation.
3 $Id$
5 =head1 NAME
7 src/nci_test.c - shared library used for testing the Native Call Interface
9 =head1 DESCRIPTION
11 From this code a shared library can be compiled and linked with a command like:
13 cc -shared -fpic nci_test.c -o libnci_test.so -g
15 For non-Unix platforms the above command has to be modified appropriately.
17 The resulting shared library should be copied to a location like:
19 parrot/runtime/parrot/dynext/libnci_test.so
21 At that location the shared library is loadable with the opcode 'loadlib'.
22 The functions in the library are available with the opcode 'dlfunc'.
23 The variables in the library are available with the opcode 'dlvar'.
25 =head2 Functions
27 The name of a test function is usually 'nci_<signature>'. E.g. the function
28 'nci_ip' takes a 'pointer' and returns a 'int'.
30 =over 4
32 =cut
36 #define PARROT_IN_EXTENSION
37 #include <stdio.h>
38 #include <stdlib.h>
39 #include <string.h>
40 #include <parrot/parrot.h>
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
47 /* Declarations of structs */
49 typedef struct Nested {
50 int y;
51 } Nested;
53 typedef struct Outer {
54 int x;
55 Nested *nested;
56 } Outer;
58 typedef struct Rect_Like {
59 int x, y;
60 int w, h;
61 } Rect_Like;
63 typedef struct Opaque {
64 int x;
65 } Opaque;
67 /* Function declarations.
69 *** If you add a new test function here,
70 *** please update src/libnci_test.def and src/call_list.txt too. ***
74 PARROT_DYNEXT_EXPORT int call_back(const char *str);
75 PARROT_DYNEXT_EXPORT char nci_c(void);
76 PARROT_DYNEXT_EXPORT char nci_csc(short, char);
77 PARROT_DYNEXT_EXPORT double nci_d(void);
78 PARROT_DYNEXT_EXPORT double nci_dd(double);
79 PARROT_DYNEXT_EXPORT float nci_f(void);
80 PARROT_DYNEXT_EXPORT float nci_fff(float, float);
81 PARROT_DYNEXT_EXPORT int nci_i(void);
82 PARROT_DYNEXT_EXPORT int nci_ib(int *);
83 PARROT_DYNEXT_EXPORT int nci_iiii(int, int, int);
84 PARROT_DYNEXT_EXPORT int nci_ii3(int, int *);
85 PARROT_DYNEXT_EXPORT int nci_ip(void *);
86 PARROT_DYNEXT_EXPORT int nci_isc(short, char);
87 PARROT_DYNEXT_EXPORT int nci_it(void *);
88 PARROT_DYNEXT_EXPORT int nci_i33(int *, int *);
89 PARROT_DYNEXT_EXPORT int nci_i4i(long *, int);
90 PARROT_DYNEXT_EXPORT long nci_l(void);
91 PARROT_DYNEXT_EXPORT int * nci_p(void);
92 PARROT_DYNEXT_EXPORT void * nci_pi(int);
93 PARROT_DYNEXT_EXPORT void * nci_pii(int, int);
94 PARROT_DYNEXT_EXPORT void * nci_piiii(int, int, int, int);
95 PARROT_DYNEXT_EXPORT void nci_pip(int, Rect_Like *);
96 PARROT_DYNEXT_EXPORT void * nci_pp(void *);
97 PARROT_DYNEXT_EXPORT short nci_s(void);
98 PARROT_DYNEXT_EXPORT short nci_ssc(short, char);
99 PARROT_DYNEXT_EXPORT char * nci_t(void);
100 PARROT_DYNEXT_EXPORT char * nci_tb(void *);
101 PARROT_DYNEXT_EXPORT char * nci_tB(void **);
102 PARROT_DYNEXT_EXPORT char * nci_tt(void *);
103 PARROT_DYNEXT_EXPORT void nci_v(void);
104 PARROT_DYNEXT_EXPORT void nci_vP(void *);
105 PARROT_DYNEXT_EXPORT void nci_vpii(Outer *, int, int);
106 PARROT_DYNEXT_EXPORT void nci_vv(void);
107 PARROT_DYNEXT_EXPORT void nci_vVi(Opaque**, int);
108 PARROT_DYNEXT_EXPORT void nci_vp(Opaque*);
109 PARROT_DYNEXT_EXPORT char * nci_ttt(char *, char *);
110 PARROT_DYNEXT_EXPORT void nci_vfff(float, float, float);
111 PARROT_DYNEXT_EXPORT void nci_vV(const char **);
112 PARROT_DYNEXT_EXPORT void nci_vVVV(const char **, const char **, const char **);
114 /* Declarations for callback tests */
116 typedef void (*cb_C1_func)(const char*, void*);
117 PARROT_DYNEXT_EXPORT void nci_cb_C1(cb_C1_func, void*);
119 typedef void (*cb_C2_func)(int, void*);
120 PARROT_DYNEXT_EXPORT void nci_cb_C2(cb_C2_func, void*);
122 typedef void (*cb_C3_func)(void*, void*);
123 PARROT_DYNEXT_EXPORT void nci_cb_C3(cb_C3_func, void*);
125 typedef void (*cb_D1_func)(void*, const char*);
126 PARROT_DYNEXT_EXPORT void nci_cb_D1(cb_D1_func, void*);
128 typedef void (*cb_D2_func)(void*, int);
129 PARROT_DYNEXT_EXPORT void nci_cb_D2(cb_D2_func, void*);
131 typedef void (*cb_D3_func)(void*, void*);
132 PARROT_DYNEXT_EXPORT void nci_cb_D3(cb_D3_func, void*);
134 typedef void (*cb_D4_func)(void*, void*);
135 PARROT_DYNEXT_EXPORT void nci_cb_D4(cb_D4_func, void*);
137 /* Variable definitions */
139 PARROT_DYNEXT_EXPORT int int_cb_D4 = -55555;
140 PARROT_DYNEXT_EXPORT int nci_dlvar_char = 22;
141 PARROT_DYNEXT_EXPORT int nci_dlvar_short = 333;
142 PARROT_DYNEXT_EXPORT int nci_dlvar_int = -4444;
143 PARROT_DYNEXT_EXPORT long nci_dlvar_long = -7777777;
144 PARROT_DYNEXT_EXPORT float nci_dlvar_float = -333.0;
145 PARROT_DYNEXT_EXPORT double nci_dlvar_double = -55555.55555;
146 PARROT_DYNEXT_EXPORT char nci_dlvar_cstring[] = "This is a C-string.\n";
149 /* Function definitions */
153 =item C<PARROT_DYNEXT_EXPORT char
154 nci_c(void)>
156 Returns the value of the variable C<nci_dlvar_char>, which is set to 22 by
157 default.
159 =cut
163 PARROT_DYNEXT_EXPORT char
164 nci_c(void) {
165 return nci_dlvar_char;
170 =item C<PARROT_DYNEXT_EXPORT char
171 nci_csc(short l1, char l2)>
173 Multiplies C<l1> and C<l2> together and returns the first byte of the result.
175 =cut
179 PARROT_DYNEXT_EXPORT char
180 nci_csc(short l1, char l2)
182 return l1 * l2;
187 =item C<PARROT_DYNEXT_EXPORT double
188 nci_d(void)>
190 Multiplies the current value of C<nci_dlvar_double> by 10.0, and returns
191 the new value.
193 =cut
197 PARROT_DYNEXT_EXPORT double
198 nci_d(void)
200 nci_dlvar_double *= 10.0;
202 return nci_dlvar_double;
207 =item C<PARROT_DYNEXT_EXPORT double
208 nci_dd(double d)>
210 Returns the value C<d> multiplied by 2.0.
212 =cut
216 PARROT_DYNEXT_EXPORT double
217 nci_dd(double d)
219 return d * 2.0;
224 =item C<PARROT_DYNEXT_EXPORT float
225 nci_f(void)>
227 Multiplies the value C<nci_dlvar_float> by 10.0 and returns the new
228 value.
230 =cut
234 PARROT_DYNEXT_EXPORT float
235 nci_f(void)
237 nci_dlvar_float *= 10.0;
239 return nci_dlvar_float;
244 =item C<PARROT_DYNEXT_EXPORT float
245 nci_fff(float l1, float l2)>
247 Returns the result of C<l1> / C<l2>.
249 =cut
253 PARROT_DYNEXT_EXPORT float
254 nci_fff(float l1, float l2)
256 return l1 / l2;
261 =item C<PARROT_DYNEXT_EXPORT int
262 nci_i(void)>
264 Returns the current value of <nci_dlvar_int>.
266 =cut
270 PARROT_DYNEXT_EXPORT int
271 nci_i(void)
273 return nci_dlvar_int;
278 =item C<PARROT_DYNEXT_EXPORT int
279 nci_isc(short l1, char l2)>
281 Returns the int product of C<l1 * l2>.
283 =cut
287 PARROT_DYNEXT_EXPORT int
288 nci_isc(short l1, char l2)
290 return l1 * l2;
295 =item C<PARROT_DYNEXT_EXPORT int
296 nci_ip(void *p)>
298 Performs a series of operations on values stored at pointer C<p>.
300 =cut
304 PARROT_DYNEXT_EXPORT int
305 nci_ip(void *p)
307 typedef struct _dfi {
308 double d;
309 float f;
310 int i;
311 char *s;
312 } dfi;
313 dfi *sp = (dfi*) p;
314 puts(sp->s);
315 fflush(stdout);
317 return (int) (sp->d + sp->f + sp->i);
322 =item C<PARROT_DYNEXT_EXPORT int
323 nci_it(void *p)>
325 test calls this with a string
327 =cut
331 PARROT_DYNEXT_EXPORT int
332 nci_it(void *p)
334 fprintf(stderr, "%c%c\n", ((char*) p)[1], ((char *) p)[0]);
335 fflush(stderr);
337 return 2;
342 =item C<PARROT_DYNEXT_EXPORT long
343 nci_l(void)>
345 Returns the value of C<nci_dlvar_long>.
347 =cut
351 PARROT_DYNEXT_EXPORT long
352 nci_l(void)
354 return nci_dlvar_long;
359 =item C<PARROT_DYNEXT_EXPORT int *
360 nci_p(void)>
362 Returns the address of C<nci_dlvar_int>.
364 =cut
368 PARROT_DYNEXT_EXPORT int *
369 nci_p(void)
371 return &nci_dlvar_int;
376 =item C<PARROT_DYNEXT_EXPORT char *
377 nci_t(void)>
379 Returns the value of C<nci_dlvar_cstring>.
381 =cut
385 PARROT_DYNEXT_EXPORT char *
386 nci_t(void)
388 return nci_dlvar_cstring;
393 =item C<PARROT_DYNEXT_EXPORT char *
394 nci_tb(void *p)>
396 Prints "xx worked", where "xx" is replaced with the first two character values
397 of C<p>, in reverse order.
399 =cut
403 static char b[] = "xx worked\n";
405 PARROT_DYNEXT_EXPORT char *
406 nci_tb(void *p)
408 b[0] = ((char*) p)[1];
409 b[1] = ((char*) p)[0];
411 return b;
416 =item C<PARROT_DYNEXT_EXPORT char *
417 nci_tt(void *p)>
419 Prints "xx worked", where "xx" is replaced with the first two character values
420 of C<p>, in reverse order.
422 =cut
426 static char s[] = "xx worked\n";
428 PARROT_DYNEXT_EXPORT char *
429 nci_tt(void *p)
431 s[0] = ((char*) p)[1];
432 s[1] = ((char*) p)[0];
434 return s;
439 =item C<PARROT_DYNEXT_EXPORT char *
440 nci_tB(void **p)>
442 Prints "xx done", where "xx" is replaced with the first two character values
443 of C<p>, in reverse order.
445 =cut
449 static char B[] = "xx done\n";
451 PARROT_DYNEXT_EXPORT char *
452 nci_tB(void **p)
454 B[0] = (*(char**) p)[1];
455 B[1] = (*(char**) p)[0];
457 return B;
462 =item C<PARROT_DYNEXT_EXPORT void *
463 nci_pp(void *p)>
465 Returns the value C<p> directly.
467 =cut
471 PARROT_DYNEXT_EXPORT void *
472 nci_pp(void *p)
474 return p;
479 =item C<PARROT_DYNEXT_EXPORT int
480 nci_iiii(int i1, int i2, int i3)>
482 Prints three integers separated by whitespace to C<stderr>.
484 =cut
488 PARROT_DYNEXT_EXPORT int
489 nci_iiii(int i1, int i2, int i3)
491 fprintf(stderr, "%d %d %d\n", i1, i2, i3);
492 fflush(stderr);
494 return 2;
499 =item C<PARROT_DYNEXT_EXPORT int
500 nci_i4i(long * l, int i)>
502 Returns the product of C<*l> and C<i>, as an int.
504 =cut
508 PARROT_DYNEXT_EXPORT int
509 nci_i4i(long * l, int i)
512 return (int) (*l * i);
517 =item C<PARROT_DYNEXT_EXPORT int
518 nci_ii3(int a, int *bp)>
520 Multiplies C<a> and C<*bp> together and returns the result. Updates C<*bp>
521 to the value 4711.
523 =cut
527 PARROT_DYNEXT_EXPORT int
528 nci_ii3(int a, int *bp)
530 int r = a * *bp;
531 *bp = 4711;
533 return r;
538 =item C<PARROT_DYNEXT_EXPORT int
539 call_back(const char *str)>
541 writes the string C<str> to stdout and returns the value 4711.
543 =cut
547 PARROT_DYNEXT_EXPORT int
548 call_back(const char *str)
550 puts(str);
551 fflush(stdout);
553 return 4711;
558 =item C<PARROT_DYNEXT_EXPORT void *
559 nci_pi(int test)>
561 Performs one from a series of tests, depending on the value given for C<test>.
563 =cut
567 PARROT_DYNEXT_EXPORT void *
568 nci_pi(int test)
570 switch (test) {
571 case 0:
573 static struct {
574 int i[2];
575 char c;
576 } t = {
577 {42, 100},
580 return &t;
582 case 1:
584 static struct {
585 float f[2];
586 double d;
587 } t = {
588 {42.0, 100.0},
589 47.11
591 return &t;
593 case 2:
595 static struct {
596 char c;
597 int i;
598 } t = {
602 return &t;
604 case 3:
606 static struct {
607 const char *c;
608 int i;
609 } t = {
610 "hello",
613 return &t;
615 case 4:
617 static struct _x {
618 int i;
619 int j;
620 double d;
621 } xx = { 100, 77, 200.0 };
622 static struct {
623 char c;
624 struct _x *x;
625 } t = {
629 return &t;
631 case 5:
633 static struct {
634 int (*f)(const char *);
635 } t = {
636 call_back
638 return &t;
640 case 6:
642 static struct xt {
643 int x;
644 struct yt {
645 int i;
646 int j;
647 } _y;
648 int z;
649 } _x = {
651 { 127, 12345 },
654 return &_x;
656 case 7:
658 static struct xt {
659 char x;
660 struct yt {
661 char i;
662 int j;
663 } _y;
664 char z;
665 } _x = {
667 { 127, 12345 },
670 return &_x;
672 case 8:
674 static struct _z {
675 int i;
676 int j;
677 } zz = { 100, 77 };
678 static struct xt {
679 int x;
680 struct yt {
681 int i;
682 int j;
683 struct _z *z;
684 } _y;
685 } _x = {
687 { 127, 12345, &zz },
689 return &_x;
691 case 9:
693 static int i = 55555;
694 return &i;
696 case 10:
697 return NULL;
698 default:
699 fprintf(stderr, "unknown test number\n");
702 return NULL;
707 =item C<PARROT_DYNEXT_EXPORT short
708 nci_s(void)>
710 Returns the value of C<nci_dlvar_short>.
712 =cut
716 PARROT_DYNEXT_EXPORT short
717 nci_s(void)
719 return nci_dlvar_short;
724 =item C<PARROT_DYNEXT_EXPORT short
725 nci_ssc(short l1, char l2)>
727 Returns the product of C<l1 * l2>.
729 =cut
733 PARROT_DYNEXT_EXPORT short
734 nci_ssc(short l1, char l2)
736 return l1 * l2;
741 =item C<PARROT_DYNEXT_EXPORT void
742 nci_vP(void *pmc)>
744 Prints "ok" if C<PMC> is not null, prints "got null" otherwise.
746 =cut
750 PARROT_DYNEXT_EXPORT void
751 nci_vP(void *pmc)
753 /* Disable this test until someone figures a way to check for
754 * PMCNULL without using libparrot.
755 if (!PMC_IS_NULL(pmc))
756 puts("ok");
757 else
759 puts("got null");
765 =back
767 =head2 Functions used for pdd16 tests
769 =over 4
771 =cut
777 =item C<PARROT_DYNEXT_EXPORT void
778 nci_cb_C1(cb_C1_func cb, void* user_data)>
780 Calls C<cb> function with the string "result" and the given C<user_data>.
781 No return value.
783 =cut
787 PARROT_DYNEXT_EXPORT void
788 nci_cb_C1(cb_C1_func cb, void* user_data)
790 const char *result = "succeeded";
791 /* call the cb synchronously */
792 (cb)(result, user_data);
794 return;
799 =item C<PARROT_DYNEXT_EXPORT void
800 nci_cb_C2(cb_C2_func cb, void* user_data)>
802 Calls the function C<cb> with the pointer C<user_data>. No return value.
804 =cut
808 PARROT_DYNEXT_EXPORT void
809 nci_cb_C2(cb_C2_func cb, void* user_data)
811 /* call the cb synchronously */
812 (cb)(77, user_data);
814 return;
819 =item C<PARROT_DYNEXT_EXPORT void
820 nci_cb_C3(cb_C3_func cb, void* user_data)>
822 Calls function C<cb> with data C<user_data>. No return value.
824 =cut
828 static int int_cb_C3 = 99;
830 PARROT_DYNEXT_EXPORT void
831 nci_cb_C3(cb_C3_func cb, void* user_data)
833 /* call the cb synchronously */
834 (cb)(&int_cb_C3, user_data);
836 return;
841 =item C<PARROT_DYNEXT_EXPORT void
842 nci_cb_D1(cb_D1_func cb, void* user_data)>
844 Calls function C<cb> with data C<user_data>. No return value.
846 =cut
850 PARROT_DYNEXT_EXPORT void
851 nci_cb_D1(cb_D1_func cb, void* user_data)
853 const char *result = "succeeded";
854 /* call the cb synchronously */
855 (cb)(user_data, result);
857 return;
862 =item C<PARROT_DYNEXT_EXPORT void
863 nci_cb_D2(cb_D2_func cb, void* user_data)>
865 Calls function C<cb> with data C<user_data>.
867 =cut
871 PARROT_DYNEXT_EXPORT void
872 nci_cb_D2(cb_D2_func cb, void* user_data)
874 /* call the cb synchronously */
875 (cb)(user_data, 88);
877 return;
882 =item C<PARROT_DYNEXT_EXPORT void
883 nci_cb_D3(cb_D3_func cb, void* user_data)>
885 Calls function C<cb> with data C<user_data>.
887 =cut
891 static int int_cb_D3 = 111;
893 PARROT_DYNEXT_EXPORT void
894 nci_cb_D3(cb_D3_func cb, void* user_data)
896 /* call the cb synchronously */
897 (cb)(user_data, &int_cb_D3);
899 return;
904 =item C<PARROT_DYNEXT_EXPORT void
905 nci_cb_D4(cb_D4_func times_ten, void* user_data)>
907 Calls function C<times_ten> with data C<user_data> 10 times in a loop.
909 =cut
913 PARROT_DYNEXT_EXPORT void
914 nci_cb_D4(cb_D4_func times_ten, void* user_data)
916 int cnt;
917 for (cnt = 0; cnt < 9; cnt++)
919 (times_ten)(user_data, &int_cb_D4);
920 int_cb_D4++;
923 return;
928 =item C<PARROT_DYNEXT_EXPORT void
929 nci_pip(int count, Rect_Like *rects)>
931 Prints a count integer and the coordinates of 4 rectangles.
933 =cut
937 PARROT_DYNEXT_EXPORT void
938 nci_pip(int count, Rect_Like *rects)
940 int i;
941 printf("Count: %d\n", count);
942 for (i = 0; i < 4; ++i)
943 printf("X: %d\nY: %d\nW: %d\nH: %d\n",
944 rects[i].x, rects[i].y, rects[i].w, rects[i].h);
949 =item C<PARROT_DYNEXT_EXPORT int
950 nci_i33(int *double_me, int *triple_me)>
952 Returns the result C<*double_me * 2 + *triple_me * 3>.
954 =cut
958 PARROT_DYNEXT_EXPORT int
959 nci_i33(int *double_me, int *triple_me)
961 *double_me *= 2;
962 *triple_me *= 3;
964 return (*double_me + *triple_me);
969 =item C<PARROT_DYNEXT_EXPORT void
970 nci_vpii(Outer *my_data, int my_x, int my_y)>
972 Updates data in structure pointer C<my_data> with the given data C<my_x> and
973 C<my_y>.
975 =cut
979 PARROT_DYNEXT_EXPORT void
980 nci_vpii(Outer *my_data, int my_x, int my_y)
982 my_data->x = my_x;
983 my_data->nested->y = my_y;
988 =item C<PARROT_DYNEXT_EXPORT void *
989 nci_piiii(int alpha, int beta, int gamma, int delta)>
991 Stores 4 integer values into an array structure, and returns the address
992 of that structure.
994 =cut
998 static int my_array[4];
1000 PARROT_DYNEXT_EXPORT void *
1001 nci_piiii(int alpha, int beta, int gamma, int delta)
1003 static struct array_container
1005 int x;
1006 int *array;
1007 } container;
1009 my_array[0] = alpha;
1010 my_array[1] = beta;
1011 my_array[2] = gamma;
1012 my_array[3] = delta;
1014 container.x = 4;
1015 container.array = my_array;
1017 return &container;
1022 =item C<PARROT_DYNEXT_EXPORT void *
1023 nci_pii(int fac1, int fac2)>
1025 Returns the address of global variable C<nci_dlvar_int> whose value is set
1026 to the product of C<fac1 * fac2>.
1028 =cut
1032 PARROT_DYNEXT_EXPORT void *
1033 nci_pii(int fac1, int fac2)
1035 nci_dlvar_int = fac1 * fac2;
1037 return &nci_dlvar_int;
1042 =item C<PARROT_DYNEXT_EXPORT void
1043 nci_v(void)>
1045 Multiplies the global variable C<nci_dlvar_int> times 10.
1047 =cut
1051 PARROT_DYNEXT_EXPORT void
1052 nci_v(void)
1054 nci_dlvar_int *= 10;
1059 =item C<PARROT_DYNEXT_EXPORT void
1060 nci_vv(void)>
1062 Multiplies the global variable C<nci_dlvar_int> by 3.
1064 =cut
1068 PARROT_DYNEXT_EXPORT void
1069 nci_vv(void)
1071 nci_dlvar_int *= 3;
1076 =item C<PARROT_DYNEXT_EXPORT void
1077 nci_vVi(Opaque**, int)>
1079 Test an NCI opaque struct out value.
1081 =cut
1085 PARROT_DYNEXT_EXPORT void
1086 nci_vVi(Opaque **outOpaque, int x)
1088 static Opaque opaque;
1089 opaque.x = x;
1090 *outOpaque = &opaque;
1095 =item C<PARROT_DYNEXT_EXPORT int
1096 nci_vp(Opaque*)>
1098 Test that a previously generated opaque struct gets passed back
1099 to an NCI function correctly.
1101 =cut
1105 PARROT_DYNEXT_EXPORT void
1106 nci_vp(Opaque *inOpaque)
1108 if (inOpaque)
1109 printf("got %d\n", inOpaque->x);
1110 else
1111 printf("got null\n");
1116 =item C<PARROT_DYNEXT_EXPORT char *
1117 nci_ttt(void *p)>
1119 Prints "s2, s1, s1d"
1121 =cut
1125 PARROT_DYNEXT_EXPORT char *
1126 nci_ttt(char *s1, char *s2)
1128 char* s = (char*) malloc(strlen(s2) + (2 * strlen(s1)) + 5);
1129 sprintf(s, "%s, %s, %s", s2, s2, s1);
1130 printf("%s\n", s);
1131 return s;
1135 static void validate_float(float f, double checkval) {
1136 int valid;
1137 double error_ratio;
1138 error_ratio = (((double)f) - checkval) / checkval;
1139 valid = error_ratio <= 0.01 && error_ratio >= -0.01;
1140 printf("%i\n", valid);
1145 =item C<PARROT_DYNEXT_EXPORT float
1146 nci_fff(float l1, float l2)>
1148 Returns the result of C<l1> / C<l2>.
1150 =cut
1154 PARROT_DYNEXT_EXPORT void
1155 nci_vfff(float l1, float l2, float l3)
1157 validate_float(l1, 3456.54);
1158 validate_float(l2, 10.1999);
1159 validate_float(l3, 14245.567);
1165 =item C<PARROT_DYNEXT_EXPORT float
1166 nci_fff(float l1, float l2)>
1168 Returns the result of C<l1> / C<l2>.
1170 =cut
1174 PARROT_DYNEXT_EXPORT void
1175 nci_vV(const char **ptr)
1177 *ptr = "Hello bright new world\n";
1182 =item C<PARROT_DYNEXT_EXPORT float
1183 nci_fff(float l1, float l2)>
1185 Returns the result of C<l1> / C<l2>.
1187 =cut
1191 PARROT_DYNEXT_EXPORT void
1192 nci_vVVV(const char **ptr1, const char **ptr2, const char **ptr3)
1194 *ptr1 = "Hello bright new world!\n";
1195 *ptr2 = "It is a beautiful day!\n";
1196 *ptr3 = "Go suck a lemon.\n";
1199 #ifdef TEST
1201 char l2 = 4;
1202 float f2 = 4.0;
1206 =item C<int
1207 main(void)>
1209 Calls test functions C<nci_ssc> and C<nci_fff> and prints their results.
1211 =cut
1216 main(void)
1218 short l1 = 3;
1219 float f, f1 = 3.0;
1220 int l = nci_ssc(l1, l2);
1221 printf("%d\n", l);
1222 f = nci_fff(f1, f2);
1223 printf("%f\n", f);
1225 return 0;
1228 #endif
1230 #ifdef __cplusplus
1232 #endif
1236 =back
1238 =head1 SEE ALSO:
1240 F<docs/pdds/pdd16_native_call.pod>
1241 F<config/gen/makefiles/root.in>
1242 F<t/pmc/nci.t>
1244 =cut
1250 * Local variables:
1251 * c-file-style: "parrot"
1252 * End:
1253 * vim: expandtab shiftwidth=4: