# HG changeset patch # User John Tsiombikas # Date 1307737165 -10800 # Node ID e6f75f91e606a47e6f3a536325b10bfac0978824 # Parent 2c401f69128e715b3c4cff42b06da953791364a5 - 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 diff -r 2c401f69128e -r e6f75f91e606 Makefile --- a/Makefile Fri Jun 10 19:54:47 2011 +0300 +++ b/Makefile Fri Jun 10 23:19:25 2011 +0300 @@ -12,7 +12,7 @@ # -nostdinc instructs the compiler to ignore standard include directories # -m32 instructs the compiler to produce 32bit code (in case we have a 64bit compiler) -CFLAGS = -m32 -Wall -g -nostdinc -fno-builtin $(inc) +CFLAGS = -O0 -m32 -Wall -g -nostdinc -fno-builtin $(inc) ASFLAGS = -m32 -g -nostdinc -fno-builtin $(inc) bin = kernel.elf @@ -23,6 +23,9 @@ $(bin): $(obj) ld -melf_i386 -o $@ -Ttext 0x100000 -e kentry $(obj) -Map link.map +%.s: %.c + $(CC) $(CFLAGS) -S -o $@ $< + -include $(dep) %.d: %.c diff -r 2c401f69128e -r e6f75f91e606 src/klibc/time.c --- a/src/klibc/time.c Fri Jun 10 19:54:47 2011 +0300 +++ b/src/klibc/time.c Fri Jun 10 23:19:25 2011 +0300 @@ -69,37 +69,35 @@ struct tm *gmtime_r(time_t *tp, struct tm *tm) { - int yrsec, yrdays, monsec, leap, day, num_days = 0; - int year = 1970; - time_t t = *tp; + int year, days, leap, yrdays; + time_t t; - while(t >= (yrsec = (yrdays = YEARDAYS(year)) * DAYSEC)) { - t -= yrsec; + year = 1970; + days = *tp / DAYSEC; + t = *tp % DAYSEC; + + tm->tm_wday = (days + 4) % 7; + + while(days >= (yrdays = YEARDAYS(year))) { + days -= yrdays; year++; - num_days += yrdays; } tm->tm_year = year - 1900; leap = is_leap_year(year); tm->tm_mon = 0; - while(t >= (monsec = mdays[leap][tm->tm_mon] * DAYSEC)) { - num_days += mdays[leap][tm->tm_mon++]; - t -= monsec; + while(days >= mdays[leap][tm->tm_mon]) { + days -= mdays[leap][tm->tm_mon++]; } - day = t / DAYSEC; - tm->tm_mday = day + 1; - t %= DAYSEC; + tm->tm_mday = days + 1; tm->tm_hour = t / HOURSEC; t %= HOURSEC; - tm->tm_min = t / MINSEC; tm->tm_sec = t % MINSEC; - num_days += day; - tm->tm_wday = (num_days + 4) % 7; - tm->tm_yday = day_of_year(year, tm->tm_mon, day); + tm->tm_yday = day_of_year(year, tm->tm_mon, days); return tm; }