Coverage Report

Created: 2025-06-10 06:49

/src/ghostpdl/base/gsroprun1.h
Line
Count
Source (jump to first uncovered line)
1
/* Copyright (C) 2001-2023 Artifex Software, Inc.
2
   All Rights Reserved.
3
4
   This software is provided AS-IS with no warranty, either express or
5
   implied.
6
7
   This software is distributed under license and may not be copied,
8
   modified or distributed except as expressly authorized under the terms
9
   of the license contained in the file LICENSE in this distribution.
10
11
   Refer to licensing information at http://www.artifex.com or contact
12
   Artifex Software, Inc.,  39 Mesa Street, Suite 108A, San Francisco,
13
   CA 94129, USA, for further information.
14
*/
15
16
17
/* This file is repeatedly included by gsroprun.c to 'autogenerate' many
18
 * different versions of roprun code. DO NOT USE THIS FILE EXCEPT FROM
19
 * gsroprun.c.
20
 */
21
22
/* Set the following defines as appropriate on entry:
23
 *   TEMPLATE_NAME (Compulsory)  The name of the function to generate
24
 *   SPECIFIC_ROP  (Optional)    If set, the function will base its decision
25
 *                               about whether to provide S and T upon
26
 *                               this value.
27
 *   SPECIFIC_CODE (Optional)    If set, this should expand out to code to
28
 *                               perform the rop. Will be invoked as:
29
 *                               SPECIFIC_ROP(OUT,D,S,T)
30
 *   S_CONST       (Optional)    If set, S will be taken to be constant, else
31
 *                               S will be read from a pointer.
32
 *   T_CONST       (Optional)    If set, T will be taken to be constant, else
33
 *                               T will be read from a pointer.
34
 */
35
36
#if defined(TEMPLATE_NAME)
37
38
#ifdef SPECIFIC_ROP
39
#if rop3_uses_S(SPECIFIC_ROP)
40
#define S_USED
41
#endif
42
#if rop3_uses_T(SPECIFIC_ROP)
43
#define T_USED
44
#endif
45
#else /* !SPECIFIC_ROP */
46
#define S_USED
47
#define T_USED
48
#endif /* SPECIFIC_ROP */
49
50
/* We work in 'chunks' here; for bigendian machines, we can safely use
51
 * chunks of 'int' size. For little endian machines where we have a cheap
52
 * endian swap, we can do likewise. For others, we'll work at the byte
53
 * level. */
54
#if !ARCH_IS_BIG_ENDIAN && !defined(ENDIAN_SWAP_INT)
55
#define CHUNKSIZE 8
56
#define CHUNK byte
57
#define CHUNKONES 255
58
59
#define ADJUST_TO_CHUNK(d,dpos) do {} while (0)
60
61
#else /* ARCH_IS_BIG_ENDIAN || defined(ENDIAN_SWAP_INT) */
62
#if ARCH_LOG2_SIZEOF_INT == 2
63
4.35M
#define CHUNKSIZE 32
64
292k
#define CHUNK unsigned int
65
143k
#define CHUNKONES 0xFFFFFFFFU
66
67
#if ARCH_SIZEOF_PTR == (1<<ARCH_LOG2_SIZEOF_INT)
68
#define ROP_PTRDIFF_T int
69
#else
70
#define ROP_PTRDIFF_T int64_t
71
#endif
72
#define ADJUST_TO_CHUNK(d, dpos)                      \
73
143k
    do { int offset = ((ROP_PTRDIFF_T)d) & ((CHUNKSIZE>>3)-1);  \
74
143k
         d = (CHUNK *)(void *)(((byte *)(void *)d)-offset);   \
75
143k
         dpos += offset<<3;                           \
76
143k
     } while (0)
77
#else
78
/* FIXME: Write more code in here when we find an example. */
79
#endif
80
#endif /* ARCH_IS_BIG_ENDIAN || defined(ENDIAN_SWAP_INT) */
81
82
/* We define an 'RE' macro that reverses the endianness of a chunk, if we
83
 * need it, and does nothing otherwise. */
84
#if !ARCH_IS_BIG_ENDIAN && defined(ENDIAN_SWAP_INT) && (CHUNKSIZE != 8)
85
3.80M
#define RE(I) ((CHUNK)ENDIAN_SWAP_INT(I))
86
#else /* ARCH_IS_BIG_ENDIAN || !defined(ENDIAN_SWAP_INT) || (CHUNKSIZE == 8) */
87
#define RE(I) (I)
88
#endif /* ARCH_IS_BIG_ENDIAN || !defined(ENDIAN_SWAP_INT) || (CHUNKSIZE == 8) */
89
90
/* In some cases we will need to fetch values from a pointer, and 'skew'
91
 * them. We need 2 variants of this macro. One that is 'SAFE' to use when
92
 * SKEW might be 0, and one that can be faster, because we know that SKEW
93
 * is non zero. */
94
#define SKEW_FETCH(S,s,SKEW) \
95
3.52M
    do { S = RE((RE(s[0])<<SKEW) | (RE(s[1])>>(CHUNKSIZE-SKEW))); s++; } while (0)
96
#define SAFE_SKEW_FETCH(S,s,SKEW,L,R)                                    \
97
138k
    do { S = RE(((L) ? 0 : (RE(s[0])<<SKEW)) | ((R) ? 0 : (RE(s[1])>>(CHUNKSIZE-SKEW)))); s++; } while (0)
98
99
#if defined(S_USED) && !defined(S_CONST)
100
#define S_SKEW
101
3.52M
#define FETCH_S           SKEW_FETCH(S,s,s_skew)
102
138k
#define SAFE_FETCH_S(L,R) SAFE_SKEW_FETCH(S,s,s_skew,L,R)
103
#else /* !defined(S_USED) || defined(S_CONST) */
104
#define FETCH_S
105
#define SAFE_FETCH_S(L,R)
106
#endif /* !defined(S_USED) || defined(S_CONST) */
107
108
#if defined(T_USED) && !defined(T_CONST)
109
#define T_SKEW
110
0
#define FETCH_T           SKEW_FETCH(T,t,t_skew)
111
0
#define SAFE_FETCH_T(L,R) SAFE_SKEW_FETCH(T,t,t_skew,L,R)
112
#else /* !defined(T_USED) || defined(T_CONST) */
113
#define FETCH_T
114
#define SAFE_FETCH_T(L,R)
115
#endif /* !defined(T_USED) || defined(T_CONST) */
116
117
static void TEMPLATE_NAME(rop_run_op *op, byte *d_, int len)
118
71.6k
{
119
#ifndef SPECIFIC_CODE
120
    rop_proc     proc = rop_proc_table[op->rop];
121
17.0k
#define SPECIFIC_CODE(OUT_, D_,S_,T_) OUT_ = proc(D_,S_,T_)
122
#endif /* !defined(SPECIFIC_CODE) */
123
71.6k
    CHUNK        lmask, rmask;
124
#ifdef S_USED
125
#ifdef S_CONST
126
0
    CHUNK        S = (CHUNK)op->s.c;
127
#else /* !defined(S_CONST) */
128
    const CHUNK *s = (CHUNK *)(void *)op->s.b.ptr;
129
71.6k
    CHUNK        S;
130
    int          s_skew;
131
#endif /* !defined(S_CONST) */
132
#else /* !defined(S_USED) */
133
#define S 0
134
#undef S_CONST
135
#endif /* !defined(S_USED) */
136
#ifdef T_USED
137
#ifdef T_CONST
138
6.01k
    CHUNK        T = (CHUNK)op->t.c;
139
#else /* !defined(T_CONST) */
140
    const CHUNK *t = (CHUNK *)(void *)op->t.b.ptr;
141
0
    CHUNK        T;
142
    int          t_skew;
143
#endif /* !defined(T_CONST) */
144
#else /* !defined(T_USED) */
145
#define T 0
146
#undef T_CONST
147
#endif /* !defined(T_USED) */
148
#if defined(S_SKEW) || defined(T_SKEW)
149
    int skewflags = 0;
150
#endif
151
71.6k
    CHUNK        D;
152
71.6k
    int          dpos = op->dpos;
153
71.6k
    CHUNK       *d = (CHUNK *)(void *)d_;
154
155
    /* Align d to CHUNKSIZE */
156
71.6k
    ADJUST_TO_CHUNK(d,dpos);
157
158
    /* On entry len = length in 'depth' chunks. Change it to be the length
159
     * in bits, and add on the number of bits we skip at the start of the
160
     * run. */
161
71.6k
    len    = len * op->depth + dpos;
162
163
    /* lmask = the set of bits to alter in the output bitmap on the left
164
     * hand edge of the run. rmask = the set of bits NOT to alter in the
165
     * output bitmap on the right hand edge of the run. */
166
71.6k
    lmask  = RE((CHUNKONES>>((CHUNKSIZE-1) & dpos)));
167
71.6k
    rmask  = RE((CHUNKONES>>((CHUNKSIZE-1) & len)));
168
71.6k
    if (rmask == CHUNKONES) rmask = 0;
169
170
#if defined(S_CONST) || defined(T_CONST)
171
    /* S and T should be supplied as 'depth' bits. Duplicate them up to be
172
     * byte size (if they are supplied byte sized, that's fine too). */
173
6.01k
    if (op->depth & 1) {
174
#ifdef S_CONST
175
        S |= S<<1;
176
#endif /* !defined(S_CONST) */
177
6.01k
#ifdef T_CONST
178
6.01k
        T |= T<<1;
179
6.01k
#endif /* !defined(T_CONST) */
180
6.01k
    }
181
6.01k
    if (op->depth & 3) {
182
#ifdef S_CONST
183
        S |= S<<2;
184
#endif /* !defined(S_CONST) */
185
6.01k
#ifdef T_CONST
186
6.01k
        T |= T<<2;
187
6.01k
#endif /* !defined(T_CONST) */
188
6.01k
    }
189
6.01k
    if (op->depth & 7) {
190
#ifdef S_CONST
191
        S |= S<<4;
192
#endif /* !defined(S_CONST) */
193
6.01k
#ifdef T_CONST
194
6.01k
        T |= T<<4;
195
6.01k
#endif /* !defined(T_CONST) */
196
6.01k
    }
197
#if CHUNKSIZE > 8
198
6.01k
    if (op->depth & 15) {
199
#ifdef S_CONST
200
        S |= S<<8;
201
#endif /* !defined(S_CONST) */
202
6.01k
#ifdef T_CONST
203
6.01k
        T |= T<<8;
204
6.01k
#endif /* !defined(T_CONST) */
205
6.01k
    }
206
#endif /* CHUNKSIZE > 8 */
207
#if CHUNKSIZE > 16
208
6.01k
    if (op->depth & 31) {
209
#ifdef S_CONST
210
        S |= S<<16;
211
#endif /* !defined(S_CONST) */
212
6.01k
#ifdef T_CONST
213
6.01k
        T |= T<<16;
214
6.01k
#endif /* !defined(T_CONST) */
215
6.01k
    }
216
#endif /* CHUNKSIZE > 16 */
217
#endif /* defined(S_CONST) || defined(T_CONST) */
218
219
    /* Note #1: This mirrors what the original code did, but I think it has
220
     * the risk of moving s and t back beyond officially allocated space. We
221
     * may be saved by the fact that all blocks have a word or two in front
222
     * of them due to the allocator. If we ever get valgrind properly marking
223
     * allocated blocks as readable etc, then this may throw some spurious
224
     * errors. RJW. */
225
#ifdef S_SKEW
226
    {
227
        int slen, slen2;
228
        int spos = op->s.b.pos;
229
71.6k
        ADJUST_TO_CHUNK(s, spos);
230
        s_skew = spos - dpos;
231
71.6k
        if (s_skew < 0) {
232
63.9k
            s_skew += CHUNKSIZE;
233
63.9k
            s--;
234
63.9k
            skewflags |= 1; /* Suppress reading off left edge */
235
63.9k
        }
236
        /* We are allowed to read all the data bits, so: len - dpos + tpos
237
         * We're allowed to read in CHUNKS, so: CHUNKUP(len-dpos+tpos).
238
         * This code will actually read CHUNKUP(len)+CHUNKSIZE bits. If
239
         * This is larger, then suppress. */
240
71.6k
        slen  = (len + s_skew    + CHUNKSIZE-1) & ~(CHUNKSIZE-1);
241
71.6k
        slen2 = (len + CHUNKSIZE + CHUNKSIZE-1) & ~(CHUNKSIZE-1);
242
71.6k
        if ((s_skew == 0) || (slen < slen2)) {
243
45.9k
            skewflags |= 4; /* Suppress reading off the right edge */
244
45.9k
        }
245
    }
246
#endif /* !defined(S_SKEW) */
247
#ifdef T_SKEW
248
    {
249
        int tlen, tlen2;
250
        int tpos = op->t.b.pos;
251
0
        ADJUST_TO_CHUNK(t, tpos);
252
        t_skew = tpos - dpos;
253
0
        if (t_skew < 0) {
254
0
            t_skew += CHUNKSIZE;
255
0
            t--;
256
0
            skewflags |= 2; /* Suppress reading off left edge */
257
0
        }
258
        /* We are allowed to read all the data bits, so: len - dpos + tpos
259
         * We're allowed to read in CHUNKS, so: CHUNKUP(len-dpos+tpos).
260
         * This code will actually read CHUNKUP(len)+CHUNKSIZE bits. If
261
         * This is larger, then suppress. */
262
0
        tlen  = (len + t_skew    + CHUNKSIZE-1) & ~(CHUNKSIZE-1);
263
0
        tlen2 = (len + CHUNKSIZE + CHUNKSIZE-1) & ~(CHUNKSIZE-1);
264
0
        if ((t_skew == 0) || (tlen < tlen2)) {
265
0
            skewflags |= 8; /* Suppress reading off the right edge */
266
0
        }
267
    }
268
#endif /* !defined(T_SKEW) */
269
270
71.6k
    len -= CHUNKSIZE; /* len = bytes to do - CHUNKSIZE */
271
    /* len <= 0 means 1 word or less to do */
272
71.6k
    if (len <= 0) {
273
        /* Short case - starts and ends in the same chunk */
274
128
        lmask &= ~rmask; /* Combined mask = bits to alter */
275
128
        SAFE_FETCH_S(skewflags & 1,skewflags & 4);
276
128
        SAFE_FETCH_T(skewflags & 2,skewflags & 8);
277
128
        SPECIFIC_CODE(D, *d, S, T);
278
128
        *d = (*d & ~lmask) | (D & lmask);
279
128
        return;
280
128
    }
281
71.5k
    if ((lmask != CHUNKONES)
282
#if defined(S_SKEW) || defined(T_SKEW)
283
4.70k
        || (skewflags & 3)
284
#endif
285
71.5k
        ) {
286
        /* Unaligned left hand case */
287
66.8k
        SAFE_FETCH_S(skewflags & 1,s_skew == 0);
288
66.8k
        SAFE_FETCH_T(skewflags & 2,t_skew == 0);
289
66.8k
        SPECIFIC_CODE(D, *d, S, T);
290
66.8k
        *d = (*d & ~lmask) | (D & lmask);
291
66.8k
        d++;
292
66.8k
        len -= CHUNKSIZE;
293
66.8k
    }
294
71.5k
    if (len > 0) {
295
        /* Simple middle case (complete destination chunks). */
296
#ifdef S_SKEW
297
53.0k
        if (s_skew == 0) {
298
#ifdef T_SKEW
299
0
            if (t_skew == 0) {
300
0
                do {
301
0
                    SPECIFIC_CODE(*d, *d, *s++, *t++);
302
0
                    d++;
303
0
                    len -= CHUNKSIZE;
304
0
                } while (len > 0);
305
0
            } else
306
0
#endif /* !defined(T_SKEW) */
307
0
            {
308
125k
                do {
309
125k
                    FETCH_T;
310
125k
                    SPECIFIC_CODE(*d, *d, *s++, T);
311
125k
                    d++;
312
125k
                    len -= CHUNKSIZE;
313
125k
                } while (len > 0);
314
0
            }
315
4.46k
        } else
316
48.5k
#endif /* !defined(S_SKEW) */
317
48.5k
        {
318
#ifdef T_SKEW
319
0
            if (t_skew == 0) {
320
0
                do {
321
0
                    FETCH_S;
322
0
                    SPECIFIC_CODE(*d, *d, S, *t++);
323
0
                    d++;
324
0
                    len -= CHUNKSIZE;
325
0
                } while (len > 0);
326
0
            } else
327
0
#endif /* !defined(T_SKEW) */
328
0
            {
329
3.52M
                do {
330
3.52M
                    FETCH_S;
331
3.52M
                    FETCH_T;
332
3.52M
                    SPECIFIC_CODE(*d, *d, S, T);
333
3.52M
                    d++;
334
3.52M
                    len -= CHUNKSIZE;
335
3.52M
                } while (len > 0);
336
0
            }
337
48.5k
        }
338
53.0k
    }
339
    /* Unaligned right hand case */
340
71.5k
    SAFE_FETCH_S(0,skewflags & 4);
341
71.5k
    SAFE_FETCH_T(0,skewflags & 8);
342
71.5k
    SPECIFIC_CODE(D, *d, S, T);
343
71.5k
    *d = (*d & rmask) | (D & ~rmask);
344
71.5k
}
gsroprun.c:notS_rop_run1_const_t
Line
Count
Source
118
2.23k
{
119
#ifndef SPECIFIC_CODE
120
    rop_proc     proc = rop_proc_table[op->rop];
121
#define SPECIFIC_CODE(OUT_, D_,S_,T_) OUT_ = proc(D_,S_,T_)
122
#endif /* !defined(SPECIFIC_CODE) */
123
2.23k
    CHUNK        lmask, rmask;
124
2.23k
#ifdef S_USED
125
#ifdef S_CONST
126
    CHUNK        S = (CHUNK)op->s.c;
127
#else /* !defined(S_CONST) */
128
2.23k
    const CHUNK *s = (CHUNK *)(void *)op->s.b.ptr;
129
2.23k
    CHUNK        S;
130
2.23k
    int          s_skew;
131
2.23k
#endif /* !defined(S_CONST) */
132
#else /* !defined(S_USED) */
133
#define S 0
134
#undef S_CONST
135
#endif /* !defined(S_USED) */
136
#ifdef T_USED
137
#ifdef T_CONST
138
    CHUNK        T = (CHUNK)op->t.c;
139
#else /* !defined(T_CONST) */
140
    const CHUNK *t = (CHUNK *)(void *)op->t.b.ptr;
141
    CHUNK        T;
142
    int          t_skew;
143
#endif /* !defined(T_CONST) */
144
#else /* !defined(T_USED) */
145
2.23k
#define T 0
146
2.23k
#undef T_CONST
147
2.23k
#endif /* !defined(T_USED) */
148
2.23k
#if defined(S_SKEW) || defined(T_SKEW)
149
2.23k
    int skewflags = 0;
150
2.23k
#endif
151
2.23k
    CHUNK        D;
152
2.23k
    int          dpos = op->dpos;
153
2.23k
    CHUNK       *d = (CHUNK *)(void *)d_;
154
155
    /* Align d to CHUNKSIZE */
156
2.23k
    ADJUST_TO_CHUNK(d,dpos);
157
158
    /* On entry len = length in 'depth' chunks. Change it to be the length
159
     * in bits, and add on the number of bits we skip at the start of the
160
     * run. */
161
2.23k
    len    = len * op->depth + dpos;
162
163
    /* lmask = the set of bits to alter in the output bitmap on the left
164
     * hand edge of the run. rmask = the set of bits NOT to alter in the
165
     * output bitmap on the right hand edge of the run. */
166
2.23k
    lmask  = RE((CHUNKONES>>((CHUNKSIZE-1) & dpos)));
167
2.23k
    rmask  = RE((CHUNKONES>>((CHUNKSIZE-1) & len)));
168
2.23k
    if (rmask == CHUNKONES) rmask = 0;
169
170
#if defined(S_CONST) || defined(T_CONST)
171
    /* S and T should be supplied as 'depth' bits. Duplicate them up to be
172
     * byte size (if they are supplied byte sized, that's fine too). */
173
    if (op->depth & 1) {
174
#ifdef S_CONST
175
        S |= S<<1;
176
#endif /* !defined(S_CONST) */
177
#ifdef T_CONST
178
        T |= T<<1;
179
#endif /* !defined(T_CONST) */
180
    }
181
    if (op->depth & 3) {
182
#ifdef S_CONST
183
        S |= S<<2;
184
#endif /* !defined(S_CONST) */
185
#ifdef T_CONST
186
        T |= T<<2;
187
#endif /* !defined(T_CONST) */
188
    }
189
    if (op->depth & 7) {
190
#ifdef S_CONST
191
        S |= S<<4;
192
#endif /* !defined(S_CONST) */
193
#ifdef T_CONST
194
        T |= T<<4;
195
#endif /* !defined(T_CONST) */
196
    }
197
#if CHUNKSIZE > 8
198
    if (op->depth & 15) {
199
#ifdef S_CONST
200
        S |= S<<8;
201
#endif /* !defined(S_CONST) */
202
#ifdef T_CONST
203
        T |= T<<8;
204
#endif /* !defined(T_CONST) */
205
    }
206
#endif /* CHUNKSIZE > 8 */
207
#if CHUNKSIZE > 16
208
    if (op->depth & 31) {
209
#ifdef S_CONST
210
        S |= S<<16;
211
#endif /* !defined(S_CONST) */
212
#ifdef T_CONST
213
        T |= T<<16;
214
#endif /* !defined(T_CONST) */
215
    }
216
#endif /* CHUNKSIZE > 16 */
217
#endif /* defined(S_CONST) || defined(T_CONST) */
218
219
    /* Note #1: This mirrors what the original code did, but I think it has
220
     * the risk of moving s and t back beyond officially allocated space. We
221
     * may be saved by the fact that all blocks have a word or two in front
222
     * of them due to the allocator. If we ever get valgrind properly marking
223
     * allocated blocks as readable etc, then this may throw some spurious
224
     * errors. RJW. */
225
2.23k
#ifdef S_SKEW
226
2.23k
    {
227
2.23k
        int slen, slen2;
228
2.23k
        int spos = op->s.b.pos;
229
2.23k
        ADJUST_TO_CHUNK(s, spos);
230
2.23k
        s_skew = spos - dpos;
231
2.23k
        if (s_skew < 0) {
232
0
            s_skew += CHUNKSIZE;
233
0
            s--;
234
0
            skewflags |= 1; /* Suppress reading off left edge */
235
0
        }
236
        /* We are allowed to read all the data bits, so: len - dpos + tpos
237
         * We're allowed to read in CHUNKS, so: CHUNKUP(len-dpos+tpos).
238
         * This code will actually read CHUNKUP(len)+CHUNKSIZE bits. If
239
         * This is larger, then suppress. */
240
2.23k
        slen  = (len + s_skew    + CHUNKSIZE-1) & ~(CHUNKSIZE-1);
241
2.23k
        slen2 = (len + CHUNKSIZE + CHUNKSIZE-1) & ~(CHUNKSIZE-1);
242
2.23k
        if ((s_skew == 0) || (slen < slen2)) {
243
2.23k
            skewflags |= 4; /* Suppress reading off the right edge */
244
2.23k
        }
245
2.23k
    }
246
2.23k
#endif /* !defined(S_SKEW) */
247
#ifdef T_SKEW
248
    {
249
        int tlen, tlen2;
250
        int tpos = op->t.b.pos;
251
        ADJUST_TO_CHUNK(t, tpos);
252
        t_skew = tpos - dpos;
253
        if (t_skew < 0) {
254
            t_skew += CHUNKSIZE;
255
            t--;
256
            skewflags |= 2; /* Suppress reading off left edge */
257
        }
258
        /* We are allowed to read all the data bits, so: len - dpos + tpos
259
         * We're allowed to read in CHUNKS, so: CHUNKUP(len-dpos+tpos).
260
         * This code will actually read CHUNKUP(len)+CHUNKSIZE bits. If
261
         * This is larger, then suppress. */
262
        tlen  = (len + t_skew    + CHUNKSIZE-1) & ~(CHUNKSIZE-1);
263
        tlen2 = (len + CHUNKSIZE + CHUNKSIZE-1) & ~(CHUNKSIZE-1);
264
        if ((t_skew == 0) || (tlen < tlen2)) {
265
            skewflags |= 8; /* Suppress reading off the right edge */
266
        }
267
    }
268
#endif /* !defined(T_SKEW) */
269
270
2.23k
    len -= CHUNKSIZE; /* len = bytes to do - CHUNKSIZE */
271
    /* len <= 0 means 1 word or less to do */
272
2.23k
    if (len <= 0) {
273
        /* Short case - starts and ends in the same chunk */
274
0
        lmask &= ~rmask; /* Combined mask = bits to alter */
275
0
        SAFE_FETCH_S(skewflags & 1,skewflags & 4);
276
0
        SAFE_FETCH_T(skewflags & 2,skewflags & 8);
277
0
        SPECIFIC_CODE(D, *d, S, T);
278
0
        *d = (*d & ~lmask) | (D & lmask);
279
0
        return;
280
0
    }
281
2.23k
    if ((lmask != CHUNKONES)
282
2.23k
#if defined(S_SKEW) || defined(T_SKEW)
283
2.23k
        || (skewflags & 3)
284
2.23k
#endif
285
2.23k
        ) {
286
        /* Unaligned left hand case */
287
0
        SAFE_FETCH_S(skewflags & 1,s_skew == 0);
288
0
        SAFE_FETCH_T(skewflags & 2,t_skew == 0);
289
0
        SPECIFIC_CODE(D, *d, S, T);
290
0
        *d = (*d & ~lmask) | (D & lmask);
291
0
        d++;
292
0
        len -= CHUNKSIZE;
293
0
    }
294
2.23k
    if (len > 0) {
295
        /* Simple middle case (complete destination chunks). */
296
2.23k
#ifdef S_SKEW
297
2.23k
        if (s_skew == 0) {
298
#ifdef T_SKEW
299
            if (t_skew == 0) {
300
                do {
301
                    SPECIFIC_CODE(*d, *d, *s++, *t++);
302
                    d++;
303
                    len -= CHUNKSIZE;
304
                } while (len > 0);
305
            } else
306
#endif /* !defined(T_SKEW) */
307
2.23k
            {
308
75.9k
                do {
309
75.9k
                    FETCH_T;
310
75.9k
                    SPECIFIC_CODE(*d, *d, *s++, T);
311
75.9k
                    d++;
312
75.9k
                    len -= CHUNKSIZE;
313
75.9k
                } while (len > 0);
314
2.23k
            }
315
2.23k
        } else
316
0
#endif /* !defined(S_SKEW) */
317
0
        {
318
#ifdef T_SKEW
319
            if (t_skew == 0) {
320
                do {
321
                    FETCH_S;
322
                    SPECIFIC_CODE(*d, *d, S, *t++);
323
                    d++;
324
                    len -= CHUNKSIZE;
325
                } while (len > 0);
326
            } else
327
#endif /* !defined(T_SKEW) */
328
0
            {
329
0
                do {
330
0
                    FETCH_S;
331
0
                    FETCH_T;
332
0
                    SPECIFIC_CODE(*d, *d, S, T);
333
0
                    d++;
334
0
                    len -= CHUNKSIZE;
335
0
                } while (len > 0);
336
0
            }
337
0
        }
338
2.23k
    }
339
    /* Unaligned right hand case */
340
2.23k
    SAFE_FETCH_S(0,skewflags & 4);
341
2.23k
    SAFE_FETCH_T(0,skewflags & 8);
342
2.23k
    SPECIFIC_CODE(D, *d, S, T);
343
2.23k
    *d = (*d & rmask) | (D & ~rmask);
344
2.23k
}
Unexecuted instantiation: gsroprun.c:invert_rop_run1
Unexecuted instantiation: gsroprun.c:xor_rop_run1_const_t
gsroprun.c:sets_rop_run1
Line
Count
Source
118
59.3k
{
119
#ifndef SPECIFIC_CODE
120
    rop_proc     proc = rop_proc_table[op->rop];
121
#define SPECIFIC_CODE(OUT_, D_,S_,T_) OUT_ = proc(D_,S_,T_)
122
#endif /* !defined(SPECIFIC_CODE) */
123
59.3k
    CHUNK        lmask, rmask;
124
59.3k
#ifdef S_USED
125
#ifdef S_CONST
126
    CHUNK        S = (CHUNK)op->s.c;
127
#else /* !defined(S_CONST) */
128
59.3k
    const CHUNK *s = (CHUNK *)(void *)op->s.b.ptr;
129
59.3k
    CHUNK        S;
130
59.3k
    int          s_skew;
131
59.3k
#endif /* !defined(S_CONST) */
132
#else /* !defined(S_USED) */
133
#define S 0
134
#undef S_CONST
135
#endif /* !defined(S_USED) */
136
#ifdef T_USED
137
#ifdef T_CONST
138
    CHUNK        T = (CHUNK)op->t.c;
139
#else /* !defined(T_CONST) */
140
    const CHUNK *t = (CHUNK *)(void *)op->t.b.ptr;
141
    CHUNK        T;
142
    int          t_skew;
143
#endif /* !defined(T_CONST) */
144
#else /* !defined(T_USED) */
145
59.3k
#define T 0
146
59.3k
#undef T_CONST
147
59.3k
#endif /* !defined(T_USED) */
148
59.3k
#if defined(S_SKEW) || defined(T_SKEW)
149
59.3k
    int skewflags = 0;
150
59.3k
#endif
151
59.3k
    CHUNK        D;
152
59.3k
    int          dpos = op->dpos;
153
59.3k
    CHUNK       *d = (CHUNK *)(void *)d_;
154
155
    /* Align d to CHUNKSIZE */
156
59.3k
    ADJUST_TO_CHUNK(d,dpos);
157
158
    /* On entry len = length in 'depth' chunks. Change it to be the length
159
     * in bits, and add on the number of bits we skip at the start of the
160
     * run. */
161
59.3k
    len    = len * op->depth + dpos;
162
163
    /* lmask = the set of bits to alter in the output bitmap on the left
164
     * hand edge of the run. rmask = the set of bits NOT to alter in the
165
     * output bitmap on the right hand edge of the run. */
166
59.3k
    lmask  = RE((CHUNKONES>>((CHUNKSIZE-1) & dpos)));
167
59.3k
    rmask  = RE((CHUNKONES>>((CHUNKSIZE-1) & len)));
168
59.3k
    if (rmask == CHUNKONES) rmask = 0;
169
170
#if defined(S_CONST) || defined(T_CONST)
171
    /* S and T should be supplied as 'depth' bits. Duplicate them up to be
172
     * byte size (if they are supplied byte sized, that's fine too). */
173
    if (op->depth & 1) {
174
#ifdef S_CONST
175
        S |= S<<1;
176
#endif /* !defined(S_CONST) */
177
#ifdef T_CONST
178
        T |= T<<1;
179
#endif /* !defined(T_CONST) */
180
    }
181
    if (op->depth & 3) {
182
#ifdef S_CONST
183
        S |= S<<2;
184
#endif /* !defined(S_CONST) */
185
#ifdef T_CONST
186
        T |= T<<2;
187
#endif /* !defined(T_CONST) */
188
    }
189
    if (op->depth & 7) {
190
#ifdef S_CONST
191
        S |= S<<4;
192
#endif /* !defined(S_CONST) */
193
#ifdef T_CONST
194
        T |= T<<4;
195
#endif /* !defined(T_CONST) */
196
    }
197
#if CHUNKSIZE > 8
198
    if (op->depth & 15) {
199
#ifdef S_CONST
200
        S |= S<<8;
201
#endif /* !defined(S_CONST) */
202
#ifdef T_CONST
203
        T |= T<<8;
204
#endif /* !defined(T_CONST) */
205
    }
206
#endif /* CHUNKSIZE > 8 */
207
#if CHUNKSIZE > 16
208
    if (op->depth & 31) {
209
#ifdef S_CONST
210
        S |= S<<16;
211
#endif /* !defined(S_CONST) */
212
#ifdef T_CONST
213
        T |= T<<16;
214
#endif /* !defined(T_CONST) */
215
    }
216
#endif /* CHUNKSIZE > 16 */
217
#endif /* defined(S_CONST) || defined(T_CONST) */
218
219
    /* Note #1: This mirrors what the original code did, but I think it has
220
     * the risk of moving s and t back beyond officially allocated space. We
221
     * may be saved by the fact that all blocks have a word or two in front
222
     * of them due to the allocator. If we ever get valgrind properly marking
223
     * allocated blocks as readable etc, then this may throw some spurious
224
     * errors. RJW. */
225
59.3k
#ifdef S_SKEW
226
59.3k
    {
227
59.3k
        int slen, slen2;
228
59.3k
        int spos = op->s.b.pos;
229
59.3k
        ADJUST_TO_CHUNK(s, spos);
230
59.3k
        s_skew = spos - dpos;
231
59.3k
        if (s_skew < 0) {
232
54.1k
            s_skew += CHUNKSIZE;
233
54.1k
            s--;
234
54.1k
            skewflags |= 1; /* Suppress reading off left edge */
235
54.1k
        }
236
        /* We are allowed to read all the data bits, so: len - dpos + tpos
237
         * We're allowed to read in CHUNKS, so: CHUNKUP(len-dpos+tpos).
238
         * This code will actually read CHUNKUP(len)+CHUNKSIZE bits. If
239
         * This is larger, then suppress. */
240
59.3k
        slen  = (len + s_skew    + CHUNKSIZE-1) & ~(CHUNKSIZE-1);
241
59.3k
        slen2 = (len + CHUNKSIZE + CHUNKSIZE-1) & ~(CHUNKSIZE-1);
242
59.3k
        if ((s_skew == 0) || (slen < slen2)) {
243
40.7k
            skewflags |= 4; /* Suppress reading off the right edge */
244
40.7k
        }
245
59.3k
    }
246
59.3k
#endif /* !defined(S_SKEW) */
247
#ifdef T_SKEW
248
    {
249
        int tlen, tlen2;
250
        int tpos = op->t.b.pos;
251
        ADJUST_TO_CHUNK(t, tpos);
252
        t_skew = tpos - dpos;
253
        if (t_skew < 0) {
254
            t_skew += CHUNKSIZE;
255
            t--;
256
            skewflags |= 2; /* Suppress reading off left edge */
257
        }
258
        /* We are allowed to read all the data bits, so: len - dpos + tpos
259
         * We're allowed to read in CHUNKS, so: CHUNKUP(len-dpos+tpos).
260
         * This code will actually read CHUNKUP(len)+CHUNKSIZE bits. If
261
         * This is larger, then suppress. */
262
        tlen  = (len + t_skew    + CHUNKSIZE-1) & ~(CHUNKSIZE-1);
263
        tlen2 = (len + CHUNKSIZE + CHUNKSIZE-1) & ~(CHUNKSIZE-1);
264
        if ((t_skew == 0) || (tlen < tlen2)) {
265
            skewflags |= 8; /* Suppress reading off the right edge */
266
        }
267
    }
268
#endif /* !defined(T_SKEW) */
269
270
59.3k
    len -= CHUNKSIZE; /* len = bytes to do - CHUNKSIZE */
271
    /* len <= 0 means 1 word or less to do */
272
59.3k
    if (len <= 0) {
273
        /* Short case - starts and ends in the same chunk */
274
86
        lmask &= ~rmask; /* Combined mask = bits to alter */
275
86
        SAFE_FETCH_S(skewflags & 1,skewflags & 4);
276
86
        SAFE_FETCH_T(skewflags & 2,skewflags & 8);
277
86
        SPECIFIC_CODE(D, *d, S, T);
278
86
        *d = (*d & ~lmask) | (D & lmask);
279
86
        return;
280
86
    }
281
59.2k
    if ((lmask != CHUNKONES)
282
59.2k
#if defined(S_SKEW) || defined(T_SKEW)
283
59.2k
        || (skewflags & 3)
284
59.2k
#endif
285
59.2k
        ) {
286
        /* Unaligned left hand case */
287
56.9k
        SAFE_FETCH_S(skewflags & 1,s_skew == 0);
288
56.9k
        SAFE_FETCH_T(skewflags & 2,t_skew == 0);
289
56.9k
        SPECIFIC_CODE(D, *d, S, T);
290
56.9k
        *d = (*d & ~lmask) | (D & lmask);
291
56.9k
        d++;
292
56.9k
        len -= CHUNKSIZE;
293
56.9k
    }
294
59.2k
    if (len > 0) {
295
        /* Simple middle case (complete destination chunks). */
296
45.4k
#ifdef S_SKEW
297
45.4k
        if (s_skew == 0) {
298
#ifdef T_SKEW
299
            if (t_skew == 0) {
300
                do {
301
                    SPECIFIC_CODE(*d, *d, *s++, *t++);
302
                    d++;
303
                    len -= CHUNKSIZE;
304
                } while (len > 0);
305
            } else
306
#endif /* !defined(T_SKEW) */
307
2.02k
            {
308
48.9k
                do {
309
48.9k
                    FETCH_T;
310
48.9k
                    SPECIFIC_CODE(*d, *d, *s++, T);
311
48.9k
                    d++;
312
48.9k
                    len -= CHUNKSIZE;
313
48.9k
                } while (len > 0);
314
2.02k
            }
315
2.02k
        } else
316
43.3k
#endif /* !defined(S_SKEW) */
317
43.3k
        {
318
#ifdef T_SKEW
319
            if (t_skew == 0) {
320
                do {
321
                    FETCH_S;
322
                    SPECIFIC_CODE(*d, *d, S, *t++);
323
                    d++;
324
                    len -= CHUNKSIZE;
325
                } while (len > 0);
326
            } else
327
#endif /* !defined(T_SKEW) */
328
43.3k
            {
329
3.51M
                do {
330
3.51M
                    FETCH_S;
331
3.51M
                    FETCH_T;
332
3.51M
                    SPECIFIC_CODE(*d, *d, S, T);
333
3.51M
                    d++;
334
3.51M
                    len -= CHUNKSIZE;
335
3.51M
                } while (len > 0);
336
43.3k
            }
337
43.3k
        }
338
45.4k
    }
339
    /* Unaligned right hand case */
340
59.2k
    SAFE_FETCH_S(0,skewflags & 4);
341
59.2k
    SAFE_FETCH_T(0,skewflags & 8);
342
59.2k
    SPECIFIC_CODE(D, *d, S, T);
343
59.2k
    *d = (*d & rmask) | (D & ~rmask);
344
59.2k
}
gsroprun.c:dors_rop_run1_const_t
Line
Count
Source
118
4.03k
{
119
#ifndef SPECIFIC_CODE
120
    rop_proc     proc = rop_proc_table[op->rop];
121
#define SPECIFIC_CODE(OUT_, D_,S_,T_) OUT_ = proc(D_,S_,T_)
122
#endif /* !defined(SPECIFIC_CODE) */
123
4.03k
    CHUNK        lmask, rmask;
124
4.03k
#ifdef S_USED
125
#ifdef S_CONST
126
    CHUNK        S = (CHUNK)op->s.c;
127
#else /* !defined(S_CONST) */
128
4.03k
    const CHUNK *s = (CHUNK *)(void *)op->s.b.ptr;
129
4.03k
    CHUNK        S;
130
4.03k
    int          s_skew;
131
4.03k
#endif /* !defined(S_CONST) */
132
#else /* !defined(S_USED) */
133
#define S 0
134
#undef S_CONST
135
#endif /* !defined(S_USED) */
136
#ifdef T_USED
137
#ifdef T_CONST
138
    CHUNK        T = (CHUNK)op->t.c;
139
#else /* !defined(T_CONST) */
140
    const CHUNK *t = (CHUNK *)(void *)op->t.b.ptr;
141
    CHUNK        T;
142
    int          t_skew;
143
#endif /* !defined(T_CONST) */
144
#else /* !defined(T_USED) */
145
4.03k
#define T 0
146
4.03k
#undef T_CONST
147
4.03k
#endif /* !defined(T_USED) */
148
4.03k
#if defined(S_SKEW) || defined(T_SKEW)
149
4.03k
    int skewflags = 0;
150
4.03k
#endif
151
4.03k
    CHUNK        D;
152
4.03k
    int          dpos = op->dpos;
153
4.03k
    CHUNK       *d = (CHUNK *)(void *)d_;
154
155
    /* Align d to CHUNKSIZE */
156
4.03k
    ADJUST_TO_CHUNK(d,dpos);
157
158
    /* On entry len = length in 'depth' chunks. Change it to be the length
159
     * in bits, and add on the number of bits we skip at the start of the
160
     * run. */
161
4.03k
    len    = len * op->depth + dpos;
162
163
    /* lmask = the set of bits to alter in the output bitmap on the left
164
     * hand edge of the run. rmask = the set of bits NOT to alter in the
165
     * output bitmap on the right hand edge of the run. */
166
4.03k
    lmask  = RE((CHUNKONES>>((CHUNKSIZE-1) & dpos)));
167
4.03k
    rmask  = RE((CHUNKONES>>((CHUNKSIZE-1) & len)));
168
4.03k
    if (rmask == CHUNKONES) rmask = 0;
169
170
#if defined(S_CONST) || defined(T_CONST)
171
    /* S and T should be supplied as 'depth' bits. Duplicate them up to be
172
     * byte size (if they are supplied byte sized, that's fine too). */
173
    if (op->depth & 1) {
174
#ifdef S_CONST
175
        S |= S<<1;
176
#endif /* !defined(S_CONST) */
177
#ifdef T_CONST
178
        T |= T<<1;
179
#endif /* !defined(T_CONST) */
180
    }
181
    if (op->depth & 3) {
182
#ifdef S_CONST
183
        S |= S<<2;
184
#endif /* !defined(S_CONST) */
185
#ifdef T_CONST
186
        T |= T<<2;
187
#endif /* !defined(T_CONST) */
188
    }
189
    if (op->depth & 7) {
190
#ifdef S_CONST
191
        S |= S<<4;
192
#endif /* !defined(S_CONST) */
193
#ifdef T_CONST
194
        T |= T<<4;
195
#endif /* !defined(T_CONST) */
196
    }
197
#if CHUNKSIZE > 8
198
    if (op->depth & 15) {
199
#ifdef S_CONST
200
        S |= S<<8;
201
#endif /* !defined(S_CONST) */
202
#ifdef T_CONST
203
        T |= T<<8;
204
#endif /* !defined(T_CONST) */
205
    }
206
#endif /* CHUNKSIZE > 8 */
207
#if CHUNKSIZE > 16
208
    if (op->depth & 31) {
209
#ifdef S_CONST
210
        S |= S<<16;
211
#endif /* !defined(S_CONST) */
212
#ifdef T_CONST
213
        T |= T<<16;
214
#endif /* !defined(T_CONST) */
215
    }
216
#endif /* CHUNKSIZE > 16 */
217
#endif /* defined(S_CONST) || defined(T_CONST) */
218
219
    /* Note #1: This mirrors what the original code did, but I think it has
220
     * the risk of moving s and t back beyond officially allocated space. We
221
     * may be saved by the fact that all blocks have a word or two in front
222
     * of them due to the allocator. If we ever get valgrind properly marking
223
     * allocated blocks as readable etc, then this may throw some spurious
224
     * errors. RJW. */
225
4.03k
#ifdef S_SKEW
226
4.03k
    {
227
4.03k
        int slen, slen2;
228
4.03k
        int spos = op->s.b.pos;
229
4.03k
        ADJUST_TO_CHUNK(s, spos);
230
4.03k
        s_skew = spos - dpos;
231
4.03k
        if (s_skew < 0) {
232
4.03k
            s_skew += CHUNKSIZE;
233
4.03k
            s--;
234
4.03k
            skewflags |= 1; /* Suppress reading off left edge */
235
4.03k
        }
236
        /* We are allowed to read all the data bits, so: len - dpos + tpos
237
         * We're allowed to read in CHUNKS, so: CHUNKUP(len-dpos+tpos).
238
         * This code will actually read CHUNKUP(len)+CHUNKSIZE bits. If
239
         * This is larger, then suppress. */
240
4.03k
        slen  = (len + s_skew    + CHUNKSIZE-1) & ~(CHUNKSIZE-1);
241
4.03k
        slen2 = (len + CHUNKSIZE + CHUNKSIZE-1) & ~(CHUNKSIZE-1);
242
4.03k
        if ((s_skew == 0) || (slen < slen2)) {
243
706
            skewflags |= 4; /* Suppress reading off the right edge */
244
706
        }
245
4.03k
    }
246
4.03k
#endif /* !defined(S_SKEW) */
247
#ifdef T_SKEW
248
    {
249
        int tlen, tlen2;
250
        int tpos = op->t.b.pos;
251
        ADJUST_TO_CHUNK(t, tpos);
252
        t_skew = tpos - dpos;
253
        if (t_skew < 0) {
254
            t_skew += CHUNKSIZE;
255
            t--;
256
            skewflags |= 2; /* Suppress reading off left edge */
257
        }
258
        /* We are allowed to read all the data bits, so: len - dpos + tpos
259
         * We're allowed to read in CHUNKS, so: CHUNKUP(len-dpos+tpos).
260
         * This code will actually read CHUNKUP(len)+CHUNKSIZE bits. If
261
         * This is larger, then suppress. */
262
        tlen  = (len + t_skew    + CHUNKSIZE-1) & ~(CHUNKSIZE-1);
263
        tlen2 = (len + CHUNKSIZE + CHUNKSIZE-1) & ~(CHUNKSIZE-1);
264
        if ((t_skew == 0) || (tlen < tlen2)) {
265
            skewflags |= 8; /* Suppress reading off the right edge */
266
        }
267
    }
268
#endif /* !defined(T_SKEW) */
269
270
4.03k
    len -= CHUNKSIZE; /* len = bytes to do - CHUNKSIZE */
271
    /* len <= 0 means 1 word or less to do */
272
4.03k
    if (len <= 0) {
273
        /* Short case - starts and ends in the same chunk */
274
0
        lmask &= ~rmask; /* Combined mask = bits to alter */
275
0
        SAFE_FETCH_S(skewflags & 1,skewflags & 4);
276
0
        SAFE_FETCH_T(skewflags & 2,skewflags & 8);
277
0
        SPECIFIC_CODE(D, *d, S, T);
278
0
        *d = (*d & ~lmask) | (D & lmask);
279
0
        return;
280
0
    }
281
4.03k
    if ((lmask != CHUNKONES)
282
4.03k
#if defined(S_SKEW) || defined(T_SKEW)
283
4.03k
        || (skewflags & 3)
284
4.03k
#endif
285
4.03k
        ) {
286
        /* Unaligned left hand case */
287
4.03k
        SAFE_FETCH_S(skewflags & 1,s_skew == 0);
288
4.03k
        SAFE_FETCH_T(skewflags & 2,t_skew == 0);
289
4.03k
        SPECIFIC_CODE(D, *d, S, T);
290
4.03k
        *d = (*d & ~lmask) | (D & lmask);
291
4.03k
        d++;
292
4.03k
        len -= CHUNKSIZE;
293
4.03k
    }
294
4.03k
    if (len > 0) {
295
        /* Simple middle case (complete destination chunks). */
296
1.86k
#ifdef S_SKEW
297
1.86k
        if (s_skew == 0) {
298
#ifdef T_SKEW
299
            if (t_skew == 0) {
300
                do {
301
                    SPECIFIC_CODE(*d, *d, *s++, *t++);
302
                    d++;
303
                    len -= CHUNKSIZE;
304
                } while (len > 0);
305
            } else
306
#endif /* !defined(T_SKEW) */
307
0
            {
308
0
                do {
309
0
                    FETCH_T;
310
0
                    SPECIFIC_CODE(*d, *d, *s++, T);
311
0
                    d++;
312
0
                    len -= CHUNKSIZE;
313
0
                } while (len > 0);
314
0
            }
315
0
        } else
316
1.86k
#endif /* !defined(S_SKEW) */
317
1.86k
        {
318
#ifdef T_SKEW
319
            if (t_skew == 0) {
320
                do {
321
                    FETCH_S;
322
                    SPECIFIC_CODE(*d, *d, S, *t++);
323
                    d++;
324
                    len -= CHUNKSIZE;
325
                } while (len > 0);
326
            } else
327
#endif /* !defined(T_SKEW) */
328
1.86k
            {
329
2.83k
                do {
330
2.83k
                    FETCH_S;
331
2.83k
                    FETCH_T;
332
2.83k
                    SPECIFIC_CODE(*d, *d, S, T);
333
2.83k
                    d++;
334
2.83k
                    len -= CHUNKSIZE;
335
2.83k
                } while (len > 0);
336
1.86k
            }
337
1.86k
        }
338
1.86k
    }
339
    /* Unaligned right hand case */
340
4.03k
    SAFE_FETCH_S(0,skewflags & 4);
341
4.03k
    SAFE_FETCH_T(0,skewflags & 8);
342
4.03k
    SPECIFIC_CODE(D, *d, S, T);
343
4.03k
    *d = (*d & rmask) | (D & ~rmask);
344
4.03k
}
Unexecuted instantiation: gsroprun.c:generic_rop_run1
gsroprun.c:generic_rop_run1_const_t
Line
Count
Source
118
6.01k
{
119
6.01k
#ifndef SPECIFIC_CODE
120
6.01k
    rop_proc     proc = rop_proc_table[op->rop];
121
6.01k
#define SPECIFIC_CODE(OUT_, D_,S_,T_) OUT_ = proc(D_,S_,T_)
122
6.01k
#endif /* !defined(SPECIFIC_CODE) */
123
6.01k
    CHUNK        lmask, rmask;
124
6.01k
#ifdef S_USED
125
#ifdef S_CONST
126
    CHUNK        S = (CHUNK)op->s.c;
127
#else /* !defined(S_CONST) */
128
6.01k
    const CHUNK *s = (CHUNK *)(void *)op->s.b.ptr;
129
6.01k
    CHUNK        S;
130
6.01k
    int          s_skew;
131
6.01k
#endif /* !defined(S_CONST) */
132
#else /* !defined(S_USED) */
133
#define S 0
134
#undef S_CONST
135
#endif /* !defined(S_USED) */
136
6.01k
#ifdef T_USED
137
6.01k
#ifdef T_CONST
138
6.01k
    CHUNK        T = (CHUNK)op->t.c;
139
#else /* !defined(T_CONST) */
140
    const CHUNK *t = (CHUNK *)(void *)op->t.b.ptr;
141
    CHUNK        T;
142
    int          t_skew;
143
#endif /* !defined(T_CONST) */
144
#else /* !defined(T_USED) */
145
#define T 0
146
#undef T_CONST
147
#endif /* !defined(T_USED) */
148
6.01k
#if defined(S_SKEW) || defined(T_SKEW)
149
6.01k
    int skewflags = 0;
150
6.01k
#endif
151
6.01k
    CHUNK        D;
152
6.01k
    int          dpos = op->dpos;
153
6.01k
    CHUNK       *d = (CHUNK *)(void *)d_;
154
155
    /* Align d to CHUNKSIZE */
156
6.01k
    ADJUST_TO_CHUNK(d,dpos);
157
158
    /* On entry len = length in 'depth' chunks. Change it to be the length
159
     * in bits, and add on the number of bits we skip at the start of the
160
     * run. */
161
6.01k
    len    = len * op->depth + dpos;
162
163
    /* lmask = the set of bits to alter in the output bitmap on the left
164
     * hand edge of the run. rmask = the set of bits NOT to alter in the
165
     * output bitmap on the right hand edge of the run. */
166
6.01k
    lmask  = RE((CHUNKONES>>((CHUNKSIZE-1) & dpos)));
167
6.01k
    rmask  = RE((CHUNKONES>>((CHUNKSIZE-1) & len)));
168
6.01k
    if (rmask == CHUNKONES) rmask = 0;
169
170
6.01k
#if defined(S_CONST) || defined(T_CONST)
171
    /* S and T should be supplied as 'depth' bits. Duplicate them up to be
172
     * byte size (if they are supplied byte sized, that's fine too). */
173
6.01k
    if (op->depth & 1) {
174
#ifdef S_CONST
175
        S |= S<<1;
176
#endif /* !defined(S_CONST) */
177
6.01k
#ifdef T_CONST
178
6.01k
        T |= T<<1;
179
6.01k
#endif /* !defined(T_CONST) */
180
6.01k
    }
181
6.01k
    if (op->depth & 3) {
182
#ifdef S_CONST
183
        S |= S<<2;
184
#endif /* !defined(S_CONST) */
185
6.01k
#ifdef T_CONST
186
6.01k
        T |= T<<2;
187
6.01k
#endif /* !defined(T_CONST) */
188
6.01k
    }
189
6.01k
    if (op->depth & 7) {
190
#ifdef S_CONST
191
        S |= S<<4;
192
#endif /* !defined(S_CONST) */
193
6.01k
#ifdef T_CONST
194
6.01k
        T |= T<<4;
195
6.01k
#endif /* !defined(T_CONST) */
196
6.01k
    }
197
6.01k
#if CHUNKSIZE > 8
198
6.01k
    if (op->depth & 15) {
199
#ifdef S_CONST
200
        S |= S<<8;
201
#endif /* !defined(S_CONST) */
202
6.01k
#ifdef T_CONST
203
6.01k
        T |= T<<8;
204
6.01k
#endif /* !defined(T_CONST) */
205
6.01k
    }
206
6.01k
#endif /* CHUNKSIZE > 8 */
207
6.01k
#if CHUNKSIZE > 16
208
6.01k
    if (op->depth & 31) {
209
#ifdef S_CONST
210
        S |= S<<16;
211
#endif /* !defined(S_CONST) */
212
6.01k
#ifdef T_CONST
213
6.01k
        T |= T<<16;
214
6.01k
#endif /* !defined(T_CONST) */
215
6.01k
    }
216
6.01k
#endif /* CHUNKSIZE > 16 */
217
6.01k
#endif /* defined(S_CONST) || defined(T_CONST) */
218
219
    /* Note #1: This mirrors what the original code did, but I think it has
220
     * the risk of moving s and t back beyond officially allocated space. We
221
     * may be saved by the fact that all blocks have a word or two in front
222
     * of them due to the allocator. If we ever get valgrind properly marking
223
     * allocated blocks as readable etc, then this may throw some spurious
224
     * errors. RJW. */
225
6.01k
#ifdef S_SKEW
226
6.01k
    {
227
6.01k
        int slen, slen2;
228
6.01k
        int spos = op->s.b.pos;
229
6.01k
        ADJUST_TO_CHUNK(s, spos);
230
6.01k
        s_skew = spos - dpos;
231
6.01k
        if (s_skew < 0) {
232
5.77k
            s_skew += CHUNKSIZE;
233
5.77k
            s--;
234
5.77k
            skewflags |= 1; /* Suppress reading off left edge */
235
5.77k
        }
236
        /* We are allowed to read all the data bits, so: len - dpos + tpos
237
         * We're allowed to read in CHUNKS, so: CHUNKUP(len-dpos+tpos).
238
         * This code will actually read CHUNKUP(len)+CHUNKSIZE bits. If
239
         * This is larger, then suppress. */
240
6.01k
        slen  = (len + s_skew    + CHUNKSIZE-1) & ~(CHUNKSIZE-1);
241
6.01k
        slen2 = (len + CHUNKSIZE + CHUNKSIZE-1) & ~(CHUNKSIZE-1);
242
6.01k
        if ((s_skew == 0) || (slen < slen2)) {
243
2.29k
            skewflags |= 4; /* Suppress reading off the right edge */
244
2.29k
        }
245
6.01k
    }
246
6.01k
#endif /* !defined(S_SKEW) */
247
#ifdef T_SKEW
248
    {
249
        int tlen, tlen2;
250
        int tpos = op->t.b.pos;
251
        ADJUST_TO_CHUNK(t, tpos);
252
        t_skew = tpos - dpos;
253
        if (t_skew < 0) {
254
            t_skew += CHUNKSIZE;
255
            t--;
256
            skewflags |= 2; /* Suppress reading off left edge */
257
        }
258
        /* We are allowed to read all the data bits, so: len - dpos + tpos
259
         * We're allowed to read in CHUNKS, so: CHUNKUP(len-dpos+tpos).
260
         * This code will actually read CHUNKUP(len)+CHUNKSIZE bits. If
261
         * This is larger, then suppress. */
262
        tlen  = (len + t_skew    + CHUNKSIZE-1) & ~(CHUNKSIZE-1);
263
        tlen2 = (len + CHUNKSIZE + CHUNKSIZE-1) & ~(CHUNKSIZE-1);
264
        if ((t_skew == 0) || (tlen < tlen2)) {
265
            skewflags |= 8; /* Suppress reading off the right edge */
266
        }
267
    }
268
#endif /* !defined(T_SKEW) */
269
270
6.01k
    len -= CHUNKSIZE; /* len = bytes to do - CHUNKSIZE */
271
    /* len <= 0 means 1 word or less to do */
272
6.01k
    if (len <= 0) {
273
        /* Short case - starts and ends in the same chunk */
274
42
        lmask &= ~rmask; /* Combined mask = bits to alter */
275
42
        SAFE_FETCH_S(skewflags & 1,skewflags & 4);
276
42
        SAFE_FETCH_T(skewflags & 2,skewflags & 8);
277
42
        SPECIFIC_CODE(D, *d, S, T);
278
42
        *d = (*d & ~lmask) | (D & lmask);
279
42
        return;
280
42
    }
281
5.97k
    if ((lmask != CHUNKONES)
282
5.97k
#if defined(S_SKEW) || defined(T_SKEW)
283
5.97k
        || (skewflags & 3)
284
5.97k
#endif
285
5.97k
        ) {
286
        /* Unaligned left hand case */
287
5.77k
        SAFE_FETCH_S(skewflags & 1,s_skew == 0);
288
5.77k
        SAFE_FETCH_T(skewflags & 2,t_skew == 0);
289
5.77k
        SPECIFIC_CODE(D, *d, S, T);
290
5.77k
        *d = (*d & ~lmask) | (D & lmask);
291
5.77k
        d++;
292
5.77k
        len -= CHUNKSIZE;
293
5.77k
    }
294
5.97k
    if (len > 0) {
295
        /* Simple middle case (complete destination chunks). */
296
3.50k
#ifdef S_SKEW
297
3.50k
        if (s_skew == 0) {
298
#ifdef T_SKEW
299
            if (t_skew == 0) {
300
                do {
301
                    SPECIFIC_CODE(*d, *d, *s++, *t++);
302
                    d++;
303
                    len -= CHUNKSIZE;
304
                } while (len > 0);
305
            } else
306
#endif /* !defined(T_SKEW) */
307
200
            {
308
256
                do {
309
256
                    FETCH_T;
310
256
                    SPECIFIC_CODE(*d, *d, *s++, T);
311
256
                    d++;
312
256
                    len -= CHUNKSIZE;
313
256
                } while (len > 0);
314
200
            }
315
200
        } else
316
3.30k
#endif /* !defined(S_SKEW) */
317
3.30k
        {
318
#ifdef T_SKEW
319
            if (t_skew == 0) {
320
                do {
321
                    FETCH_S;
322
                    SPECIFIC_CODE(*d, *d, S, *t++);
323
                    d++;
324
                    len -= CHUNKSIZE;
325
                } while (len > 0);
326
            } else
327
#endif /* !defined(T_SKEW) */
328
3.30k
            {
329
4.97k
                do {
330
4.97k
                    FETCH_S;
331
4.97k
                    FETCH_T;
332
4.97k
                    SPECIFIC_CODE(*d, *d, S, T);
333
4.97k
                    d++;
334
4.97k
                    len -= CHUNKSIZE;
335
4.97k
                } while (len > 0);
336
3.30k
            }
337
3.30k
        }
338
3.50k
    }
339
    /* Unaligned right hand case */
340
5.97k
    SAFE_FETCH_S(0,skewflags & 4);
341
5.97k
    SAFE_FETCH_T(0,skewflags & 8);
342
5.97k
    SPECIFIC_CODE(D, *d, S, T);
343
5.97k
    *d = (*d & rmask) | (D & ~rmask);
344
5.97k
}
Unexecuted instantiation: gsroprun.c:generic_rop_run1_const_st
345
346
#undef ADJUST_TO_CHUNK
347
#undef CHUNKSIZE
348
#undef CHUNK
349
#undef CHUNKONES
350
#undef FETCH_S
351
#undef FETCH_T
352
#undef SAFE_FETCH_S
353
#undef SAFE_FETCH_T
354
#undef RE
355
#undef S
356
#undef S_USED
357
#undef S_CONST
358
#undef S_SKEW
359
#undef SKEW_FETCH
360
#undef SAFE_SKEW_FETCH
361
#undef SPECIFIC_CODE
362
#undef SPECIFIC_ROP
363
#undef T
364
#undef T_USED
365
#undef T_CONST
366
#undef T_SKEW
367
#undef TEMPLATE_NAME
368
#undef ROP_PTRDIFF_T
369
370
#else
371
int dummy;
372
#endif