sl@0: /* sl@0: * LIBOIL - Library of Optimized Inner Loops sl@0: * Copyright (c) 2004 David A. Schleef sl@0: * All rights reserved. sl@0: * sl@0: * Redistribution and use in source and binary forms, with or without sl@0: * modification, are permitted provided that the following conditions sl@0: * are met: sl@0: * 1. Redistributions of source code must retain the above copyright sl@0: * notice, this list of conditions and the following disclaimer. sl@0: * 2. Redistributions in binary form must reproduce the above copyright sl@0: * notice, this list of conditions and the following disclaimer in the sl@0: * documentation and/or other materials provided with the distribution. sl@0: * sl@0: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR sl@0: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED sl@0: * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE sl@0: * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, sl@0: * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES sl@0: * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR sl@0: * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) sl@0: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, sl@0: * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING sl@0: * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE sl@0: * POSSIBILITY OF SUCH DAMAGE. sl@0: */ sl@0: sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: #include sl@0: sl@0: void print_header (void); sl@0: void print_footer (void); sl@0: void add_pointer_mask (unsigned int mask); sl@0: sl@0: unsigned int proto_masks[1000]; sl@0: int n_for_mask[1000]; sl@0: int n_proto_masks; sl@0: sl@0: int main (int argc, char *argv[]) sl@0: { sl@0: OilFunctionClass *klass; sl@0: OilPrototype *proto; sl@0: int i; sl@0: int j; sl@0: int n; sl@0: unsigned int pointer_mask; sl@0: sl@0: oil_init_no_optimize (); sl@0: sl@0: print_header (); sl@0: sl@0: n = oil_class_get_n_classes (); sl@0: for (i=0;iprototype) { sl@0: proto = oil_prototype_from_string (klass->prototype); sl@0: if (proto) { sl@0: pointer_mask = 1; sl@0: sl@0: for (j=0;jn_params;j++){ sl@0: pointer_mask <<= 1; sl@0: if (proto->params[j].is_pointer) pointer_mask |= 1; sl@0: } sl@0: sl@0: add_pointer_mask (pointer_mask); sl@0: sl@0: oil_prototype_free (proto); sl@0: } else { sl@0: printf("/* ERROR: could not parse %s(%s) */\n", klass->name, klass->prototype); sl@0: } sl@0: } sl@0: } sl@0: sl@0: for(i=0;i>=2; sl@0: sl@0: printf(" case 0x%04x:\n", pointer_mask); sl@0: printf(" oil_profile_start (prof);\n"); sl@0: printf(" ((void (*)("); sl@0: if(hibit == 0) { sl@0: printf("void"); sl@0: } else { sl@0: for(bit=hibit;bit;bit >>= 1) { sl@0: if (pointer_mask & bit) { sl@0: printf("void *"); sl@0: } else { sl@0: printf("int"); sl@0: } sl@0: if (bit > 1) { sl@0: printf(","); sl@0: } sl@0: } sl@0: } sl@0: printf("))func)\n"); sl@0: printf(" ("); sl@0: j=0; sl@0: for(bit=hibit;bit;bit >>= 1) { sl@0: if (pointer_mask & bit) { sl@0: printf("(void *)args[%d]", j); sl@0: } else { sl@0: printf("(int)args[%d]", j); sl@0: } sl@0: if (bit > 1) { sl@0: printf(","); sl@0: } sl@0: j++; sl@0: } sl@0: printf(");\n"); sl@0: printf(" oil_profile_stop (prof);\n"); sl@0: printf(" break;\n"); sl@0: } sl@0: sl@0: print_footer (); sl@0: sl@0: return 0; sl@0: } sl@0: sl@0: void sl@0: add_pointer_mask (unsigned int mask) sl@0: { sl@0: int i; sl@0: for(i=0;i\n"); sl@0: printf (" * All rights reserved.\n"); sl@0: printf (" *\n"); sl@0: printf (" * Redistribution and use in source and binary forms, with or without\n"); sl@0: printf (" * modification, are permitted provided that the following conditions\n"); sl@0: printf (" * are met:\n"); sl@0: printf (" * 1. Redistributions of source code must retain the above copyright\n"); sl@0: printf (" * notice, this list of conditions and the following disclaimer.\n"); sl@0: printf (" * 2. Redistributions in binary form must reproduce the above copyright\n"); sl@0: printf (" * notice, this list of conditions and the following disclaimer in the\n"); sl@0: printf (" * documentation and/or other materials provided with the distribution.\n"); sl@0: printf (" * \n"); sl@0: printf (" * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR\n"); sl@0: printf (" * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n"); sl@0: printf (" * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n"); sl@0: printf (" * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,\n"); sl@0: printf (" * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n"); sl@0: printf (" * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\n"); sl@0: printf (" * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n"); sl@0: printf (" * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n"); sl@0: printf (" * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING\n"); sl@0: printf (" * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n"); sl@0: printf (" * POSSIBILITY OF SUCH DAMAGE.\n"); sl@0: printf (" */\n"); sl@0: printf ("\n"); sl@0: printf ("/* This file is automatically generated. Do not edit. */\n"); sl@0: printf ("\n"); sl@0: printf ("#ifdef HAVE_CONFIG_H\n"); sl@0: printf ("#include \n"); sl@0: printf ("#endif\n"); sl@0: printf ("\n"); sl@0: printf ("#include \n"); sl@0: printf ("#include \n"); sl@0: printf ("#include \n"); sl@0: printf ("\n"); sl@0: printf ("void\n"); sl@0: printf ("_oil_test_marshal_function (void *func, unsigned long *args, int n_args,\n"); sl@0: printf (" unsigned int pointer_mask, OilProfile *prof)\n"); sl@0: printf ("{\n"); sl@0: printf (" switch (pointer_mask) {\n"); sl@0: } sl@0: sl@0: void print_footer (void) sl@0: { sl@0: printf (" default:\n"); sl@0: printf (" OIL_ERROR (\"unhandled marshal case\");\n"); sl@0: printf (" }\n"); sl@0: printf ("}\n"); sl@0: printf ("\n"); sl@0: } sl@0: