This file is indexed.

/usr/include/volk/volk_64u_byteswap.h is in libvolk1-dev 1.2.1-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
/* -*- c++ -*- */
/*
 * Copyright 2012, 2014 Free Software Foundation, Inc.
 *
 * This file is part of GNU Radio
 *
 * GNU Radio is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3, or (at your option)
 * any later version.
 *
 * GNU Radio is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with GNU Radio; see the file COPYING.  If not, write to
 * the Free Software Foundation, Inc., 51 Franklin Street,
 * Boston, MA 02110-1301, USA.
 */

/*!
 * \page volk_64u_byteswap
 *
 * \b Overview
 *
 * Byteswaps (in-place) an aligned vector of int64_t's.
 *
 * <b>Dispatcher Prototype</b>
 * \code
 * void volk_64u_byteswap(uint64_t* intsToSwap, unsigned int num_points)
 * \endcode
 *
 * \b Inputs
 * \li intsToSwap: The vector of data to byte swap
 * \li num_points: The number of data points
 *
 * \b Outputs
 * \li intsToSwap: returns as an in-place calculation.
 *
 * \b Example
 * \code
 *   int N = 10;
 *   unsigned int alignment = volk_get_alignment();
 *
 *   uint64_t bitstring[] = {0x0, 0x1, 0xf, 0xffffffffffffffff,
 *       0x5a5a5a5a5a5a5a5a, 0xa5a5a5a5a5a5a5a5, 0x2a2a2a2a2a2a2a2a,
 *       0xffffffff, 0x32, 0x64};
 *   uint64_t hamming_distance = 0;
 *
 *   printf("byteswap vector =\n");
 *   for(unsigned int ii=0; ii<N; ++ii){
 *       printf("    %.16lx\n", bitstring[ii]);
 *   }
 *
 *   volk_64u_byteswap(bitstring, N);
 *
 *   printf("byteswapped vector =\n");
 *   for(unsigned int ii=0; ii<N; ++ii){
 *       printf("    %.16lx\n", bitstring[ii]);
 *   }
 * \endcode
 */

#ifndef INCLUDED_volk_64u_byteswap_u_H
#define INCLUDED_volk_64u_byteswap_u_H

#include <inttypes.h>
#include <stdio.h>

#ifdef LV_HAVE_SSE2
#include <emmintrin.h>

static inline void volk_64u_byteswap_u_sse2(uint64_t* intsToSwap, unsigned int num_points){
    uint32_t* inputPtr = (uint32_t*)intsToSwap;
    __m128i input, byte1, byte2, byte3, byte4, output;
    __m128i byte2mask = _mm_set1_epi32(0x00FF0000);
    __m128i byte3mask = _mm_set1_epi32(0x0000FF00);
    uint64_t number = 0;
    const unsigned int halfPoints = num_points / 2;
    for(;number < halfPoints; number++){
      // Load the 32t values, increment inputPtr later since we're doing it in-place.
      input = _mm_loadu_si128((__m128i*)inputPtr);

      // Do the four shifts
      byte1 = _mm_slli_epi32(input, 24);
      byte2 = _mm_slli_epi32(input, 8);
      byte3 = _mm_srli_epi32(input, 8);
      byte4 = _mm_srli_epi32(input, 24);
      // Or bytes together
      output = _mm_or_si128(byte1, byte4);
      byte2 = _mm_and_si128(byte2, byte2mask);
      output = _mm_or_si128(output, byte2);
      byte3 = _mm_and_si128(byte3, byte3mask);
      output = _mm_or_si128(output, byte3);

      // Reorder the two words
      output = _mm_shuffle_epi32(output, _MM_SHUFFLE(2, 3, 0, 1));

      // Store the results
      _mm_storeu_si128((__m128i*)inputPtr, output);
      inputPtr += 4;
    }

    // Byteswap any remaining points:
    number = halfPoints*2;
    for(; number < num_points; number++){
    uint32_t output1 = *inputPtr;
    uint32_t output2 = inputPtr[1];

    output1 = (((output1 >> 24) & 0xff) | ((output1 >> 8) & 0x0000ff00) | ((output1 << 8) & 0x00ff0000) | ((output1 << 24) & 0xff000000));

    output2 = (((output2 >> 24) & 0xff) | ((output2 >> 8) & 0x0000ff00) | ((output2 << 8) & 0x00ff0000) | ((output2 << 24) & 0xff000000));

    *inputPtr++ = output2;
    *inputPtr++ = output1;
    }
}
#endif /* LV_HAVE_SSE2 */



#ifdef LV_HAVE_GENERIC

static inline void volk_64u_byteswap_generic(uint64_t* intsToSwap, unsigned int num_points){
  uint32_t* inputPtr = (uint32_t*)intsToSwap;
  unsigned int point;
  for(point = 0; point < num_points; point++){
    uint32_t output1 = *inputPtr;
    uint32_t output2 = inputPtr[1];

    output1 = (((output1 >> 24) & 0xff) | ((output1 >> 8) & 0x0000ff00) | ((output1 << 8) & 0x00ff0000) | ((output1 << 24) & 0xff000000));

    output2 = (((output2 >> 24) & 0xff) | ((output2 >> 8) & 0x0000ff00) | ((output2 << 8) & 0x00ff0000) | ((output2 << 24) & 0xff000000));

    *inputPtr++ = output2;
    *inputPtr++ = output1;
  }
}
#endif /* LV_HAVE_GENERIC */

#if LV_HAVE_AVX2
#include <immintrin.h>
static inline void volk_64u_byteswap_a_avx2(uint64_t* intsToSwap, unsigned int num_points)
{
  unsigned int number = 0;

  const unsigned int nPerSet = 4;
  const uint64_t     nSets   = num_points / nPerSet;

  uint32_t* inputPtr = (uint32_t*)intsToSwap;

  const uint8_t shuffleVector[32] = { 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8, 23, 22, 21, 20, 19, 18, 17, 16, 31, 30, 29, 28, 27, 26, 25, 24 };

  const __m256i myShuffle = _mm256_loadu_si256((__m256i*) &shuffleVector[0]);

  for ( ;number < nSets; number++ ) {

    // Load the 32t values, increment inputPtr later since we're doing it in-place.
    const __m256i input  = _mm256_load_si256((__m256i*)inputPtr);
    const __m256i output = _mm256_shuffle_epi8(input, myShuffle);

    // Store the results
    _mm256_store_si256((__m256i*)inputPtr, output);

    /*  inputPtr is 32bit so increment twice  */
    inputPtr += 2 * nPerSet;
  }
  _mm256_zeroupper();

  // Byteswap any remaining points:
  for(number = nSets * nPerSet; number < num_points; ++number ) {
    uint32_t output1 = *inputPtr;
    uint32_t output2 = inputPtr[1];
    uint32_t out1 = ((((output1) >> 24) & 0x000000ff) |
		     (((output1) >>  8) & 0x0000ff00) |
		     (((output1) <<  8) & 0x00ff0000) |
		     (((output1) << 24) & 0xff000000)   );

    uint32_t out2 = ((((output2) >> 24) & 0x000000ff) |
		     (((output2) >>  8) & 0x0000ff00) |
		     (((output2) <<  8) & 0x00ff0000) |
		     (((output2) << 24) & 0xff000000)   );
    *inputPtr++ = out2;
    *inputPtr++ = out1;
  }
}

#endif /* LV_HAVE_AVX2 */


#if LV_HAVE_SSSE3
#include <tmmintrin.h>
static inline void volk_64u_byteswap_a_ssse3(uint64_t* intsToSwap, unsigned int num_points)
{
  unsigned int number = 0;

  const unsigned int nPerSet = 2;
  const uint64_t     nSets   = num_points / nPerSet;

  uint32_t* inputPtr = (uint32_t*)intsToSwap;

  uint8_t shuffleVector[16] = { 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8 };

  const __m128i myShuffle = _mm_loadu_si128((__m128i*) &shuffleVector);

  for ( ;number < nSets; number++ ) {

    // Load the 32t values, increment inputPtr later since we're doing it in-place.
    const __m128i input  = _mm_load_si128((__m128i*)inputPtr);
    const __m128i output = _mm_shuffle_epi8(input,myShuffle);

    // Store the results
    _mm_store_si128((__m128i*)inputPtr, output);

    /*  inputPtr is 32bit so increment twice  */
    inputPtr += 2 * nPerSet;
  }

  // Byteswap any remaining points:
  for(number = nSets * nPerSet; number < num_points; ++number ) {
    uint32_t output1 = *inputPtr;
    uint32_t output2 = inputPtr[1];
    uint32_t out1 = ((((output1) >> 24) & 0x000000ff) |
		     (((output1) >>  8) & 0x0000ff00) |
		     (((output1) <<  8) & 0x00ff0000) |
		     (((output1) << 24) & 0xff000000)   );

    uint32_t out2 = ((((output2) >> 24) & 0x000000ff) |
		     (((output2) >>  8) & 0x0000ff00) |
		     (((output2) <<  8) & 0x00ff0000) |
		     (((output2) << 24) & 0xff000000)   );
    *inputPtr++ = out2;
    *inputPtr++ = out1;
  }
}
#endif /* LV_HAVE_SSSE3 */


#ifdef LV_HAVE_NEON
#include <arm_neon.h>

static inline void volk_64u_byteswap_neon(uint64_t* intsToSwap, unsigned int num_points){
  uint32_t* inputPtr = (uint32_t*)intsToSwap;
  unsigned int number = 0;
  unsigned int n8points = num_points / 4;

  uint8x8x4_t input_table;
  uint8x8_t int_lookup01, int_lookup23, int_lookup45, int_lookup67;
  uint8x8_t swapped_int01, swapped_int23, swapped_int45, swapped_int67;

  /* these magic numbers are used as byte-indeces in the LUT.
     they are pre-computed to save time. A simple C program
     can calculate them; for example for lookup01:
    uint8_t chars[8] = {24, 16, 8, 0, 25, 17, 9, 1};
    for(ii=0; ii < 8; ++ii) {
        index += ((uint64_t)(*(chars+ii))) << (ii*8);
    }
  */
  int_lookup01 = vcreate_u8(2269495096316185);
  int_lookup23 = vcreate_u8(146949840772469531);
  int_lookup45 = vcreate_u8(291630186448622877);
  int_lookup67 = vcreate_u8(436310532124776223);

  for(number = 0; number < n8points; ++number){
    input_table = vld4_u8((uint8_t*) inputPtr);
    swapped_int01 = vtbl4_u8(input_table, int_lookup01);
    swapped_int23 = vtbl4_u8(input_table, int_lookup23);
    swapped_int45 = vtbl4_u8(input_table, int_lookup45);
    swapped_int67 = vtbl4_u8(input_table, int_lookup67);
    vst1_u8((uint8_t*) inputPtr, swapped_int01);
    vst1_u8((uint8_t*) (inputPtr+2), swapped_int23);
    vst1_u8((uint8_t*) (inputPtr+4), swapped_int45);
    vst1_u8((uint8_t*) (inputPtr+6), swapped_int67);

    inputPtr += 4;
  }

  for(number = n8points * 4; number < num_points; ++number){
    uint32_t output1 = *inputPtr;
    uint32_t output2 = inputPtr[1];

    output1 = (((output1 >> 24) & 0xff) | ((output1 >> 8) & 0x0000ff00) | ((output1 << 8) & 0x00ff0000) | ((output1 << 24) & 0xff000000));
    output2 = (((output2 >> 24) & 0xff) | ((output2 >> 8) & 0x0000ff00) | ((output2 << 8) & 0x00ff0000) | ((output2 << 24) & 0xff000000));

    *inputPtr++ = output2;
    *inputPtr++ = output1;
  }

}
#endif /* LV_HAVE_NEON */


#endif /* INCLUDED_volk_64u_byteswap_u_H */
#ifndef INCLUDED_volk_64u_byteswap_a_H
#define INCLUDED_volk_64u_byteswap_a_H

#include <inttypes.h>
#include <stdio.h>


#ifdef LV_HAVE_SSE2
#include <emmintrin.h>

static inline void volk_64u_byteswap_a_sse2(uint64_t* intsToSwap, unsigned int num_points){
    uint32_t* inputPtr = (uint32_t*)intsToSwap;
    __m128i input, byte1, byte2, byte3, byte4, output;
    __m128i byte2mask = _mm_set1_epi32(0x00FF0000);
    __m128i byte3mask = _mm_set1_epi32(0x0000FF00);
    uint64_t number = 0;
    const unsigned int halfPoints = num_points / 2;
    for(;number < halfPoints; number++){
      // Load the 32t values, increment inputPtr later since we're doing it in-place.
      input = _mm_load_si128((__m128i*)inputPtr);

      // Do the four shifts
      byte1 = _mm_slli_epi32(input, 24);
      byte2 = _mm_slli_epi32(input, 8);
      byte3 = _mm_srli_epi32(input, 8);
      byte4 = _mm_srli_epi32(input, 24);
      // Or bytes together
      output = _mm_or_si128(byte1, byte4);
      byte2 = _mm_and_si128(byte2, byte2mask);
      output = _mm_or_si128(output, byte2);
      byte3 = _mm_and_si128(byte3, byte3mask);
      output = _mm_or_si128(output, byte3);

      // Reorder the two words
      output = _mm_shuffle_epi32(output, _MM_SHUFFLE(2, 3, 0, 1));

      // Store the results
      _mm_store_si128((__m128i*)inputPtr, output);
      inputPtr += 4;
    }

    // Byteswap any remaining points:
    number = halfPoints*2;
    for(; number < num_points; number++){
      uint32_t output1 = *inputPtr;
      uint32_t output2 = inputPtr[1];

      output1 = (((output1 >> 24) & 0xff) | ((output1 >> 8) & 0x0000ff00) | ((output1 << 8) & 0x00ff0000) | ((output1 << 24) & 0xff000000));

      output2 = (((output2 >> 24) & 0xff) | ((output2 >> 8) & 0x0000ff00) | ((output2 << 8) & 0x00ff0000) | ((output2 << 24) & 0xff000000));

      *inputPtr++ = output2;
      *inputPtr++ = output1;
    }
}
#endif /* LV_HAVE_SSE2 */

#if LV_HAVE_AVX2
#include <immintrin.h>
static inline void volk_64u_byteswap_u_avx2(uint64_t* intsToSwap, unsigned int num_points)
{
  unsigned int number = 0;

  const unsigned int nPerSet = 4;
  const uint64_t     nSets   = num_points / nPerSet;

  uint32_t* inputPtr = (uint32_t*)intsToSwap;

  const uint8_t shuffleVector[32] = { 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8, 23, 22, 21, 20, 19, 18, 17, 16, 31, 30, 29, 28, 27, 26, 25, 24 };

  const __m256i myShuffle = _mm256_loadu_si256((__m256i*) &shuffleVector[0]);

  for ( ;number < nSets; number++ ) {
    // Load the 32t values, increment inputPtr later since we're doing it in-place.
    const __m256i input  = _mm256_loadu_si256((__m256i*)inputPtr);
    const __m256i output = _mm256_shuffle_epi8(input,myShuffle);

    // Store the results
    _mm256_storeu_si256((__m256i*)inputPtr, output);

    /*  inputPtr is 32bit so increment twice  */
    inputPtr += 2 * nPerSet;
  }
  _mm256_zeroupper();

  // Byteswap any remaining points:
  for(number = nSets * nPerSet; number < num_points; ++number ) {
    uint32_t output1 = *inputPtr;
    uint32_t output2 = inputPtr[1];
    uint32_t out1 = ((((output1) >> 24) & 0x000000ff) |
		     (((output1) >>  8) & 0x0000ff00) |
		     (((output1) <<  8) & 0x00ff0000) |
		     (((output1) << 24) & 0xff000000)   );

    uint32_t out2 = ((((output2) >> 24) & 0x000000ff) |
		     (((output2) >>  8) & 0x0000ff00) |
		     (((output2) <<  8) & 0x00ff0000) |
		     (((output2) << 24) & 0xff000000)   );
    *inputPtr++ = out2;
    *inputPtr++ = out1;
  }
}

#endif /* LV_HAVE_AVX2 */


#if LV_HAVE_SSSE3
#include <tmmintrin.h>
static inline void volk_64u_byteswap_u_ssse3(uint64_t* intsToSwap, unsigned int num_points)
{
  unsigned int number = 0;

  const unsigned int nPerSet = 2;
  const uint64_t     nSets   = num_points / nPerSet;

  uint32_t* inputPtr = (uint32_t*)intsToSwap;

  uint8_t shuffleVector[16] = { 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8 };

  const __m128i myShuffle = _mm_loadu_si128((__m128i*) &shuffleVector);

  for ( ;number < nSets; number++ ) {
    // Load the 32t values, increment inputPtr later since we're doing it in-place.
    const __m128i input  = _mm_loadu_si128((__m128i*)inputPtr);
    const __m128i output = _mm_shuffle_epi8(input,myShuffle);

    // Store the results
    _mm_storeu_si128((__m128i*)inputPtr, output);

    /*  inputPtr is 32bit so increment twice  */
    inputPtr += 2 * nPerSet;
  }

  // Byteswap any remaining points:
  for(number = nSets * nPerSet; number < num_points; ++number ) {
    uint32_t output1 = *inputPtr;
    uint32_t output2 = inputPtr[1];
    uint32_t out1 = ((((output1) >> 24) & 0x000000ff) |
		     (((output1) >>  8) & 0x0000ff00) |
		     (((output1) <<  8) & 0x00ff0000) |
		     (((output1) << 24) & 0xff000000)   );

    uint32_t out2 = ((((output2) >> 24) & 0x000000ff) |
		     (((output2) >>  8) & 0x0000ff00) |
		     (((output2) <<  8) & 0x00ff0000) |
		     (((output2) << 24) & 0xff000000)   );
    *inputPtr++ = out2;
    *inputPtr++ = out1;
  }
}
#endif /* LV_HAVE_SSSE3 */

#ifdef LV_HAVE_GENERIC

static inline void volk_64u_byteswap_a_generic(uint64_t* intsToSwap, unsigned int num_points){
  uint32_t* inputPtr = (uint32_t*)intsToSwap;
  unsigned int point;
  for(point = 0; point < num_points; point++){
    uint32_t output1 = *inputPtr;
    uint32_t output2 = inputPtr[1];

    output1 = (((output1 >> 24) & 0xff) | ((output1 >> 8) & 0x0000ff00) | ((output1 << 8) & 0x00ff0000) | ((output1 << 24) & 0xff000000));

    output2 = (((output2 >> 24) & 0xff) | ((output2 >> 8) & 0x0000ff00) | ((output2 << 8) & 0x00ff0000) | ((output2 << 24) & 0xff000000));

    *inputPtr++ = output2;
    *inputPtr++ = output1;
  }
}
#endif /* LV_HAVE_GENERIC */




#endif /* INCLUDED_volk_64u_byteswap_a_H */