summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.symbian13
-rw-r--r--build/s60v3/bld.inf15
-rw-r--r--build/s60v3/libgc.mmp70
-rw-r--r--global_end.cpp16
-rw-r--r--global_start.cpp16
-rw-r--r--include/gc_config_macros.h9
-rw-r--r--include/gc_cpp.h16
-rw-r--r--include/init_global_static_roots.h13
-rw-r--r--include/private/gc_priv.h9
-rw-r--r--include/private/gcconfig.h35
-rw-r--r--init_global_static_roots.cpp36
-rw-r--r--mach_dep.c2
-rw-r--r--misc.c14
-rw-r--r--os_dep.c24
-rw-r--r--symbian.cpp55
15 files changed, 324 insertions, 19 deletions
diff --git a/README.symbian b/README.symbian
new file mode 100644
index 0000000..679160c
--- /dev/null
+++ b/README.symbian
@@ -0,0 +1,13 @@
+2-3 ptites infos car il manque le readme.txt et les tests
+le build se fait avec libgc.mmp(dll)
+Il faut juste faire attention a la limitation introduite par l'emulateur,
+les static roots ne sont pas recuperables dynamiquement(il y a les API pour
+ca, mais ce sont des bouchons).
+Donc sur emulateur, il faut uniquement travailler avec des dlls(gc et
+clients de gc) ou un exe, et recuperer les statics roots avec
+global_init_static_root, a appeler par dll. ou exe.
+Sur target, il faut utiliser au contraire des libs statiques, on recupere
+les static roots avec le linker. Il faut simplement appeler
+global_init_static_root dans l'exe principal comem pr l'emu, qui se charge
+de tout.
+
diff --git a/build/s60v3/bld.inf b/build/s60v3/bld.inf
new file mode 100644
index 0000000..4c3855e
--- /dev/null
+++ b/build/s60v3/bld.inf
@@ -0,0 +1,15 @@
+/*
+============================================================================
+ Name : bld.inf
+ Author :
+ Copyright :
+ Description : This file provides the information required for building the
+ whole of a libgc.
+============================================================================
+*/
+
+PRJ_PLATFORMS
+default armv5
+
+PRJ_MMPFILES
+libgc.mmp
diff --git a/build/s60v3/libgc.mmp b/build/s60v3/libgc.mmp
new file mode 100644
index 0000000..bbee121
--- /dev/null
+++ b/build/s60v3/libgc.mmp
@@ -0,0 +1,70 @@
+TARGET libgc.dll
+
+TARGETTYPE dll
+UID 0x1000008d 0x200107C2 // check uid
+
+EXPORTUNFROZEN
+EPOCALLOWDLLDATA
+//ALWAYS_BUILD_AS_ARM
+//nocompresstarget
+//srcdbg
+//baseaddress 00500000
+//LINKEROPTION CW -map libgc.map
+//LINKEROPTION CW -filealign 0x10000
+
+CAPABILITY PowerMgmt ReadDeviceData ReadUserData WriteDeviceData WriteUserData SwEvent LocalServices NetworkServices UserEnvironment
+
+
+MACRO ALL_INTERIOR_POINTERS
+MACRO GC_DLL
+MACRO GC_BUILD
+MACRO SYMBIAN
+
+USERINCLUDE ..\..\include
+USERINCLUDE ..\..\include\private
+
+SYSTEMINCLUDE \epoc32\include
+SYSTEMINCLUDE \epoc32\include\stdapis
+
+SOURCEPATH ..\..\
+
+SOURCE allchblk.c
+SOURCE alloc.c
+SOURCE blacklst.c
+SOURCE dbg_mlc.c
+SOURCE dyn_load.c
+SOURCE finalize.c
+//SOURCE gc_cpp.cpp
+SOURCE headers.c
+SOURCE mach_dep.c
+SOURCE malloc.c
+SOURCE mallocx.c
+SOURCE mark.c
+SOURCE mark_rts.c
+SOURCE misc.c
+SOURCE new_hblk.c
+SOURCE obj_map.c
+SOURCE os_dep.c
+SOURCE symbian.cpp
+SOURCE ptr_chck.c
+SOURCE reclaim.c
+SOURCE stubborn.c
+SOURCE typd_mlc.c
+
+/*
+#ifdef ENABLE_ABIV2_MODE
+ DEBUGGABLE_UDEBONLY
+#endif
+*/
+
+// Using main() as entry point
+STATICLIBRARY libcrt0.lib
+
+// libc and euser are always needed when using main() entry point
+LIBRARY libc.lib
+
+
+LIBRARY euser.lib
+LIBRARY efsrv.lib
+LIBRARY avkon.lib
+LIBRARY eikcore.lib \ No newline at end of file
diff --git a/global_end.cpp b/global_end.cpp
new file mode 100644
index 0000000..f47e19a
--- /dev/null
+++ b/global_end.cpp
@@ -0,0 +1,16 @@
+
+// INCLUDE FILES
+#include "gcconfig.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int winscw_data_end;
+
+#ifdef __cplusplus
+ }
+#endif
+
+// End Of File
+
diff --git a/global_start.cpp b/global_start.cpp
new file mode 100644
index 0000000..8d0ca20
--- /dev/null
+++ b/global_start.cpp
@@ -0,0 +1,16 @@
+
+// INCLUDE FILES
+#include "gcconfig.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int winscw_data_start;
+
+#ifdef __cplusplus
+ }
+#endif
+
+// End Of File
+
diff --git a/include/gc_config_macros.h b/include/gc_config_macros.h
index 66abf0b..7328d66 100644
--- a/include/gc_config_macros.h
+++ b/include/gc_config_macros.h
@@ -173,6 +173,15 @@
# endif
#endif
+#if defined(__SYMBIAN32__) && defined(GC_DLL)
+# ifdef GC_BUILD
+# define GC_API extern EXPORT_C
+# else
+# define GC_API extern IMPORT_C
+# endif
+#endif
+
+
#ifndef GC_API
#define GC_API extern
#endif
diff --git a/include/gc_cpp.h b/include/gc_cpp.h
index 2a69f05..cbcd583 100644
--- a/include/gc_cpp.h
+++ b/include/gc_cpp.h
@@ -140,6 +140,8 @@ by UseGC. GC is an alias for UseGC, unless GC_NAME_CONFLICT is defined.
#include "gc.h"
+#include "gcconfig.h"
+
#ifndef THINK_CPLUS
# define GC_cdecl
#else
@@ -294,7 +296,7 @@ inline void* gc::operator new( size_t size, GCPlacement gcp ) {
else
return GC_MALLOC_UNCOLLECTABLE( size );}
-inline void* gc::operator new( size_t size, void *p ) {
+inline void* gc::operator new( size_t /*size*/, void *p ) {
return p;}
inline void gc::operator delete( void* obj ) {
@@ -303,7 +305,7 @@ inline void gc::operator delete( void* obj ) {
#ifdef GC_PLACEMENT_DELETE
inline void gc::operator delete( void*, void* ) {}
- inline void gc::operator delete( void* p, GCPlacement gcp ) {
+ inline void gc::operator delete( void* p, GCPlacement /*gcp*/ ) {
GC_FREE(p);
}
#endif
@@ -316,7 +318,7 @@ inline void* gc::operator new[]( size_t size ) {
inline void* gc::operator new[]( size_t size, GCPlacement gcp ) {
return gc::operator new( size, gcp );}
-inline void* gc::operator new[]( size_t size, void *p ) {
+inline void* gc::operator new[]( size_t /*size*/, void *p ) {
return p;}
inline void gc::operator delete[]( void* obj ) {
@@ -325,7 +327,7 @@ inline void gc::operator delete[]( void* obj ) {
#ifdef GC_PLACEMENT_DELETE
inline void gc::operator delete[]( void*, void* ) {}
- inline void gc::operator delete[]( void* p, GCPlacement gcp ) {
+ inline void gc::operator delete[]( void* p, GCPlacement /*gcp*/ ) {
gc::operator delete(p); }
#endif
@@ -373,9 +375,9 @@ inline void* operator new(
# ifdef GC_PLACEMENT_DELETE
inline void operator delete (
void *p,
- GCPlacement gcp,
- GCCleanUpFunc cleanup,
- void* clientData )
+ GCPlacement /*gcp*/,
+ GCCleanUpFunc /*cleanup*/,
+ void* /*clientData*/ )
{
GC_FREE(p);
}
diff --git a/include/init_global_static_roots.h b/include/init_global_static_roots.h
new file mode 100644
index 0000000..cfc4b0d
--- /dev/null
+++ b/include/init_global_static_roots.h
@@ -0,0 +1,13 @@
+#ifndef __INIT_GLOBAL_STATIC_ROOTS_H_
+#define __INIT_GLOBAL_STATIC_ROOTS_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+void init_global_static_roots();
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif // __INIT_GLOBAL_STATIC_ROOTS_H_ \ No newline at end of file
diff --git a/include/private/gc_priv.h b/include/private/gc_priv.h
index 1d96d87..7eea1c1 100644
--- a/include/private/gc_priv.h
+++ b/include/private/gc_priv.h
@@ -1664,6 +1664,7 @@ GC_bool GC_collect_or_expand(word needed_blocks, GC_bool ignore_off_page);
extern GC_bool GC_is_initialized; /* GC_init() has been run. */
+
#if defined(MSWIN32) || defined(MSWINCE)
void GC_deinit(void);
/* Free any resources allocated by */
@@ -1924,7 +1925,15 @@ GC_API void GC_printf (const char * format, ...);
/* (We use sprintf. Hopefully that doesn't */
/* allocate for long arguments.) */
GC_API void GC_err_printf(const char * format, ...);
+
+#ifdef __cplusplus
+extern "C" {
+#endif
GC_API void GC_log_printf(const char * format, ...);
+#ifdef __cplusplus
+ }
+#endif
+
void GC_err_puts(const char *s);
/* Write s to stderr, don't buffer, don't add */
/* newlines, don't ... */
diff --git a/include/private/gcconfig.h b/include/private/gcconfig.h
index a7128f1..03c6f53 100644
--- a/include/private/gcconfig.h
+++ b/include/private/gcconfig.h
@@ -38,6 +38,16 @@
/* Machine specific parts contributed by various people. See README file. */
+/* SYMBIAN */
+# if defined(__SYMBIAN32__)
+# ifndef SYMBIAN
+# define SYMBIAN
+ #ifdef __WINS__
+ #pragma data_seg(".data2")
+ #endif
+# endif
+# endif
+
/* First a unified test for Linux: */
# if defined(linux) || defined(__linux__)
# ifndef LINUX
@@ -64,7 +74,7 @@
/* Determine the machine type: */
# if defined(__arm__) || defined(__thumb__)
# define ARM32
-# if !defined(LINUX) && !defined(NETBSD)
+# if !defined(LINUX) && !defined(NETBSD) && !defined(SYMBIAN)
# define NOSYS
# define mach_type_known
# endif
@@ -280,12 +290,12 @@
# define M68K
# define mach_type_known
# endif
-# if defined(THINK_C) || defined(__MWERKS__) && !defined(__powerc)
+# if defined(THINK_C) || defined(__MWERKS__) && !defined(__powerc) && !defined(SYMBIAN)
# define M68K
# define MACOS
# define mach_type_known
# endif
-# if defined(__MWERKS__) && defined(__powerc) && !defined(__MACH__)
+# if defined(__MWERKS__) && defined(__powerc) && !defined(__MACH__) && !defined(SYMBIAN)
# define POWERPC
# define MACOS
# define mach_type_known
@@ -373,7 +383,8 @@
# define mach_type_known
# else
# if (defined(_MSDOS) || defined(_MSC_VER)) && (_M_IX86 >= 300) \
- || defined(_WIN32) && !defined(__CYGWIN32__) && !defined(__CYGWIN__)
+ || defined(_WIN32) && !defined(__CYGWIN32__) && !defined(__CYGWIN__) \
+ && !defined(SYMBIAN)
# if defined(__LP64__) || defined(_WIN64)
# define X86_64
# else
@@ -462,7 +473,10 @@
# endif
/* Feel free to add more clauses here */
-
+# if defined(SYMBIAN)
+# define mach_type_known
+# endif
+
/* Or manually define the machine type here. A machine type is */
/* characterized by the architecture. Some */
/* machine types are further subdivided by OS. */
@@ -643,6 +657,17 @@
# define HAVE_BUILTIN_UNWIND_INIT
# endif
+# ifdef SYMBIAN
+# define MACH_TYPE "SYMBIAN"
+# define OS_TYPE "SYMBIAN"
+# define CPP_WORDSZ 32
+# define ALIGNMENT 4
+ #define DATASTART NULL
+ #define DATAEND NULL
+# define USE_MMAP
+# define NO_EXECUTE_PERMISSION
+# endif
+
# define STACK_GRAN 0x1000000
# ifdef M68K
# define MACH_TYPE "M68K"
diff --git a/init_global_static_roots.cpp b/init_global_static_roots.cpp
new file mode 100644
index 0000000..a39b380
--- /dev/null
+++ b/init_global_static_roots.cpp
@@ -0,0 +1,36 @@
+
+// INCLUDE FILES
+#include <e32def.h>
+
+#include <gc.h>
+#include <gcconfig.h>
+
+#include "init_global_static_roots.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+void init_global_static_roots()
+{
+ ptr_t dataStart = NULL;
+ ptr_t dataEnd = NULL;
+ #if defined (__WINS__)
+ extern int winscw_data_start, winscw_data_end;
+ dataStart = ((ptr_t)&winscw_data_start);
+ dataEnd = ((ptr_t)&winscw_data_end);
+ #else
+ extern int Image$$RW$$Limit[], Image$$RW$$Base[];
+ dataStart = ((ptr_t)Image$$RW$$Base);
+ dataEnd = ((ptr_t)Image$$RW$$Limit);
+ #endif //__WINS__
+
+ GC_add_roots(dataStart, dataEnd);
+
+}
+
+
+#ifdef __cplusplus
+ }
+#endif
diff --git a/mach_dep.c b/mach_dep.c
index 0491a52..c664bf1 100644
--- a/mach_dep.c
+++ b/mach_dep.c
@@ -27,7 +27,7 @@
# endif
# endif
-#if defined(__MWERKS__) && !defined(POWERPC)
+#if defined(__MWERKS__) && !defined(POWERPC) && !defined(SYMBIAN)
asm static void PushMacRegisters()
{
diff --git a/misc.c b/misc.c
index 5f3eef6..22fc0f5 100644
--- a/misc.c
+++ b/misc.c
@@ -35,7 +35,7 @@
# include <tchar.h>
#endif
-#ifdef UNIX_LIKE
+#if defined (UNIX_LIKE) || defined(SYMBIAN)
# include <fcntl.h>
# include <sys/types.h>
# include <sys/stat.h>
@@ -63,7 +63,11 @@
#ifdef DYNAMIC_LOADING
# define GC_REGISTER_MAIN_STATIC_DATA() GC_register_main_static_data()
#else
+#ifdef SYMBIAN
+# define GC_REGISTER_MAIN_STATIC_DATA() FALSE
+#else
# define GC_REGISTER_MAIN_STATIC_DATA() TRUE
+#endif //SYMBIAN
#endif
GC_FAR struct _GC_arrays GC_arrays /* = { 0 } */;
@@ -513,9 +517,13 @@ void GC_init_inner()
if (0 != GETENV("GC_PRINT_VERBOSE_STATS")) {
GC_print_stats = VERBOSE;
}
-# if defined(UNIX_LIKE)
- {
+#if defined (UNIX_LIKE) || defined(SYMBIAN)
+ {
+ #if defined(SYMBIAN)
+ char * file_name = "c:\\libgc.log";
+ #else
char * file_name = GETENV("GC_LOG_FILE");
+ #endif
if (0 != file_name) {
int log_d = open(file_name, O_CREAT|O_WRONLY|O_APPEND, 0666);
if (log_d < 0) {
diff --git a/os_dep.c b/os_dep.c
index f403375..96737a0 100644
--- a/os_dep.c
+++ b/os_dep.c
@@ -51,6 +51,7 @@
# if !defined(OS2) && !defined(PCR) && !defined(AMIGA) && !defined(MACOS) \
&& !defined(MSWINCE)
# include <sys/types.h>
+# include <fcntl.h>
# if !defined(MSWIN32)
# include <unistd.h>
# endif
@@ -1104,9 +1105,16 @@ ptr_t GC_get_main_stack_base(void)
#endif /* FREEBSD_STACKBOTTOM */
+#ifdef SYMBIAN
+ptr_t GC_get_main_stack_base(void)
+{
+ return (ptr_t)GC_get_main_symbian_stack_base();
+}
+#endif
+
#if !defined(BEOS) && !defined(AMIGA) && !defined(MSWIN32) \
&& !defined(MSWINCE) && !defined(OS2) && !defined(NOSYS) && !defined(ECOS) \
- && !defined(CYGWIN32)
+ && !defined(CYGWIN32) && !defined(SYMBIAN)
ptr_t GC_get_main_stack_base(void)
{
@@ -1760,6 +1768,10 @@ void GC_register_data_segments(void)
# define HEAP_START 0
#endif
+#ifdef SYMBIAN
+extern char* GC_get_private_path_and_zero_file();
+#endif
+
ptr_t GC_unix_mmap_get_mem(word bytes)
{
void *result;
@@ -1768,8 +1780,14 @@ ptr_t GC_unix_mmap_get_mem(word bytes)
# ifndef USE_MMAP_ANON
static GC_bool initialized = FALSE;
- if (!initialized) {
- zero_fd = open("/dev/zero", O_RDONLY);
+ if (!initialized) {
+ #ifdef SYMBIAN
+ char* path = GC_get_private_path_and_zero_file();
+ zero_fd = open(path, O_RDWR | O_CREAT, 0666);
+ free( path );
+ #else
+ zero_fd = open("/dev/zero", O_RDONLY);
+ #endif
fcntl(zero_fd, F_SETFD, FD_CLOEXEC);
initialized = TRUE;
}
diff --git a/symbian.cpp b/symbian.cpp
new file mode 100644
index 0000000..29a960d
--- /dev/null
+++ b/symbian.cpp
@@ -0,0 +1,55 @@
+
+#include <e32cmn.h>
+#include <e32std.h>
+#include <f32file.h>
+#include <aknutils.h>
+#include <stdlib.h>
+#include <string.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int GC_get_main_symbian_stack_base()
+ {
+ TThreadStackInfo aInfo;
+ TInt err = RThread().StackInfo(aInfo);
+ if ( !err )
+ {
+ return aInfo.iBase;
+ }
+ else
+ {
+ return 0;
+ }
+ }
+
+char* GC_get_private_path_and_zero_file()
+ {
+ // always on c: drive
+ RFs fs;
+ fs.Connect();
+ fs.CreatePrivatePath( EDriveC );
+ TFileName path;
+ fs.PrivatePath( path );
+ fs.Close();
+ _LIT( KCDrive, "c:" );
+ path.Insert( 0, KCDrive );
+
+
+ //convert to char*, assume ascii
+ TBuf8<KMaxFileName> path8;
+ path8.Copy( path );
+ _LIT8( KZero8, "zero" );
+ path8.Append( KZero8 );
+
+ size_t size = path8.Length() + 1;
+ char* copyChar = (char*) malloc( size );
+ memcpy( copyChar, path8.PtrZ(), size );
+
+ return copyChar; // ownership passed
+ }
+
+#ifdef __cplusplus
+ }
+#endif