From 701b1c520865388a4287c6a3f63afb3ce2626cf1 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 5 May 2011 19:02:03 -0700 Subject: volk: make volk_machines.cc c-safe Initialize the list of machine structs w/ pointers, this does not rely on C++ initialization and is smaller. In addition, rename the file extension to .c so we know its C only. Interesting note, this also fixes a bug when compiling under MSVC, the machines list initialization seemed to have problems prior to this change. --- volk/gen/make_machines_c.py | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) (limited to 'volk/gen/make_machines_c.py') diff --git a/volk/gen/make_machines_c.py b/volk/gen/make_machines_c.py index 9ad56fb62..ccac21131 100644 --- a/volk/gen/make_machines_c.py +++ b/volk/gen/make_machines_c.py @@ -1,5 +1,5 @@ # -# Copyright 2010 Free Software Foundation, Inc. +# Copyright 2010-2011 Free Software Foundation, Inc. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -26,32 +26,16 @@ def make_machines_c(machines): #include <volk/volk_typedefs.h> #include <volk/volk_machines.h> -struct volk_machine volk_machines[] = { +struct volk_machine *volk_machines[] = { """ for machine in machines: tempstring += """#if LV_MACHINE_""" + machine.swapcase() + "\n" - tempstring += "volk_machine_" + machine + tempstring += "&volk_machine_" + machine tempstring += "," tempstring += "\n#endif\n" tempstring += r""" }; - -""" - - for machine in machines: - tempstring += "#if LV_MACHINE_" + machine.swapcase() + "\n" - tempstring += "#define LV_MACHINE_" + machine.swapcase() + "_CNT 1\n" - tempstring += "#else\n" - tempstring += "#define LV_MACHINE_" + machine.swapcase() + "_CNT 0\n" - tempstring += "#endif\n" - - tempstring += """unsigned int n_volk_machines = +unsigned int n_volk_machines = sizeof(volk_machines)/sizeof(*volk_machines); """ - for machine in machines: - tempstring += "(LV_MACHINE_" + machine.swapcase() + "_CNT) " - tempstring += "+ " - tempstring = tempstring[:-2] - tempstring += ";\n" - return tempstring -- cgit