Ignore:
Timestamp:
08/07/08 03:10:26 (4 years ago)
Author:
godzil
Message:

Apply Lionel Patch (and first real commit on this marvelous fork #hehe#)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tigcc/ld-tigcc/main.c

    r1171 r1260  
    4040#include <string.h> 
    4141#include <ctype.h> 
     42#include <time.h> 
    4243 
    4344#define RESULT_OK             0 
     
    122123} 
    123124 
     125// Fill internal structures with time information 
     126static void ComputeTimeInformation(PROGRAM *Program) 
     127{ 
     128        // Get the timestamp. 
     129        if (time(&Program->LinkTime.LinkTime) != (time_t)-1) 
     130        { 
     131                struct tm * broken_down_time; 
     132 
     133                broken_down_time = gmtime(&Program->LinkTime.LinkTime); 
     134                if (broken_down_time != NULL) { 
     135                        // gmtime returns the number of years since 1900. 
     136                        Program->LinkTime.year = broken_down_time->tm_year + 1900; 
     137                        // gmtime returns the month between 0 and 11. 
     138                        Program->LinkTime.month = broken_down_time->tm_mon + 1; 
     139                        Program->LinkTime.day = broken_down_time->tm_mday; 
     140                        // Convert from "seconds since Jan 1, 1970" to "seconds since Jan 1, 1997". 
     141                        // 197x: 8x365 days, 2x366 days (leap years: 1972, 1976) => 315532800 seconds 
     142                        // 198x: 7x365 days, 3x366 days (leap years: 1980, 1984, 1988) => 315619200 seconds 
     143                        // 199x: 5x365 days, 2x366 days (leap years: 1992, 1996) => 220924800 seconds 
     144                        // Total: 852076800 seconds. 
     145                        Program->LinkTime.LinkTime -= (time_t)852076800L; 
     146                        return; 
     147                } 
     148        } 
     149 
     150        // Failed, so set dummy values. 
     151        Warning (NULL, "Couldn't get current time, setting dummy values."); 
     152        Program->LinkTime.LinkTime = (time_t)0, 
     153        Program->LinkTime.year = 1997, 
     154        Program->LinkTime.month = 1, 
     155        Program->LinkTime.day = 1; 
     156} 
     157 
    124158int main (int ArgCount, const char **Args) 
    125159{ 
     
    170204        // Initialize. 
    171205        memset (&Program, 0, sizeof (Program)); 
     206         
     207        ComputeTimeInformation(&Program); 
     208         
    172209        Program.EntryPoint.SymbolName = "__entry_point"; 
    173210#ifdef TARGET_EMBEDDED 
Note: See TracChangeset for help on using the changeset viewer.