static void writePacks( void ) { PRAG_STACK *pack_entry; PRAG_STACK *reversed_packs; unsigned pack_amount; reversed_packs = NULL; for( ; ; ) { pack_entry = StackPop( &HeadPacks ); if( pack_entry == NULL ) break; StackPush( &reversed_packs, pack_entry ); } for( ; ; ) { pack_entry = StackPop( &reversed_packs ); if( pack_entry == NULL ) break; pack_amount = pack_entry->value; PCHWriteUInt( pack_amount ); StackPush( &HeadPacks, pack_entry ); } pack_amount = -1; PCHWriteUInt( pack_amount ); if( HeadPacks != NULL ) { pack_amount = PackAmount; } else if( PackAmount != GblPackAmount ) { pack_amount = PackAmount; } PCHWriteUInt( pack_amount ); }
static void alignPCH( unsigned i, bool writing ) { unsigned skip; char dummy[PCH_ALIGN] = {0}; if( writing ) { skip = - cursorWriteFilePosition(); skip &= PCH_ALIGN - 1; PCHWriteUInt( skip ); DbgAssert( skip == 0 ); if( skip != 0 ) { PCHWrite( dummy, skip ); } } else { skip = PCHReadUInt(); if( skip != 0 ) { PCHRead( dummy, skip ); } } #ifndef NDEBUG if( writing ) { unsigned w = -i; PCHWriteUInt( w ); } else { unsigned r; r = PCHReadUInt(); if( r != -i ) { printf( "index = %u\n", i ); CFatal( "pre-compiled header read/write out of synch" ); } } #else i = i; #endif }
pch_status PCHWriteGenerators( void ) { RTN_GEN *c; for( c = useSYMBOL; c != NULL; c = c->next ) { SymbolPCHWrite( c->parm ); PCHWriteUInt( c->index ); } PCHWriteCVIndexTerm(); for( c = useTYPE; c != NULL; c = c->next ) { TypePCHWrite( c->parm ); PCHWriteUInt( c->index ); } PCHWriteCVIndexTerm(); return( PCHCB_OK ); }
static void dumpFileString( char *str ) { unsigned len; len = strlen( str ) + 1; PCHWriteUInt( len ); PCHWrite( str, len ); }
pch_status PCHWritePragmaData( void ) { unsigned depth; unsigned value; PCHWriteVar( PragToggle ); CgInfoLibPCHWrite(); writePacks(); writeEnums(); writeExtrefs(); PCHWriteVar( CompInfo.init_priority ); PCHWriteVar( CompInfo.dt_method_speced ); depth = CgBackGetInlineDepth(); PCHWriteUInt( depth ); value = CgBackGetInlineRecursion(); PCHWriteUInt( value ); return( PCHCB_OK ); }
pch_status PCHWriteRTFNames( void ) { NAME *name; for( name = runTimeCodeName; name < &runTimeCodeName[ RTF_LAST ]; ++name ) { PCHWriteUInt( PCHGetUInt( NameGetIndex( *name ) ) ); } return( PCHCB_OK ); }
pch_status PCHWritePragmas( void ) { unsigned index; unsigned len; AUX_INFO *info; AUX_ENTRY *e; // get aux_info count for( e = AuxList; e != NULL; e = e->next ) { e->info->index = PCH_NULL_INDEX; } index = PCH_FIRST_USER_INDEX; for( e = AuxList; e != NULL; e = e->next ) { if( e->info->index == PCH_NULL_INDEX ) { e->info->index = index++; } } PCHWriteUInt( index ); for( e = AuxList; e != NULL; e = e->next ) { e->info->index = PCH_NULL_INDEX; } // write built-in aux_info for( index = PCH_FIRST_INDEX; index < PCH_FIRST_USER_INDEX; ++index ) { info = BuiltinAuxInfo + index - PCH_FIRST_INDEX; writeAuxInfo( info, index ); } // write user aux_info for( e = AuxList; e != NULL; e = e->next ) { info = e->info; if( info->index == PCH_NULL_INDEX ) { writeAuxInfo( info, index++ ); } } // write aux entries for( e = AuxList; e != NULL; e = e->next ) { len = strlen( e->name ); PCHWriteUInt( len ); PCHWrite( e->name, len + 1 ); PCHWriteUInt( PCHGetUInt( PragmaGetIndex( e->info ) ) ); } PCHWriteUInt( 0 ); return( PCHCB_OK ); }
pch_status PCHWriteNames( void ) { unsigned len; int i; idname *name; idname **p; PCHWriteVar( nameCount ); PCHWriteVar( nameDummyIndex ); p = nameTranslateTable; for( i = 0; i < nameCount; ++i ) { name = *p++; len = strlen( name->name ); DbgAssert( len != 0 ); PCHWriteUInt( len ); PCHWrite( &(name->xhash), NAME_SIZE_PCH + len + 1 ); } PCHWriteUInt( 0 ); return( PCHCB_OK ); }
static void writeExtrefs( void ) { unsigned len; PRAG_EXT_REF *e; RingIterBeg( pragmaExtrefs, e ) { if( e->symbol != NULL ) { SymbolPCHWrite( e->symbol ); } } RingIterEnd( e ) PCHWriteCVIndexTerm(); RingIterBeg( pragmaExtrefs, e ) { if( e->symbol == NULL ) { len = strlen( e->name ); PCHWriteUInt( len ); PCHWrite( e->name, len + 1 ); } } RingIterEnd( e ) PCHWriteUInt( 0 ); }
void CgInfoLibPCHWrite( void ) /****************************/ { size_t len; LIB_LIST *lib; RingIterBeg( libRing, lib ) { len = sizeof( *lib ) + strlen( lib->name ); PCHWriteUInt( len ); PCHWrite( lib, len ); } RingIterEnd( lib )
static void writeEnums( void ) { PRAG_STACK *enum_entry; PRAG_STACK *reversed_enums; unsigned enum_int; reversed_enums = NULL; for( ; ; ) { enum_entry = StackPop( &HeadPacks ); if( enum_entry == NULL ) break; StackPush( &reversed_enums, enum_entry ); } for( ; ; ) { enum_entry = StackPop( &reversed_enums ); if( enum_entry == NULL ) break; enum_int = enum_entry->value; PCHWriteUInt( enum_int ); StackPush( &HeadPacks, enum_entry ); } enum_int = -1; PCHWriteUInt( enum_int ); PCHWriteUInt( CompFlags.make_enums_an_int ); }
static void dumpCheckData( char *include_file ) { SRCFILE src; time_t stamp; auto char buff[_MAX_PATH]; PCHWriteVar( GenSwitches ); PCHWriteVar( TargetSwitches ); PCHWriteUInt( ErrPCHVersion() ); PCHWriteUInt( TYPC_LAST ); PCHWriteUInt( sizeof( COMP_FLAGS ) ); PCHWriteVar( CompFlags ); dumpFileString( WholeFName ); include_file = IoSuppFullPath( include_file, buff, sizeof( buff ) ); dumpFileString( include_file ); getcwd( buff, sizeof( buff ) ); dumpFileString( buff ); HFileListStart(); for( ; ; ) { HFileListNext( buff ); dumpFileString( buff ); if( buff[0] == '\0' ) break; } src = SrcFileNotReadOnly( SrcFileWalkInit() ); for( ; src != NULL; ) { if( ! IsSrcFilePrimary( src ) ) { dumpFileString( SrcFileName( src ) ); stamp = SrcFileTimeStamp( src ); PCHWriteVar( stamp ); } src = SrcFileNotReadOnly( SrcFileWalkNext( src ) ); } buff[0] = '\0'; dumpFileString( buff ); PCHDumpMacroCheck(); }
void AsmSysPCHWriteCode( AUX_INFO *info ) /***************************************/ { BYTE_SEQ_SYM sym; byte_seq_len code_length; byte_seq_len seq_size; unsigned fixup; byte_seq *code; byte *d; byte *s; byte *c; byte *p; byte *tmp_buff; #ifndef NDEBUG byte buff[8]; #else byte buff[1024]; #endif seq_size = 0; code = info->code; if( code == NULL ) { /* no code */ PCHWriteUInt( seq_size ); return; } code_length = code->length; seq_size = offsetof( byte_seq, data ) + code_length; PCHWriteUInt( seq_size ); if( !code->relocs ) { /* code has no relocs */ PCHWrite( code, seq_size ); return; } /* code has relocs */ tmp_buff = buff; if( seq_size > sizeof( buff ) ) { tmp_buff = CMemAlloc( seq_size ); } c = code->data; s = code->data + code_length; d = copyCodeLen( tmp_buff, code, offsetof( byte_seq, data ) ); for( p = c; p != s; ) { if( p[0] == FLOATING_FIXUP_BYTE ) { fixup = p[1]; *d++ = *p++; *d++ = *p++; if( fixup != FLOATING_FIXUP_BYTE ) { switch( fixup ) { case FIX_SYM_OFFSET: case FIX_SYM_SEGMENT: case FIX_SYM_RELOFF: sym = SymbolGetIndex( *((BYTE_SEQ_SYM *)p) ); d = copyCodeLen( d, &sym, sizeof( sym ) ); p += sizeof( BYTE_SEQ_SYM ); d = copyCodeLen( d, p, sizeof( BYTE_SEQ_OFF ) ); p += sizeof( BYTE_SEQ_OFF ); break; default: break; } } } else { *d++ = *p++; } } PCHWrite( tmp_buff, seq_size ); if( tmp_buff != buff ) { CMemFree( tmp_buff ); } }
pch_status PCHWriteStats( void ) { PCHWriteUInt( IncLineCount ); return( PCHCB_OK ); }