⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 utility.cc

📁 Nachos 线程
💻 CC
字号:
// utility.cc //	Debugging routines.  Allows users to control whether to //	print DEBUG statements, based on a command line argument.//// Copyright (c) 1992-1993 The Regents of the University of California.// All rights reserved.  See copyright.h for copyright notice and limitation // of liability and disclaimer of warranty provisions.#include "copyright.h"#include "utility.h"// this seems to be dependent on how the compiler is configured.// if you have problems with va_start, try both of these alternatives#ifdef HOST_SNAKE#include <stdarg.h>#else#ifdef HOST_SPARC#include <stdarg.h>#else//#include "/usr/include/stdarg.h"#include <stdarg.h>#endif#endifstatic char *enableFlags = NULL; // controls which DEBUG messages are printed //----------------------------------------------------------------------// DebugInit//      Initialize so that only DEBUG messages with a flag in flagList //	will be printed.////	If the flag is "+", we enable all DEBUG messages.//// 	"flagList" is a string of characters for whose DEBUG messages are //		to be enabled.//----------------------------------------------------------------------voidDebugInit(char *flagList){    enableFlags = flagList;}//----------------------------------------------------------------------// DebugIsEnabled//      Return TRUE if DEBUG messages with "flag" are to be printed.//----------------------------------------------------------------------boolDebugIsEnabled(char flag){    if (enableFlags != NULL)       return (strchr(enableFlags, flag) != 0) 		|| (strchr(enableFlags, '+') != 0);    else      return FALSE;}//----------------------------------------------------------------------// DEBUG//      Print a debug message, if flag is enabled.  Like printf,//	only with an extra argument on the front.//----------------------------------------------------------------------void DEBUG(char flag, char *format, ...){    if (DebugIsEnabled(flag)) {	va_list ap;	// You will get an unused variable message here -- ignore it.	va_start(ap, format);	vfprintf(stdout, format, ap);	va_end(ap);	fflush(stdout);    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -