summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog22
-rw-r--r--alloc.c4
-rw-r--r--dyn_load.c2
-rw-r--r--include/private/gc_priv.h2
-rw-r--r--include/private/gcconfig.h43
-rw-r--r--mach_dep.c2
-rw-r--r--mark.c2
-rw-r--r--misc.c8
-rw-r--r--os_dep.c61
-rw-r--r--ptr_chck.c2
10 files changed, 85 insertions, 63 deletions
diff --git a/ChangeLog b/ChangeLog
index bfbf9de7..a8b064c4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2011-04-26 Ivan Maidanski <ivmai@mail.ru>
+
+ * alloc.c: Don't include sys/types.h for ArmCC.
+ * dyn_load.c: Ditto.
+ * os_dep.c: Ditto.
+ * mach_dep.c (_setjmp, _longjmp): Redirect to setjmp/longjmp for
+ ArmCC.
+ * mark.c (GC_noop): Define specially for ArmCC.
+ * include/private/gc_priv.h (GC_noop): Ditto.
+ * misc.c (GC_init): Don't test pointers comparison for ArmCC.
+ * misc.c: Don't include unistd.h for ArmCC.
+ * os_dep.c (pages_executable): Rename to GC_pages_executable;
+ make STATIC.
+ * os_dep.c (GC_unix_mmap_get_mem): Don't define for ArmCC.
+ * ptr_chck.c (GC_is_visible): Explicitly cast
+ (GC_DS_PER_OBJECT-GC_INDIR_PER_OBJ_BIAS) to word (to suppress
+ a compiler warning).
+ * include/private/gcconfig.h: Recognize __arm.
+ * include/private/gcconfig.h (HBLKPTR): Define for ArmCC.
+ * include/private/gcconfig.h (HBLKPTR): Add parentheses for
+ "bytes" argument.
+
2011-04-24 Ivan Maidanski <ivmai@mail.ru>
* pthread_support.c (GC_get_nprocs): Don't define for Android.
diff --git a/alloc.c b/alloc.c
index 79fce2a2..df77781f 100644
--- a/alloc.c
+++ b/alloc.c
@@ -20,7 +20,9 @@
#include <stdio.h>
#if !defined(MACOS) && !defined(MSWINCE)
# include <signal.h>
-# include <sys/types.h>
+# if !defined(__CC_ARM)
+# include <sys/types.h>
+# endif
#endif
/*
diff --git a/dyn_load.c b/dyn_load.c
index 50ab3ca2..9cc854db 100644
--- a/dyn_load.c
+++ b/dyn_load.c
@@ -29,7 +29,7 @@
* But then not much of anything is safe in the presence of dlclose.
*/
-#if !defined(MACOS) && !defined(_WIN32_WCE)
+#if !defined(MACOS) && !defined(_WIN32_WCE) && !defined(__CC_ARM)
# include <sys/types.h>
#endif
diff --git a/include/private/gc_priv.h b/include/private/gc_priv.h
index 79bb0084..9e34c769 100644
--- a/include/private/gc_priv.h
+++ b/include/private/gc_priv.h
@@ -1920,7 +1920,7 @@ void GC_print_static_roots(void);
#endif
/* Make arguments appear live to compiler */
-#if defined(__BORLANDC__) || defined(__WATCOMC__)
+#if defined(__BORLANDC__) || defined(__WATCOMC__) || defined(__CC_ARM)
void GC_noop(void*, ...);
#else
# ifdef __DMC__
diff --git a/include/private/gcconfig.h b/include/private/gcconfig.h
index 1428d5b7..f541d7a7 100644
--- a/include/private/gcconfig.h
+++ b/include/private/gcconfig.h
@@ -70,7 +70,7 @@
# define I386
# define mach_type_known
# endif
-# if defined(__arm__) || defined(__thumb__)
+# if defined(__arm) || defined(__arm__) || defined(__thumb__)
# define ARM32
# if !defined(LINUX) && !defined(NETBSD) && !defined(OPENBSD) \
&& !defined(DARWIN) && !defined(_WIN32) && !defined(__CEGCC__)
@@ -186,8 +186,8 @@
# define mach_type_known
# endif
# if defined(sparc) && defined(unix) && !defined(sun) && !defined(linux) \
- && !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__FreeBSD__) \
- && !defined(__DragonFly__)
+ && !defined(__OpenBSD__) && !defined(__NetBSD__) \
+ && !defined(__FreeBSD__) && !defined(__DragonFly__)
# define SPARC
# define DRSNX
# define mach_type_known
@@ -250,7 +250,7 @@
# define IA64
# define mach_type_known
# endif
-# if defined(LINUX) && defined(__arm__)
+# if defined(LINUX) && (defined(__arm) || defined(__arm__))
# define ARM32
# define mach_type_known
# endif
@@ -265,10 +265,6 @@
# define POWERPC
# define mach_type_known
# endif
-# if defined(FREEBSD) && (defined(powerpc) || defined(__powerpc__))
-# define POWERPC
-# define mach_type_known
-# endif
# if defined(LINUX) && defined(__mc68000__)
# define M68K
# define mach_type_known
@@ -277,10 +273,6 @@
# define SPARC
# define mach_type_known
# endif
-# if defined(LINUX) && defined(__arm__)
-# define ARM32
-# define mach_type_known
-# endif
# if defined(LINUX) && defined(__sh__)
# define SH
# define mach_type_known
@@ -293,9 +285,14 @@
# define M32R
# define mach_type_known
# endif
+# if defined(FREEBSD) && (defined(powerpc) || defined(__powerpc__))
+# define POWERPC
+# define mach_type_known
+# endif
# if defined(__alpha) || defined(__alpha__)
# define ALPHA
-# if !defined(LINUX) && !defined(NETBSD) && !defined(OPENBSD) && !defined(FREEBSD)
+# if !defined(LINUX) && !defined(NETBSD) && !defined(OPENBSD) \
+ && !defined(FREEBSD)
# define OSF1 /* a.k.a Digital Unix */
# endif
# define mach_type_known
@@ -2652,18 +2649,18 @@
struct hblk; /* See gc_priv.h. */
# if defined(PCR)
char * real_malloc(size_t bytes);
-# define GET_MEM(bytes) HBLKPTR(real_malloc((size_t)bytes + GC_page_size) \
+# define GET_MEM(bytes) HBLKPTR(real_malloc((size_t)(bytes) + GC_page_size) \
+ GC_page_size-1)
# elif defined(OS2)
void * os2_alloc(size_t bytes);
-# define GET_MEM(bytes) HBLKPTR((ptr_t)os2_alloc((size_t)bytes \
- + GC_page_size) \
- + GC_page_size-1)
+# define GET_MEM(bytes) HBLKPTR((ptr_t)os2_alloc((size_t)(bytes) \
+ + GC_page_size) + GC_page_size-1)
# elif defined(NEXT) || defined(DOS4GW) || defined(NONSTOP) \
|| (defined(AMIGA) && !defined(GC_AMIGA_FASTALLOC)) \
- || (defined(SOLARIS) && !defined(USE_MMAP)) || defined(RTEMS)
+ || (defined(SOLARIS) && !defined(USE_MMAP)) || defined(RTEMS) \
+ || defined(__CC_ARM)
# define GET_MEM(bytes) HBLKPTR((size_t)calloc(1, \
- (size_t)bytes + GC_page_size) \
+ (size_t)(bytes) + GC_page_size) \
+ GC_page_size - 1)
# elif defined(MSWIN32) || defined(CYGWIN32)
ptr_t GC_win32_get_mem(GC_word bytes);
@@ -2672,10 +2669,10 @@
# if defined(USE_TEMPORARY_MEMORY)
Ptr GC_MacTemporaryNewPtr(size_t size, Boolean clearMemory);
# define GET_MEM(bytes) HBLKPTR( \
- GC_MacTemporaryNewPtr(bytes + GC_page_size, true) \
- + GC_page_size-1)
+ GC_MacTemporaryNewPtr((bytes) + GC_page_size, true) \
+ + GC_page_size-1)
# else
-# define GET_MEM(bytes) HBLKPTR(NewPtrClear(bytes + GC_page_size) \
+# define GET_MEM(bytes) HBLKPTR(NewPtrClear((bytes) + GC_page_size) \
+ GC_page_size-1)
# endif
# elif defined(MSWINCE)
@@ -2684,7 +2681,7 @@
# elif defined(AMIGA) && defined(GC_AMIGA_FASTALLOC)
void *GC_amiga_get_mem(size_t size);
# define GET_MEM(bytes) HBLKPTR((size_t) \
- GC_amiga_get_mem((size_t)bytes + GC_page_size) \
+ GC_amiga_get_mem((size_t)(bytes) + GC_page_size) \
+ GC_page_size-1)
# elif defined(SN_TARGET_PS3)
void *ps3_get_mem(size_t size);
diff --git a/mach_dep.c b/mach_dep.c
index 19e688dd..969947c2 100644
--- a/mach_dep.c
+++ b/mach_dep.c
@@ -17,7 +17,7 @@
#include <stdio.h>
#include <setjmp.h>
-#if defined(OS2) || defined(CX_UX)
+#if defined(OS2) || defined(CX_UX) || defined(__CC_ARM)
# define _setjmp(b) setjmp(b)
# define _longjmp(b,v) longjmp(b,v)
#endif
diff --git a/mark.c b/mark.c
index 99fa4327..8a3610dc 100644
--- a/mark.c
+++ b/mark.c
@@ -24,7 +24,7 @@
/* We put this here to minimize the risk of inlining. */
/*VARARGS*/
-#if defined(__BORLANDC__) || defined(__WATCOMC__)
+#if defined(__BORLANDC__) || defined(__WATCOMC__) || defined(__CC_ARM)
/*ARGSUSED*/
void GC_noop(void *p, ...) {}
#else
diff --git a/misc.c b/misc.c
index ee6fa963..bd8730f0 100644
--- a/misc.c
+++ b/misc.c
@@ -951,9 +951,9 @@ GC_API void GC_CALL GC_init(void)
GC_STATIC_ASSERT((word)(-1) > (word)0);
/* word should be unsigned */
# endif
-# if !defined(__BORLANDC__) /* Workaround for Borland C */
- GC_STATIC_ASSERT((ptr_t)(word)(-1) > (ptr_t)0);
- /* Ptr_t comparisons should behave as unsigned comparisons. */
+# if !defined(__BORLANDC__) && !defined(__CC_ARM) /* Workaround */
+ GC_STATIC_ASSERT((ptr_t)(word)(-1) > (ptr_t)0);
+ /* Ptr_t comparisons should behave as unsigned comparisons. */
# endif
GC_STATIC_ASSERT((signed_word)(-1) < (signed_word)0);
# ifndef GC_DISABLE_INCREMENTAL
@@ -1245,7 +1245,7 @@ GC_API void GC_CALL GC_enable_incremental(void)
# define WRITE(f, buf, len) (GC_set_files(), GC_write(f, buf, len))
#else
-# if !defined(AMIGA)
+# if !defined(AMIGA) && !defined(__CC_ARM)
# include <unistd.h>
# endif
diff --git a/os_dep.c b/os_dep.c
index 17ba79db..a3e7a28e 100644
--- a/os_dep.c
+++ b/os_dep.c
@@ -47,7 +47,7 @@
#endif
#if !defined(OS2) && !defined(PCR) && !defined(AMIGA) && !defined(MACOS) \
- && !defined(MSWINCE)
+ && !defined(MSWINCE) && !defined(__CC_ARM)
# include <sys/types.h>
# if !defined(MSWIN32)
# include <unistd.h>
@@ -131,12 +131,12 @@
#endif
#if !defined(NO_EXECUTE_PERMISSION)
- static GC_bool pages_executable = TRUE;
+ STATIC GC_bool GC_pages_executable = TRUE;
#else
- static GC_bool pages_executable = FALSE;
+ STATIC GC_bool GC_pages_executable = FALSE;
#endif
#define IGNORE_PAGES_EXECUTABLE 1
- /* Undefined on pages_executable real use. */
+ /* Undefined on GC_pages_executable real use. */
#if defined(LINUX) && (defined(USE_PROC_FOR_LIBRARIES) || defined(IA64) \
|| !defined(SMALL_CONFIG))
@@ -2014,7 +2014,8 @@ void GC_register_data_segments(void)
# if !defined(OS2) && !defined(PCR) && !defined(AMIGA) && !defined(MSWIN32) \
&& !defined(MSWINCE) && !defined(MACOS) && !defined(DOS4GW) \
- && !defined(NONSTOP) && !defined(SN_TARGET_PS3) && !defined(RTEMS)
+ && !defined(NONSTOP) && !defined(SN_TARGET_PS3) && !defined(RTEMS) \
+ && !defined(__CC_ARM)
# define SBRK_ARG_T ptrdiff_t
@@ -2061,7 +2062,7 @@ STATIC ptr_t GC_unix_mmap_get_mem(word bytes)
if (bytes & (GC_page_size - 1)) ABORT("Bad GET_MEM arg");
result = mmap(last_addr, bytes, (PROT_READ | PROT_WRITE)
- | (pages_executable ? PROT_EXEC : 0),
+ | (GC_pages_executable ? PROT_EXEC : 0),
GC_MMAP_FLAGS | OPT_MAP_ANON, zero_fd, 0/* offset */);
# undef IGNORE_PAGES_EXECUTABLE
@@ -2166,7 +2167,7 @@ void * os2_alloc(size_t bytes)
void * result;
if (DosAllocMem(&result, bytes, (PAG_READ | PAG_WRITE | PAG_COMMIT)
- | (pages_executable ? PAG_EXECUTE : 0))
+ | (GC_pages_executable ? PAG_EXECUTE : 0))
!= NO_ERROR) {
return(0);
}
@@ -2245,8 +2246,8 @@ void * os2_alloc(size_t bytes)
GetWriteWatch_alloc_flag
| (MEM_COMMIT | MEM_RESERVE)
| GC_mem_top_down,
- pages_executable ? PAGE_EXECUTE_READWRITE :
- PAGE_READWRITE);
+ GC_pages_executable ? PAGE_EXECUTE_READWRITE :
+ PAGE_READWRITE);
# undef IGNORE_PAGES_EXECUTABLE
}
# endif /* !CYGWIN32 */
@@ -2312,8 +2313,8 @@ void * os2_alloc(size_t bytes)
/* argument to span regions, so we should be OK for now. */
result = (ptr_t) VirtualAlloc(NULL, res_bytes,
MEM_RESERVE | MEM_TOP_DOWN,
- pages_executable ? PAGE_EXECUTE_READWRITE :
- PAGE_READWRITE);
+ GC_pages_executable ? PAGE_EXECUTE_READWRITE :
+ PAGE_READWRITE);
if (HBLKDISPL(result) != 0) ABORT("Bad VirtualAlloc result");
/* If I read the documentation correctly, this can */
/* only happen if HBLKSIZE > 64k or not a power of 2. */
@@ -2326,8 +2327,8 @@ void * os2_alloc(size_t bytes)
/* Commit pages */
result = (ptr_t) VirtualAlloc(result, bytes, MEM_COMMIT,
- pages_executable ? PAGE_EXECUTE_READWRITE :
- PAGE_READWRITE);
+ GC_pages_executable ? PAGE_EXECUTE_READWRITE :
+ PAGE_READWRITE);
# undef IGNORE_PAGES_EXECUTABLE
if (result != NULL) {
@@ -2438,8 +2439,8 @@ GC_INNER void GC_remap(ptr_t start, size_t bytes)
ABORT("Weird VirtualQuery result");
alloc_len = (len < mem_info.RegionSize) ? len : mem_info.RegionSize;
result = VirtualAlloc(start_addr, alloc_len, MEM_COMMIT,
- pages_executable ? PAGE_EXECUTE_READWRITE :
- PAGE_READWRITE);
+ GC_pages_executable ? PAGE_EXECUTE_READWRITE :
+ PAGE_READWRITE);
if (result != start_addr) {
if (GetLastError() == ERROR_NOT_ENOUGH_MEMORY ||
GetLastError() == ERROR_OUTOFMEMORY) {
@@ -2459,12 +2460,12 @@ GC_INNER void GC_remap(ptr_t start, size_t bytes)
# ifndef NACL
result = mprotect(start_addr, len, (PROT_READ | PROT_WRITE)
- | (pages_executable ? PROT_EXEC : 0));
+ | (GC_pages_executable ? PROT_EXEC : 0));
# else
{
/* NaCl does not expose mprotect, but mmap should work fine. */
void *mmap_result = mmap(start_addr, len, (PROT_READ | PROT_WRITE)
- | (pages_executable ? PROT_EXEC : 0),
+ | (GC_pages_executable ? PROT_EXEC : 0),
MAP_PRIVATE | MAP_FIXED | OPT_MAP_ANON,
zero_fd, 0 /* offset */);
if (mmap_result != (void *)start_addr)
@@ -2932,14 +2933,14 @@ STATIC void GC_default_push_other_roots(void)
# define PROTECT(addr,len) \
if(vm_protect(GC_task_self,(vm_address_t)(addr),(vm_size_t)(len), \
FALSE, VM_PROT_READ \
- | (pages_executable ? VM_PROT_EXECUTE : 0)) \
+ | (GC_pages_executable ? VM_PROT_EXECUTE : 0)) \
!= KERN_SUCCESS) { \
ABORT("vm_protect(PROTECT) failed"); \
}
# define UNPROTECT(addr,len) \
if(vm_protect(GC_task_self,(vm_address_t)(addr),(vm_size_t)(len), \
FALSE, (VM_PROT_READ | VM_PROT_WRITE) \
- | (pages_executable ? VM_PROT_EXECUTE : 0)) \
+ | (GC_pages_executable ? VM_PROT_EXECUTE : 0)) \
!= KERN_SUCCESS) { \
ABORT("vm_protect(UNPROTECT) failed"); \
}
@@ -2952,15 +2953,15 @@ STATIC void GC_default_push_other_roots(void)
# define PROTECT(addr, len) \
if (mprotect((caddr_t)(addr), (size_t)(len), \
PROT_READ \
- | (pages_executable ? PROT_EXEC : 0)) < 0) { \
+ | (GC_pages_executable ? PROT_EXEC : 0)) < 0) { \
ABORT("mprotect failed"); \
}
# define UNPROTECT(addr, len) \
if (mprotect((caddr_t)(addr), (size_t)(len), \
(PROT_READ | PROT_WRITE) \
- | (pages_executable ? PROT_EXEC : 0)) < 0) { \
- ABORT(pages_executable ? "un-mprotect executable page" \
- " failed (probably disabled by OS)" : \
+ | (GC_pages_executable ? PROT_EXEC : 0)) < 0) { \
+ ABORT(GC_pages_executable ? "un-mprotect executable page" \
+ " failed (probably disabled by OS)" : \
"un-mprotect failed"); \
}
# undef IGNORE_PAGES_EXECUTABLE
@@ -2973,8 +2974,8 @@ STATIC void GC_default_push_other_roots(void)
static DWORD protect_junk;
# define PROTECT(addr, len) \
if (!VirtualProtect((addr), (len), \
- pages_executable ? PAGE_EXECUTE_READ : \
- PAGE_READONLY, \
+ GC_pages_executable ? PAGE_EXECUTE_READ : \
+ PAGE_READONLY, \
&protect_junk)) { \
if (GC_print_stats) \
GC_log_printf("Last error code: 0x%lx\n", (long)GetLastError()); \
@@ -2982,8 +2983,8 @@ STATIC void GC_default_push_other_roots(void)
}
# define UNPROTECT(addr, len) \
if (!VirtualProtect((addr), (len), \
- pages_executable ? PAGE_EXECUTE_READWRITE : \
- PAGE_READWRITE, \
+ GC_pages_executable ? PAGE_EXECUTE_READWRITE : \
+ PAGE_READWRITE, \
&protect_junk)) { \
ABORT("un-VirtualProtect failed"); \
}
@@ -4413,9 +4414,9 @@ catch_exception_raise(mach_port_t exception_port, mach_port_t thread,
GC_API void GC_CALL GC_set_pages_executable(int value)
{
GC_ASSERT(!GC_is_initialized);
- /* Even if IGNORE_PAGES_EXECUTABLE is defined, pages_executable is */
+ /* Even if IGNORE_PAGES_EXECUTABLE is defined, GC_pages_executable is */
/* touched here to prevent a compiler warning. */
- pages_executable = (GC_bool)(value != 0);
+ GC_pages_executable = (GC_bool)(value != 0);
}
/* Returns non-zero if the GC-allocated memory is executable. */
@@ -4426,7 +4427,7 @@ GC_API int GC_CALL GC_get_pages_executable(void)
# ifdef IGNORE_PAGES_EXECUTABLE
return 1; /* Always allocate executable memory. */
# else
- return (int)pages_executable;
+ return (int)GC_pages_executable;
# endif
}
diff --git a/ptr_chck.c b/ptr_chck.c
index 9b0da0c1..d8076e84 100644
--- a/ptr_chck.c
+++ b/ptr_chck.c
@@ -242,7 +242,7 @@ GC_API void * GC_CALL GC_is_visible(void *p)
} else {
ptr_t type_descr = *(ptr_t *)base;
descr = *(word *)(type_descr
- - (descr - (GC_DS_PER_OBJECT
+ - (descr - (word)(GC_DS_PER_OBJECT
- GC_INDIR_PER_OBJ_BIAS)));
}
goto retry;