-
Notifications
You must be signed in to change notification settings - Fork 920
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
C init #549
C init #549
Conversation
This comment has been minimized.
This comment has been minimized.
Interesting. Do you know what it may have looked like? It would be great if we could reconstruct this! |
@squidcc When you start you comment with "Not sure where/why you...", it's easy to feel like you're criticizing the person making the PR and not the implementation. If you instead start with your findings and then follow with your recommended change it becomes a factual argument and much less likely to be taken the wrong way. About this solution; while we talked on the chat we came to the believe that some sort of C++ helper was used, but we currently do not know how this would be implemented. The initial plan there for is to get things running so that we can get the compiler chain matching what is indicated by the rich header, then once that is done we would focus on how to get the different parts bin exact. When looking at using data_seg we felt that putting it in existing segments might not be safe/good practice. In the article I linked there are also some thoughts on this matter as well. XIM was one that I cam across a few times as a recommendation when I was doing further research on the subject, it simply puts it in the middle of the C init range (XIA-XIZ), and before globals are initialized (XIU). |
dthread.cpp dx.cpp init logging.cpp fault.cpp msgcmd.cpp nthread.cpp
PR rebased on nightly and engine.cpp is now also compiled as C |
This comment has been minimized.
This comment has been minimized.
Quoting @AJenbo :
I have lost track of project's changes already so asking directly. Could it be that structs |
Ok, remember that a lot of this is happening on the chat so if you want to be deeply involved with the project and know the what and why, then that would be a good place to go. Is there something about Discord that doesn't work for you?
Do you think that this solution would get us close to bin exact if we changed it from XIM to XCU? I feel that this method is a bit hackish and probably won't be bin exact and so would like to do it a bit conservatively, hence using a unused section.
My understaning is that CRT's C globals are initialized during XIA, XIAA, XIC & XID, afaik XIU is only where own application variables gets initialized. I have also verified that the game works and that onexit functions are called correctly with this solution. |
It might be possible, but it wouldn't really give you any benefits over simply calling them from the start of
You might be thinking of the INFINITY property, it appeared in any file that used critical sections, but was unused. There's there for a good chance that there was a helper libery used that took care of initialization the needed functionality (it's header would have defined INFINITY). |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
To be honest this is outside of my knowledge or expertise. However, if changing to XCU does not break the game, then sure go for it! Eventually, we want to try to nail the original implementation anyways, so this is more of a temporary HACK to just get it compiling as C, to match the Rich header. In the end, we most likely want to figure out how they managed to compile C++ code into the project (either by HPP headers, or compiled objects), that did not add the C++ field ( So, yeah. Make the change and lets more forward! :) |
This comment has been minimized.
This comment has been minimized.
Pretty sure the answer would be they were compiled using an earlier compiler build that didn't put the metadata fields in the output. |
To move forward, lets merge this and get the entire project compiling as C. When we figure out the deal with the C++ header, and how |
This allows us to compile the following 6 files as C
dthread.cpp dx.cpp logging.cpp fault.cpp msgcmd.cpp nthread.cpp engine.cpp
See https://www.codeguru.com/cpp/misc/misc/applicationcontrol/article.php/c6945/Running-Code-Before-and-After-Main.htm for what's being done here.
Most importantly things still compiles and runs as C++ and under other compilers.