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

📄 mips-tfile.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 5 页
字号:
  st_Max	= stMax		/* max type+1 */} st_t;/* Redefinition of type qualifiers.  */typedef enum tq {  tq_Nil	= tqNil,	/* bt is what you see */  tq_Ptr	= tqPtr,	/* pointer */  tq_Proc	= tqProc,	/* procedure */  tq_Array	= tqArray,	/* duh */  tq_Far	= tqFar,	/* longer addressing - 8086/8 land */  tq_Vol	= tqVol,	/* volatile */  tq_Max	= tqMax		/* Max type qualifier+1 */} tq_t;/* Redefinition of basic types.  */typedef enum bt {  bt_Nil	= btNil,	/* undefined */  bt_Adr	= btAdr,	/* address - integer same size as pointer */  bt_Char	= btChar,	/* character */  bt_UChar	= btUChar,	/* unsigned character */  bt_Short	= btShort,	/* short */  bt_UShort	= btUShort,	/* unsigned short */  bt_Int	= btInt,	/* int */  bt_UInt	= btUInt,	/* unsigned int */  bt_Long	= btLong,	/* long */  bt_ULong	= btULong,	/* unsigned long */  bt_Float	= btFloat,	/* float (real) */  bt_Double	= btDouble,	/* Double (real) */  bt_Struct	= btStruct,	/* Structure (Record) */  bt_Union	= btUnion,	/* Union (variant) */  bt_Enum	= btEnum,	/* Enumerated */  bt_Typedef	= btTypedef,	/* defined via a typedef, isymRef points */  bt_Range	= btRange,	/* subrange of int */  bt_Set	= btSet,	/* pascal sets */  bt_Complex	= btComplex,	/* fortran complex */  bt_DComplex	= btDComplex,	/* fortran double complex */  bt_Indirect	= btIndirect,	/* forward or unnamed typedef */  bt_FixedDec	= btFixedDec,	/* Fixed Decimal */  bt_FloatDec	= btFloatDec,	/* Float Decimal */  bt_String	= btString,	/* Varying Length Character String */  bt_Bit	= btBit,	/* Aligned Bit String */  bt_Picture	= btPicture,	/* Picture */#ifdef btVoid  bt_Void	= btVoid,	/* Void */#else#define bt_Void	bt_Nil#endif  bt_Max	= btMax		/* Max basic type+1 */} bt_t;/* Basic COFF storage classes.  */enum coff_storage {  C_EFCN	= -1,  C_NULL	= 0,  C_AUTO	= 1,  C_EXT		= 2,  C_STAT	= 3,  C_REG		= 4,  C_EXTDEF	= 5,  C_LABEL	= 6,  C_ULABEL	= 7,  C_MOS		= 8,  C_ARG		= 9,  C_STRTAG	= 10,  C_MOU		= 11,  C_UNTAG	= 12,  C_TPDEF	= 13,  C_USTATIC	= 14,  C_ENTAG	= 15,  C_MOE		= 16,  C_REGPARM	= 17,  C_FIELD	= 18,  C_BLOCK	= 100,  C_FCN		= 101,  C_EOS		= 102,  C_FILE	= 103,  C_LINE	= 104,  C_ALIAS	= 105,  C_HIDDEN	= 106,  C_MAX		= 107} coff_storage_t;/* Regular COFF fundamental type.  */typedef enum coff_type {  T_NULL	= 0,  T_ARG		= 1,  T_CHAR	= 2,  T_SHORT	= 3,  T_INT		= 4,  T_LONG	= 5,  T_FLOAT	= 6,  T_DOUBLE	= 7,  T_STRUCT	= 8,  T_UNION	= 9,  T_ENUM	= 10,  T_MOE		= 11,  T_UCHAR	= 12,  T_USHORT	= 13,  T_UINT	= 14,  T_ULONG	= 15,  T_MAX		= 16} coff_type_t;/* Regular COFF derived types.  */typedef enum coff_dt {  DT_NON	= 0,  DT_PTR	= 1,  DT_FCN	= 2,  DT_ARY	= 3,  DT_MAX	= 4} coff_dt_t;#define N_BTMASK	017	/* bitmask to isolate basic type */#define N_TMASK		003	/* bitmask to isolate derived type */#define N_BT_SHIFT	4	/* # bits to shift past basic type */#define N_TQ_SHIFT	2	/* # bits to shift derived types */#define	N_TQ		6	/* # of type qualifiers *//* States for whether to hash type or not.  */typedef enum hash_state {  hash_no	= 0,		/* don't hash type */  hash_yes	= 1,		/* ok to hash type, or use previous hash */  hash_record	= 2		/* ok to record hash, but don't use prev. */} hash_state_t;/* Types of different sized allocation requests.  */enum alloc_type {  alloc_type_none,		/* dummy value */  alloc_type_scope,		/* nested scopes linked list */  alloc_type_vlinks,		/* glue linking pages in varray */  alloc_type_shash,		/* string hash element */  alloc_type_thash,		/* type hash element */  alloc_type_tag,		/* struct/union/tag element */  alloc_type_forward,		/* element to hold unknown tag */  alloc_type_thead,		/* head of type hash list */  alloc_type_varray,		/* general varray allocation */  alloc_type_last		/* last+1 element for array bounds */};#define WORD_ALIGN(x)  (((x) + 3) & ~3)#define DWORD_ALIGN(x) (((x) + 7) & ~7)/* Structures to provide n-number of virtual arrays, each of which can   grow linearly, and which are written in the object file as sequential   pages.  On systems with a BSD malloc that define USE_MALLOC, the   MAX_CLUSTER_PAGES should be 1 less than a power of two, since malloc   adds it's overhead, and rounds up to the next power of 2.  Pages are   linked together via a linked list.   If PAGE_SIZE is > 4096, the string length in the shash_t structure   can't be represented (assuming there are strings > 4096 bytes).  */#ifndef PAGE_SIZE#define PAGE_SIZE 4096		/* size of varray pages */#endif#define PAGE_USIZE ((Size_t)PAGE_SIZE)#ifndef MAX_CLUSTER_PAGES	/* # pages to get from system */#ifndef USE_MALLOC		/* in one memory request */#define MAX_CLUSTER_PAGES 64#else#define MAX_CLUSTER_PAGES 63#endif#endif/* Linked list connecting separate page allocations.  */typedef struct vlinks {  struct vlinks	*prev;		/* previous set of pages */  struct vlinks *next;		/* next set of pages */  union  page   *datum;		/* start of page */  unsigned long	 start_index;	/* starting index # of page */} vlinks_t;/* Virtual array header.  */typedef struct varray {  vlinks_t	*first;			/* first page link */  vlinks_t	*last;			/* last page link */  unsigned long	 num_allocated;		/* # objects allocated */  unsigned short object_size;		/* size in bytes of each object */  unsigned short objects_per_page;	/* # objects that can fit on a page */  unsigned short objects_last_page;	/* # objects allocated on last page */} varray_t;#ifndef MALLOC_CHECK#define OBJECTS_PER_PAGE(type) (PAGE_SIZE / sizeof (type))#else#define OBJECTS_PER_PAGE(type) ((sizeof (type) > 1) ? 1 : PAGE_SIZE)#endif#define INIT_VARRAY(type) {	/* macro to initialize a varray */	\  (vlinks_t *)0,		/* first */				\  (vlinks_t *)0,		/* last */				\  0,				/* num_allocated */			\  sizeof (type),		/* object_size */			\  OBJECTS_PER_PAGE (type),	/* objects_per_page */			\  OBJECTS_PER_PAGE (type),	/* objects_last_page */			\}/* Master type for indexes within the symbol table. */typedef unsigned long symint_t;/* Linked list support for nested scopes (file, block, structure, etc.).  */typedef struct scope {  struct scope	*prev;		/* previous scope level */  struct scope	*free;		/* free list pointer */  SYMR		*lsym;		/* pointer to local symbol node */  symint_t	 lnumber;	/* lsym index */  st_t		 type;		/* type of the node */} scope_t;/* Forward reference list for tags referenced, but not yet defined.  */typedef struct forward {  struct forward *next;		/* next forward reference */  struct forward *free;		/* free list pointer */  AUXU		 *ifd_ptr;	/* pointer to store file index */  AUXU		 *index_ptr;	/* pointer to store symbol index */  AUXU		 *type_ptr;	/* pointer to munge type info */} forward_t;/* Linked list support for tags.  The first tag in the list is always   the current tag for that block.  */typedef struct tag {  struct tag	 *free;		/* free list pointer */  struct shash	 *hash_ptr;	/* pointer to the hash table head */  struct tag	 *same_name;	/* tag with same name in outer scope */  struct tag	 *same_block;	/* next tag defined in the same block.  */  struct forward *forward_ref;	/* list of forward references */  bt_t		  basic_type;	/* bt_Struct, bt_Union, or bt_Enum */  symint_t	  ifd;		/* file # tag defined in */  symint_t	  indx;		/* index within file's local symbols */} tag_t;/* Head of a block's linked list of tags.  */typedef struct thead {  struct thead	*prev;		/* previous block */  struct thead	*free;		/* free list pointer */  struct tag	*first_tag;	/* first tag in block defined */} thead_t;/* Union containing pointers to each the small structures which are freed up.  */typedef union small_free {  scope_t	*f_scope;	/* scope structure */  thead_t	*f_thead;	/* tag head structure */  tag_t		*f_tag;		/* tag element structure */  forward_t	*f_forward;	/* forward tag reference */} small_free_t;/* String hash table support.  The size of the hash table must fit   within a page.  */#ifndef SHASH_SIZE#define SHASH_SIZE 1009#endif#define HASH_LEN_MAX ((1 << 12) - 1)	/* Max length we can store */typedef struct shash {  struct shash	*next;		/* next hash value */  char		*string;	/* string we are hashing */  symint_t	 len;		/* string length */  symint_t	 indx;		/* index within string table */  EXTR		*esym_ptr;	/* global symbol pointer */  SYMR		*sym_ptr;	/* local symbol pointer */  SYMR		*end_ptr;	/* symbol pointer to end block */  tag_t		*tag_ptr;	/* tag pointer */  PDR		*proc_ptr;	/* procedure descriptor pointer */} shash_t;/* Type hash table support.  The size of the hash table must fit   within a page with the other extended file descriptor information.   Because unique types which are hashed are fewer in number than   strings, we use a smaller hash value.  */#ifndef THASH_SIZE#define THASH_SIZE 113#endiftypedef struct thash {  struct thash	*next;		/* next hash value */  AUXU		 type;		/* type we are hashing */  symint_t	 indx;		/* index within string table */} thash_t;/* Extended file descriptor that contains all of the support necessary   to add things to each file separately.  */typedef struct efdr {  FDR		 fdr;		/* File header to be written out */  FDR		*orig_fdr;	/* original file header */  char		*name;		/* filename */  int		 name_len;	/* length of the filename */  symint_t	 void_type;	/* aux. pointer to 'void' type */  symint_t	 int_type;	/* aux. pointer to 'int' type */  scope_t	*cur_scope;	/* current nested scopes */  symint_t	 file_index;	/* current file number */  int		 nested_scopes;	/* # nested scopes */  varray_t	 strings;	/* local strings */  varray_t	 symbols;	/* local symbols */  varray_t	 procs;		/* procedures */  varray_t	 aux_syms;	/* auxiliary symbols */  struct efdr	*next_file;	/* next file descriptor */				/* string/type hash tables */  shash_t      **shash_head;	/* string hash table */  thash_t	*thash_head[THASH_SIZE];} efdr_t;/* Pre-initialized extended file structure.  */static efdr_t init_file = {  {			/* FDR structure */    0,			/* adr:		memory address of beginning of file */    0,			/* rss:		file name (of source, if known) */    0,			/* issBase:	file's string space */    0,			/* cbSs:	number of bytes in the ss */    0,			/* isymBase:	beginning of symbols */    0,			/* csym:	count file's of symbols */    0,			/* ilineBase:	file's line symbols */    0,			/* cline:	count of file's line symbols */    0,			/* ioptBase:	file's optimization entries */    0,			/* copt:	count of file's optimization entries */    0,			/* ipdFirst:	start of procedures for this file */    0,			/* cpd:		count of procedures for this file */    0,			/* iauxBase:	file's auxiliary entries */    0,			/* caux:	count of file's auxiliary entries */    0,			/* rfdBase:	index into the file indirect table */    0,			/* crfd:	count file indirect entries */    langC,		/* lang:	language for this file */    1,			/* fMerge:	whether this file can be merged */    0,			/* fReadin:	true if read in (not just created) */#if BYTES_BIG_ENDIAN    1,			/* fBigendian:	if 1, compiled on big endian machine */#else    0,			/* fBigendian:	if 1, compiled on big endian machine */#endif    GLEVEL_2,		/* glevel:	level this file was compiled with */    0,			/* reserved:	reserved for future use */    0,			/* cbLineOffset: byte offset from header for this file ln's */    0,			/* cbLine:	size of lines for this file */  },  (FDR *)0,		/* orig_fdr:	original file header pointer */  (char *)0,		/* name:	pointer to filename */  0,			/* name_len:	length of filename */  0,			/* void_type:	ptr to aux node for void type */  0,			/* int_type:	ptr to aux node for int type */  (scope_t *)0,		/* cur_scope:	current scope being processed */  0,			/* file_index:	current file # */  0,			/* nested_scopes: # nested scopes */  INIT_VARRAY (char),	/* strings:	local string varray */  INIT_VARRAY (SYMR),	/* symbols:	local symbols varray */  INIT_VARRAY (PDR),	/* procs:	procedure varray */  INIT_VARRAY (AUXU),	/* aux_syms:	auxiliary symbols varray */  (struct efdr *)0,	/* next_file:	next file structure */  (shash_t **)0,	/* shash_head:	string hash table */  { 0 },		/* thash_head:	type hash table */};static efdr_t *first_file;			/* first file descriptor */static efdr_t **last_file_ptr = &first_file;	/* file descriptor tail *//* Union of various things that are held in pages.  */typedef union page {  char		byte	[ PAGE_SIZE ];  unsigned char	ubyte	[ PAGE_SIZE ];  efdr_t	file	[ PAGE_SIZE / sizeof (efdr_t)	 ];  FDR		ofile	[ PAGE_SIZE / sizeof (FDR)	 ];  PDR		proc	[ PAGE_SIZE / sizeof (PDR)	 ];  SYMR		sym	[ PAGE_SIZE / sizeof (SYMR)	 ];  EXTR		esym	[ PAGE_SIZE / sizeof (EXTR)	 ];  AUXU		aux	[ PAGE_SIZE / sizeof (AUXU)	 ];  DNR		dense	[ PAGE_SIZE / sizeof (DNR)	 ];  scope_t	scope	[ PAGE_SIZE / sizeof (scope_t)	 ];  vlinks_t	vlinks	[ PAGE_SIZE / sizeof (vlinks_t)	 ];  shash_t	shash	[ PAGE_SIZE / sizeof (shash_t)	 ];

⌨️ 快捷键说明

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