simos_vars.c
来自「一个用在mips体系结构中的操作系统」· C语言 代码 · 共 131 行
C
131 行
/* * Copyright (C) 1996-1998 by the Board of Trustees * of Leland Stanford Junior University. * * This file is part of the SimOS distribution. * See LICENSE file for terms of the license. * *//***************************************************************** * simos_vars.c * * This file incorporates all accesses to the SIMOS array. This array * is used to access variables that refer to the simulator itself * rather than any particular workload. * * Author: $Author: bosch $ * Date: $Date: 1998/02/10 00:29:50 $ *****************************************************************/#include <sys/utsname.h>#include "simutil.h"#include "tcl_init.h"extern int restoringCpt;#if !defined(NO_EMBRA) && (defined(SIM_MIPS32) || defined(SIM_MIPS64))static int embraPresent = 1;#elsestatic int embraPresent = 0;#endif#if defined(SIM_ALPHA)static char simosISA[] = "ALPHA";#endif#if defined(SIM_MIPS32)static char simosISA[] = "MIPS32";#endif#if defined(SIM_MIPS64)static char simosISA[] = "MIPS";#endif#if defined(SIM_X86)static char simosISA[] = "X86";#endif#if (defined(SIM_MIPS64) || defined(SIM_MIPS32))# if defined(SIM_MIPS64)# if defined(IRIX6_4) static char targetOS[] = "IRIX6.4";# else static char targetOS[] = "IRIX6.2";# endif# else static char targetOS[] = "IRIX5.3";# endif#else#if defined(SIM_X86) static char targetOS[] = "LINUX";#else static char targetOS[] = "UNKNOWN";#endif#endifstatic char *HostOSAccess(ClientData clientData, Tcl_Interp *interp, char *name1, char *name2, int flags){ struct utsname name; if (flags & TCL_TRACE_WRITES) { return "Writes to SIMOS(HostOS) ignored"; } if (uname(&name) == -1) { return "SIMOS(HostOS) implementation failed"; } Tcl_SetVar2(interp, name1, name2, name.sysname, 0); return NULL; }static char *ISAAccess(ClientData clientData, Tcl_Interp *interp, char *name1, char *name2, int flags){ struct utsname name; if (flags & TCL_TRACE_WRITES) { return "Writes to SIMOS(ISA) ignored"; } if (uname(&name) == -1) { return "SIMOS(ISA) implementation failed"; } Tcl_SetVar2(interp, name1, name2, simosISA, 0); return NULL; }static char *TargetOSAccess(ClientData clientData, Tcl_Interp *interp, char *name1, char *name2, int flags){ Tcl_SetVar2(interp, name1, name2, targetOS , 0); return NULL; }voidSimOSVarsInit(Tcl_Interp *interp){ Tcl_LinkVar(interp, SaveString("SIMOS(RestoringCpt)"), (char*)&restoringCpt, TCL_LINK_READ_ONLY | TCL_LINK_BOOLEAN); Tcl_LinkVar(interp, SaveString("SIMOS(EmbraPresent)"), (char*)&embraPresent, TCL_LINK_READ_ONLY | TCL_LINK_BOOLEAN); Tcl_TraceVar(interp, SaveString("SIMOS(TargetOS)"), TCL_TRACE_READS | TCL_GLOBAL_ONLY, TargetOSAccess, (ClientData) NULL); Tcl_TraceVar(interp, SaveString("SIMOS(HostOS)"), TCL_TRACE_READS | TCL_TRACE_WRITES | TCL_GLOBAL_ONLY, HostOSAccess, (ClientData) NULL); Tcl_TraceVar(interp, SaveString("SIMOS(ISA)"), TCL_TRACE_READS | TCL_TRACE_WRITES | TCL_GLOBAL_ONLY, ISAAccess, (ClientData) NULL); }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?