mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-13 04:44:39 +00:00
Estimated hours taken: 2 Various bug fixes and cleanups for the code in the runtime directory. runtime/mercury_bootstrap.h: runtime/mercury_regs.h: runtime/mercury_stacks.h: runtime/mercury_type_info.h: Move #defines that are there just for backwards compatibility into mercury_bootstrap.h. runtime/process_getopt: Add MR_ prefixes to the names `_GETOPT_H', `no_arguments', and `required_argument' which are defined by mercury_getopt.h, to make mercury_getopt.h macro-namespace-clean. runtime/mercury_getopt.h: Apply the new version of the process_getopt script. runtime/mercury_imp.h: Make mercury_bootstrap the first header file that is #included, in case some of the macros defined in it are used in declarations in other header files. runtime/mercury_memory.h: Delete duplicate definitions of MAX_REAL_REG, NUM_SPECIAL_REG, and MAX_VIRTUAL_REG -- these are all already defined in mercury_memory_zones.h. runtime/mercury_memory_zones.h: Delete definition of NUM_SPECIAL_REG, since mercury_regorder.h already defines MR_NUM_SPECIAL_REG, which should be used instead of NUM_SPECIAL_REG. The value of NUM_SPECIAL_REG was long obsolete. runtime/mercury_regorder.h: Fix some bugs in the definition of MR_min_sol_hp_rec -- it was using `mr40', which is undefined, instead of `mr(40)'. Also add some comments. runtime/mercury_regs.h: Fix a bug: use MR_NUM_SPECIAL_REGS instead of NUM_SPECIAL_REGS. Note that this bug fix unfortunately breaks backwards compatibility, at least for procedures with more than 32 arguments, since it affects the mapping from r(N) to the fake_reg array. However, there was no alternative, since the old mapping was broken: for example, the old mapping used the same fake_reg slot for both r(41) and MR_global_hp. runtime/mercury_bootstrap.h: Change MR_GRADE_PART_0 from `redofr' to `v1', and document that that part of the grade is a binary compatibility version number. The reason for changing the grade is to ensure that the change in binary backwards compatibility resulting from the changes to runtime/mercury_regs.h will cause link errors rather than just random behaviour for procedures with >32 arguments. runtime/mercury_agc_debug.c: Use MR_NUM_SPECIAL_REGS instead of NUM_SPECIAL_REGS. Also add some XXX comments, since all of the places where NUM_SPECIAL_REGS was used are broken anyway -- they should be using MAX_FAKE_REG instead of MAX_REAL_REG + NUM_SPECIAL_REG. But I think the current definition is put there for efficiency, even though it's known to be broken for procedures with >32 arguments, so I didn't change the code to use MAX_FAKE_REG.
57 lines
1.3 KiB
Bash
Executable File
57 lines
1.3 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
chmod 644 mercury_getopt.h mercury_getopt.c mercury_getopt1.c
|
|
|
|
for file in getopt.h getopt.c getopt1.c
|
|
do
|
|
echo processing mercury_$file
|
|
cp GETOPT/$file mercury_$file
|
|
ex mercury_$file << END
|
|
g/#include/s/getopt/mercury_getopt/
|
|
g/\<getopt/s//MR_getopt/g
|
|
g/\<optarg/s//MR_optarg/g
|
|
g/\<optind/s//MR_optind/g
|
|
g/\<opterr/s//MR_opterr/g
|
|
g/\<optopt/s//MR_optopt/g
|
|
g/\<option/s//MR_option/g
|
|
g/\<_getopt/s//MR__getopt/g
|
|
g/\<_GETOPT/s//MERCURY_GETOPT/g
|
|
g/no_argument/s//MR_no_argument/g
|
|
g/required_argument/s//MR_required_argument/g
|
|
g/#ifndef/s/ELIDE_CODE/XXXELIDE_CODEXXX/
|
|
w
|
|
q
|
|
END
|
|
done
|
|
|
|
echo finalizing mercury_getopt.h
|
|
ex mercury_getopt.h << END
|
|
1i
|
|
#undef __GNU_LIBRARY__
|
|
#define __GNU_LIBRARY__
|
|
.
|
|
w
|
|
q
|
|
END
|
|
|
|
echo finalizing mercury_getopt.c
|
|
ex mercury_getopt.c << END
|
|
1i
|
|
extern char *getenv(const char *);
|
|
.
|
|
g/nextchar/s//MR_nextchar/g
|
|
g/ordering/s//MR_ordering/g
|
|
g/posixly_correct/s//MR_posixly_correct/g
|
|
g/first_nonopt/s//MR_first_nonopt/g
|
|
g/last_nonopt/s//MR_last_nonopt/g
|
|
g/__getopt_initialized/s//MR____getopt_initialized/g
|
|
g/%s: MR_option/s//%s: option/g
|
|
g/%s: unrecognized MR_option/s//%s: unrecognized option/g
|
|
g/%s: illegal MR_option/s//%s: illegal option/g
|
|
g/%s: invalid MR_option/s//%s: invalid option/g
|
|
w
|
|
q
|
|
END
|
|
|
|
chmod 444 mercury_getopt.h mercury_getopt.c mercury_getopt1.c
|