mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-14 05:12:33 +00:00
Make a step towards supporting the automatic running of compiler-provided
Estimated hours taken: 4 Branches: main Make a step towards supporting the automatic running of compiler-provided initialization functions at startup. The idea is that in each module that defines a solver type which wants to keep the solver state in a global variable, the compiler will generate a function to initialize this global variable and put a line containing REQUIRED_INIT function_name in the generated .c file. Mkinit will then see this and put a call to the named function in the program's init_modules_required function, which (once this diff is installed) will be called from the tail end of mercury_init. util/mkinit.c: Until now, mkinit didn't open .c files unless given the -x option, because doing so was expensive: the list of .c (and .init) files was scanned five times, and opening and reading each file five times is excessive. This diff changes that. Each file is now opened and read (until a line containing only ENDINIT) just once, and the info found therein put into some new mkinit data structures. The five scans through the file list now scan through these data structures instead. This is now fast enough to leave -x on all the time: mkinit -x now takes 3-4 seconds in the compiler directory, and at most 0.15s in the other directories. Add a sixth scan through the data structures to generate calls to the functions named in REQUIRED_INIT lines; make bunches of these calls the body of the program's init_modules_required function. runtime/mercury_array_macro.h: Fix indentation. runtime/mercury_dlist.[ch]: Move the documentation of the exported functions from the .c file to the .h file. runtime/mercury_std.h: Add a missing () around a macro argument.
This commit is contained in:
@@ -222,8 +222,7 @@
|
||||
do { \
|
||||
(element) = (next) - 1; \
|
||||
while ((element) >= 0 && (COMPARE) > 0) { \
|
||||
MR_assign_structure(items[element + 1], \
|
||||
items[element]); \
|
||||
MR_assign_structure(items[element + 1], items[element]); \
|
||||
(element) -= 1; \
|
||||
} \
|
||||
(element) += 1; \
|
||||
|
||||
Reference in New Issue
Block a user