00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include <stdio.h>
00012 #include <setjmp.h>
00013 #include "config.h"
00014
00015 #ifdef __hpux
00016
00017
00018
00019
00020 #define _CLASSIC_XOPEN_TYPES
00021 #include <unistd.h>
00022 int
00023 getpagesize()
00024 {
00025 return sysconf(_SC_PAGE_SIZE);
00026 }
00027 #endif
00028
00029 #if defined(SUNOS5)
00030 #define _CLASSIC_XOPEN_TYPES
00031 #include <unistd.h>
00032 int
00033 getpagesize()
00034 {
00035 return sysconf(_SC_PAGESIZE);
00036 }
00037 #endif
00038
00039 #ifdef _AUX_SOURCE
00040 #include <sys/mmu.h>
00041 int
00042 getpagesize()
00043 {
00044 return PAGESIZE;
00045 }
00046 #endif
00047
00048 #ifdef __OS2__
00049 #define INCL_DOSFILEMGR
00050 #define INCL_DOSMISC
00051 #define INCL_DOSERRORS
00052 #include <os2.h>
00053
00054 int
00055 getpagesize()
00056 {
00057 ULONG result[1];
00058
00059 if (DosQuerySysInfo(QSV_PAGE_SIZE, QSV_PAGE_SIZE,
00060 (void *)result, sizeof(ULONG)) != NO_ERROR) {
00061 fprintf(stderr, "DosQuerySysInfo failed\n");
00062 result[0] = 4096;
00063 }
00064 return((int)(result[0]));
00065 }
00066 #endif
00067
00068 struct {char a_a; char * a_b;} a;
00069
00070 int * nested_sp()
00071 {
00072 int dummy;
00073
00074 return(&dummy);
00075 }
00076
00077 main()
00078 {
00079 int dummy;
00080 long ps = getpagesize();
00081 jmp_buf b;
00082 register int x = strlen("a");
00083 static int y = 0;
00084
00085 if (nested_sp() < &dummy) {
00086 printf("Stack appears to grow down, which is the default.\n");
00087 printf("A good guess for STACKBOTTOM on this machine is 0x%X.\n",
00088 ((long)(&dummy) + ps) & ~(ps-1));
00089 } else {
00090 printf("Stack appears to grow up.\n");
00091 printf("Define STACK_GROWS_UP in gc_private.h\n");
00092 printf("A good guess for STACKBOTTOM on this machine is 0x%X.\n",
00093 ((long)(&dummy) + ps) & ~(ps-1));
00094 }
00095 printf("Note that this may vary between machines of ostensibly\n");
00096 printf("the same architecture (e.g. Sun 3/50s and 3/80s).\n");
00097 printf("A good guess for ALIGNMENT on this machine is %d.\n",
00098 (unsigned long)(&(a.a_b))-(unsigned long)(&a));
00099
00100
00101 x = 2*x-1;
00102 printf("");
00103 x = 2*x-1;
00104 setjmp(b);
00105 if (y == 1) {
00106 if (x == 2) {
00107 printf("Generic mark_regs code probably wont work\n");
00108 # if defined(SPARC) || defined(IBMRS6000)
00109 printf("Assembly code supplied\n");
00110 # else
00111 printf("Need assembly code\n");
00112 # endif
00113 } else if (x == 1) {
00114 printf("Generic mark_regs code may work\n");
00115 } else {
00116 printf("Very strange setjmp implementation\n");
00117 }
00118 }
00119 y++;
00120 x = 2;
00121 if (y == 1) longjmp(b,1);
00122 return(0);
00123 }
00124
00125 int g(x)
00126 int x;
00127 {
00128 return(x);
00129 }