Coverage Report

Created: 2025-08-28 07:06

/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
1.77G
#define CHUNKSIZE 32
64
301M
#define CHUNK unsigned int
65
148M
#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
148M
    do { int offset = ((ROP_PTRDIFF_T)d) & ((CHUNKSIZE>>3)-1);  \
74
148M
         d = (CHUNK *)(void *)(((byte *)(void *)d)-offset);   \
75
148M
         dpos += offset<<3;                           \
76
148M
     } 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
855M
#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
570M
    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
135M
    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
570M
#define FETCH_S           SKEW_FETCH(S,s,s_skew)
102
135M
#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
74.2M
{
119
#ifndef SPECIFIC_CODE
120
    rop_proc     proc = rop_proc_table[op->rop];
121
20.9M
#define SPECIFIC_CODE(OUT_, D_,S_,T_) OUT_ = proc(D_,S_,T_)
122
#endif /* !defined(SPECIFIC_CODE) */
123
74.2M
    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
74.2M
    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
4.67M
    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
74.2M
    CHUNK        D;
152
74.2M
    int          dpos = op->dpos;
153
74.2M
    CHUNK       *d = (CHUNK *)(void *)d_;
154
155
    /* Align d to CHUNKSIZE */
156
74.2M
    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
74.2M
    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
74.2M
    lmask  = RE((CHUNKONES>>((CHUNKSIZE-1) & dpos)));
167
74.2M
    rmask  = RE((CHUNKONES>>((CHUNKSIZE-1) & len)));
168
74.2M
    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
4.67M
    if (op->depth & 1) {
174
#ifdef S_CONST
175
        S |= S<<1;
176
#endif /* !defined(S_CONST) */
177
4.67M
#ifdef T_CONST
178
4.67M
        T |= T<<1;
179
4.67M
#endif /* !defined(T_CONST) */
180
4.67M
    }
181
4.67M
    if (op->depth & 3) {
182
#ifdef S_CONST
183
        S |= S<<2;
184
#endif /* !defined(S_CONST) */
185
4.67M
#ifdef T_CONST
186
4.67M
        T |= T<<2;
187
4.67M
#endif /* !defined(T_CONST) */
188
4.67M
    }
189
4.67M
    if (op->depth & 7) {
190
#ifdef S_CONST
191
        S |= S<<4;
192
#endif /* !defined(S_CONST) */
193
4.67M
#ifdef T_CONST
194
4.67M
        T |= T<<4;
195
4.67M
#endif /* !defined(T_CONST) */
196
4.67M
    }
197
#if CHUNKSIZE > 8
198
4.67M
    if (op->depth & 15) {
199
#ifdef S_CONST
200
        S |= S<<8;
201
#endif /* !defined(S_CONST) */
202
4.67M
#ifdef T_CONST
203
4.67M
        T |= T<<8;
204
4.67M
#endif /* !defined(T_CONST) */
205
4.67M
    }
206
#endif /* CHUNKSIZE > 8 */
207
#if CHUNKSIZE > 16
208
4.67M
    if (op->depth & 31) {
209
#ifdef S_CONST
210
        S |= S<<16;
211
#endif /* !defined(S_CONST) */
212
4.67M
#ifdef T_CONST
213
4.67M
        T |= T<<16;
214
4.67M
#endif /* !defined(T_CONST) */
215
4.67M
    }
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
74.2M
        ADJUST_TO_CHUNK(s, spos);
230
        s_skew = spos - dpos;
231
74.2M
        if (s_skew < 0) {
232
56.2M
            s_skew += CHUNKSIZE;
233
56.2M
            s--;
234
56.2M
            skewflags |= 1; /* Suppress reading off left edge */
235
56.2M
        }
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
74.2M
        slen  = (len + s_skew    + CHUNKSIZE-1) & ~(CHUNKSIZE-1);
241
74.2M
        slen2 = (len + CHUNKSIZE + CHUNKSIZE-1) & ~(CHUNKSIZE-1);
242
74.2M
        if ((s_skew == 0) || (slen < slen2)) {
243
41.3M
            skewflags |= 4; /* Suppress reading off the right edge */
244
41.3M
        }
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
74.2M
    len -= CHUNKSIZE; /* len = bytes to do - CHUNKSIZE */
271
    /* len <= 0 means 1 word or less to do */
272
74.2M
    if (len <= 0) {
273
        /* Short case - starts and ends in the same chunk */
274
361k
        lmask &= ~rmask; /* Combined mask = bits to alter */
275
361k
        SAFE_FETCH_S(skewflags & 1,skewflags & 4);
276
361k
        SAFE_FETCH_T(skewflags & 2,skewflags & 8);
277
361k
        SPECIFIC_CODE(D, *d, S, T);
278
361k
        *d = (*d & ~lmask) | (D & lmask);
279
361k
        return;
280
361k
    }
281
73.9M
    if ((lmask != CHUNKONES)
282
#if defined(S_SKEW) || defined(T_SKEW)
283
12.3M
        || (skewflags & 3)
284
#endif
285
73.9M
        ) {
286
        /* Unaligned left hand case */
287
61.5M
        SAFE_FETCH_S(skewflags & 1,s_skew == 0);
288
61.5M
        SAFE_FETCH_T(skewflags & 2,t_skew == 0);
289
61.5M
        SPECIFIC_CODE(D, *d, S, T);
290
61.5M
        *d = (*d & ~lmask) | (D & lmask);
291
61.5M
        d++;
292
61.5M
        len -= CHUNKSIZE;
293
61.5M
    }
294
73.9M
    if (len > 0) {
295
        /* Simple middle case (complete destination chunks). */
296
#ifdef S_SKEW
297
54.5M
        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
491M
                do {
309
491M
                    FETCH_T;
310
491M
                    SPECIFIC_CODE(*d, *d, *s++, T);
311
491M
                    d++;
312
491M
                    len -= CHUNKSIZE;
313
491M
                } while (len > 0);
314
0
            }
315
12.6M
        } else
316
41.9M
#endif /* !defined(S_SKEW) */
317
41.9M
        {
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
570M
                do {
330
570M
                    FETCH_S;
331
570M
                    FETCH_T;
332
570M
                    SPECIFIC_CODE(*d, *d, S, T);
333
570M
                    d++;
334
570M
                    len -= CHUNKSIZE;
335
570M
                } while (len > 0);
336
0
            }
337
41.9M
        }
338
54.5M
    }
339
    /* Unaligned right hand case */
340
73.9M
    SAFE_FETCH_S(0,skewflags & 4);
341
73.9M
    SAFE_FETCH_T(0,skewflags & 8);
342
73.9M
    SPECIFIC_CODE(D, *d, S, T);
343
73.9M
    *d = (*d & rmask) | (D & ~rmask);
344
73.9M
}
gsroprun.c:notS_rop_run1_const_t
Line
Count
Source
118
169k
{
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
169k
    CHUNK        lmask, rmask;
124
169k
#ifdef S_USED
125
#ifdef S_CONST
126
    CHUNK        S = (CHUNK)op->s.c;
127
#else /* !defined(S_CONST) */
128
169k
    const CHUNK *s = (CHUNK *)(void *)op->s.b.ptr;
129
169k
    CHUNK        S;
130
169k
    int          s_skew;
131
169k
#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
169k
#define T 0
146
169k
#undef T_CONST
147
169k
#endif /* !defined(T_USED) */
148
169k
#if defined(S_SKEW) || defined(T_SKEW)
149
169k
    int skewflags = 0;
150
169k
#endif
151
169k
    CHUNK        D;
152
169k
    int          dpos = op->dpos;
153
169k
    CHUNK       *d = (CHUNK *)(void *)d_;
154
155
    /* Align d to CHUNKSIZE */
156
169k
    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
169k
    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
169k
    lmask  = RE((CHUNKONES>>((CHUNKSIZE-1) & dpos)));
167
169k
    rmask  = RE((CHUNKONES>>((CHUNKSIZE-1) & len)));
168
169k
    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
169k
#ifdef S_SKEW
226
169k
    {
227
169k
        int slen, slen2;
228
169k
        int spos = op->s.b.pos;
229
169k
        ADJUST_TO_CHUNK(s, spos);
230
169k
        s_skew = spos - dpos;
231
169k
        if (s_skew < 0) {
232
88.2k
            s_skew += CHUNKSIZE;
233
88.2k
            s--;
234
88.2k
            skewflags |= 1; /* Suppress reading off left edge */
235
88.2k
        }
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
169k
        slen  = (len + s_skew    + CHUNKSIZE-1) & ~(CHUNKSIZE-1);
241
169k
        slen2 = (len + CHUNKSIZE + CHUNKSIZE-1) & ~(CHUNKSIZE-1);
242
169k
        if ((s_skew == 0) || (slen < slen2)) {
243
153k
            skewflags |= 4; /* Suppress reading off the right edge */
244
153k
        }
245
169k
    }
246
169k
#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
169k
    len -= CHUNKSIZE; /* len = bytes to do - CHUNKSIZE */
271
    /* len <= 0 means 1 word or less to do */
272
169k
    if (len <= 0) {
273
        /* Short case - starts and ends in the same chunk */
274
3
        lmask &= ~rmask; /* Combined mask = bits to alter */
275
3
        SAFE_FETCH_S(skewflags & 1,skewflags & 4);
276
3
        SAFE_FETCH_T(skewflags & 2,skewflags & 8);
277
3
        SPECIFIC_CODE(D, *d, S, T);
278
3
        *d = (*d & ~lmask) | (D & lmask);
279
3
        return;
280
3
    }
281
169k
    if ((lmask != CHUNKONES)
282
169k
#if defined(S_SKEW) || defined(T_SKEW)
283
169k
        || (skewflags & 3)
284
169k
#endif
285
169k
        ) {
286
        /* Unaligned left hand case */
287
115k
        SAFE_FETCH_S(skewflags & 1,s_skew == 0);
288
115k
        SAFE_FETCH_T(skewflags & 2,t_skew == 0);
289
115k
        SPECIFIC_CODE(D, *d, S, T);
290
115k
        *d = (*d & ~lmask) | (D & lmask);
291
115k
        d++;
292
115k
        len -= CHUNKSIZE;
293
115k
    }
294
169k
    if (len > 0) {
295
        /* Simple middle case (complete destination chunks). */
296
169k
#ifdef S_SKEW
297
169k
        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
75.2k
            {
308
2.97M
                do {
309
2.97M
                    FETCH_T;
310
2.97M
                    SPECIFIC_CODE(*d, *d, *s++, T);
311
2.97M
                    d++;
312
2.97M
                    len -= CHUNKSIZE;
313
2.97M
                } while (len > 0);
314
75.2k
            }
315
75.2k
        } else
316
94.2k
#endif /* !defined(S_SKEW) */
317
94.2k
        {
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
94.2k
            {
329
973k
                do {
330
973k
                    FETCH_S;
331
973k
                    FETCH_T;
332
973k
                    SPECIFIC_CODE(*d, *d, S, T);
333
973k
                    d++;
334
973k
                    len -= CHUNKSIZE;
335
973k
                } while (len > 0);
336
94.2k
            }
337
94.2k
        }
338
169k
    }
339
    /* Unaligned right hand case */
340
169k
    SAFE_FETCH_S(0,skewflags & 4);
341
169k
    SAFE_FETCH_T(0,skewflags & 8);
342
169k
    SPECIFIC_CODE(D, *d, S, T);
343
169k
    *d = (*d & rmask) | (D & ~rmask);
344
169k
}
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
64.6M
{
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
64.6M
    CHUNK        lmask, rmask;
124
64.6M
#ifdef S_USED
125
#ifdef S_CONST
126
    CHUNK        S = (CHUNK)op->s.c;
127
#else /* !defined(S_CONST) */
128
64.6M
    const CHUNK *s = (CHUNK *)(void *)op->s.b.ptr;
129
64.6M
    CHUNK        S;
130
64.6M
    int          s_skew;
131
64.6M
#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
64.6M
#define T 0
146
64.6M
#undef T_CONST
147
64.6M
#endif /* !defined(T_USED) */
148
64.6M
#if defined(S_SKEW) || defined(T_SKEW)
149
64.6M
    int skewflags = 0;
150
64.6M
#endif
151
64.6M
    CHUNK        D;
152
64.6M
    int          dpos = op->dpos;
153
64.6M
    CHUNK       *d = (CHUNK *)(void *)d_;
154
155
    /* Align d to CHUNKSIZE */
156
64.6M
    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
64.6M
    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
64.6M
    lmask  = RE((CHUNKONES>>((CHUNKSIZE-1) & dpos)));
167
64.6M
    rmask  = RE((CHUNKONES>>((CHUNKSIZE-1) & len)));
168
64.6M
    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
64.6M
#ifdef S_SKEW
226
64.6M
    {
227
64.6M
        int slen, slen2;
228
64.6M
        int spos = op->s.b.pos;
229
64.6M
        ADJUST_TO_CHUNK(s, spos);
230
64.6M
        s_skew = spos - dpos;
231
64.6M
        if (s_skew < 0) {
232
47.4M
            s_skew += CHUNKSIZE;
233
47.4M
            s--;
234
47.4M
            skewflags |= 1; /* Suppress reading off left edge */
235
47.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
64.6M
        slen  = (len + s_skew    + CHUNKSIZE-1) & ~(CHUNKSIZE-1);
241
64.6M
        slen2 = (len + CHUNKSIZE + CHUNKSIZE-1) & ~(CHUNKSIZE-1);
242
64.6M
        if ((s_skew == 0) || (slen < slen2)) {
243
36.5M
            skewflags |= 4; /* Suppress reading off the right edge */
244
36.5M
        }
245
64.6M
    }
246
64.6M
#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
64.6M
    len -= CHUNKSIZE; /* len = bytes to do - CHUNKSIZE */
271
    /* len <= 0 means 1 word or less to do */
272
64.6M
    if (len <= 0) {
273
        /* Short case - starts and ends in the same chunk */
274
346k
        lmask &= ~rmask; /* Combined mask = bits to alter */
275
346k
        SAFE_FETCH_S(skewflags & 1,skewflags & 4);
276
346k
        SAFE_FETCH_T(skewflags & 2,skewflags & 8);
277
346k
        SPECIFIC_CODE(D, *d, S, T);
278
346k
        *d = (*d & ~lmask) | (D & lmask);
279
346k
        return;
280
346k
    }
281
64.3M
    if ((lmask != CHUNKONES)
282
64.3M
#if defined(S_SKEW) || defined(T_SKEW)
283
64.3M
        || (skewflags & 3)
284
64.3M
#endif
285
64.3M
        ) {
286
        /* Unaligned left hand case */
287
52.5M
        SAFE_FETCH_S(skewflags & 1,s_skew == 0);
288
52.5M
        SAFE_FETCH_T(skewflags & 2,t_skew == 0);
289
52.5M
        SPECIFIC_CODE(D, *d, S, T);
290
52.5M
        *d = (*d & ~lmask) | (D & lmask);
291
52.5M
        d++;
292
52.5M
        len -= CHUNKSIZE;
293
52.5M
    }
294
64.3M
    if (len > 0) {
295
        /* Simple middle case (complete destination chunks). */
296
48.5M
#ifdef S_SKEW
297
48.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
12.1M
            {
308
484M
                do {
309
484M
                    FETCH_T;
310
484M
                    SPECIFIC_CODE(*d, *d, *s++, T);
311
484M
                    d++;
312
484M
                    len -= CHUNKSIZE;
313
484M
                } while (len > 0);
314
12.1M
            }
315
12.1M
        } else
316
36.4M
#endif /* !defined(S_SKEW) */
317
36.4M
        {
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
36.4M
            {
329
553M
                do {
330
553M
                    FETCH_S;
331
553M
                    FETCH_T;
332
553M
                    SPECIFIC_CODE(*d, *d, S, T);
333
553M
                    d++;
334
553M
                    len -= CHUNKSIZE;
335
553M
                } while (len > 0);
336
36.4M
            }
337
36.4M
        }
338
48.5M
    }
339
    /* Unaligned right hand case */
340
64.3M
    SAFE_FETCH_S(0,skewflags & 4);
341
64.3M
    SAFE_FETCH_T(0,skewflags & 8);
342
64.3M
    SPECIFIC_CODE(D, *d, S, T);
343
64.3M
    *d = (*d & rmask) | (D & ~rmask);
344
64.3M
}
gsroprun.c:dors_rop_run1_const_t
Line
Count
Source
118
4.79M
{
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.79M
    CHUNK        lmask, rmask;
124
4.79M
#ifdef S_USED
125
#ifdef S_CONST
126
    CHUNK        S = (CHUNK)op->s.c;
127
#else /* !defined(S_CONST) */
128
4.79M
    const CHUNK *s = (CHUNK *)(void *)op->s.b.ptr;
129
4.79M
    CHUNK        S;
130
4.79M
    int          s_skew;
131
4.79M
#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.79M
#define T 0
146
4.79M
#undef T_CONST
147
4.79M
#endif /* !defined(T_USED) */
148
4.79M
#if defined(S_SKEW) || defined(T_SKEW)
149
4.79M
    int skewflags = 0;
150
4.79M
#endif
151
4.79M
    CHUNK        D;
152
4.79M
    int          dpos = op->dpos;
153
4.79M
    CHUNK       *d = (CHUNK *)(void *)d_;
154
155
    /* Align d to CHUNKSIZE */
156
4.79M
    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.79M
    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.79M
    lmask  = RE((CHUNKONES>>((CHUNKSIZE-1) & dpos)));
167
4.79M
    rmask  = RE((CHUNKONES>>((CHUNKSIZE-1) & len)));
168
4.79M
    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.79M
#ifdef S_SKEW
226
4.79M
    {
227
4.79M
        int slen, slen2;
228
4.79M
        int spos = op->s.b.pos;
229
4.79M
        ADJUST_TO_CHUNK(s, spos);
230
4.79M
        s_skew = spos - dpos;
231
4.79M
        if (s_skew < 0) {
232
4.53M
            s_skew += CHUNKSIZE;
233
4.53M
            s--;
234
4.53M
            skewflags |= 1; /* Suppress reading off left edge */
235
4.53M
        }
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.79M
        slen  = (len + s_skew    + CHUNKSIZE-1) & ~(CHUNKSIZE-1);
241
4.79M
        slen2 = (len + CHUNKSIZE + CHUNKSIZE-1) & ~(CHUNKSIZE-1);
242
4.79M
        if ((s_skew == 0) || (slen < slen2)) {
243
2.21M
            skewflags |= 4; /* Suppress reading off the right edge */
244
2.21M
        }
245
4.79M
    }
246
4.79M
#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.79M
    len -= CHUNKSIZE; /* len = bytes to do - CHUNKSIZE */
271
    /* len <= 0 means 1 word or less to do */
272
4.79M
    if (len <= 0) {
273
        /* Short case - starts and ends in the same chunk */
274
9.51k
        lmask &= ~rmask; /* Combined mask = bits to alter */
275
9.51k
        SAFE_FETCH_S(skewflags & 1,skewflags & 4);
276
9.51k
        SAFE_FETCH_T(skewflags & 2,skewflags & 8);
277
9.51k
        SPECIFIC_CODE(D, *d, S, T);
278
9.51k
        *d = (*d & ~lmask) | (D & lmask);
279
9.51k
        return;
280
9.51k
    }
281
4.78M
    if ((lmask != CHUNKONES)
282
4.78M
#if defined(S_SKEW) || defined(T_SKEW)
283
4.78M
        || (skewflags & 3)
284
4.78M
#endif
285
4.78M
        ) {
286
        /* Unaligned left hand case */
287
4.56M
        SAFE_FETCH_S(skewflags & 1,s_skew == 0);
288
4.56M
        SAFE_FETCH_T(skewflags & 2,t_skew == 0);
289
4.56M
        SPECIFIC_CODE(D, *d, S, T);
290
4.56M
        *d = (*d & ~lmask) | (D & lmask);
291
4.56M
        d++;
292
4.56M
        len -= CHUNKSIZE;
293
4.56M
    }
294
4.78M
    if (len > 0) {
295
        /* Simple middle case (complete destination chunks). */
296
2.89M
#ifdef S_SKEW
297
2.89M
        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
147k
            {
308
1.01M
                do {
309
1.01M
                    FETCH_T;
310
1.01M
                    SPECIFIC_CODE(*d, *d, *s++, T);
311
1.01M
                    d++;
312
1.01M
                    len -= CHUNKSIZE;
313
1.01M
                } while (len > 0);
314
147k
            }
315
147k
        } else
316
2.74M
#endif /* !defined(S_SKEW) */
317
2.74M
        {
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.74M
            {
329
7.51M
                do {
330
7.51M
                    FETCH_S;
331
7.51M
                    FETCH_T;
332
7.51M
                    SPECIFIC_CODE(*d, *d, S, T);
333
7.51M
                    d++;
334
7.51M
                    len -= CHUNKSIZE;
335
7.51M
                } while (len > 0);
336
2.74M
            }
337
2.74M
        }
338
2.89M
    }
339
    /* Unaligned right hand case */
340
4.78M
    SAFE_FETCH_S(0,skewflags & 4);
341
4.78M
    SAFE_FETCH_T(0,skewflags & 8);
342
4.78M
    SPECIFIC_CODE(D, *d, S, T);
343
4.78M
    *d = (*d & rmask) | (D & ~rmask);
344
4.78M
}
Unexecuted instantiation: gsroprun.c:generic_rop_run1
gsroprun.c:generic_rop_run1_const_t
Line
Count
Source
118
4.67M
{
119
4.67M
#ifndef SPECIFIC_CODE
120
4.67M
    rop_proc     proc = rop_proc_table[op->rop];
121
4.67M
#define SPECIFIC_CODE(OUT_, D_,S_,T_) OUT_ = proc(D_,S_,T_)
122
4.67M
#endif /* !defined(SPECIFIC_CODE) */
123
4.67M
    CHUNK        lmask, rmask;
124
4.67M
#ifdef S_USED
125
#ifdef S_CONST
126
    CHUNK        S = (CHUNK)op->s.c;
127
#else /* !defined(S_CONST) */
128
4.67M
    const CHUNK *s = (CHUNK *)(void *)op->s.b.ptr;
129
4.67M
    CHUNK        S;
130
4.67M
    int          s_skew;
131
4.67M
#endif /* !defined(S_CONST) */
132
#else /* !defined(S_USED) */
133
#define S 0
134
#undef S_CONST
135
#endif /* !defined(S_USED) */
136
4.67M
#ifdef T_USED
137
4.67M
#ifdef T_CONST
138
4.67M
    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
4.67M
#if defined(S_SKEW) || defined(T_SKEW)
149
4.67M
    int skewflags = 0;
150
4.67M
#endif
151
4.67M
    CHUNK        D;
152
4.67M
    int          dpos = op->dpos;
153
4.67M
    CHUNK       *d = (CHUNK *)(void *)d_;
154
155
    /* Align d to CHUNKSIZE */
156
4.67M
    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.67M
    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.67M
    lmask  = RE((CHUNKONES>>((CHUNKSIZE-1) & dpos)));
167
4.67M
    rmask  = RE((CHUNKONES>>((CHUNKSIZE-1) & len)));
168
4.67M
    if (rmask == CHUNKONES) rmask = 0;
169
170
4.67M
#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
4.67M
    if (op->depth & 1) {
174
#ifdef S_CONST
175
        S |= S<<1;
176
#endif /* !defined(S_CONST) */
177
4.67M
#ifdef T_CONST
178
4.67M
        T |= T<<1;
179
4.67M
#endif /* !defined(T_CONST) */
180
4.67M
    }
181
4.67M
    if (op->depth & 3) {
182
#ifdef S_CONST
183
        S |= S<<2;
184
#endif /* !defined(S_CONST) */
185
4.67M
#ifdef T_CONST
186
4.67M
        T |= T<<2;
187
4.67M
#endif /* !defined(T_CONST) */
188
4.67M
    }
189
4.67M
    if (op->depth & 7) {
190
#ifdef S_CONST
191
        S |= S<<4;
192
#endif /* !defined(S_CONST) */
193
4.67M
#ifdef T_CONST
194
4.67M
        T |= T<<4;
195
4.67M
#endif /* !defined(T_CONST) */
196
4.67M
    }
197
4.67M
#if CHUNKSIZE > 8
198
4.67M
    if (op->depth & 15) {
199
#ifdef S_CONST
200
        S |= S<<8;
201
#endif /* !defined(S_CONST) */
202
4.67M
#ifdef T_CONST
203
4.67M
        T |= T<<8;
204
4.67M
#endif /* !defined(T_CONST) */
205
4.67M
    }
206
4.67M
#endif /* CHUNKSIZE > 8 */
207
4.67M
#if CHUNKSIZE > 16
208
4.67M
    if (op->depth & 31) {
209
#ifdef S_CONST
210
        S |= S<<16;
211
#endif /* !defined(S_CONST) */
212
4.67M
#ifdef T_CONST
213
4.67M
        T |= T<<16;
214
4.67M
#endif /* !defined(T_CONST) */
215
4.67M
    }
216
4.67M
#endif /* CHUNKSIZE > 16 */
217
4.67M
#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.67M
#ifdef S_SKEW
226
4.67M
    {
227
4.67M
        int slen, slen2;
228
4.67M
        int spos = op->s.b.pos;
229
4.67M
        ADJUST_TO_CHUNK(s, spos);
230
4.67M
        s_skew = spos - dpos;
231
4.67M
        if (s_skew < 0) {
232
4.26M
            s_skew += CHUNKSIZE;
233
4.26M
            s--;
234
4.26M
            skewflags |= 1; /* Suppress reading off left edge */
235
4.26M
        }
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.67M
        slen  = (len + s_skew    + CHUNKSIZE-1) & ~(CHUNKSIZE-1);
241
4.67M
        slen2 = (len + CHUNKSIZE + CHUNKSIZE-1) & ~(CHUNKSIZE-1);
242
4.67M
        if ((s_skew == 0) || (slen < slen2)) {
243
2.39M
            skewflags |= 4; /* Suppress reading off the right edge */
244
2.39M
        }
245
4.67M
    }
246
4.67M
#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.67M
    len -= CHUNKSIZE; /* len = bytes to do - CHUNKSIZE */
271
    /* len <= 0 means 1 word or less to do */
272
4.67M
    if (len <= 0) {
273
        /* Short case - starts and ends in the same chunk */
274
5.43k
        lmask &= ~rmask; /* Combined mask = bits to alter */
275
5.43k
        SAFE_FETCH_S(skewflags & 1,skewflags & 4);
276
5.43k
        SAFE_FETCH_T(skewflags & 2,skewflags & 8);
277
5.43k
        SPECIFIC_CODE(D, *d, S, T);
278
5.43k
        *d = (*d & ~lmask) | (D & lmask);
279
5.43k
        return;
280
5.43k
    }
281
4.66M
    if ((lmask != CHUNKONES)
282
4.66M
#if defined(S_SKEW) || defined(T_SKEW)
283
4.66M
        || (skewflags & 3)
284
4.66M
#endif
285
4.66M
        ) {
286
        /* Unaligned left hand case */
287
4.39M
        SAFE_FETCH_S(skewflags & 1,s_skew == 0);
288
4.39M
        SAFE_FETCH_T(skewflags & 2,t_skew == 0);
289
4.39M
        SPECIFIC_CODE(D, *d, S, T);
290
4.39M
        *d = (*d & ~lmask) | (D & lmask);
291
4.39M
        d++;
292
4.39M
        len -= CHUNKSIZE;
293
4.39M
    }
294
4.66M
    if (len > 0) {
295
        /* Simple middle case (complete destination chunks). */
296
2.96M
#ifdef S_SKEW
297
2.96M
        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
293k
            {
308
3.47M
                do {
309
3.47M
                    FETCH_T;
310
3.47M
                    SPECIFIC_CODE(*d, *d, *s++, T);
311
3.47M
                    d++;
312
3.47M
                    len -= CHUNKSIZE;
313
3.47M
                } while (len > 0);
314
293k
            }
315
293k
        } else
316
2.67M
#endif /* !defined(S_SKEW) */
317
2.67M
        {
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.67M
            {
329
8.36M
                do {
330
8.36M
                    FETCH_S;
331
8.36M
                    FETCH_T;
332
8.36M
                    SPECIFIC_CODE(*d, *d, S, T);
333
8.36M
                    d++;
334
8.36M
                    len -= CHUNKSIZE;
335
8.36M
                } while (len > 0);
336
2.67M
            }
337
2.67M
        }
338
2.96M
    }
339
    /* Unaligned right hand case */
340
4.66M
    SAFE_FETCH_S(0,skewflags & 4);
341
4.66M
    SAFE_FETCH_T(0,skewflags & 8);
342
4.66M
    SPECIFIC_CODE(D, *d, S, T);
343
4.66M
    *d = (*d & rmask) | (D & ~rmask);
344
4.66M
}
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