2011-04-03 Ivan Maidanski <ivmai@mail.ru>
+ * misc.c (GC_stdout, GC_stderr): Move the definition to the place
+ where GC_log is defined (Unix only).
+ * misc.c (GC_init): Recognize "GC_ONLY_LOG_TO_FILE" environment
+ variable and the similar macro; redirect GC_stdout and GC_stderr
+ to GC_log if "GC_LOG_FILE" environment variable is set unless
+ prohibited by GC_ONLY_LOG_TO_FILE (Unix only).
+ * doc/README.environment (GC_ONLY_LOG_TO_FILE): Document.
+ * doc/README.macros (GC_ONLY_LOG_TO_FILE): Ditto.
+
+2011-04-03 Ivan Maidanski <ivmai@mail.ru>
+
* misc.c (GC_stdout, GC_write): Rename GC_stdout to GC_log (Win32
only).
* misc.c (GC_write): Add for MacOS (and OS/2); change WRITE()
GC_LOG_FILE - The name of the log file. Stderr by default. Not functional
with SMALL_CONFIG.
+GC_ONLY_LOG_TO_FILE - Turns off redirection of GC stdout and stderr to the log
+ file specified by GC_LOG_FILE. Has no effect unless
+ GC_LOG_FILE is set. Not functional with SMALL_CONFIG.
+
GC_PRINT_VERBOSE_STATS - Turn on even more logging. Not functional with
SMALL_CONFIG.
GC_PRINT_VERBOSE_STATS Permanently turn on verbose logging (useful for
debugging and profiling on WinCE).
+GC_ONLY_LOG_TO_FILE Don't redirect GC stdout and stderr to the log file
+ specified by GC_LOG_FILE environment variable. Has effect only when the
+ variable is set (to anything other than "0").
+
GC_DONT_EXPAND Don't expand the heap unless explicitly requested or forced to.
GC_USE_ENTIRE_HEAP Causes the non-incremental collector to use the
#endif
#if !defined(OS2) && !defined(MACOS) && !defined(MSWIN32) && !defined(MSWINCE)
- STATIC int GC_log = 2;
+ STATIC int GC_stdout = 1;
+ STATIC int GC_stderr = 2;
+ STATIC int GC_log = 2; /* stderr */
#endif
GC_INNER void GC_initialize_offsets(void); /* defined in obj_map.c */
if (log_d < 0) {
GC_err_printf("Failed to open %s as log file\n", file_name);
} else {
+ char *str;
GC_log = log_d;
+ str = GETENV("GC_ONLY_LOG_TO_FILE");
+# ifdef GC_ONLY_LOG_TO_FILE
+ /* The similar environment variable set to "0" */
+ /* overrides the effect of the macro defined. */
+ if (str != NULL && *str == '0' && *(str + 1) == '\0')
+# else
+ /* Otherwise setting the environment variable */
+ /* to anything other than "0" will prevent from */
+ /* redirecting stdout/err to the log file. */
+ if (str == NULL || (*str == '0' && *(str + 1) == '\0'))
+# endif
+ {
+ GC_stdout = log_d;
+ GC_stderr = log_d;
+ }
}
}
}
# define WRITE(f, buf, len) (GC_set_files(), GC_write(f, buf, len))
#else
- STATIC int GC_stdout = 1;
- STATIC int GC_stderr = 2;
- /* GC_log is defined above. */
# if !defined(AMIGA)
# include <unistd.h>
# endif