kern

changeset 38:e6f75f91e606

- added makefile pattern to produce assembly output from c source files. - removed a commented out previous version of the gmtime_r function in klibc/time.c
author John Tsiombikas <nuclear@member.fsf.org>
date Fri, 10 Jun 2011 23:19:25 +0300
parents 2c401f69128e
children 92297f65aaef
files Makefile src/klibc/time.c
diffstat 2 files changed, 18 insertions(+), 17 deletions(-) [+]
line diff
     1.1 --- a/Makefile	Fri Jun 10 19:54:47 2011 +0300
     1.2 +++ b/Makefile	Fri Jun 10 23:19:25 2011 +0300
     1.3 @@ -12,7 +12,7 @@
     1.4  
     1.5  # -nostdinc instructs the compiler to ignore standard include directories
     1.6  # -m32 instructs the compiler to produce 32bit code (in case we have a 64bit compiler)
     1.7 -CFLAGS = -m32 -Wall -g -nostdinc -fno-builtin $(inc)
     1.8 +CFLAGS = -O0 -m32 -Wall -g -nostdinc -fno-builtin $(inc)
     1.9  ASFLAGS = -m32 -g -nostdinc -fno-builtin $(inc)
    1.10  
    1.11  bin = kernel.elf
    1.12 @@ -23,6 +23,9 @@
    1.13  $(bin): $(obj)
    1.14  	ld -melf_i386 -o $@ -Ttext 0x100000 -e kentry $(obj) -Map link.map
    1.15  
    1.16 +%.s: %.c
    1.17 +	$(CC) $(CFLAGS) -S -o $@ $<
    1.18 +
    1.19  -include $(dep)
    1.20  
    1.21  %.d: %.c
     2.1 --- a/src/klibc/time.c	Fri Jun 10 19:54:47 2011 +0300
     2.2 +++ b/src/klibc/time.c	Fri Jun 10 23:19:25 2011 +0300
     2.3 @@ -69,37 +69,35 @@
     2.4  
     2.5  struct tm *gmtime_r(time_t *tp, struct tm *tm)
     2.6  {
     2.7 -	int yrsec, yrdays, monsec, leap, day, num_days = 0;
     2.8 -	int year = 1970;
     2.9 -	time_t t = *tp;
    2.10 +	int year, days, leap, yrdays;
    2.11 +	time_t t;
    2.12  
    2.13 -	while(t >= (yrsec = (yrdays = YEARDAYS(year)) * DAYSEC)) {
    2.14 -		t -= yrsec;
    2.15 +	year = 1970;
    2.16 +	days = *tp / DAYSEC;
    2.17 +	t = *tp % DAYSEC;
    2.18 +
    2.19 +	tm->tm_wday = (days + 4) % 7;
    2.20 +
    2.21 +	while(days >= (yrdays = YEARDAYS(year))) {
    2.22 +		days -= yrdays;
    2.23  		year++;
    2.24 -		num_days += yrdays;
    2.25  	}
    2.26  	tm->tm_year = year - 1900;
    2.27  
    2.28  	leap = is_leap_year(year);
    2.29  	tm->tm_mon = 0;
    2.30 -	while(t >= (monsec = mdays[leap][tm->tm_mon] * DAYSEC)) {
    2.31 -		num_days += mdays[leap][tm->tm_mon++];
    2.32 -		t -= monsec;
    2.33 +	while(days >= mdays[leap][tm->tm_mon]) {
    2.34 +		days -= mdays[leap][tm->tm_mon++];
    2.35  	}
    2.36  
    2.37 -	day = t / DAYSEC;
    2.38 -	tm->tm_mday = day + 1;
    2.39 -	t %= DAYSEC;
    2.40 +	tm->tm_mday = days + 1;
    2.41  
    2.42  	tm->tm_hour = t / HOURSEC;
    2.43  	t %= HOURSEC;
    2.44 -
    2.45  	tm->tm_min = t / MINSEC;
    2.46  	tm->tm_sec = t % MINSEC;
    2.47  
    2.48 -	num_days += day;
    2.49 -	tm->tm_wday = (num_days + 4) % 7;
    2.50 -	tm->tm_yday = day_of_year(year, tm->tm_mon, day);
    2.51 +	tm->tm_yday = day_of_year(year, tm->tm_mon, days);
    2.52  	return tm;
    2.53  }
    2.54