Hi all.
I'm currently working on a performance critical application which incorporates legacy c code (a SPICE variant).
The problem is as follows:
The creators of the legacy c code apparently believed that the use of argument passing is one of the great evils of the modern age. Thus about 90% of all the variables were declared globally.
The legacy code has to be called repeatedly for simulation purposes and it would be seam that using threads for concurrent calls to this code section would be beneficial for the overall execution time.
My idea was to encapsulate the legacy c code (which I already modified slightly for g++ compilation) so that multiple objects for the legacy code can be created removing the necessity of to many mutex locks. Obviously the global variables will thus be encapsulated as member variables.
This brought another problem to the table. The legacy coders also did not believe in the initialization of global variables; probably since C tend to init global variables to 0. C++ member variables does not seam to get the same treatment though. A few variables has to be initialized to 0 for the correct operation of the legacy c code. But finding these variables have proven to be quite difficult due to the vast amount of global variables used.
Please keep in mind that time does not permit me to modify the legacy c code to any major degree.
My questions are as follows:
Am I correct in the assumption that the encapsulation of the C code would be faster than the use of about 90 mutex locks?
Is there an easy way of finding uninitialized member variable use? (As I understand gcc can only do this for automatic variables). So that I can init only the critical variables?
If not Question 2 ... is there a fast and clean way to initialize all the member variables without using the normal constructor init method?
Or (a long shot) is there a fast way of following program flow so that I might incorporate the argument passing myself?
Any help will be vastly appreciated. N.B.