filled in a few more formatting routines; linking with libgcc.a to work with 64-bit unsigned integer division/modulus
git-svn-id: svn://anubis/hos/trunk@45 5b3e749e-e535-0410-8002-a9bb6afbdfca
This commit is contained in:
parent
6a8c7431ff
commit
6a69fd06ec
@ -12,6 +12,7 @@ export CPPFLAGS := -I$(HOS_TOPLEVEL) -I$(HOS_TOPLEVEL)/include
|
|||||||
export CFLAGS := -Wall -O2
|
export CFLAGS := -Wall -O2
|
||||||
export CXXFLAGS := -Wall -O2 -fno-rtti -fno-exceptions
|
export CXXFLAGS := -Wall -O2 -fno-rtti -fno-exceptions
|
||||||
export LDFLAGS := -T $(LDSCRIPT) -Map $(KERNEL).map
|
export LDFLAGS := -T $(LDSCRIPT) -Map $(KERNEL).map
|
||||||
|
export LDLIBS := `$(CC) -print-libgcc-file-name`
|
||||||
|
|
||||||
SUBDIRS := boot mm lang
|
SUBDIRS := boot mm lang
|
||||||
SUBDIRS_clean := $(SUBDIRS:%=%.clean)
|
SUBDIRS_clean := $(SUBDIRS:%=%.clean)
|
||||||
@ -23,7 +24,7 @@ $(KERNEL).gz: $(KERNEL)
|
|||||||
gzip -c $< > $@
|
gzip -c $< > $@
|
||||||
|
|
||||||
$(KERNEL): $(SUBDIRS)
|
$(KERNEL): $(SUBDIRS)
|
||||||
$(LD) $(LDFLAGS) -o $@ $(foreach subdir,$(SUBDIRS),$(subdir)/$(subdir)_all.o)
|
$(LD) $(LDFLAGS) -o $@ $(foreach subdir,$(SUBDIRS),$(subdir)/$(subdir)_all.o) $(LDLIBS)
|
||||||
|
|
||||||
.PHONY: $(SUBDIRS)
|
.PHONY: $(SUBDIRS)
|
||||||
$(SUBDIRS):
|
$(SUBDIRS):
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include "kio.h"
|
#include "kio.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
|
|
||||||
|
#include <limits.h>
|
||||||
#include <stdarg.h> /* va_*() */
|
#include <stdarg.h> /* va_*() */
|
||||||
|
|
||||||
static void fmt_d2a(char * buf, int val);
|
static void fmt_d2a(char * buf, int val);
|
||||||
@ -95,7 +96,7 @@ void kputs(char * s)
|
|||||||
|
|
||||||
static void fmt_d2a(char * buf, int val)
|
static void fmt_d2a(char * buf, int val)
|
||||||
{
|
{
|
||||||
if (val == 0x7FFFFFFF)
|
if (val == INT_MIN)
|
||||||
{
|
{
|
||||||
strcpy(buf, "-2147483648");
|
strcpy(buf, "-2147483648");
|
||||||
}
|
}
|
||||||
@ -112,14 +113,55 @@ static void fmt_d2a(char * buf, int val)
|
|||||||
|
|
||||||
static void fmt_u2a(char * buf, unsigned int val)
|
static void fmt_u2a(char * buf, unsigned int val)
|
||||||
{
|
{
|
||||||
|
bool printing = false;
|
||||||
|
for (unsigned int div = 1000000000; div >= 1; div /= 10)
|
||||||
|
{
|
||||||
|
unsigned int n = val / div;
|
||||||
|
if (n)
|
||||||
|
{
|
||||||
|
printing = true;
|
||||||
|
}
|
||||||
|
if (printing)
|
||||||
|
{
|
||||||
|
*buf++ = '0' + (val % div);
|
||||||
|
}
|
||||||
|
val -= n * div;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fmt_ll2a(char * buf, long long val)
|
static void fmt_ll2a(char * buf, long long val)
|
||||||
{
|
{
|
||||||
|
if (val == LONG_LONG_MIN)
|
||||||
|
{
|
||||||
|
strcpy(buf, "-9223372036854775808");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (val < 0)
|
||||||
|
{
|
||||||
|
*buf++ = '-';
|
||||||
|
val = -val;
|
||||||
|
}
|
||||||
|
fmt_ull2a(buf, (unsigned long long) val);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fmt_ull2a(char * buf, unsigned long long val)
|
static void fmt_ull2a(char * buf, unsigned long long val)
|
||||||
{
|
{
|
||||||
|
bool printing = false;
|
||||||
|
for (unsigned long long div = 10000000000000000000ull; div >= 1; div /= 10)
|
||||||
|
{
|
||||||
|
unsigned long long n = val / div;
|
||||||
|
if (n)
|
||||||
|
{
|
||||||
|
printing = true;
|
||||||
|
}
|
||||||
|
if (printing)
|
||||||
|
{
|
||||||
|
*buf++ = '0' + (val % div);
|
||||||
|
}
|
||||||
|
val -= n * div;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fmt_x2a(char * buf, unsigned int val)
|
static void fmt_x2a(char * buf, unsigned int val)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user