Coverage Report

Created: 2026-08-08 08:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/ghostpdl/base/gsroprun1.h
Line
Count
Source
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
984M
#define CHUNKSIZE 32
64
179M
#define CHUNK unsigned int
65
87.4M
#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
87.6M
    do { int offset = ((ROP_PTRDIFF_T)d) & ((CHUNKSIZE>>3)-1);  \
74
87.6M
         d = (CHUNK *)(void *)(((byte *)(void *)d)-offset);   \
75
87.6M
         dpos += offset<<3;                           \
76
87.6M
     } 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
520M
#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
352M
    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
80.1M
    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
352M
#define FETCH_S           SKEW_FETCH(S,s,s_skew)
102
80.1M
#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
43.8M
{
119
#ifndef SPECIFIC_CODE
120
    rop_proc     proc = rop_proc_table[op->rop];
121
17.2M
#define SPECIFIC_CODE(OUT_, D_,S_,T_) OUT_ = proc(D_,S_,T_)
122
#endif /* !defined(SPECIFIC_CODE) */
123
43.8M
    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
43.8M
    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
3.78M
    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
43.8M
    CHUNK        D;
152
43.8M
    int          dpos = op->dpos;
153
43.8M
    CHUNK       *d = (CHUNK *)(void *)d_;
154
155
    /* Align d to CHUNKSIZE */
156
43.8M
    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
43.8M
    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
43.8M
    lmask  = RE((CHUNKONES>>((CHUNKSIZE-1) & dpos)));
167
43.8M
    rmask  = RE((CHUNKONES>>((CHUNKSIZE-1) & len)));
168
43.8M
    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
3.78M
    if (op->depth & 1) {
174
#ifdef S_CONST
175
        S |= S<<1;
176
#endif /* !defined(S_CONST) */
177
3.78M
#ifdef T_CONST
178
3.78M
        T |= T<<1;
179
3.78M
#endif /* !defined(T_CONST) */
180
3.78M
    }
181
3.78M
    if (op->depth & 3) {
182
#ifdef S_CONST
183
        S |= S<<2;
184
#endif /* !defined(S_CONST) */
185
3.78M
#ifdef T_CONST
186
3.78M
        T |= T<<2;
187
3.78M
#endif /* !defined(T_CONST) */
188
3.78M
    }
189
3.78M
    if (op->depth & 7) {
190
#ifdef S_CONST
191
        S |= S<<4;
192
#endif /* !defined(S_CONST) */
193
3.78M
#ifdef T_CONST
194
3.78M
        T |= T<<4;
195
3.78M
#endif /* !defined(T_CONST) */
196
3.78M
    }
197
#if CHUNKSIZE > 8
198
3.78M
    if (op->depth & 15) {
199
#ifdef S_CONST
200
        S |= S<<8;
201
#endif /* !defined(S_CONST) */
202
3.78M
#ifdef T_CONST
203
3.78M
        T |= T<<8;
204
3.78M
#endif /* !defined(T_CONST) */
205
3.78M
    }
206
#endif /* CHUNKSIZE > 8 */
207
#if CHUNKSIZE > 16
208
3.78M
    if (op->depth & 31) {
209
#ifdef S_CONST
210
        S |= S<<16;
211
#endif /* !defined(S_CONST) */
212
3.78M
#ifdef T_CONST
213
3.78M
        T |= T<<16;
214
3.78M
#endif /* !defined(T_CONST) */
215
3.78M
    }
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
43.8M
        ADJUST_TO_CHUNK(s, spos);
230
        s_skew = spos - dpos;
231
43.8M
        if (s_skew < 0) {
232
33.8M
            s_skew += CHUNKSIZE;
233
33.8M
            s--;
234
33.8M
            skewflags |= 1; /* Suppress reading off left edge */
235
33.8M
        }
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
43.8M
        slen  = (len + s_skew    + CHUNKSIZE-1) & ~(CHUNKSIZE-1);
241
43.8M
        slen2 = (len + CHUNKSIZE + CHUNKSIZE-1) & ~(CHUNKSIZE-1);
242
43.8M
        if ((s_skew == 0) || (slen < slen2)) {
243
23.2M
            skewflags |= 4; /* Suppress reading off the right edge */
244
23.2M
        }
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
43.8M
    len -= CHUNKSIZE; /* len = bytes to do - CHUNKSIZE */
271
    /* len <= 0 means 1 word or less to do */
272
43.8M
    if (len <= 0) {
273
        /* Short case - starts and ends in the same chunk */
274
205k
        lmask &= ~rmask; /* Combined mask = bits to alter */
275
205k
        SAFE_FETCH_S(skewflags & 1,skewflags & 4);
276
205k
        SAFE_FETCH_T(skewflags & 2,skewflags & 8);
277
205k
        SPECIFIC_CODE(D, *d, S, T);
278
205k
        *d = (*d & ~lmask) | (D & lmask);
279
205k
        return;
280
205k
    }
281
43.6M
    if ((lmask != CHUNKONES)
282
#if defined(S_SKEW) || defined(T_SKEW)
283
7.32M
        || (skewflags & 3)
284
#endif
285
43.6M
        ) {
286
        /* Unaligned left hand case */
287
36.2M
        SAFE_FETCH_S(skewflags & 1,s_skew == 0);
288
36.2M
        SAFE_FETCH_T(skewflags & 2,t_skew == 0);
289
36.2M
        SPECIFIC_CODE(D, *d, S, T);
290
36.2M
        *d = (*d & ~lmask) | (D & lmask);
291
36.2M
        d++;
292
36.2M
        len -= CHUNKSIZE;
293
36.2M
    }
294
43.6M
    if (len > 0) {
295
        /* Simple middle case (complete destination chunks). */
296
#ifdef S_SKEW
297
31.3M
        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
210M
                do {
309
210M
                    FETCH_T;
310
210M
                    SPECIFIC_CODE(*d, *d, *s++, T);
311
210M
                    d++;
312
210M
                    len -= CHUNKSIZE;
313
210M
                } while (len > 0);
314
0
            }
315
7.02M
        } else
316
24.3M
#endif /* !defined(S_SKEW) */
317
24.3M
        {
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
352M
                do {
330
352M
                    FETCH_S;
331
352M
                    FETCH_T;
332
352M
                    SPECIFIC_CODE(*d, *d, S, T);
333
352M
                    d++;
334
352M
                    len -= CHUNKSIZE;
335
352M
                } while (len > 0);
336
0
            }
337
24.3M
        }
338
31.3M
    }
339
    /* Unaligned right hand case */
340
43.6M
    SAFE_FETCH_S(0,skewflags & 4);
341
43.6M
    SAFE_FETCH_T(0,skewflags & 8);
342
43.6M
    SPECIFIC_CODE(D, *d, S, T);
343
43.6M
    *d = (*d & rmask) | (D & ~rmask);
344
43.6M
}
gsroprun.c:notS_rop_run1_const_t
Line
Count
Source
118
321k
{
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
321k
    CHUNK        lmask, rmask;
124
321k
#ifdef S_USED
125
#ifdef S_CONST
126
    CHUNK        S = (CHUNK)op->s.c;
127
#else /* !defined(S_CONST) */
128
321k
    const CHUNK *s = (CHUNK *)(void *)op->s.b.ptr;
129
321k
    CHUNK        S;
130
321k
    int          s_skew;
131
321k
#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
321k
#define T 0
146
321k
#undef T_CONST
147
321k
#endif /* !defined(T_USED) */
148
321k
#if defined(S_SKEW) || defined(T_SKEW)
149
321k
    int skewflags = 0;
150
321k
#endif
151
321k
    CHUNK        D;
152
321k
    int          dpos = op->dpos;
153
321k
    CHUNK       *d = (CHUNK *)(void *)d_;
154
155
    /* Align d to CHUNKSIZE */
156
321k
    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
321k
    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
321k
    lmask  = RE((CHUNKONES>>((CHUNKSIZE-1) & dpos)));
167
321k
    rmask  = RE((CHUNKONES>>((CHUNKSIZE-1) & len)));
168
321k
    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
321k
#ifdef S_SKEW
226
321k
    {
227
321k
        int slen, slen2;
228
321k
        int spos = op->s.b.pos;
229
321k
        ADJUST_TO_CHUNK(s, spos);
230
321k
        s_skew = spos - dpos;
231
321k
        if (s_skew < 0) {
232
91.7k
            s_skew += CHUNKSIZE;
233
91.7k
            s--;
234
91.7k
            skewflags |= 1; /* Suppress reading off left edge */
235
91.7k
        }
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
321k
        slen  = (len + s_skew    + CHUNKSIZE-1) & ~(CHUNKSIZE-1);
241
321k
        slen2 = (len + CHUNKSIZE + CHUNKSIZE-1) & ~(CHUNKSIZE-1);
242
321k
        if ((s_skew == 0) || (slen < slen2)) {
243
302k
            skewflags |= 4; /* Suppress reading off the right edge */
244
302k
        }
245
321k
    }
246
321k
#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
321k
    len -= CHUNKSIZE; /* len = bytes to do - CHUNKSIZE */
271
    /* len <= 0 means 1 word or less to do */
272
321k
    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
321k
    if ((lmask != CHUNKONES)
282
202k
#if defined(S_SKEW) || defined(T_SKEW)
283
202k
        || (skewflags & 3)
284
321k
#endif
285
321k
        ) {
286
        /* Unaligned left hand case */
287
118k
        SAFE_FETCH_S(skewflags & 1,s_skew == 0);
288
118k
        SAFE_FETCH_T(skewflags & 2,t_skew == 0);
289
118k
        SPECIFIC_CODE(D, *d, S, T);
290
118k
        *d = (*d & ~lmask) | (D & lmask);
291
118k
        d++;
292
118k
        len -= CHUNKSIZE;
293
118k
    }
294
321k
    if (len > 0) {
295
        /* Simple middle case (complete destination chunks). */
296
320k
#ifdef S_SKEW
297
320k
        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
223k
            {
308
8.09M
                do {
309
8.09M
                    FETCH_T;
310
8.09M
                    SPECIFIC_CODE(*d, *d, *s++, T);
311
8.09M
                    d++;
312
8.09M
                    len -= CHUNKSIZE;
313
8.09M
                } while (len > 0);
314
223k
            }
315
223k
        } else
316
97.0k
#endif /* !defined(S_SKEW) */
317
97.0k
        {
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
97.0k
            {
329
987k
                do {
330
987k
                    FETCH_S;
331
987k
                    FETCH_T;
332
987k
                    SPECIFIC_CODE(*d, *d, S, T);
333
987k
                    d++;
334
987k
                    len -= CHUNKSIZE;
335
987k
                } while (len > 0);
336
97.0k
            }
337
97.0k
        }
338
320k
    }
339
    /* Unaligned right hand case */
340
321k
    SAFE_FETCH_S(0,skewflags & 4);
341
321k
    SAFE_FETCH_T(0,skewflags & 8);
342
321k
    SPECIFIC_CODE(D, *d, S, T);
343
321k
    *d = (*d & rmask) | (D & ~rmask);
344
321k
}
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
34.5M
{
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
34.5M
    CHUNK        lmask, rmask;
124
34.5M
#ifdef S_USED
125
#ifdef S_CONST
126
    CHUNK        S = (CHUNK)op->s.c;
127
#else /* !defined(S_CONST) */
128
34.5M
    const CHUNK *s = (CHUNK *)(void *)op->s.b.ptr;
129
34.5M
    CHUNK        S;
130
34.5M
    int          s_skew;
131
34.5M
#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
34.5M
#define T 0
146
34.5M
#undef T_CONST
147
34.5M
#endif /* !defined(T_USED) */
148
34.5M
#if defined(S_SKEW) || defined(T_SKEW)
149
34.5M
    int skewflags = 0;
150
34.5M
#endif
151
34.5M
    CHUNK        D;
152
34.5M
    int          dpos = op->dpos;
153
34.5M
    CHUNK       *d = (CHUNK *)(void *)d_;
154
155
    /* Align d to CHUNKSIZE */
156
34.5M
    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
34.5M
    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
34.5M
    lmask  = RE((CHUNKONES>>((CHUNKSIZE-1) & dpos)));
167
34.5M
    rmask  = RE((CHUNKONES>>((CHUNKSIZE-1) & len)));
168
34.5M
    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
34.5M
#ifdef S_SKEW
226
34.5M
    {
227
34.5M
        int slen, slen2;
228
34.5M
        int spos = op->s.b.pos;
229
34.5M
        ADJUST_TO_CHUNK(s, spos);
230
34.5M
        s_skew = spos - dpos;
231
34.5M
        if (s_skew < 0) {
232
25.4M
            s_skew += CHUNKSIZE;
233
25.4M
            s--;
234
25.4M
            skewflags |= 1; /* Suppress reading off left edge */
235
25.4M
        }
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
34.5M
        slen  = (len + s_skew    + CHUNKSIZE-1) & ~(CHUNKSIZE-1);
241
34.5M
        slen2 = (len + CHUNKSIZE + CHUNKSIZE-1) & ~(CHUNKSIZE-1);
242
34.5M
        if ((s_skew == 0) || (slen < slen2)) {
243
18.6M
            skewflags |= 4; /* Suppress reading off the right edge */
244
18.6M
        }
245
34.5M
    }
246
34.5M
#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
34.5M
    len -= CHUNKSIZE; /* len = bytes to do - CHUNKSIZE */
271
    /* len <= 0 means 1 word or less to do */
272
34.5M
    if (len <= 0) {
273
        /* Short case - starts and ends in the same chunk */
274
191k
        lmask &= ~rmask; /* Combined mask = bits to alter */
275
191k
        SAFE_FETCH_S(skewflags & 1,skewflags & 4);
276
191k
        SAFE_FETCH_T(skewflags & 2,skewflags & 8);
277
191k
        SPECIFIC_CODE(D, *d, S, T);
278
191k
        *d = (*d & ~lmask) | (D & lmask);
279
191k
        return;
280
191k
    }
281
34.3M
    if ((lmask != CHUNKONES)
282
6.67M
#if defined(S_SKEW) || defined(T_SKEW)
283
6.67M
        || (skewflags & 3)
284
34.3M
#endif
285
34.3M
        ) {
286
        /* Unaligned left hand case */
287
27.6M
        SAFE_FETCH_S(skewflags & 1,s_skew == 0);
288
27.6M
        SAFE_FETCH_T(skewflags & 2,t_skew == 0);
289
27.6M
        SPECIFIC_CODE(D, *d, S, T);
290
27.6M
        *d = (*d & ~lmask) | (D & lmask);
291
27.6M
        d++;
292
27.6M
        len -= CHUNKSIZE;
293
27.6M
    }
294
34.3M
    if (len > 0) {
295
        /* Simple middle case (complete destination chunks). */
296
25.5M
#ifdef S_SKEW
297
25.5M
        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
6.41M
            {
308
198M
                do {
309
198M
                    FETCH_T;
310
198M
                    SPECIFIC_CODE(*d, *d, *s++, T);
311
198M
                    d++;
312
198M
                    len -= CHUNKSIZE;
313
198M
                } while (len > 0);
314
6.41M
            }
315
6.41M
        } else
316
19.1M
#endif /* !defined(S_SKEW) */
317
19.1M
        {
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
19.1M
            {
329
337M
                do {
330
337M
                    FETCH_S;
331
337M
                    FETCH_T;
332
337M
                    SPECIFIC_CODE(*d, *d, S, T);
333
337M
                    d++;
334
337M
                    len -= CHUNKSIZE;
335
337M
                } while (len > 0);
336
19.1M
            }
337
19.1M
        }
338
25.5M
    }
339
    /* Unaligned right hand case */
340
34.3M
    SAFE_FETCH_S(0,skewflags & 4);
341
34.3M
    SAFE_FETCH_T(0,skewflags & 8);
342
34.3M
    SPECIFIC_CODE(D, *d, S, T);
343
34.3M
    *d = (*d & rmask) | (D & ~rmask);
344
34.3M
}
gsroprun.c:dors_rop_run1_const_t
Line
Count
Source
118
5.16M
{
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
5.16M
    CHUNK        lmask, rmask;
124
5.16M
#ifdef S_USED
125
#ifdef S_CONST
126
    CHUNK        S = (CHUNK)op->s.c;
127
#else /* !defined(S_CONST) */
128
5.16M
    const CHUNK *s = (CHUNK *)(void *)op->s.b.ptr;
129
5.16M
    CHUNK        S;
130
5.16M
    int          s_skew;
131
5.16M
#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
5.16M
#define T 0
146
5.16M
#undef T_CONST
147
5.16M
#endif /* !defined(T_USED) */
148
5.16M
#if defined(S_SKEW) || defined(T_SKEW)
149
5.16M
    int skewflags = 0;
150
5.16M
#endif
151
5.16M
    CHUNK        D;
152
5.16M
    int          dpos = op->dpos;
153
5.16M
    CHUNK       *d = (CHUNK *)(void *)d_;
154
155
    /* Align d to CHUNKSIZE */
156
5.16M
    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
5.16M
    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
5.16M
    lmask  = RE((CHUNKONES>>((CHUNKSIZE-1) & dpos)));
167
5.16M
    rmask  = RE((CHUNKONES>>((CHUNKSIZE-1) & len)));
168
5.16M
    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
5.16M
#ifdef S_SKEW
226
5.16M
    {
227
5.16M
        int slen, slen2;
228
5.16M
        int spos = op->s.b.pos;
229
5.16M
        ADJUST_TO_CHUNK(s, spos);
230
5.16M
        s_skew = spos - dpos;
231
5.16M
        if (s_skew < 0) {
232
4.90M
            s_skew += CHUNKSIZE;
233
4.90M
            s--;
234
4.90M
            skewflags |= 1; /* Suppress reading off left edge */
235
4.90M
        }
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
5.16M
        slen  = (len + s_skew    + CHUNKSIZE-1) & ~(CHUNKSIZE-1);
241
5.16M
        slen2 = (len + CHUNKSIZE + CHUNKSIZE-1) & ~(CHUNKSIZE-1);
242
5.16M
        if ((s_skew == 0) || (slen < slen2)) {
243
2.36M
            skewflags |= 4; /* Suppress reading off the right edge */
244
2.36M
        }
245
5.16M
    }
246
5.16M
#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
5.16M
    len -= CHUNKSIZE; /* len = bytes to do - CHUNKSIZE */
271
    /* len <= 0 means 1 word or less to do */
272
5.16M
    if (len <= 0) {
273
        /* Short case - starts and ends in the same chunk */
274
10.2k
        lmask &= ~rmask; /* Combined mask = bits to alter */
275
10.2k
        SAFE_FETCH_S(skewflags & 1,skewflags & 4);
276
10.2k
        SAFE_FETCH_T(skewflags & 2,skewflags & 8);
277
10.2k
        SPECIFIC_CODE(D, *d, S, T);
278
10.2k
        *d = (*d & ~lmask) | (D & lmask);
279
10.2k
        return;
280
10.2k
    }
281
5.15M
    if ((lmask != CHUNKONES)
282
215k
#if defined(S_SKEW) || defined(T_SKEW)
283
215k
        || (skewflags & 3)
284
5.15M
#endif
285
5.15M
        ) {
286
        /* Unaligned left hand case */
287
4.94M
        SAFE_FETCH_S(skewflags & 1,s_skew == 0);
288
4.94M
        SAFE_FETCH_T(skewflags & 2,t_skew == 0);
289
4.94M
        SPECIFIC_CODE(D, *d, S, T);
290
4.94M
        *d = (*d & ~lmask) | (D & lmask);
291
4.94M
        d++;
292
4.94M
        len -= CHUNKSIZE;
293
4.94M
    }
294
5.15M
    if (len > 0) {
295
        /* Simple middle case (complete destination chunks). */
296
3.09M
#ifdef S_SKEW
297
3.09M
        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
144k
            {
308
878k
                do {
309
878k
                    FETCH_T;
310
878k
                    SPECIFIC_CODE(*d, *d, *s++, T);
311
878k
                    d++;
312
878k
                    len -= CHUNKSIZE;
313
878k
                } while (len > 0);
314
144k
            }
315
144k
        } else
316
2.95M
#endif /* !defined(S_SKEW) */
317
2.95M
        {
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
2.95M
            {
329
7.23M
                do {
330
7.23M
                    FETCH_S;
331
7.23M
                    FETCH_T;
332
7.23M
                    SPECIFIC_CODE(*d, *d, S, T);
333
7.23M
                    d++;
334
7.23M
                    len -= CHUNKSIZE;
335
7.23M
                } while (len > 0);
336
2.95M
            }
337
2.95M
        }
338
3.09M
    }
339
    /* Unaligned right hand case */
340
5.15M
    SAFE_FETCH_S(0,skewflags & 4);
341
5.15M
    SAFE_FETCH_T(0,skewflags & 8);
342
5.15M
    SPECIFIC_CODE(D, *d, S, T);
343
5.15M
    *d = (*d & rmask) | (D & ~rmask);
344
5.15M
}
Unexecuted instantiation: gsroprun.c:generic_rop_run1
gsroprun.c:generic_rop_run1_const_t
Line
Count
Source
118
3.78M
{
119
3.78M
#ifndef SPECIFIC_CODE
120
3.78M
    rop_proc     proc = rop_proc_table[op->rop];
121
3.78M
#define SPECIFIC_CODE(OUT_, D_,S_,T_) OUT_ = proc(D_,S_,T_)
122
3.78M
#endif /* !defined(SPECIFIC_CODE) */
123
3.78M
    CHUNK        lmask, rmask;
124
3.78M
#ifdef S_USED
125
#ifdef S_CONST
126
    CHUNK        S = (CHUNK)op->s.c;
127
#else /* !defined(S_CONST) */
128
3.78M
    const CHUNK *s = (CHUNK *)(void *)op->s.b.ptr;
129
3.78M
    CHUNK        S;
130
3.78M
    int          s_skew;
131
3.78M
#endif /* !defined(S_CONST) */
132
#else /* !defined(S_USED) */
133
#define S 0
134
#undef S_CONST
135
#endif /* !defined(S_USED) */
136
3.78M
#ifdef T_USED
137
3.78M
#ifdef T_CONST
138
3.78M
    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
3.78M
#if defined(S_SKEW) || defined(T_SKEW)
149
3.78M
    int skewflags = 0;
150
3.78M
#endif
151
3.78M
    CHUNK        D;
152
3.78M
    int          dpos = op->dpos;
153
3.78M
    CHUNK       *d = (CHUNK *)(void *)d_;
154
155
    /* Align d to CHUNKSIZE */
156
3.78M
    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
3.78M
    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
3.78M
    lmask  = RE((CHUNKONES>>((CHUNKSIZE-1) & dpos)));
167
3.78M
    rmask  = RE((CHUNKONES>>((CHUNKSIZE-1) & len)));
168
3.78M
    if (rmask == CHUNKONES) rmask = 0;
169
170
3.78M
#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
3.78M
    if (op->depth & 1) {
174
#ifdef S_CONST
175
        S |= S<<1;
176
#endif /* !defined(S_CONST) */
177
3.78M
#ifdef T_CONST
178
3.78M
        T |= T<<1;
179
3.78M
#endif /* !defined(T_CONST) */
180
3.78M
    }
181
3.78M
    if (op->depth & 3) {
182
#ifdef S_CONST
183
        S |= S<<2;
184
#endif /* !defined(S_CONST) */
185
3.78M
#ifdef T_CONST
186
3.78M
        T |= T<<2;
187
3.78M
#endif /* !defined(T_CONST) */
188
3.78M
    }
189
3.78M
    if (op->depth & 7) {
190
#ifdef S_CONST
191
        S |= S<<4;
192
#endif /* !defined(S_CONST) */
193
3.78M
#ifdef T_CONST
194
3.78M
        T |= T<<4;
195
3.78M
#endif /* !defined(T_CONST) */
196
3.78M
    }
197
3.78M
#if CHUNKSIZE > 8
198
3.78M
    if (op->depth & 15) {
199
#ifdef S_CONST
200
        S |= S<<8;
201
#endif /* !defined(S_CONST) */
202
3.78M
#ifdef T_CONST
203
3.78M
        T |= T<<8;
204
3.78M
#endif /* !defined(T_CONST) */
205
3.78M
    }
206
3.78M
#endif /* CHUNKSIZE > 8 */
207
3.78M
#if CHUNKSIZE > 16
208
3.78M
    if (op->depth & 31) {
209
#ifdef S_CONST
210
        S |= S<<16;
211
#endif /* !defined(S_CONST) */
212
3.78M
#ifdef T_CONST
213
3.78M
        T |= T<<16;
214
3.78M
#endif /* !defined(T_CONST) */
215
3.78M
    }
216
3.78M
#endif /* CHUNKSIZE > 16 */
217
3.78M
#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
3.78M
#ifdef S_SKEW
226
3.78M
    {
227
3.78M
        int slen, slen2;
228
3.78M
        int spos = op->s.b.pos;
229
3.78M
        ADJUST_TO_CHUNK(s, spos);
230
3.78M
        s_skew = spos - dpos;
231
3.78M
        if (s_skew < 0) {
232
3.44M
            s_skew += CHUNKSIZE;
233
3.44M
            s--;
234
3.44M
            skewflags |= 1; /* Suppress reading off left edge */
235
3.44M
        }
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
3.78M
        slen  = (len + s_skew    + CHUNKSIZE-1) & ~(CHUNKSIZE-1);
241
3.78M
        slen2 = (len + CHUNKSIZE + CHUNKSIZE-1) & ~(CHUNKSIZE-1);
242
3.78M
        if ((s_skew == 0) || (slen < slen2)) {
243
1.93M
            skewflags |= 4; /* Suppress reading off the right edge */
244
1.93M
        }
245
3.78M
    }
246
3.78M
#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
3.78M
    len -= CHUNKSIZE; /* len = bytes to do - CHUNKSIZE */
271
    /* len <= 0 means 1 word or less to do */
272
3.78M
    if (len <= 0) {
273
        /* Short case - starts and ends in the same chunk */
274
4.24k
        lmask &= ~rmask; /* Combined mask = bits to alter */
275
4.24k
        SAFE_FETCH_S(skewflags & 1,skewflags & 4);
276
4.24k
        SAFE_FETCH_T(skewflags & 2,skewflags & 8);
277
4.24k
        SPECIFIC_CODE(D, *d, S, T);
278
4.24k
        *d = (*d & ~lmask) | (D & lmask);
279
4.24k
        return;
280
4.24k
    }
281
3.78M
    if ((lmask != CHUNKONES)
282
235k
#if defined(S_SKEW) || defined(T_SKEW)
283
235k
        || (skewflags & 3)
284
3.78M
#endif
285
3.78M
        ) {
286
        /* Unaligned left hand case */
287
3.54M
        SAFE_FETCH_S(skewflags & 1,s_skew == 0);
288
3.54M
        SAFE_FETCH_T(skewflags & 2,t_skew == 0);
289
3.54M
        SPECIFIC_CODE(D, *d, S, T);
290
3.54M
        *d = (*d & ~lmask) | (D & lmask);
291
3.54M
        d++;
292
3.54M
        len -= CHUNKSIZE;
293
3.54M
    }
294
3.78M
    if (len > 0) {
295
        /* Simple middle case (complete destination chunks). */
296
2.36M
#ifdef S_SKEW
297
2.36M
        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
237k
            {
308
2.95M
                do {
309
2.95M
                    FETCH_T;
310
2.95M
                    SPECIFIC_CODE(*d, *d, *s++, T);
311
2.95M
                    d++;
312
2.95M
                    len -= CHUNKSIZE;
313
2.95M
                } while (len > 0);
314
237k
            }
315
237k
        } else
316
2.12M
#endif /* !defined(S_SKEW) */
317
2.12M
        {
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
2.12M
            {
329
6.91M
                do {
330
6.91M
                    FETCH_S;
331
6.91M
                    FETCH_T;
332
6.91M
                    SPECIFIC_CODE(*d, *d, S, T);
333
6.91M
                    d++;
334
6.91M
                    len -= CHUNKSIZE;
335
6.91M
                } while (len > 0);
336
2.12M
            }
337
2.12M
        }
338
2.36M
    }
339
    /* Unaligned right hand case */
340
3.78M
    SAFE_FETCH_S(0,skewflags & 4);
341
3.78M
    SAFE_FETCH_T(0,skewflags & 8);
342
3.78M
    SPECIFIC_CODE(D, *d, S, T);
343
3.78M
    *d = (*d & rmask) | (D & ~rmask);
344
3.78M
}
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