summaryrefslogtreecommitdiff
path: root/boehm-gc/os_dep.c
diff options
context:
space:
mode:
authorBryce McKinlay <bryce@gcc.gnu.org>2000-04-19 11:10:01 +0100
committerBryce McKinlay <bryce@gcc.gnu.org>2000-04-19 11:10:01 +0100
commit93002327db5e5f466de60dc3f8c876cf9a56e183 (patch)
treefec69f60b37ca7ee4a47582f914dabbc7b3ee0c4 /boehm-gc/os_dep.c
parent5e787f078df8900b34981443e9f968fd5c3b039c (diff)
downloadgcc-93002327db5e5f466de60dc3f8c876cf9a56e183.tar.gz
Imported version version 5.0alpha6.
* acinclude.m4: Bump version to 5.0a6. * configure.in: Don't use alpha_mach_dep.s. * include/private/config.h, irix_threads.c gc_watcom.asm: Delete obsolete files. From-SVN: r33251
Diffstat (limited to 'boehm-gc/os_dep.c')
-rw-r--r--boehm-gc/os_dep.c50
1 files changed, 39 insertions, 11 deletions
diff --git a/boehm-gc/os_dep.c b/boehm-gc/os_dep.c
index 5bc41f1ddf6..a972dec805c 100644
--- a/boehm-gc/os_dep.c
+++ b/boehm-gc/os_dep.c
@@ -66,7 +66,7 @@
# define NEED_FIND_LIMIT
# endif
-# if (defined(SUNOS4) & defined(DYNAMIC_LOADING)) && !defined(PCR)
+# if (defined(SUNOS4) && defined(DYNAMIC_LOADING)) && !defined(PCR)
# define NEED_FIND_LIMIT
# endif
@@ -75,7 +75,8 @@
# endif
# if defined(LINUX) && \
- (defined(SPARC) || defined(IA64))
+ (defined(POWERPC) || defined(SPARC) || defined(ALPHA) || defined(IA64) \
+ || defined(MIPS))
# define NEED_FIND_LIMIT
# endif
@@ -142,7 +143,8 @@
# define OPT_PROT_EXEC 0
#endif
-#if defined(LINUX) && (defined(SPARC) || defined(IA64))
+#if defined(SEARCH_FOR_DATA_START)
+ /* The following doesn't work if the GC is in a dynamic library. */
/* The I386 case can be handled without a search. The Alpha case */
/* used to be handled differently as well, but the rules changed */
/* for recent Linux versions. This seems to be the easiest way to */
@@ -641,19 +643,17 @@ ptr_t GC_get_stack_base()
#ifdef LINUX_STACKBOTTOM
# define STAT_SKIP 27 /* Number of fields preceding startstack */
- /* field in /proc/<pid>/stat */
+ /* field in /proc/self/stat */
ptr_t GC_linux_stack_base(void)
{
- char buf[50];
FILE *f;
char c;
word result = 0;
int i;
- sprintf(buf, "/proc/%d/stat", getpid());
- f = fopen(buf, "r");
- if (NULL == f) ABORT("Couldn't open /proc/<pid>/stat");
+ f = fopen("/proc/self/stat", "r");
+ if (NULL == f) ABORT("Couldn't open /proc/self/stat");
c = getc(f);
/* Skip the required number of fields. This number is hopefully */
/* constant across all Linux implementations. */
@@ -1874,6 +1874,9 @@ SIG_PF GC_old_segv_handler; /* Also old MSWIN32 ACCESS_VIOLATION filter */
# else
# ifdef IA64
char * addr = si -> si_addr;
+ /* I believe this is claimed to work on all platforms for */
+ /* Linux 2.3.47 and later. Hopefully we don't have to */
+ /* worry about earlier kernels on IA64. */
# else
# if defined(POWERPC)
char * addr = (char *) (sc.regs->dar);
@@ -2178,12 +2181,13 @@ word len;
((ptr_t)end_block - (ptr_t)start_block) + HBLKSIZE);
}
-#ifndef MSWIN32
+#if !defined(MSWIN32) && !defined(LINUX_THREADS)
/* Replacement for UNIX system call. */
/* Other calls that write to the heap */
/* should be handled similarly. */
# if defined(__STDC__) && !defined(SUNOS4)
# include <unistd.h>
+# include <sys/uio.h>
ssize_t read(int fd, void *buf, size_t nbyte)
# else
# ifndef LINT
@@ -2200,10 +2204,12 @@ word len;
GC_begin_syscall();
GC_unprotect_range(buf, (word)nbyte);
-# ifdef IRIX5
+# if defined(IRIX5) || defined(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. */
+ /* On Linux, we have to be careful with the linuxthreads */
+ /* read interception. */
{
struct iovec iov;
@@ -2217,7 +2223,29 @@ word len;
GC_end_syscall();
return(result);
}
-#endif /* !MSWIN32 */
+#endif /* !MSWIN32 && !LINUX */
+
+#ifdef USE_LD_WRAP
+ /* 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. */
+ /* I'm not sure that this actually wraps whatever version of read */
+ /* is called by stdio. That code also mentions __read. */
+# include <unistd.h>
+ ssize_t __wrap_read(int fd, void *buf, size_t nbyte)
+ {
+ int result;
+
+ GC_begin_syscall();
+ GC_unprotect_range(buf, (word)nbyte);
+ result = __real_read(fd, buf, nbyte);
+ GC_end_syscall();
+ return(result);
+ }
+
+ /* We should probably also do this for __read, or whatever stdio */
+ /* actually calls. */
+#endif
/*ARGSUSED*/
GC_bool GC_page_was_ever_dirty(h)