aboutsummaryrefslogtreecommitdiffstats
path: root/mps/code/mpm.h
diff options
context:
space:
mode:
authorRichard Kistruck2007-08-07 19:09:43 +0100
committerRichard Kistruck2007-08-07 19:09:43 +0100
commit5cbd84f9b46384ee08da255db816a0971fd5bf3f (patch)
treeab667435bae3f2b2659fcc561f0473e24cf7bc9f /mps/code/mpm.h
parent5a478d9a7d637d87a07625ad1c37bac5c3633573 (diff)
downloademacs-5cbd84f9b46384ee08da255db816a0971fd5bf3f.tar.gz
emacs-5cbd84f9b46384ee08da255db816a0971fd5bf3f.zip
Mps br/diagtag:
diag.c: support tagging of diagnostics, and avoid having to say DIAG_STREAM every time, with new macros: DIAG_SINGLEF, DIAG_FIRSTF, DIAG_MOREF, DIAG_END. mpm.c: new WriteF_firstformat_v required by DIAG_MOREF. Copied from Perforce Change: 163059 ServerID: perforce.ravenbrook.com
Diffstat (limited to 'mps/code/mpm.h')
-rw-r--r--mps/code/mpm.h49
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
145extern Res WriteF(mps_lib_FILE *stream, ...); 145extern Res WriteF(mps_lib_FILE *stream, ...);
146extern Res WriteF_v(mps_lib_FILE *stream, va_list args); 146extern Res WriteF_v(mps_lib_FILE *stream, va_list args);
147extern 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);
953Bool DiagIsOn(void); 955Bool DiagIsOn(void);
954mps_lib_FILE *DiagStream(void); 956mps_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
964extern void DiagSingleF(const char *tag, ...);
965extern void DiagFirstF(const char *tag, ...);
966extern void DiagMoreF(const char *format, ...);
967extern 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 --------------- */