~ubuntu-branches/ubuntu/raring/boost-build/raring

« back to all changes in this revision

Viewing changes to jam_src/boehm_gc/setjmp_t.c

  • Committer: Bazaar Package Importer
  • Author(s): Steve M. Robbins
  • Date: 2008-08-06 00:38:31 UTC
  • mfrom: (4.1.1 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080806003831-zr65893244swds0b
Tags: 2.0-m12-2
* debian/rules: Do not install /etc/user-config.jam.
* debian/site-config.jam: New.  Install into /etc instead of empty
  example.  Closes: #493323.

* debian/control: Update homepage.  Update description.  Closes:
  #493510.  Update Standards-Version to 3.8.0; no changes.

* debian/compat: New.  Set compat level to 7.
* debian/rules: Remove DH_COMPAT setting.
* debian/control: Change debhelper build-dep to version >= 7.

* debian/control: Remove docbook-to-man, bison from build-deps.

* debian/rules: Clean up upstream source by removing debian/conffiles.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (c) 1991-1994 by Xerox Corporation.  All rights reserved.
 
3
 *
 
4
 * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
 
5
 * OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.
 
6
 *
 
7
 * Permission is hereby granted to use or copy this program
 
8
 * for any purpose,  provided the above notices are retained on all copies.
 
9
 * Permission to modify the code and to distribute modified code is granted,
 
10
 * provided the above notices are retained, and a notice that the code was
 
11
 * modified is included with the above copyright notice.
 
12
 */
 
13
 
 
14
/* Check whether setjmp actually saves registers in jmp_buf. */
 
15
/* If it doesn't, the generic mark_regs code won't work.     */
 
16
/* Compilers vary as to whether they will put x in a         */
 
17
/* (callee-save) register without -O.  The code is           */
 
18
/* contrived such that any decent compiler should put x in   */
 
19
/* a callee-save register with -O.  Thus it is is            */
 
20
/* recommended that this be run optimized.  (If the machine  */
 
21
/* has no callee-save registers, then the generic code is    */
 
22
/* safe, but this will not be noticed by this piece of       */
 
23
/* code.)  This test appears to be far from perfect.         */
 
24
#include <stdio.h>
 
25
#include <setjmp.h>
 
26
#include <string.h>
 
27
#include "private/gc_priv.h"
 
28
 
 
29
#ifdef OS2
 
30
/* GETPAGESIZE() is set to getpagesize() by default, but that   */
 
31
/* doesn't really exist, and the collector doesn't need it.     */
 
32
#define INCL_DOSFILEMGR
 
33
#define INCL_DOSMISC
 
34
#define INCL_DOSERRORS
 
35
#include <os2.h>
 
36
 
 
37
int
 
38
getpagesize()
 
39
{
 
40
    ULONG result[1];
 
41
    
 
42
    if (DosQuerySysInfo(QSV_PAGE_SIZE, QSV_PAGE_SIZE,
 
43
                        (void *)result, sizeof(ULONG)) != NO_ERROR) {
 
44
        fprintf(stderr, "DosQuerySysInfo failed\n");
 
45
        result[0] = 4096;
 
46
    }
 
47
    return((int)(result[0]));
 
48
}
 
49
#endif
 
50
 
 
51
struct {char a_a; char * a_b;} a;
 
52
 
 
53
int * nested_sp()
 
54
{
 
55
    int dummy;
 
56
    
 
57
    return(&dummy);
 
58
}
 
59
 
 
60
int main()
 
61
{
 
62
        int dummy;
 
63
        long ps = GETPAGESIZE();
 
64
        jmp_buf b;
 
65
        register int x = (int)strlen("a");  /* 1, slightly disguised */
 
66
        static int y = 0;
 
67
 
 
68
        printf("This appears to be a %s running %s\n", MACH_TYPE, OS_TYPE);
 
69
        if (nested_sp() < &dummy) {
 
70
          printf("Stack appears to grow down, which is the default.\n");
 
71
          printf("A good guess for STACKBOTTOM on this machine is 0x%lx.\n",
 
72
                 ((unsigned long)(&dummy) + ps) & ~(ps-1));
 
73
        } else {
 
74
          printf("Stack appears to grow up.\n");
 
75
          printf("Define STACK_GROWS_UP in gc_private.h\n");
 
76
          printf("A good guess for STACKBOTTOM on this machine is 0x%lx.\n",
 
77
                 ((unsigned long)(&dummy) + ps) & ~(ps-1));
 
78
        }
 
79
        printf("Note that this may vary between machines of ostensibly\n");
 
80
        printf("the same architecture (e.g. Sun 3/50s and 3/80s).\n");
 
81
        printf("On many machines the value is not fixed.\n");
 
82
        printf("A good guess for ALIGNMENT on this machine is %ld.\n",
 
83
               (unsigned long)(&(a.a_b))-(unsigned long)(&a));
 
84
        
 
85
        printf("The following is a very dubious test of one root marking"
 
86
               " strategy.\n");
 
87
        printf("Results may not be accurate/useful:\n");
 
88
        /* Encourage the compiler to keep x in a callee-save register */
 
89
        x = 2*x-1;
 
90
        printf("");
 
91
        x = 2*x-1;
 
92
        setjmp(b);
 
93
        if (y == 1) {
 
94
            if (x == 2) {
 
95
                printf("Setjmp-based generic mark_regs code probably wont work.\n");
 
96
                printf("But we rarely try that anymore.  If you have getcontect()\n");
 
97
                printf("this probably doesn't matter.\n");
 
98
            } else if (x == 1) {
 
99
                printf("Setjmp-based register marking code may work.\n");
 
100
            } else {
 
101
                printf("Very strange setjmp implementation.\n");
 
102
            }
 
103
        }
 
104
        y++;
 
105
        x = 2;
 
106
        if (y == 1) longjmp(b,1);
 
107
        printf("Some GC internal configuration stuff: \n");
 
108
        printf("\tWORDSZ = %d, ALIGNMENT = %d, GC_GRANULE_BYTES = %d\n",
 
109
               WORDSZ, ALIGNMENT, GC_GRANULE_BYTES);
 
110
        printf("\tUsing one mark ");
 
111
#       if defined(USE_MARK_BYTES)
 
112
          printf("byte");
 
113
#       elif defined(USE_MARK_BITS)
 
114
          printf("bit");
 
115
#       endif
 
116
        printf(" per ");
 
117
#       if defined(MARK_BIT_PER_OBJ)
 
118
          printf("object.\n");
 
119
#       elif defined(MARK_BIT_PER_GRANULE)
 
120
          printf("granule.\n");
 
121
#       endif
 
122
#       ifdef THREAD_LOCAL_ALLOC
 
123
          printf("Thread local allocation enabled.\n");
 
124
#       endif
 
125
#       ifdef PARALLEL_MARK
 
126
          printf("Parallel marking enabled.\n");
 
127
#       endif
 
128
        return(0);
 
129
}
 
130
 
 
131
int g(x)
 
132
int x;
 
133
{
 
134
        return(x);
 
135
}