[docs] Add some POD to Tapir, rurban++
[parrot.git] / src / nci_test.c
blobf532174477d8c9f1909a6ea593386163c7ef74ee
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/nci/extra_thunks.nci 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(char *);
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 nci_c(void)>
155 Returns the value of the variable C<nci_dlvar_char>, which is set to 22 by
156 default.
158 =cut
162 PARROT_DYNEXT_EXPORT char
163 nci_c(void) {
164 return nci_dlvar_char;
169 =item C<PARROT_DYNEXT_EXPORT char nci_csc(short l1, char l2)>
171 Multiplies C<l1> and C<l2> together and returns the first byte of the result.
173 =cut
177 PARROT_DYNEXT_EXPORT char
178 nci_csc(short l1, char l2)
180 return l1 * l2;
185 =item C<PARROT_DYNEXT_EXPORT double nci_d(void)>
187 Multiplies the current value of C<nci_dlvar_double> by 10.0, and returns
188 the new value.
190 =cut
194 PARROT_DYNEXT_EXPORT double
195 nci_d(void)
197 nci_dlvar_double *= 10.0;
199 return nci_dlvar_double;
204 =item C<PARROT_DYNEXT_EXPORT double nci_dd(double d)>
206 Returns the value C<d> multiplied by 2.0.
208 =cut
212 PARROT_DYNEXT_EXPORT double
213 nci_dd(double d)
215 return d * 2.0;
220 =item C<PARROT_DYNEXT_EXPORT float nci_f(void)>
222 Multiplies the value C<nci_dlvar_float> by 10.0 and returns the new
223 value.
225 =cut
229 PARROT_DYNEXT_EXPORT float
230 nci_f(void)
232 nci_dlvar_float *= 10.0;
234 return nci_dlvar_float;
239 =item C<PARROT_DYNEXT_EXPORT float nci_fff(float l1, float l2)>
241 Returns the result of C<l1> / C<l2>.
243 =cut
247 PARROT_DYNEXT_EXPORT float
248 nci_fff(float l1, float l2)
250 return l1 / l2;
255 =item C<PARROT_DYNEXT_EXPORT int nci_i(void)>
257 Returns the current value of <nci_dlvar_int>.
259 =cut
263 PARROT_DYNEXT_EXPORT int
264 nci_i(void)
266 return nci_dlvar_int;
271 =item C<PARROT_DYNEXT_EXPORT int nci_isc(short l1, char l2)>
273 Returns the int product of C<l1 * l2>.
275 =cut
279 PARROT_DYNEXT_EXPORT int
280 nci_isc(short l1, char l2)
282 return l1 * l2;
287 =item C<PARROT_DYNEXT_EXPORT int nci_ip(void *p)>
289 Performs a series of operations on values stored at pointer C<p>.
291 =cut
295 PARROT_DYNEXT_EXPORT int
296 nci_ip(void *p)
298 typedef struct _dfi {
299 double d;
300 float f;
301 int i;
302 char *s;
303 } dfi;
304 dfi *sp = (dfi*) p;
305 puts(sp->s);
306 fflush(stdout);
308 return (int) (sp->d + sp->f + sp->i);
313 =item C<PARROT_DYNEXT_EXPORT int nci_it(void *p)>
315 Prints the first two characters in C<p>, in reversed order. Returns 2.
317 =cut
321 PARROT_DYNEXT_EXPORT int
322 nci_it(void *p)
324 fprintf(stderr, "%c%c\n", ((char*) p)[1], ((char *) p)[0]);
325 fflush(stderr);
327 return 2;
332 =item C<PARROT_DYNEXT_EXPORT long nci_l(void)>
334 Returns the value of C<nci_dlvar_long>.
336 =cut
340 PARROT_DYNEXT_EXPORT long
341 nci_l(void)
343 return nci_dlvar_long;
348 =item C<PARROT_DYNEXT_EXPORT int * nci_p(void)>
350 Returns the address of C<nci_dlvar_int>.
352 =cut
356 PARROT_DYNEXT_EXPORT int *
357 nci_p(void)
359 return &nci_dlvar_int;
364 =item C<PARROT_DYNEXT_EXPORT char * nci_t(void)>
366 Returns the value of C<nci_dlvar_cstring>.
368 =cut
372 PARROT_DYNEXT_EXPORT char *
373 nci_t(void)
375 return nci_dlvar_cstring;
380 =item C<PARROT_DYNEXT_EXPORT char * nci_tb(void *p)>
382 Returns "xx worked", where "xx" is replaced with the first two character values
383 of C<p>, in reverse order.
385 =cut
389 static char b[] = "xx worked\n";
391 PARROT_DYNEXT_EXPORT char *
392 nci_tb(void *p)
394 b[0] = ((char*) p)[1];
395 b[1] = ((char*) p)[0];
397 return b;
402 =item C<PARROT_DYNEXT_EXPORT char * nci_tt(char *p)>
404 Returns "xx worked", where "xx" is replaced with the first two character values
405 of C<p>, in reverse order.
407 =cut
411 static char s[] = "xx worked\n";
413 PARROT_DYNEXT_EXPORT char *
414 nci_tt(char *p)
416 s[0] = p[1];
417 s[1] = p[0];
419 return s;
424 =item C<PARROT_DYNEXT_EXPORT char * nci_tB(void **p)>
426 Returns "xx done", where "xx" is replaced with the first two character values
427 of C<p>, in reverse order.
429 =cut
433 static char B[] = "xx done\n";
435 PARROT_DYNEXT_EXPORT char *
436 nci_tB(void **p)
438 B[0] = (*(char**) p)[1];
439 B[1] = (*(char**) p)[0];
441 return B;
446 =item C<PARROT_DYNEXT_EXPORT void * nci_pp(void *p)>
448 Returns the value C<p> directly.
450 =cut
454 PARROT_DYNEXT_EXPORT void *
455 nci_pp(void *p)
457 return p;
462 =item C<PARROT_DYNEXT_EXPORT int nci_iiii(int i1, int i2, int i3)>
464 Prints three integers separated by whitespace to C<stderr>.
465 Returns 2.
467 =cut
471 PARROT_DYNEXT_EXPORT int
472 nci_iiii(int i1, int i2, int i3)
474 fprintf(stderr, "%d %d %d\n", i1, i2, i3);
475 fflush(stderr);
477 return 2;
482 =item C<PARROT_DYNEXT_EXPORT int nci_i4i(long * l, int i)>
484 Returns the product of C<*l> and C<i>, as an int.
486 =cut
490 PARROT_DYNEXT_EXPORT int
491 nci_i4i(long * l, int i)
494 return (int) (*l * i);
499 =item C<PARROT_DYNEXT_EXPORT int nci_ii3(int a, int *bp)>
501 Multiplies C<a> and C<*bp> together and returns the result. Updates C<*bp>
502 to the value 4711.
504 =cut
508 PARROT_DYNEXT_EXPORT int
509 nci_ii3(int a, int *bp)
511 int r = a * *bp;
512 *bp = 4711;
514 return r;
519 =item C<PARROT_DYNEXT_EXPORT int call_back(const char *str)>
521 writes the string C<str> to stdout and returns the value 4711.
523 =cut
527 PARROT_DYNEXT_EXPORT int
528 call_back(const char *str)
530 puts(str);
531 fflush(stdout);
533 return 4711;
538 =item C<PARROT_DYNEXT_EXPORT void * nci_pi(int test)>
540 Performs one from a series of tests, depending on the value given for C<test>.
542 =cut
546 PARROT_DYNEXT_EXPORT void *
547 nci_pi(int test)
549 switch (test) {
550 case 0:
552 static struct {
553 int i[2];
554 char c;
555 } t = {
556 {42, 100},
559 return &t;
561 case 1:
563 static struct {
564 float f[2];
565 double d;
566 } t = {
567 {42.0, 100.0},
568 47.11
570 return &t;
572 case 2:
574 static struct {
575 char c;
576 int i;
577 } t = {
581 return &t;
583 case 3:
585 static struct {
586 const char *c;
587 int i;
588 } t = {
589 "hello",
592 return &t;
594 case 4:
596 static struct _x {
597 int i;
598 int j;
599 double d;
600 } xx = { 100, 77, 200.0 };
601 static struct {
602 char c;
603 struct _x *x;
604 } t = {
608 return &t;
610 case 5:
612 static struct {
613 int (*f)(const char *);
614 } t = {
615 call_back
617 return &t;
619 case 6:
621 static struct xt {
622 int x;
623 struct yt {
624 int i;
625 int j;
626 } _y;
627 int z;
628 } _x = {
630 { 127, 12345 },
633 return &_x;
635 case 7:
637 static struct xt {
638 char x;
639 struct yt {
640 char i;
641 int j;
642 } _y;
643 char z;
644 } _x = {
646 { 127, 12345 },
649 return &_x;
651 case 8:
653 static struct _z {
654 int i;
655 int j;
656 } zz = { 100, 77 };
657 static struct xt {
658 int x;
659 struct yt {
660 int i;
661 int j;
662 struct _z *z;
663 } _y;
664 } _x = {
666 { 127, 12345, &zz },
668 return &_x;
670 case 9:
672 static int i = 55555;
673 return &i;
675 case 10:
676 return NULL;
677 default:
678 fprintf(stderr, "unknown test number\n");
681 return NULL;
686 =item C<PARROT_DYNEXT_EXPORT short nci_s(void)>
688 Returns the value of C<nci_dlvar_short>.
690 =cut
694 PARROT_DYNEXT_EXPORT short
695 nci_s(void)
697 return nci_dlvar_short;
702 =item C<PARROT_DYNEXT_EXPORT short nci_ssc(short l1, char l2)>
704 Returns the product of C<l1 * l2>.
706 =cut
710 PARROT_DYNEXT_EXPORT short
711 nci_ssc(short l1, char l2)
713 return l1 * l2;
718 =item C<PARROT_DYNEXT_EXPORT void nci_vP(void *pmc)>
720 Prints "ok" if C<PMC> is not null, prints "got null" otherwise.
722 =cut
726 PARROT_DYNEXT_EXPORT void
727 nci_vP(void *pmc)
729 /* TODO:
730 * Disable this test until someone figures a way to check for
731 * PMCNULL without using libparrot.
732 if (!PMC_IS_NULL(pmc))
733 puts("ok");
734 else
736 puts("got null");
742 =back
744 =head2 Functions used for pdd16 tests
746 =over 4
748 =cut
754 =item C<PARROT_DYNEXT_EXPORT void nci_cb_C1(cb_C1_func cb, void* user_data)>
756 Calls C<cb> function with the string "result" and the given C<user_data>.
757 No return value.
759 =cut
763 PARROT_DYNEXT_EXPORT void
764 nci_cb_C1(cb_C1_func cb, void* user_data)
766 const char *result = "succeeded";
767 /* call the cb synchronously */
768 (cb)(result, user_data);
770 return;
775 =item C<PARROT_DYNEXT_EXPORT void nci_cb_C2(cb_C2_func cb, void* user_data)>
777 Calls the function C<cb> with the integer 77 and the given C<user_data>.
778 No return value.
780 =cut
784 PARROT_DYNEXT_EXPORT void
785 nci_cb_C2(cb_C2_func cb, void* user_data)
787 /* call the cb synchronously */
788 (cb)(77, user_data);
790 return;
795 =item C<PARROT_DYNEXT_EXPORT void nci_cb_C3(cb_C3_func cb, void* user_data)>
797 Calls function C<cb> with C<&int_cb_C3> and the givn C<user_data>.
798 No return value.
800 =cut
804 static int int_cb_C3 = 99;
806 PARROT_DYNEXT_EXPORT void
807 nci_cb_C3(cb_C3_func cb, void* user_data)
809 /* call the cb synchronously */
810 (cb)(&int_cb_C3, user_data);
812 return;
817 =item C<PARROT_DYNEXT_EXPORT void nci_cb_D1(cb_D1_func cb, void* user_data)>
819 Calls function C<cb> with data C<user_data> and the string "succeeded".
820 No return value.
822 =cut
826 PARROT_DYNEXT_EXPORT void
827 nci_cb_D1(cb_D1_func cb, void* user_data)
829 const char *result = "succeeded";
830 /* call the cb synchronously */
831 (cb)(user_data, result);
833 return;
838 =item C<PARROT_DYNEXT_EXPORT void nci_cb_D2(cb_D2_func cb, void* user_data)>
840 Calls function C<cb> with data C<user_data> and the integer 88.
841 No return value.
843 =cut
847 PARROT_DYNEXT_EXPORT void
848 nci_cb_D2(cb_D2_func cb, void* user_data)
850 /* call the cb synchronously */
851 (cb)(user_data, 88);
853 return;
858 =item C<PARROT_DYNEXT_EXPORT void nci_cb_D3(cb_D3_func cb, void* user_data)>
860 Calls function C<cb> with data C<user_data> and C<&int_cb_D3>.
861 No return value.
863 =cut
867 static int int_cb_D3 = 111;
869 PARROT_DYNEXT_EXPORT void
870 nci_cb_D3(cb_D3_func cb, void* user_data)
872 /* call the cb synchronously */
873 (cb)(user_data, &int_cb_D3);
875 return;
880 =item C<PARROT_DYNEXT_EXPORT void nci_cb_D4(cb_D4_func times_ten, void*
881 user_data)>
883 Calls function C<times_ten> with data C<user_data> and C<&int_cb_D4> 10 times
884 in a loop, incrementing C<int_cb_D4> after every call.
885 No return value.
887 =cut
891 PARROT_DYNEXT_EXPORT void
892 nci_cb_D4(cb_D4_func times_ten, void* user_data)
894 int cnt;
895 for (cnt = 0; cnt < 9; cnt++)
897 (times_ten)(user_data, &int_cb_D4);
898 int_cb_D4++;
901 return;
906 =item C<PARROT_DYNEXT_EXPORT void nci_pip(int count, Rect_Like *rects)>
908 Prints a count integer and the coordinates of 4 rectangles.
910 =cut
914 PARROT_DYNEXT_EXPORT void
915 nci_pip(int count, Rect_Like *rects)
917 int i;
918 printf("Count: %d\n", count);
919 for (i = 0; i < 4; ++i)
920 printf("X: %d\nY: %d\nW: %d\nH: %d\n",
921 rects[i].x, rects[i].y, rects[i].w, rects[i].h);
926 =item C<PARROT_DYNEXT_EXPORT int nci_i33(int *double_me, int *triple_me)>
928 Doubles C<double_me> and triples C<triple_me>. Returns their sum.
930 =cut
934 PARROT_DYNEXT_EXPORT int
935 nci_i33(int *double_me, int *triple_me)
937 *double_me *= 2;
938 *triple_me *= 3;
940 return (*double_me + *triple_me);
945 =item C<PARROT_DYNEXT_EXPORT void nci_vpii(Outer *my_data, int my_x, int my_y)>
947 Updates data in structure pointer C<my_data> with the given data C<my_x> and
948 C<my_y>.
950 =cut
954 PARROT_DYNEXT_EXPORT void
955 nci_vpii(Outer *my_data, int my_x, int my_y)
957 my_data->x = my_x;
958 my_data->nested->y = my_y;
963 =item C<PARROT_DYNEXT_EXPORT void * nci_piiii(int alpha, int beta, int gamma,
964 int delta)>
966 Stores 4 integer values into an array structure, and returns the address
967 of that structure.
969 =cut
973 static int my_array[4];
975 PARROT_DYNEXT_EXPORT void *
976 nci_piiii(int alpha, int beta, int gamma, int delta)
978 static struct array_container
980 int x;
981 int *array;
982 } container;
984 my_array[0] = alpha;
985 my_array[1] = beta;
986 my_array[2] = gamma;
987 my_array[3] = delta;
989 container.x = 4;
990 container.array = my_array;
992 return &container;
997 =item C<PARROT_DYNEXT_EXPORT void * nci_pii(int fac1, int fac2)>
999 Returns the address of global variable C<nci_dlvar_int> whose value is set
1000 to the product of C<fac1 * fac2>.
1002 =cut
1006 PARROT_DYNEXT_EXPORT void *
1007 nci_pii(int fac1, int fac2)
1009 nci_dlvar_int = fac1 * fac2;
1011 return &nci_dlvar_int;
1016 =item C<PARROT_DYNEXT_EXPORT void nci_v(void)>
1018 Multiplies the global variable C<nci_dlvar_int> times 10.
1020 =cut
1024 PARROT_DYNEXT_EXPORT void
1025 nci_v(void)
1027 nci_dlvar_int *= 10;
1032 =item C<PARROT_DYNEXT_EXPORT void nci_vv(void)>
1034 Multiplies the global variable C<nci_dlvar_int> by 3.
1036 =cut
1040 PARROT_DYNEXT_EXPORT void
1041 nci_vv(void)
1043 nci_dlvar_int *= 3;
1048 =item C<PARROT_DYNEXT_EXPORT void nci_vVi(Opaque **outOpaque, int x)>
1050 Test an NCI opaque struct out value.
1052 =cut
1056 PARROT_DYNEXT_EXPORT void
1057 nci_vVi(Opaque **outOpaque, int x)
1059 static Opaque opaque;
1060 opaque.x = x;
1061 *outOpaque = &opaque;
1066 =item C<PARROT_DYNEXT_EXPORT void nci_vp(Opaque *inOpaque)>
1068 Test that a previously generated opaque struct gets passed back
1069 to an NCI function correctly.
1071 =cut
1075 PARROT_DYNEXT_EXPORT void
1076 nci_vp(Opaque *inOpaque)
1078 if (inOpaque)
1079 printf("got %d\n", inOpaque->x);
1080 else
1081 printf("got null\n");
1086 =item C<PARROT_DYNEXT_EXPORT char * nci_ttt(char *s1, char *s2)>
1088 Prints and returns "s2, s2, s1"
1090 =cut
1094 PARROT_DYNEXT_EXPORT char *
1095 nci_ttt(char *s1, char *s2)
1097 char* s = (char*) malloc((2 * strlen(s2)) + strlen(s1) + 5);
1098 sprintf(s, "%s, %s, %s", s2, s2, s1);
1099 printf("%s\n", s);
1100 return s;
1104 static void
1105 validate_float(float f, double checkval) {
1106 int valid;
1107 double error_ratio;
1108 error_ratio = (((double)f) - checkval) / checkval;
1109 valid = error_ratio <= 0.01 && error_ratio >= -0.01;
1110 printf("%i\n", valid);
1115 =item C<PARROT_DYNEXT_EXPORT void nci_vfff(float l1, float l2, float l3)>
1117 Checks that C<[ l1, l2, l3 ]> = C<[ 3456.54, 10.1999, 14245.567 ]> within an
1118 error of 0.01.
1120 =cut
1124 PARROT_DYNEXT_EXPORT void
1125 nci_vfff(float l1, float l2, float l3)
1127 validate_float(l1, 3456.54);
1128 validate_float(l2, 10.1999);
1129 validate_float(l3, 14245.567);
1135 =item C<PARROT_DYNEXT_EXPORT void nci_vV(const char **ptr)>
1137 Sets C<*ptr> to "Hello bright new world\n".
1139 =cut
1143 PARROT_DYNEXT_EXPORT void
1144 nci_vV(const char **ptr)
1146 *ptr = "Hello bright new world\n";
1151 =item C<PARROT_DYNEXT_EXPORT void nci_vVVV(const char **ptr1, const char **ptr2,
1152 const char **ptr3)>
1154 Sets C<*ptr1> to "Hello bright new world!\n", C<*ptr2> to "It is a beautiful
1155 day!\n", and C<*ptr3> to "Go suck a lemon.\n".
1157 =cut
1161 PARROT_DYNEXT_EXPORT void
1162 nci_vVVV(const char **ptr1, const char **ptr2, const char **ptr3)
1164 *ptr1 = "Hello bright new world!\n";
1165 *ptr2 = "It is a beautiful day!\n";
1166 *ptr3 = "Go suck a lemon.\n";
1169 #ifdef TEST
1171 char l2 = 4;
1172 float f2 = 4.0;
1176 =item C<int main(void)>
1178 Calls test functions C<nci_ssc> and C<nci_fff> and prints their results.
1180 =cut
1185 main(void)
1187 short l1 = 3;
1188 float f, f1 = 3.0;
1189 int l = nci_ssc(l1, l2);
1190 printf("%d\n", l);
1191 f = nci_fff(f1, f2);
1192 printf("%f\n", f);
1194 return 0;
1197 #endif
1199 #ifdef __cplusplus
1201 #endif
1205 =back
1207 =head1 SEE ALSO:
1209 F<docs/pdds/pdd16_native_call.pod>
1210 F<config/gen/makefiles/root.in>
1211 F<t/pmc/nci.t>
1213 =cut
1219 * Local variables:
1220 * c-file-style: "parrot"
1221 * End:
1222 * vim: expandtab shiftwidth=4: