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

📄 c.m4.mipsy

📁 一个用在mips体系结构中的操作系统
💻 MIPSY
📖 第 1 页 / 共 2 页
字号:
divert(-1)dnl Copyright (C) 1996-1998 by the Board of Trusteesdnl   of Leland Stanford Junior University.dnl dnl This file is part of the SimOS distribution. dnl See LICENSE file for terms of the license. dnl --------------------------------------------------------------------dnl  c.m4.mipsy:  m4 macro definitions for use with Solo Mipsy or IRIX.dnl  This file implements a high-level synchronization model for "C".dnl dnl  Steve Herroddnl  10/19/95dnl --------------------------------------------------------------------dnl ----------------------------------------------------------------------dnl ENVIRONMENT SETUPdnl ----------------------------------------------------------------------define(MAIN_ENV, `#include <stdlib.h>#include <stdarg.h>#include "solo_interface.h"int _in_solo_mode;int _num_procs = 1;')define(EXTERN_ENV, `#include <stdlib.h>#include "solo_interface.h"extern int _in_solo_mode;extern int _num_procs;')dnl ----------------------------------------------------------------------dnl INITIALIZATION CALLSdnl ----------------------------------------------------------------------define(MAIN_INITENV, `INITENV($1,$2)')dnl -----------------------------------------------------------------------dnl We use a system call hack to determine if the application isdnl running directly on irix or on top of solo mipsy. Based on the dnl return value, we initialize the communication area appropriately.dnl -----------------------------------------------------------------------define(INITENV, `    if (_CheckPlatform() == 51071) {       _in_solo_mode = 1;       CommAreaPtr->SetupCommArea();       CommAreaPtr->libcStart = &LibcStart;       fprintf(stderr, "M: Running on top of solo mipsy\n");    } else {       _in_solo_mode = 0;       IrixSetupCommArea();       fprintf(stderr, "M: Running on an IRIX machine\n");           }')dnl ----------------------------------------------------------------------dnl INSTRUCTION REPLACEMENTSdnldnl We can't get ld, sd, or sync to compile in quite yet, so we use thesednl calls to the support library. These routines should be made intodnl asm() calls so that the compiler can deal with them better.dnl ----------------------------------------------------------------------define(SYNC_OP, `_Sync();')define(LD, `_LoadDouble((unsigned long long *)($1));')define(SD, `_StoreDouble((unsigned long long *)($1),        (unsigned long long)($2));')dnl ----------------------------------------------------------------dnl NON-SYNCHRONIZATION CALLSdnl ----------------------------------------------------------------define(CLOCK, `$1 = CommAreaPtr->CurrentTime();')define(MAIN_END, `{  fflush(stdout);   fflush(stderr);   SYNC_OP();  _Exit();}')define(CREATE, `{  SYNC_OP;   CommAreaPtr->Create((Func) $1);  _num_procs++;}')define(GET_PID, `$1 = CommAreaPtr->GetCPUNum();')define(RESET_STATS, `CommAreaPtr->ResetStats();')define(AUG_ON,  `  fprintf(stderr, "M: aug on command is not supported\n");')define(AUG_OFF, `fprintf(stderr, "M: aug off command is not supported\n");')dnl ----------------------------------------------------------------dnl CACHE-RELATED CALLSdnl ----------------------------------------------------------------define(CACHE_ON,  `CommAreaPtr->TurnOnCaches(); ')define(CACHE_OFF, `CommAreaPtr->TurnOffCaches(); ')dnl FLUSH_LINE will spin until it succeeds, to allow it to bednl preempted if necessary.define(FLUSH_LINE, `while (!CommAreaPtr->Flush((void *) ($1)));');dnl ----------------------------------------------------------------dnl SYNCHRONIZATION CALLSdnl ----------------------------------------------------------------dnl -------------------------------------------------------------------------dnl LOCK implementation dnl THESE NEED TO BE DEFINED FIRST SO IT EXPANDS CORRECTLY!dnl -------------------------------------------------------------------------dnl -----------------------------dnl        _FAKELOCK MACROSdnldnl This is a pure magic lock implementation: No application caching occursdnl for these locks, but it also avoids problems where the applicationdnl mistakenly caches lock data structures, in conflict with backdoor calls.dnldnl -----------------------------define(_FAKELOCKDEC, `void * $1;')define(_FAKELOCKINIT, `$1 = CommAreaPtr->LockInit();')dnl The lock MUST be set by the RETURN VALUE of this call.  That's becausednl we want the lock POINTER to be cached by the user, but the userdnl should never dereference this pointer!!define(_FAKELOCK, `CommAreaPtr->LockEnter(); while (!CommAreaPtr->Lock($1)) ;')define(_FAKEUNLOCK, `SYNC_OP  CommAreaPtr->Unlock($1);')dnl -----------------------------dnl        _REALLOCK MACROSdnldnl Real LL/SC locks. dnl -----------------------------define(_REALLOCKDEC, `      struct {           int _pad1[(SOLO_CACHE_LINE_SIZE/sizeof(int))-1];          unsigned int lock;           int _pad2[(SOLO_CACHE_LINE_SIZE/sizeof(int))-1];      } $1; ')define(_REALLOCKDEC_UNPADDED, `      struct {           unsigned int lock;       } $1; ')define(_REALLOCKINIT, `$1.lock = 0;')define(_REALLOCK, `_LockEnter(&($1.lock));')define(_REALUNLOCK, `_Unlock(&($1.lock));')define(LOCKDEC,     `#ifdef FAKE_LOCKS     _FAKELOCKDEC($1)#else#ifndef NO_PADDED_LOCKS     _REALLOCKDEC($1)#else     _REALLOCKDEC_UNPADDED($1)#endif#endif    ')define(LOCKDEC_UNPADDED,     `#ifdef FAKE_LOCKS     _FAKELOCKDEC($1)#else     _REALLOCKDEC_UNPADDED($1)#endif    ')define(LOCKINIT,     `#ifdef FAKE_LOCKS     _FAKELOCKINIT($1)#else     _REALLOCKINIT($1)#endif    ')define(LOCK,     `#ifdef FAKE_LOCKS     _FAKELOCK($1)#else     _REALLOCK($1)#endif    ')define(UNLOCK,     `#ifdef FAKE_LOCKS     _FAKEUNLOCK($1)#else     _REALUNLOCK($1)#endif    ')define(_FAKEALOCKDEC, `_FAKELOCKDEC($1[$2])')define(_FAKEALOCKINIT,   `{      int _soloi;      for(_soloi = 0; _soloi < $2; _soloi++) {        _FAKELOCKINIT($1[_soloi])      }   }')define(_FAKEALOCK, `_FAKELOCK($1[$2])')define(_FAKEAULOCK, `_FAKEUNLOCK($1[$2])')define(_REALALOCKDEC, `        struct {             int _pad1[(SOLO_CACHE_LINE_SIZE/sizeof(int))-1];                   struct {                unsigned int lock;                int _pad1[(SOLO_CACHE_LINE_SIZE/sizeof(int))-1];                   } _alock[$2];        } $1; ')define(_REALALOCKDEC_UNPADDED, `        struct {             struct {                unsigned int lock;             } _alock[$2];        } $1; ')define(_REALALOCKINIT,   `{      int _soloi;      for(_soloi = 0; _soloi < $2; _soloi++) {       $1._alock[_soloi].lock = 0;      }   }')define(_REALALOCK, `_LockEnter(&$1._alock[$2].lock);')define(_REALAULOCK, `_Unlock(&$1._alock[$2].lock);')define(ALOCKDEC,     `#ifdef FAKE_LOCKS     _FAKEALOCKDEC($1,$2)#else#ifndef NO_PADDED_LOCKS     _REALALOCKDEC_UNPADDED($1,$2)#else     _REALALOCKDEC($1,$2)#endif#endif    ')define(ALOCKDEC_UNPADDED,     `#ifdef FAKE_LOCKS     _FAKEALOCKDEC($1,$2)#else     _REALALOCKDEC_UNPADDED($1,$2)#endif    ')define(ALOCKINIT,     `#ifdef FAKE_LOCKS     _FAKEALOCKINIT($1,$2)#else     _REALALOCKINIT($1,$2)#endif    ')define(ALOCK,     `#ifdef FAKE_LOCKS     _FAKEALOCK($1,$2)#else     _REALALOCK($1,$2)#endif    ')define(AULOCK,     `#ifdef FAKE_LOCKS     _FAKEAULOCK($1,$2)#else     _REALAULOCK($1,$2)#endif    ')dnl ----------------------------------------------------------------------

⌨️ 快捷键说明

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