diff options
Diffstat (limited to 'mps/code/mpm.h')
| -rw-r--r-- | mps/code/mpm.h | 49 |
1 files changed, 44 insertions, 5 deletions
diff --git a/mps/code/mpm.h b/mps/code/mpm.h index 8c1a61617ca..02bb0659915 100644 --- a/mps/code/mpm.h +++ b/mps/code/mpm.h | |||
| @@ -144,6 +144,8 @@ extern Shift SizeFloorLog2(Size size); | |||
| 144 | 144 | ||
| 145 | extern Res WriteF(mps_lib_FILE *stream, ...); | 145 | extern Res WriteF(mps_lib_FILE *stream, ...); |
| 146 | extern Res WriteF_v(mps_lib_FILE *stream, va_list args); | 146 | extern Res WriteF_v(mps_lib_FILE *stream, va_list args); |
| 147 | extern Res WriteF_firstformat_v(mps_lib_FILE *stream, | ||
| 148 | const char *firstformat, va_list args); | ||
| 147 | 149 | ||
| 148 | 150 | ||
| 149 | /* Miscellaneous support -- see <code/mpm.c> */ | 151 | /* Miscellaneous support -- see <code/mpm.c> */ |
| @@ -953,6 +955,18 @@ extern void StackProbe(Size depth); | |||
| 953 | Bool DiagIsOn(void); | 955 | Bool DiagIsOn(void); |
| 954 | mps_lib_FILE *DiagStream(void); | 956 | mps_lib_FILE *DiagStream(void); |
| 955 | 957 | ||
| 958 | |||
| 959 | /* Diag*F functions -- formatted diagnostic output | ||
| 960 | * | ||
| 961 | * Note: do not call these directly; use the DIAG_*F macros below. | ||
| 962 | */ | ||
| 963 | |||
| 964 | extern void DiagSingleF(const char *tag, ...); | ||
| 965 | extern void DiagFirstF(const char *tag, ...); | ||
| 966 | extern void DiagMoreF(const char *format, ...); | ||
| 967 | extern void DiagEnd(const char *tag); | ||
| 968 | |||
| 969 | |||
| 956 | #if defined(DIAG_WITH_STREAM_AND_WRITEF) | 970 | #if defined(DIAG_WITH_STREAM_AND_WRITEF) |
| 957 | 971 | ||
| 958 | /* Diagnostic Calculation and Output */ | 972 | /* Diagnostic Calculation and Output */ |
| @@ -961,17 +975,36 @@ mps_lib_FILE *DiagStream(void); | |||
| 961 | #define DIAG(s) BEGIN \ | 975 | #define DIAG(s) BEGIN \ |
| 962 | s \ | 976 | s \ |
| 963 | END | 977 | END |
| 964 | /* | 978 | |
| 965 | * Note the macro argument args should have parens around it (in the | 979 | |
| 966 | * invocation); it is a variable number of arguments that we pass | 980 | /* DIAG_*F macros -- formatted diagnostic output |
| 967 | * to another function. | 981 | * |
| 968 | * That makes this macro unclean in all sorts of ways. | 982 | * Note: when invoking these macros, the value passed as macro |
| 983 | * argument "args" might contain commas; it must therefore be | ||
| 984 | * enclosed in parentheses. That makes these macros unclean in | ||
| 985 | * all sorts of ways. | ||
| 969 | */ | 986 | */ |
| 987 | |||
| 970 | #define DIAG_WRITEF(args) DIAG( \ | 988 | #define DIAG_WRITEF(args) DIAG( \ |
| 971 | if(DiagIsOn()) { \ | 989 | if(DiagIsOn()) { \ |
| 972 | WriteF args; \ | 990 | WriteF args; \ |
| 973 | } \ | 991 | } \ |
| 974 | ) | 992 | ) |
| 993 | #define DIAG_SINGLEF(args) DIAG( \ | ||
| 994 | DiagSingleF args; \ | ||
| 995 | ) | ||
| 996 | #define DIAG_FIRSTF(args) DIAG( \ | ||
| 997 | DiagFirstF args; \ | ||
| 998 | ) | ||
| 999 | #define DIAG_MOREF(args) DIAG( \ | ||
| 1000 | DiagMoreF args; \ | ||
| 1001 | ) | ||
| 1002 | |||
| 1003 | /* Note: extra parens *not* required when invoking DIAG_END */ | ||
| 1004 | #define DIAG_END(tag) DIAG( \ | ||
| 1005 | DiagEnd(tag); \ | ||
| 1006 | ) | ||
| 1007 | |||
| 975 | 1008 | ||
| 976 | #else | 1009 | #else |
| 977 | 1010 | ||
| @@ -980,6 +1013,12 @@ mps_lib_FILE *DiagStream(void); | |||
| 980 | #define DIAG(s) BEGIN END | 1013 | #define DIAG(s) BEGIN END |
| 981 | #define DIAG_WRITEF(args) BEGIN END | 1014 | #define DIAG_WRITEF(args) BEGIN END |
| 982 | 1015 | ||
| 1016 | /* DIAG_*F macros */ | ||
| 1017 | #define DIAG_SINGLEF(args) BEGIN END | ||
| 1018 | #define DIAG_FIRSTF(args) BEGIN END | ||
| 1019 | #define DIAG_MOREF(args) BEGIN END | ||
| 1020 | #define DIAG_END(tag) BEGIN END | ||
| 1021 | |||
| 983 | #endif | 1022 | #endif |
| 984 | 1023 | ||
| 985 | /* ------------ DIAG_WITH_PRINTF --------------- */ | 1024 | /* ------------ DIAG_WITH_PRINTF --------------- */ |