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: static char * xstrdup (const char *s); sl@0: sl@0: void print_header (void); sl@0: void print_footer (void); 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 n; sl@0: char *string; sl@0: char *arg_string; 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: string = oil_prototype_to_string (proto); sl@0: if (strlen (string) == 0) { sl@0: free (string); sl@0: string = xstrdup("void"); sl@0: } sl@0: arg_string = oil_prototype_to_arg_string (proto); sl@0: sl@0: printf ("#undef oil_%s\n", klass->name); sl@0: printf ("void\n"); sl@0: printf ("oil_%s (%s)\n", klass->name, string); sl@0: printf ("{\n"); sl@0: printf (" if (_oil_function_class_%s.func == NULL) {\n", klass->name); sl@0: printf (" oil_class_optimize (&_oil_function_class_%s);\n", klass->name); sl@0: printf (" }\n"); sl@0: printf (" ((void (*)(%s))(_oil_function_class_%s.func))(%s);\n", sl@0: string, klass->name, arg_string); sl@0: printf ("}\n"); sl@0: printf ("\n"); sl@0: sl@0: oil_prototype_free (proto); sl@0: free (string); sl@0: free (arg_string); 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: print_footer (); sl@0: sl@0: return 0; sl@0: } sl@0: sl@0: void print_header (void) sl@0: { sl@0: printf ("/*\n"); sl@0: printf (" * LIBOIL - Library of Optimized Inner Loops\n"); sl@0: printf (" * Copyright (c) 2004 David A. Schleef \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 ("#include \n"); sl@0: printf ("#include \n"); sl@0: printf ("#include \n"); sl@0: printf ("\n"); sl@0: } sl@0: sl@0: void print_footer (void) sl@0: { sl@0: printf ("\n"); sl@0: } sl@0: sl@0: static char * sl@0: xstrdup (const char *s) sl@0: { sl@0: int n = strlen(s); sl@0: char *t; sl@0: sl@0: n = strlen(s); sl@0: t = malloc(n + 1); sl@0: memcpy (t, s, n); sl@0: t[n] = 0; sl@0: sl@0: return t; sl@0: } sl@0: