mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-01-12 02:43:14 +01:00
[svn r347] Foundation for adding tangobos to test environment is in place.
This commit is contained in:
@@ -38,7 +38,7 @@ echo
|
||||
|
||||
if [ -z "$DMD" ] ; then
|
||||
echo "Testing with llvmdc. Set DMD environment variable to select compiler."
|
||||
DMD="llvmdc -O0 -I$BASEPATH/testincludes"
|
||||
DMD="llvmdc -O0 -I$BASEPATH/testincludes -L$BASEPATH/testincludes/libtangobos-partial.a"
|
||||
echo "Default is $DMD"
|
||||
else
|
||||
echo "Using compiler given by DMD environment variable: $DMD"
|
||||
|
||||
81
tests/testincludes/Makefile
Normal file
81
tests/testincludes/Makefile
Normal file
@@ -0,0 +1,81 @@
|
||||
# Copied from tango runtime makefile.
|
||||
# Designed to work with GNU make
|
||||
# Targets:
|
||||
# make
|
||||
# Same as make all
|
||||
# make lib
|
||||
# Build the common library
|
||||
# make doc
|
||||
# Generate documentation
|
||||
# make clean
|
||||
# Delete unneeded files created by build process
|
||||
|
||||
LIB_TARGET=libtangobos-partial.a
|
||||
LIB_MASK=libtangobos-partial.a*
|
||||
|
||||
CP=cp -f
|
||||
RM=rm -f
|
||||
MD=mkdir -p
|
||||
|
||||
ADD_CFLAGS=
|
||||
ADD_DFLAGS=
|
||||
|
||||
#CFLAGS=-O3 $(ADD_CFLAGS)
|
||||
CFLAGS=-g $(ADD_CFLAGS)
|
||||
|
||||
#DFLAGS=-release -O3 -inline -w $(ADD_DFLAGS)
|
||||
DFLAGS=-g -w -noasm $(ADD_DFLAGS)
|
||||
|
||||
#TFLAGS=-O3 -inline -w $(ADD_DFLAGS)
|
||||
TFLAGS=-g -w -noasm $(ADD_DFLAGS)
|
||||
|
||||
DOCFLAGS=-version=DDoc
|
||||
|
||||
CC=gcc
|
||||
LC=llvm-ar rsv
|
||||
CLC=ar rsv
|
||||
DC=llvmdc
|
||||
LLC=llvm-as
|
||||
LLVMLINK=llvm-link
|
||||
LLC=llc
|
||||
|
||||
INC_DEST=
|
||||
LIB_DEST=
|
||||
DOC_DEST=
|
||||
|
||||
.SUFFIXES: .d .bc
|
||||
|
||||
.d.bc:
|
||||
$(DC) -c $(DFLAGS) $< -of$@
|
||||
# $(DC) -c $(DFLAGS) $< -of$@
|
||||
|
||||
targets : lib
|
||||
all : lib
|
||||
lib : tangobos.lib
|
||||
|
||||
######################################################
|
||||
|
||||
OBJ_CORE= \
|
||||
std/gc.bc \
|
||||
# std/asserterror.bc \
|
||||
# std/math.bc \
|
||||
# std/stdarg.bc
|
||||
# std/format.bc \
|
||||
|
||||
ALL_OBJS= \
|
||||
$(OBJ_CORE)
|
||||
|
||||
######################################################
|
||||
|
||||
tangobos.lib : $(LIB_TARGET)
|
||||
|
||||
$(LIB_TARGET) : $(ALL_OBJS)
|
||||
$(RM) $@
|
||||
$(LLVMLINK) -o=$(LIB_TARGET).bc `find -name "*.bc"`
|
||||
$(LLC) -o=$(LIB_TARGET).s $(LIB_TARGET).bc
|
||||
$(CC) -c -o $(LIB_TARGET) $(LIB_TARGET).s
|
||||
|
||||
clean :
|
||||
$(RM) $(ALL_OBJS)
|
||||
find . -name "$(LIB_MASK)" | xargs $(RM)
|
||||
|
||||
247
tests/testincludes/std/gc.d
Normal file
247
tests/testincludes/std/gc.d
Normal file
@@ -0,0 +1,247 @@
|
||||
|
||||
/*
|
||||
* Copyright (C) 1999-2006 by Digital Mars, www.digitalmars.com
|
||||
* Written by Walter Bright
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* o The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* o Altered source versions must be plainly marked as such, and must not
|
||||
* be misrepresented as being the original software.
|
||||
* o This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* The garbage collector normally works behind the scenes without needing any
|
||||
* specific interaction. These functions are for advanced applications that
|
||||
* benefit from tuning the operation of the collector.
|
||||
* Macros:
|
||||
* WIKI=Phobos/StdGc
|
||||
*/
|
||||
|
||||
module std.gc;
|
||||
|
||||
import tango.core.Memory;
|
||||
|
||||
/**
|
||||
* Add p to list of roots. Roots are references to memory allocated by the
|
||||
collector that are maintained in memory outside the collector pool. The garbage
|
||||
collector will by default look for roots in the stacks of each thread, the
|
||||
registers, and the default static data segment. If roots are held elsewhere,
|
||||
use addRoot() or addRange() to tell the collector not to free the memory it
|
||||
points to.
|
||||
*/
|
||||
void addRoot(void *p) // add p to list of roots
|
||||
{
|
||||
GC.addRoot(p);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove p from list of roots.
|
||||
*/
|
||||
void removeRoot(void *p) // remove p from list of roots
|
||||
{
|
||||
GC.removeRoot(p);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add range to scan for roots.
|
||||
*/
|
||||
void addRange(void *pbot, void *ptop) // add range to scan for roots
|
||||
{
|
||||
GC.addRange(pbot, ptop-pbot);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove range.
|
||||
*/
|
||||
void removeRange(void *pbot) // remove range
|
||||
{
|
||||
GC.removeRange(pbot);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark a gc allocated block of memory as possibly containing pointers.
|
||||
*/
|
||||
void hasPointers(void* p)
|
||||
{
|
||||
GC.clrAttr(p, GC.BlkAttr.NO_SCAN);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark a gc allocated block of memory as definitely NOT containing pointers.
|
||||
*/
|
||||
void hasNoPointers(void* p)
|
||||
{
|
||||
GC.setAttr(p, GC.BlkAttr.NO_SCAN);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark a gc allocated block of memory pointed to by p as being populated with
|
||||
* an array of TypeInfo ti (as many as will fit).
|
||||
*/
|
||||
//void setTypeInfo(TypeInfo ti, void* p);
|
||||
|
||||
/**
|
||||
* Allocate nbytes of uninitialized data.
|
||||
* The allocated memory will be scanned for pointers during
|
||||
* a gc collection cycle, unless
|
||||
* it is followed by a call to hasNoPointers().
|
||||
*/
|
||||
void[] malloc(size_t nbytes)
|
||||
{
|
||||
void* p = GC.malloc(nbytes);
|
||||
if (p is null)
|
||||
return null;
|
||||
else
|
||||
return p[0..nbytes];
|
||||
}
|
||||
|
||||
/**
|
||||
* Resize allocated memory block pointed to by p to be at least nbytes long.
|
||||
* It will try to resize the memory block in place.
|
||||
* If nbytes is 0, the memory block is free'd.
|
||||
* If p is null, the memory block is allocated using malloc.
|
||||
* The returned array may not be at the same location as the original
|
||||
* memory block.
|
||||
* The allocated memory will be scanned for pointers during
|
||||
* a gc collection cycle, unless
|
||||
* it is followed by a call to hasNoPointers().
|
||||
*/
|
||||
void[] realloc(void* p, size_t nbytes)
|
||||
{
|
||||
p = GC.realloc(p, nbytes);
|
||||
if (p is null)
|
||||
return null;
|
||||
else
|
||||
return p[0..nbytes];
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to enlarge the memory block pointed to by p
|
||||
* by at least minbytes beyond its current capacity,
|
||||
* up to a maximum of maxbytes.
|
||||
* Returns:
|
||||
* 0 if could not extend p,
|
||||
* total size of entire memory block if successful.
|
||||
*/
|
||||
size_t extend(void* p, size_t minbytes, size_t maxbytes)
|
||||
{
|
||||
return GC.extend(p, maxbytes, minbytes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns capacity (size of the memory block) that p
|
||||
* points to the beginning of.
|
||||
* If p does not point into the gc memory pool, or does
|
||||
* not point to the beginning of an allocated memory block,
|
||||
* 0 is returned.
|
||||
*/
|
||||
size_t capacity(void* p)
|
||||
{
|
||||
return GC.sizeOf(p);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set gc behavior to match that of 1.0.
|
||||
*/
|
||||
void setV1_0()
|
||||
{
|
||||
}
|
||||
|
||||
/***********************************
|
||||
* Run a full garbage collection cycle.
|
||||
*
|
||||
* The collector normally runs synchronously with a storage allocation request
|
||||
(i.e. it never happens when in code that does not allocate memory). In some
|
||||
circumstances, for example when a particular task is finished, it is convenient
|
||||
to explicitly run the collector and free up all memory used by that task. It
|
||||
can also be helpful to run a collection before starting a new task that would
|
||||
be annoying if it ran a collection in the middle of that task. Explicitly
|
||||
running a collection can also be done in a separate very low priority thread,
|
||||
so that if the program is idly waiting for input, memory can be cleaned up.
|
||||
*/
|
||||
|
||||
void fullCollect()
|
||||
{
|
||||
GC.collect();
|
||||
}
|
||||
|
||||
/***********************************
|
||||
* Run a generational garbage collection cycle.
|
||||
* Takes less time than a fullcollect(), but isn't
|
||||
* as effective.
|
||||
*/
|
||||
|
||||
void genCollect()
|
||||
{
|
||||
GC.collect();
|
||||
}
|
||||
|
||||
//void genCollectNoStack();
|
||||
|
||||
/**
|
||||
* Minimizes physical memory usage
|
||||
*/
|
||||
//void minimize();
|
||||
|
||||
/***************************************
|
||||
* disable() temporarily disables garbage collection cycle, enable()
|
||||
* then reenables them.
|
||||
*
|
||||
* This is used for brief time critical sections of code, so the amount of time
|
||||
* it will take is predictable.
|
||||
* If the collector runs out of memory while it is disabled, it will throw an
|
||||
* std.outofmemory.OutOfMemoryException.
|
||||
* The disable() function calls can be nested, but must be
|
||||
* matched with corresponding enable() calls.
|
||||
* By default collections are enabled.
|
||||
*/
|
||||
|
||||
void disable()
|
||||
{
|
||||
GC.disable();
|
||||
}
|
||||
|
||||
/**
|
||||
* ditto
|
||||
*/
|
||||
void enable()
|
||||
{
|
||||
GC.enable();
|
||||
}
|
||||
|
||||
//void getStats(out GCStats stats);
|
||||
|
||||
/***************************************
|
||||
* Get handle to the collector.
|
||||
*/
|
||||
|
||||
//void* getGCHandle();
|
||||
|
||||
/***************************************
|
||||
* Set handle to the collector.
|
||||
*/
|
||||
|
||||
//void setGCHandle(void* p);
|
||||
|
||||
//void endGCHandle();
|
||||
|
||||
/*
|
||||
extern (C)
|
||||
{
|
||||
void gc_init();
|
||||
void gc_term();
|
||||
}
|
||||
*/
|
||||
Reference in New Issue
Block a user