Skip to content

Commit

Permalink
adding hash code, removing cross-comp invokation
Browse files Browse the repository at this point in the history
  • Loading branch information
dlubarov committed Jan 21, 2012
1 parent ddd718b commit 263fe40
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
GCC = i386-elf-gcc -O0
GPP = i386-elf-g++ -O0 -c -nostdlib -nostartfiles -nodefaultlibs -fno-builtin -fno-exceptions -fno-rtti -fno-stack-protector
LD = i386-elf-ld
GCC = gcc -O0
GPP = g++ -O0 -c -nostdlib -nostartfiles -nodefaultlibs -fno-builtin -fno-exceptions -fno-rtti -fno-stack-protector
LD = ld
QEMU = @qemu-system-i386
objects = boot.o kernel.o console.o memory.o panic.o random.o itoa.o icxxabi.o hash.o \
suite.o testframework.o teststring.o testcircularbuffer.o testdeque.o testvector.o testhashmap.o
Expand Down Expand Up @@ -32,7 +32,7 @@ panic.o: panic.cpp common.h
random.o: random.cpp common.h
$(GPP) random.cpp

hash.o: util/hash.cpp
hash.o: util/hash.cpp util/hash.h
$(GPP) util/hash.cpp

icxxabi.o: icxxabi.cpp icxxabi.h
Expand Down
2 changes: 1 addition & 1 deletion kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "common.h"
#include "util/hashmap.h"

#define CHECK_FLAG(flags,bit) ((flags) & (1 << (bit)))
#define CHECK_FLAG(flags,bit) ((flags) & (1 << (bit)))

extern "C" unsigned long start_ctors, end_ctors, start_dtors, end_dtors;
void test_all();
Expand Down
12 changes: 12 additions & 0 deletions util/hash.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include "hash.h"

unsigned int hash_string(const char *s)
{
int n = 0;
while (*s != 0)
{
n = n * 17 ^ *s;
++s;
}
return n;
}
3 changes: 3 additions & 0 deletions util/hash.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma once

unsigned int hash_string(const char *s);

0 comments on commit 263fe40

Please sign in to comment.