Update contrib.
2 * LIBOIL - Library of Optimized Inner Loops
3 * Copyright (c) 2004 David A. Schleef <ds@schleef.org>
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
19 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
23 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
30 #include <liboil/liboil.h>
35 #include <liboil/liboilprototype.h>
37 void print_header (void);
38 void print_footer (void);
39 void add_pointer_mask (unsigned int mask);
41 unsigned int proto_masks[1000];
45 int main (int argc, char *argv[])
47 OilFunctionClass *klass;
52 unsigned int pointer_mask;
54 oil_init_no_optimize ();
58 n = oil_class_get_n_classes ();
60 klass = oil_class_get_by_index (i);
62 if(klass->prototype) {
63 proto = oil_prototype_from_string (klass->prototype);
67 for (j=0;j<proto->n_params;j++){
69 if (proto->params[j].is_pointer) pointer_mask |= 1;
72 add_pointer_mask (pointer_mask);
74 oil_prototype_free (proto);
76 printf("/* ERROR: could not parse %s(%s) */\n", klass->name, klass->prototype);
81 for(i=0;i<n_proto_masks;i++){
85 pointer_mask = proto_masks[i];
86 for(hibit=1;hibit<=pointer_mask;hibit<<=1);
89 printf(" case 0x%04x:\n", pointer_mask);
90 printf(" oil_profile_start (prof);\n");
91 printf(" ((void (*)(");
95 for(bit=hibit;bit;bit >>= 1) {
96 if (pointer_mask & bit) {
109 for(bit=hibit;bit;bit >>= 1) {
110 if (pointer_mask & bit) {
111 printf("(void *)args[%d]", j);
113 printf("(int)args[%d]", j);
121 printf(" oil_profile_stop (prof);\n");
131 add_pointer_mask (unsigned int mask)
134 for(i=0;i<n_proto_masks;i++){
135 if (proto_masks[i] == mask) {
140 proto_masks[n_proto_masks] = mask;
141 n_for_mask[n_proto_masks]++;
145 void print_header (void)
148 printf (" * LIBOIL - Library of Optimized Inner Loops\n");
149 printf (" * Copyright (c) 2004 David A. Schleef <ds@schleef.org>\n");
150 printf (" * All rights reserved.\n");
152 printf (" * Redistribution and use in source and binary forms, with or without\n");
153 printf (" * modification, are permitted provided that the following conditions\n");
154 printf (" * are met:\n");
155 printf (" * 1. Redistributions of source code must retain the above copyright\n");
156 printf (" * notice, this list of conditions and the following disclaimer.\n");
157 printf (" * 2. Redistributions in binary form must reproduce the above copyright\n");
158 printf (" * notice, this list of conditions and the following disclaimer in the\n");
159 printf (" * documentation and/or other materials provided with the distribution.\n");
161 printf (" * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR\n");
162 printf (" * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n");
163 printf (" * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n");
164 printf (" * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,\n");
165 printf (" * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n");
166 printf (" * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\n");
167 printf (" * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n");
168 printf (" * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n");
169 printf (" * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING\n");
170 printf (" * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n");
171 printf (" * POSSIBILITY OF SUCH DAMAGE.\n");
174 printf ("/* This file is automatically generated. Do not edit. */\n");
176 printf ("#ifdef HAVE_CONFIG_H\n");
177 printf ("#include <config.h>\n");
180 printf ("#include <liboil/liboiltest.h>\n");
181 printf ("#include <liboil/liboildebug.h>\n");
182 printf ("#include <liboil/liboilprofile.h>\n");
185 printf ("_oil_test_marshal_function (void *func, unsigned long *args, int n_args,\n");
186 printf (" unsigned int pointer_mask, OilProfile *prof)\n");
188 printf (" switch (pointer_mask) {\n");
191 void print_footer (void)
193 printf (" default:\n");
194 printf (" OIL_ERROR (\"unhandled marshal case\");\n");