~statik/ubuntu/maverick/erlang/erlang-merge-testing

« back to all changes in this revision

Viewing changes to erts/emulator/beam/bif.h

  • Committer: Bazaar Package Importer
  • Author(s): Sergei Golovan
  • Date: 2009-05-01 10:14:38 UTC
  • mfrom: (3.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20090501101438-6qlr6rsdxgyzrg2z
Tags: 1:13.b-dfsg-2
* Cleaned up patches: removed unneeded patch which helped to support
  different SCTP library versions, made sure that changes for m68k
  architecture applied only when building on this architecture.
* Removed duplicated information from binary packages descriptions.
* Don't require libsctp-dev build-dependency on solaris-i386 architecture
  which allows to build Erlang on Nexenta (thanks to Tim Spriggs for
  the suggestion).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* ``The contents of this file are subject to the Erlang Public License,
 
1
/*
 
2
 * %CopyrightBegin%
 
3
 * 
 
4
 * Copyright Ericsson AB 1996-2009. All Rights Reserved.
 
5
 * 
 
6
 * The contents of this file are subject to the Erlang Public License,
2
7
 * Version 1.1, (the "License"); you may not use this file except in
3
8
 * compliance with the License. You should have received a copy of the
4
9
 * Erlang Public License along with this software. If not, it can be
5
 
 * retrieved via the world wide web at http://www.erlang.org/.
 
10
 * retrieved online at http://www.erlang.org/.
6
11
 * 
7
12
 * Software distributed under the License is distributed on an "AS IS"
8
13
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
9
14
 * the License for the specific language governing rights and limitations
10
15
 * under the License.
11
16
 * 
12
 
 * The Initial Developer of the Original Code is Ericsson Utvecklings AB.
13
 
 * Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings
14
 
 * AB. All Rights Reserved.''
15
 
 * 
16
 
 *     $Id$
 
17
 * %CopyrightEnd%
17
18
 */
 
19
 
18
20
#ifndef __BIF_H__
19
21
#define __BIF_H__
20
22
 
 
23
extern Export* erts_format_cpu_topology_trap;
 
24
 
21
25
#define BIF_RETTYPE Eterm
22
26
 
23
27
#define BIF_P A__p
32
36
#define BIF_ARG_3  A_3
33
37
 
34
38
#define BUMP_ALL_REDS(p) do {                   \
35
 
    if ((p)->ct == NULL)                        \
 
39
    if (!ERTS_PROC_GET_SAVED_CALLS_BUF((p)))    \
36
40
        (p)->fcalls = 0;                        \
37
41
    else                                        \
38
42
        (p)->fcalls = -CONTEXT_REDS;            \
39
43
} while(0)
40
44
 
 
45
 
 
46
#define ERTS_VBUMP_ALL_REDS(p)                                          \
 
47
do {                                                                    \
 
48
    if (!ERTS_PROC_GET_SAVED_CALLS_BUF((p))) {                          \
 
49
        if ((p)->fcalls > 0)                                            \
 
50
            ERTS_PROC_GET_SCHDATA((p))->virtual_reds += (p)->fcalls;    \
 
51
        (p)->fcalls = 0;                                                \
 
52
    }                                                                   \
 
53
    else {                                                              \
 
54
        if ((p)->fcalls > -CONTEXT_REDS)                                \
 
55
            ERTS_PROC_GET_SCHDATA((p))->virtual_reds                    \
 
56
                += ((p)->fcalls - (-CONTEXT_REDS));                     \
 
57
        (p)->fcalls = -CONTEXT_REDS;                                    \
 
58
    }                                                                   \
 
59
} while(0)
 
60
 
41
61
#define BUMP_REDS(p, gc) do {                      \
42
62
     (p)->fcalls -= (gc);                          \
43
63
     if ((p)->fcalls < 0) {                        \
44
 
        if ((p)->ct == NULL)                       \
 
64
        if (!ERTS_PROC_GET_SAVED_CALLS_BUF((p)))   \
45
65
           (p)->fcalls = 0;                        \
46
66
        else if ((p)->fcalls < -CONTEXT_REDS)      \
47
67
           (p)->fcalls = -CONTEXT_REDS;            \
48
68
     }                                             \
49
69
} while(0)
50
70
 
 
71
 
 
72
#define ERTS_VBUMP_REDS(p, reds)                                        \
 
73
do {                                                                    \
 
74
    if (!ERTS_PROC_GET_SAVED_CALLS_BUF((p))) {                          \
 
75
        if ((p)->fcalls >= reds) {                                      \
 
76
            (p)->fcalls -= reds;                                        \
 
77
            ERTS_PROC_GET_SCHDATA((p))->virtual_reds += reds;           \
 
78
        }                                                               \
 
79
        else {                                                          \
 
80
            if ((p)->fcalls > 0)                                        \
 
81
                ERTS_PROC_GET_SCHDATA((p))->virtual_reds += (p)->fcalls;\
 
82
            (p)->fcalls = 0;                                            \
 
83
        }                                                               \
 
84
    }                                                                   \
 
85
    else {                                                              \
 
86
        if ((p)->fcalls >= reds - CONTEXT_REDS) {                       \
 
87
            (p)->fcalls -= reds;                                        \
 
88
            ERTS_PROC_GET_SCHDATA((p))->virtual_reds += reds;           \
 
89
        }                                                               \
 
90
        else {                                                          \
 
91
            if ((p)->fcalls > -CONTEXT_REDS)                            \
 
92
                ERTS_PROC_GET_SCHDATA((p))->virtual_reds                \
 
93
                    += (p)->fcalls - (-CONTEXT_REDS);                   \
 
94
            (p)->fcalls = -CONTEXT_REDS;                                \
 
95
        }                                                               \
 
96
    }                                                                   \
 
97
} while(0)
 
98
 
51
99
#define ERTS_BIF_REDS_LEFT(p)                                           \
52
 
  ((p)->ct                                                              \
 
100
  (ERTS_PROC_GET_SAVED_CALLS_BUF((p))                                   \
53
101
   ? ((p)->fcalls > -CONTEXT_REDS ? ((p)->fcalls - (-CONTEXT_REDS)) : 0)\
54
102
   : ((p)->fcalls > 0 ? (p)->fcalls : 0))
55
103
 
146
194
      return THE_NON_VALUE;                     \
147
195
 } while(0)
148
196
 
149
 
#define ERTS_BIF_YIELD_BUMP_REDS__(P)                                   \
150
 
    ERTS_GET_SCHEDULER_DATA_FROM_PROC((P))->yield_reduction_bump        \
151
 
      = ERTS_BIF_REDS_LEFT((P));                                        \
152
 
    BUMP_ALL_REDS((P))
 
197
extern Export bif_return_trap_export;
 
198
#ifdef DEBUG
 
199
#define ERTS_BIF_YIELD_RETURN(P, VAL, DEBUG_VAL)                        \
 
200
do {                                                                    \
 
201
    ERTS_VBUMP_ALL_REDS(P);                                             \
 
202
    BIF_TRAP2(&bif_return_trap_export, (P), (VAL), (DEBUG_VAL));        \
 
203
} while (0)
 
204
#else
 
205
#define ERTS_BIF_YIELD_RETURN(P, VAL, DEBUG_VAL)                        \
 
206
do {                                                                    \
 
207
    ERTS_VBUMP_ALL_REDS(P);                                             \
 
208
    BIF_TRAP1(&bif_return_trap_export, (P), (VAL));                     \
 
209
} while (0)
 
210
#endif
 
211
 
153
212
 
154
213
#define ERTS_BIF_PREP_YIELD0(RET, TRP, P)                               \
155
214
do {                                                                    \
156
 
    ERTS_BIF_YIELD_BUMP_REDS__((P));                                    \
 
215
    ERTS_VBUMP_ALL_REDS((P));                                           \
157
216
    ERTS_BIF_PREP_TRAP0(RET, (TRP), (P));                               \
158
217
} while (0)
159
218
 
160
219
#define ERTS_BIF_PREP_YIELD1(RET, TRP, P, A0)                           \
161
220
do {                                                                    \
162
 
    ERTS_BIF_YIELD_BUMP_REDS__((P));                                    \
 
221
    ERTS_VBUMP_ALL_REDS((P));                                           \
163
222
    ERTS_BIF_PREP_TRAP1(RET, (TRP), (P), (A0));                         \
164
223
} while (0)
165
224
 
166
225
#define ERTS_BIF_PREP_YIELD2(RET, TRP, P, A0, A1)                       \
167
226
do {                                                                    \
168
 
    ERTS_BIF_YIELD_BUMP_REDS__((P));                                    \
 
227
    ERTS_VBUMP_ALL_REDS((P));                                           \
169
228
    ERTS_BIF_PREP_TRAP2(RET, (TRP), (P), (A0), (A1));                   \
170
229
} while (0)
171
230
 
172
231
#define ERTS_BIF_PREP_YIELD3(RET, TRP, P, A0, A1, A2)                   \
173
232
do {                                                                    \
174
 
    ERTS_BIF_YIELD_BUMP_REDS__((P));                                    \
 
233
    ERTS_VBUMP_ALL_REDS((P));                                           \
175
234
    ERTS_BIF_PREP_TRAP3(RET, (TRP), (P), (A0), (A1), (A2));             \
176
235
} while (0)
177
236
 
178
237
#define ERTS_BIF_YIELD0(TRP, P)                                         \
179
238
do {                                                                    \
180
 
    ERTS_BIF_YIELD_BUMP_REDS__((P));                                    \
 
239
    ERTS_VBUMP_ALL_REDS((P));                                           \
181
240
    BIF_TRAP0((TRP), (P));                                              \
182
241
} while (0)
183
242
 
184
243
#define ERTS_BIF_YIELD1(TRP, P, A0)                                     \
185
244
do {                                                                    \
186
 
    ERTS_BIF_YIELD_BUMP_REDS__((P));                                    \
 
245
    ERTS_VBUMP_ALL_REDS((P));                                           \
187
246
    BIF_TRAP1((TRP), (P), (A0));                                        \
188
247
} while (0)
189
248
 
190
249
#define ERTS_BIF_YIELD2(TRP, P, A0, A1)                                 \
191
250
do {                                                                    \
192
 
    ERTS_BIF_YIELD_BUMP_REDS__((P));                                    \
 
251
    ERTS_VBUMP_ALL_REDS((P));                                           \
193
252
    BIF_TRAP2((TRP), (P), (A0), (A1));                                  \
194
253
} while (0)
195
254
 
196
255
#define ERTS_BIF_YIELD3(TRP, P, A0, A1, A2)                             \
197
256
do {                                                                    \
198
 
    ERTS_BIF_YIELD_BUMP_REDS__((P));                                    \
 
257
    ERTS_VBUMP_ALL_REDS((P));                                           \
199
258
    BIF_TRAP3((TRP), (P), (A0), (A1), (A2));                            \
200
259
} while (0)
201
260