diff options
Diffstat (limited to 'gc/os_dep.c')
-rw-r--r-- | gc/os_dep.c | 79 |
1 files changed, 46 insertions, 33 deletions
diff --git a/gc/os_dep.c b/gc/os_dep.c index 79bed4c..cfbd837 100644 --- a/gc/os_dep.c +++ b/gc/os_dep.c @@ -71,10 +71,6 @@ # define NEED_FIND_LIMIT # endif -# if defined(IRIX_THREADS) || defined(HPUX_THREADS) -# define NEED_FIND_LIMIT -# endif - # if (defined(SUNOS4) && defined(DYNAMIC_LOADING)) && !defined(PCR) # define NEED_FIND_LIMIT # endif @@ -219,7 +215,7 @@ static void *tiny_sbrk(ptrdiff_t increment) #define sbrk tiny_sbrk # endif /* ECOS */ -#if defined(NETBSD) && defined(__ELF__) +#if (defined(NETBSD) || defined(OPENBSD)) && defined(__ELF__) ptr_t GC_data_start; void GC_init_netbsd_elf() @@ -561,7 +557,7 @@ ptr_t GC_get_stack_base() /* signal mask. */ (void) sigemptyset(&act.sa_mask); -# ifdef IRIX_THREADS +# ifdef GC_IRIX_THREADS /* Older versions have a bug related to retrieving and */ /* and setting a handler at the same time. */ (void) sigaction(SIGSEGV, 0, &old_segv_act); @@ -575,7 +571,7 @@ ptr_t GC_get_stack_base() /* don't have to worry in the threads case. */ (void) sigaction(SIGBUS, &act, &old_bus_act); # endif -# endif /* IRIX_THREADS */ +# endif /* GC_IRIX_THREADS */ # else old_segv_handler = signal(SIGSEGV, h); # ifdef SIGBUS @@ -670,7 +666,12 @@ ptr_t GC_get_stack_base() ptr_t GC_get_register_stack_base(void) { - if (0 != &__libc_ia64_register_backing_store_base) { + if (0 != &__libc_ia64_register_backing_store_base + && 0 != __libc_ia64_register_backing_store_base) { + /* Glibc 2.2.4 has a bug such that for dynamically linked */ + /* executables __libc_ia64_register_backing_store_base is */ + /* defined but ininitialized during constructor calls. */ + /* Hence we check for both nonzero address and value. */ return __libc_ia64_register_backing_store_base; } else { word result = (word)GC_stackbottom - BACKING_STORE_DISPLACEMENT; @@ -1079,7 +1080,7 @@ void GC_register_data_segments() { # if !defined(PCR) && !defined(SRC_M3) && !defined(NEXT) && !defined(MACOS) \ && !defined(MACOSX) -# if defined(REDIRECT_MALLOC) && defined(SOLARIS_THREADS) +# if defined(REDIRECT_MALLOC) && defined(GC_SOLARIS_THREADS) /* As of Solaris 2.3, the Solaris threads implementation */ /* allocates the data structure for the initial thread with */ /* sbrk at process startup. It needs to be scanned, so that */ @@ -1090,6 +1091,9 @@ void GC_register_data_segments() GC_add_roots_inner(DATASTART, (char *)sbrk(0), FALSE); # else GC_add_roots_inner(DATASTART, (char *)(DATAEND), FALSE); +# if defined(DATASTART2) + GC_add_roots_inner(DATASTART2, (char *)(DATAEND2), FALSE); +# endif # endif # endif # if !defined(PCR) && (defined(NEXT) || defined(MACOSX)) @@ -1288,8 +1292,14 @@ void * os2_alloc(size_t bytes) SYSTEM_INFO GC_sysinfo; # endif - # ifdef MSWIN32 + +# ifdef USE_GLOBAL_ALLOC +# define GLOBAL_ALLOC_TEST 1 +# else +# define GLOBAL_ALLOC_TEST GC_win32s +# endif + word GC_n_heap_bases = 0; ptr_t GC_win32_get_mem(bytes) @@ -1297,7 +1307,7 @@ word bytes; { ptr_t result; - if (GC_win32s) { + if (GLOBAL_ALLOC_TEST) { /* VirtualAlloc doesn't like PAGE_EXECUTE_READWRITE. */ /* There are also unconfirmed rumors of other */ /* problems, so we dodge the issue. */ @@ -1640,9 +1650,8 @@ void GC_default_push_other_roots GC_PROTO((void)) # endif /* SRC_M3 */ -# if defined(SOLARIS_THREADS) || defined(WIN32_THREADS) \ - || defined(IRIX_THREADS) || defined(LINUX_THREADS) \ - || defined(HPUX_THREADS) +# if defined(GC_SOLARIS_THREADS) || defined(GC_PTHREADS) || \ + defined(GC_WIN32_THREADS) extern void GC_push_all_stacks(); @@ -1651,11 +1660,11 @@ void GC_default_push_other_roots GC_PROTO((void)) GC_push_all_stacks(); } -# endif /* SOLARIS_THREADS || ... */ +# endif /* GC_SOLARIS_THREADS || GC_PTHREADS */ void (*GC_push_other_roots) GC_PROTO((void)) = GC_default_push_other_roots; -#endif +#endif /* THREADS */ /* * Routines for accessing dirty bits on virtual pages. @@ -2399,7 +2408,7 @@ void GC_dirty_init() # if defined(SUNOS5SIGS) || defined(IRIX5) || defined(LINUX) \ || defined(OSF1) || defined(HURD) /* SUNOS5SIGS includes HPUX */ -# if defined(IRIX_THREADS) +# if defined(GC_IRIX_THREADS) sigaction(SIGSEGV, 0, &oldact); sigaction(SIGSEGV, &act, 0); # else @@ -2537,11 +2546,15 @@ word len; ((ptr_t)end_block - (ptr_t)start_block) + HBLKSIZE); } -#if !defined(MSWIN32) && !defined(MSWINCE) && !defined(LINUX_THREADS) \ +#if !defined(MSWIN32) && !defined(MSWINCE) && !defined(THREADS) \ && !defined(GC_USE_LD_WRAP) -/* Replacement for UNIX system call. */ -/* Other calls that write to the heap */ -/* should be handled similarly. */ +/* Replacement for UNIX system call. */ +/* Other calls that write to the heap should be handled similarly. */ +/* Note that this doesn't work well for blocking reads: It will hold */ +/* tha allocation lock for the entur duration of the call. Multithreaded */ +/* clients should really ensure that it won't block, either by setting */ +/* the descriptor nonblocking, or by calling select or poll first, to */ +/* make sure that input is available. */ # if defined(__STDC__) && !defined(SUNOS4) # include <unistd.h> # include <sys/uio.h> @@ -2561,7 +2574,7 @@ word len; GC_begin_syscall(); GC_unprotect_range(buf, (word)nbyte); -# if defined(IRIX5) || defined(LINUX_THREADS) +# if defined(IRIX5) || defined(GC_LINUX_THREADS) /* Indirect system call may not always be easily available. */ /* We could call _read, but that would interfere with the */ /* libpthread interception of read. */ @@ -2587,9 +2600,9 @@ word len; GC_end_syscall(); return(result); } -#endif /* !MSWIN32 && !MSWINCE && !LINUX_THREADS */ +#endif /* !MSWIN32 && !MSWINCE && !GC_LINUX_THREADS */ -#ifdef GC_USE_LD_WRAP +#if defined(GC_USE_LD_WRAP) && !defined(THREADS) /* We use the GNU ld call wrapping facility. */ /* This requires that the linker be invoked with "--wrap read". */ /* This can be done by passing -Wl,"--wrap read" to gcc. */ @@ -2660,7 +2673,7 @@ word n; word GC_proc_buf_size = INITIAL_BUF_SZ; char *GC_proc_buf; -#ifdef SOLARIS_THREADS +#ifdef GC_SOLARIS_THREADS /* We don't have exact sp values for threads. So we count on */ /* occasionally declaring stack pages to be fresh. Thus we */ /* need a real implementation of GC_is_fresh. We can't clear */ @@ -2715,7 +2728,7 @@ void GC_dirty_init() ABORT("/proc ioctl failed"); } GC_proc_buf = GC_scratch_alloc(GC_proc_buf_size); -# ifdef SOLARIS_THREADS +# ifdef GC_SOLARIS_THREADS GC_fresh_pages = (struct hblk **) GC_scratch_alloc(MAX_FRESH_PAGES * sizeof (struct hblk *)); if (GC_fresh_pages == 0) { @@ -2733,7 +2746,7 @@ struct hblk *h; { } -#ifdef SOLARIS_THREADS +#ifdef GC_SOLARIS_THREADS # define READ(fd,buf,nbytes) syscall(SYS_read, fd, buf, nbytes) #else # define READ(fd,buf,nbytes) read(fd, buf, nbytes) @@ -2772,7 +2785,7 @@ int dummy; /* Punt: */ memset(GC_grungy_pages, 0xff, sizeof (page_hash_table)); memset(GC_written_pages, 0xff, sizeof(page_hash_table)); -# ifdef SOLARIS_THREADS +# ifdef GC_SOLARIS_THREADS BZERO(GC_fresh_pages, MAX_FRESH_PAGES * sizeof (struct hblk *)); # endif @@ -2802,7 +2815,7 @@ int dummy; register word index = PHT_HASH(h); set_pht_entry_from_index(GC_grungy_pages, index); -# ifdef SOLARIS_THREADS +# ifdef GC_SOLARIS_THREADS { register int slot = FRESH_PAGE_SLOT(h); @@ -2820,7 +2833,7 @@ int dummy; } /* Update GC_written_pages. */ GC_or_pages(GC_written_pages, GC_grungy_pages); -# ifdef SOLARIS_THREADS +# ifdef GC_SOLARIS_THREADS /* Make sure that old stacks are considered completely clean */ /* unless written again. */ GC_old_stacks_are_fresh(); @@ -2836,7 +2849,7 @@ struct hblk *h; register GC_bool result; result = get_pht_entry_from_index(GC_grungy_pages, index); -# ifdef SOLARIS_THREADS +# ifdef GC_SOLARIS_THREADS if (result && PAGE_IS_FRESH(h)) result = FALSE; /* This happens only if page was declared fresh since */ /* the read_dirty call, e.g. because it's in an unused */ @@ -2854,7 +2867,7 @@ struct hblk *h; register GC_bool result; result = get_pht_entry_from_index(GC_written_pages, index); -# ifdef SOLARIS_THREADS +# ifdef GC_SOLARIS_THREADS if (result && PAGE_IS_FRESH(h)) result = FALSE; # endif return(result); @@ -2868,7 +2881,7 @@ word n; register word index; -# ifdef SOLARIS_THREADS +# ifdef GC_SOLARIS_THREADS register word i; if (GC_fresh_pages != 0) { |