diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2011-08-25 10:21:19 +0400 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2011-08-25 10:21:19 +0400 |
commit | f73c7687a129ac0cb3918b4bd0186d9cb48aa0f3 (patch) | |
tree | f1948b9b1151efc83ccc48b9476942ae46b5ad00 /tools | |
parent | 64517562486bbd3e67f2b9d8106e87c1bab40109 (diff) | |
download | bdwgc-f73c7687a129ac0cb3918b4bd0186d9cb48aa0f3.tar.gz |
Move build tools sources from "extra" to "tools" folder.
* EMX_MAKEFILE (setjmp_test): Move setjmp_t.c to "tools" folder.
* Makefile.am (EXTRA_DIST): Move add_gc_prefix.c, gcname.c,
if_mach.c, if_not_there.c, setjmp_t.c and threadlibs.c to "tools"
folder.
* Makefile.direct (SRCS, OTHER_FILES, if_mach, threadlibs,
if_not_there, setjmp_test, add_gc_prefix, gcname): Ditto.
* Makefile.dj (SRCS, OTHER_FILES, if_mach, threadlibs, if_not_there,
setjmp_test, add_gc_prefix): Ditto.
* PCR-Makefile (if_mach, if_not_there): Ditto.
* SMakefile.amiga (setjmp_t): Ditto.
* doc/simple_example.html: Change folder name for threadlibs.c file.
* EMX_MAKEFILE: Remove trailing spaces at EOLn.
* SMakefile.amiga: Ditto.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/add_gc_prefix.c | 20 | ||||
-rw-r--r-- | tools/gcname.c | 13 | ||||
-rw-r--r-- | tools/if_mach.c | 25 | ||||
-rw-r--r-- | tools/if_not_there.c | 38 | ||||
-rw-r--r-- | tools/setjmp_t.c | 136 | ||||
-rw-r--r-- | tools/threadlibs.c | 83 |
6 files changed, 315 insertions, 0 deletions
diff --git a/tools/add_gc_prefix.c b/tools/add_gc_prefix.c new file mode 100644 index 00000000..a7fd4fc4 --- /dev/null +++ b/tools/add_gc_prefix.c @@ -0,0 +1,20 @@ +# include <stdio.h> +# include <gc.h> + +int main(argc, argv, envp) +int argc; +char ** argv; +char ** envp; +{ + int i; + + for (i = 1; i < argc; i++) { + if (GC_ALPHA_VERSION == GC_NOT_ALPHA) { + printf("gc%d.%d/%s ", GC_VERSION_MAJOR, GC_VERSION_MINOR, argv[i]); + } else { + printf("gc%d.%dalpha%d/%s ", GC_VERSION_MAJOR, + GC_VERSION_MINOR, GC_ALPHA_VERSION, argv[i]); + } + } + return(0); +} diff --git a/tools/gcname.c b/tools/gcname.c new file mode 100644 index 00000000..55b7c9fb --- /dev/null +++ b/tools/gcname.c @@ -0,0 +1,13 @@ +#include <stdio.h> +#include <gc.h> + +int main() +{ + if (GC_ALPHA_VERSION == GC_NOT_ALPHA) { + printf("gc%d.%d", GC_VERSION_MAJOR, GC_VERSION_MINOR); + } else { + printf("gc%d.%dalpha%d", GC_VERSION_MAJOR, + GC_VERSION_MINOR, GC_ALPHA_VERSION); + } + return 0; +} diff --git a/tools/if_mach.c b/tools/if_mach.c new file mode 100644 index 00000000..d6e0a70d --- /dev/null +++ b/tools/if_mach.c @@ -0,0 +1,25 @@ +/* Conditionally execute a command based on machine and OS from gcconfig.h */ + +# include "private/gcconfig.h" +# include <stdio.h> +# include <string.h> +# include <unistd.h> + +int main(int argc, char **argv, char **envp) +{ + if (argc < 4) goto Usage; + if (strcmp(MACH_TYPE, argv[1]) != 0) return(0); + if (strcmp(OS_TYPE, "") != 0 && strcmp(argv[2], "") != 0 + && strcmp(OS_TYPE, argv[2]) != 0) return(0); + fprintf(stderr, "^^^^Starting command^^^^\n"); + fflush(stdout); + execvp(argv[3], argv+3); + perror("Couldn't execute"); + +Usage: + fprintf(stderr, "Usage: %s mach_type os_type command\n", argv[0]); + fprintf(stderr, "Currently mach_type = %s, os_type = %s\n", + MACH_TYPE, OS_TYPE); + return(1); +} + diff --git a/tools/if_not_there.c b/tools/if_not_there.c new file mode 100644 index 00000000..7af6fba4 --- /dev/null +++ b/tools/if_not_there.c @@ -0,0 +1,38 @@ +/* Conditionally execute a command based if the file argv[1] doesn't exist */ +/* Except for execvp, we stick to ANSI C. */ +# include "private/gcconfig.h" +# include <stdio.h> +# include <stdlib.h> +# include <unistd.h> +#ifdef __DJGPP__ +#include <dirent.h> +#endif /* __DJGPP__ */ + +int main(int argc, char **argv, char **envp) +{ + FILE * f; +#ifdef __DJGPP__ + DIR * d; +#endif /* __DJGPP__ */ + if (argc < 3) goto Usage; + if ((f = fopen(argv[1], "rb")) != 0 + || (f = fopen(argv[1], "r")) != 0) { + fclose(f); + return(0); + } +#ifdef __DJGPP__ + if ((d = opendir(argv[1])) != 0) { + closedir(d); + return(0); + } +#endif + printf("^^^^Starting command^^^^\n"); + fflush(stdout); + execvp(argv[2], argv+2); + exit(1); + +Usage: + fprintf(stderr, "Usage: %s file_name command\n", argv[0]); + return(1); +} + diff --git a/tools/setjmp_t.c b/tools/setjmp_t.c new file mode 100644 index 00000000..0952fb03 --- /dev/null +++ b/tools/setjmp_t.c @@ -0,0 +1,136 @@ +/* + * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ + +/* Check whether setjmp actually saves registers in jmp_buf. */ +/* If it doesn't, the generic mark_regs code won't work. */ +/* Compilers vary as to whether they will put x in a */ +/* (callee-save) register without -O. The code is */ +/* contrived such that any decent compiler should put x in */ +/* a callee-save register with -O. Thus it is */ +/* recommended that this be run optimized. (If the machine */ +/* has no callee-save registers, then the generic code is */ +/* safe, but this will not be noticed by this piece of */ +/* code.) This test appears to be far from perfect. */ +#include <stdio.h> +#include <setjmp.h> +#include <string.h> +#include "private/gc_priv.h" + +#ifdef OS2 +/* GETPAGESIZE() is set to getpagesize() by default, but that */ +/* doesn't really exist, and the collector doesn't need it. */ +#define INCL_DOSFILEMGR +#define INCL_DOSMISC +#define INCL_DOSERRORS +#include <os2.h> + +int getpagesize(void) +{ + ULONG result[1]; + + if (DosQuerySysInfo(QSV_PAGE_SIZE, QSV_PAGE_SIZE, + (void *)result, sizeof(ULONG)) != NO_ERROR) { + fprintf(stderr, "DosQuerySysInfo failed\n"); + result[0] = 4096; + } + return((int)(result[0])); +} +#endif + +struct { + char a_a; + char * a_b; +} a; + +int * nested_sp(void) +{ + volatile int sp; + sp = (int)&sp; + return (int *)sp; +} + +int main(void) +{ + int dummy; + long ps = GETPAGESIZE(); + jmp_buf b; + register int x = (int)strlen("a"); /* 1, slightly disguised */ + static int y = 0; + + printf("This appears to be a %s running %s\n", MACH_TYPE, OS_TYPE); + if (nested_sp() < &dummy) { + printf("Stack appears to grow down, which is the default.\n"); + printf("A good guess for STACKBOTTOM on this machine is 0x%lx.\n", + ((unsigned long)(&dummy) + ps) & ~(ps-1)); + } else { + printf("Stack appears to grow up.\n"); + printf("Define STACK_GROWS_UP in gc_private.h\n"); + printf("A good guess for STACKBOTTOM on this machine is 0x%lx.\n", + ((unsigned long)(&dummy) + ps) & ~(ps-1)); + } + printf("Note that this may vary between machines of ostensibly\n"); + printf("the same architecture (e.g. Sun 3/50s and 3/80s).\n"); + printf("On many machines the value is not fixed.\n"); + printf("A good guess for ALIGNMENT on this machine is %ld.\n", + (unsigned long)(&(a.a_b))-(unsigned long)(&a)); + + printf("The following is a very dubious test of one root marking" + " strategy.\n"); + printf("Results may not be accurate/useful:\n"); + /* Encourage the compiler to keep x in a callee-save register */ + x = 2*x-1; + printf(""); + x = 2*x-1; + setjmp(b); + if (y == 1) { + if (x == 2) { + printf("Setjmp-based generic mark_regs code probably wont work.\n"); + printf("But we rarely try that anymore. If you have getcontect()\n"); + printf("this probably doesn't matter.\n"); + } else if (x == 1) { + printf("Setjmp-based register marking code may work.\n"); + } else { + printf("Very strange setjmp implementation.\n"); + } + } + y++; + x = 2; + if (y == 1) longjmp(b,1); + printf("Some GC internal configuration stuff: \n"); + printf("\tWORDSZ = %d, ALIGNMENT = %d, GC_GRANULE_BYTES = %d\n", + WORDSZ, ALIGNMENT, GC_GRANULE_BYTES); + printf("\tUsing one mark "); +# if defined(USE_MARK_BYTES) + printf("byte"); +# else + printf("bit"); +# endif + printf(" per "); +# if defined(MARK_BIT_PER_OBJ) + printf("object.\n"); +# elif defined(MARK_BIT_PER_GRANULE) + printf("granule.\n"); +# endif +# ifdef THREAD_LOCAL_ALLOC + printf("Thread local allocation enabled.\n"); +# endif +# ifdef PARALLEL_MARK + printf("Parallel marking enabled.\n"); +# endif + return(0); +} + +int g(int x) +{ + return(x); +} diff --git a/tools/threadlibs.c b/tools/threadlibs.c new file mode 100644 index 00000000..6d84efdb --- /dev/null +++ b/tools/threadlibs.c @@ -0,0 +1,83 @@ +/* + * Copyright (c) 1994 by Xerox Corporation. All rights reserved. + * Copyright (c) 1996 by Silicon Graphics. All rights reserved. + * Copyright (c) 1998 by Fergus Henderson. All rights reserved. + * Copyright (c) 2000-2010 by Hewlett-Packard Development Company. + * All rights reserved. + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ + +# include "gc_config_macros.h" +# include "private/gcconfig.h" + +# include <stdio.h> + +int main(void) +{ +# if defined(GC_USE_LD_WRAP) + printf("-Wl,--wrap -Wl,dlopen " + "-Wl,--wrap -Wl,pthread_create -Wl,--wrap -Wl,pthread_join " + "-Wl,--wrap -Wl,pthread_detach -Wl,--wrap -Wl,pthread_sigmask " + "-Wl,--wrap -Wl,pthread_exit -Wl,--wrap -Wl,pthread_cancel\n"); +# endif +# if (defined(GC_LINUX_THREADS) && !defined(PLATFORM_ANDROID)) \ + || defined(GC_IRIX_THREADS) || defined(GC_DARWIN_THREADS) \ + || defined(GC_AIX_THREADS) || defined(GC_GNU_THREADS) +# ifdef GC_USE_DLOPEN_WRAP + printf("-ldl "); +# endif + printf("-lpthread\n"); +# endif +# if defined(GC_OPENBSD_THREADS) + printf("-pthread\n"); +# endif +# if defined(GC_FREEBSD_THREADS) +# ifdef GC_USE_DLOPEN_WRAP + printf("-ldl "); +# endif +# if (__FREEBSD_version >= 500000) + printf("-lpthread\n"); +# else + printf("-pthread\n"); +# endif +# endif +# if defined(GC_NETBSD_THREADS) + printf("-lpthread -lrt\n"); +# endif + +# if defined(GC_HPUX_THREADS) || defined(GC_OSF1_THREADS) + printf("-lpthread -lrt\n"); +# endif +# if defined(GC_SOLARIS_THREADS) + printf("-lthread -lposix4\n"); + /* Is this right for recent versions? */ +# endif +# if defined(GC_WIN32_THREADS) && defined(CYGWIN32) + printf("-lpthread\n"); +# endif +# if defined(GC_WIN32_PTHREADS) +# ifdef PTW32_STATIC_LIB + /* assume suffix s for static version of the win32 pthread library */ + printf("-lpthreadGC2s -lws2_32\n"); +# else + printf("-lpthreadGC2\n"); +# endif +# endif +# if defined(GC_OSF1_THREADS) + printf("-pthread -lrt"); /* DOB: must be -pthread, not -lpthread */ +# endif + /* You need GCC 3.0.3 to build this one! */ + /* DG/UX native gcc doesn't know what "-pthread" is */ +# if defined(GC_DGUX386_THREADS) + printf("-ldl -pthread\n"); +# endif + return 0; +} |