Skip to content
Browse files

remove or isolate symbols that conflict between d runtime and c runtime

  • Loading branch information...
1 parent 477a0d4 commit 9bbfa8c178f83d4a4022dc5ec380ebeddd8551fc @wolfwood wolfwood committed Oct 3, 2011
View
2 app/d/hello/dsss.conf
@@ -26,7 +26,7 @@ postbuild = \
echo ; \
echo Creating Application Executable; \
echo '--> hello';\
-ld -nostdlib -nodefaultlibs -T../../build/elf.ld -o hello `ls dsss_objs/O/*.o` ../../../runtimes/mindrt/mindrt.a ../../../runtimes/mindrt/drt0.a;\
+ld -nostdlib -nodefaultlibs -T../../build/elf.ld -o hello `ls dsss_objs/O/*.o` ../../../runtimes/mindrt/mindrt.a ../../../runtimes/mindrt/drt0.a ../../../runtimes/mindrt/libd.a;\
\
echo ;\
echo Creating App Symbol File; \
View
2 app/d/xsh/dsss.conf
@@ -27,7 +27,7 @@ postbuild = \
echo ; \
echo Creating Application Executable; \
echo '--> xsh';\
-ld -nostdlib -nodefaultlibs -T../../build/elf.ld -o xsh `ls dsss_objs/O/*.o` ../../../runtimes/mindrt/mindrt.a ../../../runtimes/mindrt/drt0.a;\
+ld -nostdlib -nodefaultlibs -T../../build/elf.ld -o xsh `ls dsss_objs/O/*.o` ../../../runtimes/mindrt/mindrt.a ../../../runtimes/mindrt/drt0.a ../../../runtimes/mindrt/libd.a;\
\
echo ;\
echo Creating App Symbol File; \
View
6 runtimes/mindrt/Makefile
@@ -1,10 +1,14 @@
DFLAGS = -I../. -I../../. -O2 -release
-drt0.a: entry.d mindrt.a
+drt0.a: entry.d mindrt.a libd.a
yasm -g stabs -felf64 entry.S -o dsss_objs/O/runtime.Sentry.o
ldc -nodefaultlib -I../../. ${DFLAGS} -c entry.d -ofdsss_objs/O/runtime.entry.o;
ar rcs drt0.a dsss_objs/O/*.o
+libd.a: libd.d
+ ldc -nodefaultlib ${DFLAGS} -c libd.d -oflibd.o
+ ar rcs libd.a libd.o
+
mindrt.a: object.d dinvariant.d dstubs.d util.d dstatic.d error.d exception.d
mkdir -p dsss_imports;
mkdir -p dsss_objs;
View
17 runtimes/mindrt/dstubs.d
@@ -28,7 +28,6 @@ private template Stub(char[] signature) {
Random stubs (they'll go somewhere eventually)
**************************************************/
-mixin(Stub!("void abort()"));
mixin(Stub!("bool rt_isHalting()"));
mixin(Stub!("bool runModuleUnitTests()"));
mixin(Stub!("void _d_monitordelete(Object h, bool det = true)"));
@@ -98,25 +97,9 @@ mixin(Stub!("void _d_throw_exception(Object e)"));*/
mixin(Stub!("void _gdc_cleanupException()"));
mixin(Stub!("void _d_throw(Object obj)"));
mixin(Stub!("int __gdc_personality_v0()"));
-mixin(Stub!("void _Unwind_RaiseException ()"));
-mixin(Stub!("void _Unwind_ForcedUnwind ()"));
-mixin(Stub!("void _Unwind_DeleteException ()"));
-mixin(Stub!("void _Unwind_Resume()"));
-mixin(Stub!("void _Unwind_Resume_or_Rethrow ()"));
-mixin(Stub!("void _Unwind_Backtrace ()"));
-mixin(Stub!("void _Unwind_GetGR ()"));
-mixin(Stub!("void _Unwind_SetGR ()"));
-mixin(Stub!("void _Unwind_GetIP ()"));
-mixin(Stub!("void _Unwind_SetIP ()"));
-mixin(Stub!("void _Unwind_GetCFA ()"));
-mixin(Stub!("void *_Unwind_GetLanguageSpecificData ()"));
-mixin(Stub!("void _Unwind_GetRegionStart ()"));
mixin(Stub!("void _Unwind_SjLj_RaiseException()"));
mixin(Stub!("void _Unwind_SjLj_ForcedUnwind()"));
mixin(Stub!("void _Unwind_SjLj_Resume ()"));
-mixin(Stub!("void _Unwind_GetDataRelBase ()"));
-mixin(Stub!("void _Unwind_GetTextRelBase ()"));
-mixin(Stub!("uint size_of_encoded_value (ubyte encoding)"));
mixin(Stub!("void base_of_encoded_value ()"));
mixin(Stub!("void read_uleb128()"));
mixin(Stub!("void read_sleb128()"));
View
5 runtimes/mindrt/entry.d
@@ -48,13 +48,18 @@ void start(){
mov RCX, endBSS;
//mov RCX, [RCX];
+ // if bss is zero size, skip
+ cmp RCX, RDX;
+ je setupstack;
+
// zero, one byte at a time
loop:
movb [RDX], 0;
inc RDX;
cmp RCX, RDX;
jne loop;
+ setupstack:
// now set the stack
movq RSP, tempStackTop;
View
95 runtimes/mindrt/libd.d
@@ -0,0 +1,95 @@
+/*
+ * libD
+ *
+ * All the things that D needs that conflict with libC
+ *
+ */
+
+module mindrt.libd;
+
+
+
+/**
+This function copies data from a source piece of memory to a destination piece of memory.
+ Params:
+ dest = A pointer to the piece of memory serving as the copy destination.
+ src = A pointer to the piece of memory serving as the copy source.
+ count = The number of bytes to copy form src to dest.
+ Returns: A void pointer to the start of the destination data (dest).
+*/
+extern(C) void* memcpy(void* dest, void* src, size_t count)
+{
+ //version(LDC)
+ //{
+ // llvm_memcpy(dest, src, count, 0);
+ // return dest;
+ //}
+ //else
+ {
+ ubyte* d = cast(ubyte*)dest;
+ ubyte* s = cast(ubyte*)src;
+
+ for(size_t i = count; count; count--, d++, s++)
+ *d = *s;
+
+ return dest;
+ }
+}
+
+/**
+Memcpy and memmove only really have differences at the user level, where they have slightly
+different semantics. Here, they're pretty much the same.
+*/
+extern(C) void* memmove(void* dest, void* src, size_t count)
+{
+ ubyte* d = cast(ubyte*)dest;
+ ubyte* s = cast(ubyte*)src;
+
+ for(size_t i = count; count; count--, d++, s++)
+ *d = *s;
+
+ return dest;
+}
+
+/**
+Compare two blocks of memory.
+
+Params:
+ a = Pointer to the first block.
+ b = Pointer to the second block.
+ n = The number of bytes to compare.
+
+Returns:
+ 0 if they are equal, < 0 if a is less than b, and > 0 if a is greater than b.
+*/
+extern(C) int memcmp(void* a, void* b, size_t n)
+{
+ ubyte* str_a = cast(ubyte*)a;
+ ubyte* str_b = cast(ubyte*)b;
+
+ for(size_t i = 0; i < n; i++)
+ {
+ if(*str_a != *str_b)
+ return *str_a - *str_b;
+
+ str_a++;
+ str_b++;
+ }
+
+ return 0;
+}
+
+/**
+This function sets a particular piece of memory to a particular value.
+ Params:
+ addr = The address of the piece of memory you wish to write.
+ val = The value you wish to write to memory.
+ numBytes = The number of bytes you would like to write to memory.
+*/
+extern(C) void memset(void *addr, int val, uint numBytes){
+ ubyte *data = cast(ubyte*) addr;
+
+ for(int i = 0; i < numBytes; i++){
+ data[i] = cast(ubyte)val;
+ }
+}
View
86 runtimes/mindrt/util.d
@@ -10,6 +10,8 @@
module mindrt.util;
+public import mindrt.libd;
+
/**
This function converts an integer to a string, depending on the base passed in.
Params:
@@ -51,90 +53,6 @@ char[] itoa(char[] buf, char base, long d)
return buf[p + 1 .. $];
}
-/**
-This function copies data from a source piece of memory to a destination piece of memory.
- Params:
- dest = A pointer to the piece of memory serving as the copy destination.
- src = A pointer to the piece of memory serving as the copy source.
- count = The number of bytes to copy form src to dest.
- Returns: A void pointer to the start of the destination data (dest).
-*/
-extern(C) void* memcpy(void* dest, void* src, size_t count)
-{
- //version(LDC)
- //{
- // llvm_memcpy(dest, src, count, 0);
- // return dest;
- //}
- //else
- {
- ubyte* d = cast(ubyte*)dest;
- ubyte* s = cast(ubyte*)src;
-
- for(size_t i = count; count; count--, d++, s++)
- *d = *s;
-
- return dest;
- }
-}
-
-/**
-Memcpy and memmove only really have differences at the user level, where they have slightly
-different semantics. Here, they're pretty much the same.
-*/
-extern(C) void* memmove(void* dest, void* src, size_t count)
-{
- ubyte* d = cast(ubyte*)dest;
- ubyte* s = cast(ubyte*)src;
-
- for(size_t i = count; count; count--, d++, s++)
- *d = *s;
-
- return dest;
-}
-
-/**
-Compare two blocks of memory.
-
-Params:
- a = Pointer to the first block.
- b = Pointer to the second block.
- n = The number of bytes to compare.
-
-Returns:
- 0 if they are equal, < 0 if a is less than b, and > 0 if a is greater than b.
-*/
-extern(C) int memcmp(void* a, void* b, size_t n)
-{
- ubyte* str_a = cast(ubyte*)a;
- ubyte* str_b = cast(ubyte*)b;
-
- for(size_t i = 0; i < n; i++)
- {
- if(*str_a != *str_b)
- return *str_a - *str_b;
-
- str_a++;
- str_b++;
- }
-
- return 0;
-}
-
-/**
-This function sets a particular piece of memory to a particular value.
- Params:
- addr = The address of the piece of memory you wish to write.
- val = The value you wish to write to memory.
- numBytes = The number of bytes you would like to write to memory.
-*/
-extern(C) void memset(void *addr, int val, uint numBytes){
- ubyte *data = cast(ubyte*) addr;
-
- for(int i = 0; i < numBytes; i++){
- data[i] = cast(ubyte)val;
- }
-}
/**
This function determines the size of a passed-in string.
View
6 user/c/csyscall.d
@@ -123,7 +123,7 @@ void perfPoll(int event) {
return Syscall.perfPoll(event);
}
-void exit(ulong val) {
+void __exit(ulong val) {
return Sched.exit(val);
}
@@ -143,11 +143,11 @@ int rmdir(char *pathname){
}
//char *getcwd(char *buf, size_t size)
-char *getcwd(char *buf, ulong size){
+char *getwd(char *buf){
// XXX: get CWD from key value store in bottle
char[] name = "/postmark";
- uint len = ((size-1) > name.length) ? name.length : size;
+ uint len = name.length;
buf[0..len] = name[0..len];
buf[len] = '\0';

0 comments on commit 9bbfa8c

Please sign in to comment.
Something went wrong with that request. Please try again.