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

📄 genprocoffsets.awk

📁 C++ 编写的EROS RTOS
💻 AWK
字号:
## Copyright (C) 1998, 1999, Jonathan S. Shapiro.## This file is part of the EROS Operating System.## This program is free software; you can redistribute it and/or# modify it under the terms of the GNU General Public License# as published by the Free Software Foundation; either version 2,# or (at your option) any later version.## This program is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the# GNU General Public License for more details.## You should have received a copy of the GNU General Public License# along with this program; if not, write to the Free Software# Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.## program to generate procoffsets.h from LAYOUT file.  This exists because# I eventually got sick and tired of miscomputing the offsets by hand.BEGIN {  nmask = 0;  nfx = 0;  npr = 0;  nunit = 0;  cur_proc_offset = 0;	/* LAYOUT file does not include keyring structures */  cur_fix_offset = 0;  fixregs_offset = 0;    type_sizes["uint8_t"]  = 1;  type_sizes["uint16_t"] = 2;  type_sizes["uint32_t"] = 4;  type_sizes["uint64_t"] = 8;  type_sizes["uint80_t"] = 10;  type_sizes["KEYREGS"] = 32*16;  type_sizes["KEYRING"] = 12;  type_sizes["SLEEPQ"] = 8;  type_sizes["alias32"] = 0;  type_align["uint8_t"]  = 1;  type_align["uint16_t"] = 2;  type_align["uint32_t"] = 4;  type_align["uint64_t"] = 4;  type_align["uint80_t"] = 4;  type_align["KEYREGS"] = 4;  type_align["KEYRING"] = 4;  type_align["SLEEPQ"] = 4;  type_align["alias32"] = 4;}/^opaque/ {  /* compute the correct offset alignment */  cur_proc_offset += (type_align[$3] - 1);  cur_proc_offset -= (cur_proc_offset % type_align[$3]);    cur_proc_offset += type_sizes[$3];}/^fix/	{  /* compute the correct offset alignment */  cur_proc_offset += (type_align[$5] - 1);  cur_proc_offset -= (cur_proc_offset % type_align[$5]);  cur_fix_offset += (type_align[$5] - 1);  cur_fix_offset -= (cur_fix_offset % type_align[$5]);    proc_offset[npr] = sprintf("#define PR_OFF_%-16s __U(0x%x) /* %u */\n", $2, cur_proc_offset, cur_proc_offset);  fix_offset[nfx] = sprintf("#define FX_OFF_%-16s __U(0x%x) /* %u */\n", $2, cur_fix_offset, cur_fix_offset);  if (fixregs_offset == 0)    fixregs_offset = cur_proc_offset;    cur_proc_offset += type_sizes[$5];  cur_fix_offset += type_sizes[$5];    npr++;  nfx++;}/^(proc|gen)/	{  /* compute the correct offset alignment */  cur_proc_offset += (type_align[$4] - 1);  cur_proc_offset -= (cur_proc_offset % type_align[$4]);    proc_offset[npr] = sprintf("#define PR_OFF_%-16s __U(0x%x) /* %u */\n", $2, cur_proc_offset, cur_proc_offset);  cur_proc_offset += type_sizes[$4];    npr++;}END	{  printf("#ifndef __PROC_OFFSETS_H__\n");	  printf("#define __PROC_OFFSETS_H__\n\n");	  printf("/* This file is automatically generated and is hereby\n");  printf("   placed in the public domain */\n");  printf("\n#if defined(__ASSEMBLER__)\n\n");	  printf("#define PR_OFF_%-16s __U(0x%x) /* %u */\n", "FIXREGS",	 fixregs_offset, fixregs_offset);  for (i = 0; i < npr; i++)    printf(proc_offset[i]);  printf("\n");    for (i = 0; i < nfx; i++)    printf(fix_offset[i]);  printf("\n#endif /* __ASSEMBLER__ */\n");  printf("\n#endif /* __PROC_OFFSETS_H__ */\n");	}

⌨️ 快捷键说明

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