]> granicus.if.org Git - gc/commitdiff
libgc_7_1_symbian tarball import gc7_1-symbian
authorIvan Maidanski <ivmai@mail.ru>
Tue, 6 Sep 2011 19:25:43 +0000 (23:25 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 6 Sep 2011 19:25:43 +0000 (23:25 +0400)
15 files changed:
README.symbian [new file with mode: 0644]
build/s60v3/bld.inf [new file with mode: 0644]
build/s60v3/libgc.mmp [new file with mode: 0644]
global_end.cpp [new file with mode: 0644]
global_start.cpp [new file with mode: 0644]
include/gc_config_macros.h
include/gc_cpp.h
include/init_global_static_roots.h [new file with mode: 0644]
include/private/gc_priv.h
include/private/gcconfig.h
init_global_static_roots.cpp [new file with mode: 0644]
mach_dep.c
misc.c
os_dep.c
symbian.cpp [new file with mode: 0644]

diff --git a/README.symbian b/README.symbian
new file mode 100644 (file)
index 0000000..679160c
--- /dev/null
@@ -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 (file)
index 0000000..4c3855e
--- /dev/null
@@ -0,0 +1,15 @@
+/*\r
+============================================================================\r
+ Name          : bld.inf\r
+ Author          : \r
+ Copyright   : \r
+ Description : This file provides the information required for building the\r
+                               whole of a libgc.\r
+============================================================================\r
+*/\r
+\r
+PRJ_PLATFORMS\r
+default armv5\r
+\r
+PRJ_MMPFILES\r
+libgc.mmp\r
diff --git a/build/s60v3/libgc.mmp b/build/s60v3/libgc.mmp
new file mode 100644 (file)
index 0000000..bbee121
--- /dev/null
@@ -0,0 +1,70 @@
+TARGET     libgc.dll\r
+\r
+TARGETTYPE        dll\r
+UID       0x1000008d 0x200107C2 // check uid\r
+\r
+EXPORTUNFROZEN\r
+EPOCALLOWDLLDATA\r
+//ALWAYS_BUILD_AS_ARM\r
+//nocompresstarget\r
+//srcdbg\r
+//baseaddress  00500000\r
+//LINKEROPTION CW -map libgc.map\r
+//LINKEROPTION CW -filealign 0x10000\r
+\r
+CAPABILITY PowerMgmt ReadDeviceData ReadUserData WriteDeviceData WriteUserData SwEvent LocalServices NetworkServices UserEnvironment\r
+\r
+\r
+MACRO ALL_INTERIOR_POINTERS\r
+MACRO GC_DLL\r
+MACRO GC_BUILD\r
+MACRO SYMBIAN\r
+\r
+USERINCLUDE     ..\..\include\r
+USERINCLUDE     ..\..\include\private\r
+\r
+SYSTEMINCLUDE   \epoc32\include\r
+SYSTEMINCLUDE   \epoc32\include\stdapis\r
+\r
+SOURCEPATH       ..\..\\r
+\r
+SOURCE           allchblk.c\r
+SOURCE                 alloc.c\r
+SOURCE                 blacklst.c\r
+SOURCE                 dbg_mlc.c\r
+SOURCE                 dyn_load.c\r
+SOURCE                 finalize.c\r
+//SOURCE                       gc_cpp.cpp\r
+SOURCE                 headers.c\r
+SOURCE                 mach_dep.c\r
+SOURCE                 malloc.c\r
+SOURCE                 mallocx.c\r
+SOURCE                 mark.c\r
+SOURCE                 mark_rts.c\r
+SOURCE                 misc.c\r
+SOURCE                 new_hblk.c\r
+SOURCE                         obj_map.c\r
+SOURCE                 os_dep.c\r
+SOURCE                 symbian.cpp\r
+SOURCE                 ptr_chck.c\r
+SOURCE                 reclaim.c\r
+SOURCE                 stubborn.c\r
+SOURCE                 typd_mlc.c\r
+\r
+/*\r
+#ifdef ENABLE_ABIV2_MODE\r
+  DEBUGGABLE_UDEBONLY\r
+#endif\r
+*/\r
+\r
+// Using main() as entry point\r
+STATICLIBRARY   libcrt0.lib\r
+\r
+// libc and euser are always needed when using main() entry point\r
+LIBRARY         libc.lib \r
+\r
+\r
+LIBRARY euser.lib\r
+LIBRARY efsrv.lib\r
+LIBRARY avkon.lib\r
+LIBRARY eikcore.lib
\ No newline at end of file
diff --git a/global_end.cpp b/global_end.cpp
new file mode 100644 (file)
index 0000000..f47e19a
--- /dev/null
@@ -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 (file)
index 0000000..8d0ca20
--- /dev/null
@@ -0,0 +1,16 @@
+
+// INCLUDE FILES
+#include "gcconfig.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int winscw_data_start;
+
+#ifdef __cplusplus
+       }
+#endif
+
+// End Of File
+
index 66abf0b1e3e371d0e5aa16b4c7c186a8d9ef9811..7328d66fca3a261bcc9951b1f14d8e6b8588c072 100644 (file)
 # 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
index 2a69f0528f43a83532399b0aea8058666e693fa6..cbcd583bbd3de40c9cac790af999dd6246a8b422 100644 (file)
@@ -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 (file)
index 0000000..cfc4b0d
--- /dev/null
@@ -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
index 1d96d87c85812c28770364e44b4a9cb45b6a2443..7eea1c1ae2e9e7d1999beb5444ac08bf844c10a8 100644 (file)
@@ -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 ...                          */
index a7128f148910d5af538a2298cab26a845baa064d..03c6f53f59c769505a763aa462473fe189c7ea59 100644 (file)
 
 /* 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
 #   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
 #   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
 # 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.                         */
 #   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 (file)
index 0000000..a39b380
--- /dev/null
@@ -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
index 0491a52d7756d98c8b05b4c439be098ae13a783f..c664bf11f8193b05fde3d100d1fe873d6a5ee887 100644 (file)
@@ -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 5f3eef6e17869151112ca49eddc000489f54488a..22fc0f5d9b207d64599a4a4a1a39fe6bf44bec89 100644 (file)
--- 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>
 #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) {
index f40337565004d5068f9f92158c3f95d8eb2096ee..96737a011737c575470a87007a66f23b13d9349a 100644 (file)
--- 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 (file)
index 0000000..29a960d
--- /dev/null
@@ -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