1 /* { dg-require-effective-target int32plus } */
2 /* { dg-require-effective-target size24plus } */
4 /* Reduced from coreutils's cksum.c: cksum_slice8 */
6 typedef long unsigned int size_t;
7 typedef unsigned int __uint32_t
;
8 typedef unsigned long int __uintmax_t
;
9 typedef struct _IO_FILE
FILE;
16 fread_unlocked(void* __restrict __ptr
,
19 FILE* __restrict __stream
);
21 feof_unlocked(FILE* __stream
) __attribute__((__nothrow__
, __leaf__
));
23 ferror_unlocked(FILE* __stream
) __attribute__((__nothrow__
, __leaf__
));
24 static __inline __uint32_t
25 __bswap_32(__uint32_t __bsx
)
28 return __builtin_bswap32(__bsx
);
30 typedef __uint32_t
uint32_t;
31 typedef unsigned long int uint_fast32_t;
32 typedef __uintmax_t
uintmax_t;
34 __errno_location(void) __attribute__((__nothrow__
, __leaf__
))
35 __attribute__((__const__
));
36 extern uint_fast32_t const crctab
[8][256];
39 cksum_slice8(FILE* fp
, uint_fast32_t* crc_out
, uintmax_t* length_out
)
41 uint32_t buf
[(1 << 16) / sizeof(uint32_t)];
42 uint_fast32_t crc
= 0;
46 if (!fp
|| !crc_out
|| !length_out
)
49 while ((bytes_read
= fread_unlocked(buf
, 1, (1 << 16), fp
)) > 0) {
52 if (length
+ bytes_read
< length
) {
54 (*__errno_location()) = 75;
59 if (bytes_read
== 0) {
60 if (ferror_unlocked(fp
))
64 datap
= (uint32_t*)buf
;
65 while (bytes_read
>= 8) {
66 uint32_t first
= *datap
++, second
= *datap
++; /* { dg-bogus "use of uninitialized value" "PR analyzer/108664" } */
67 crc
^= __bswap_32(first
);
68 second
= __bswap_32(second
);
70 (crctab
[7][(crc
>> 24) & 0xFF] ^ crctab
[6][(crc
>> 16) & 0xFF] ^
71 crctab
[5][(crc
>> 8) & 0xFF] ^ crctab
[4][(crc
)&0xFF] ^
72 crctab
[3][(second
>> 24) & 0xFF] ^ crctab
[2][(second
>> 16) & 0xFF] ^
73 crctab
[1][(second
>> 8) & 0xFF] ^ crctab
[0][(second
)&0xFF]);
77 unsigned char* cp
= (unsigned char*)datap
;
79 crc
= (crc
<< 8) ^ crctab
[0][((crc
>> 24) ^ *cp
++) & 0xFF];
80 if (feof_unlocked(fp
))