Rizin
unix-like reverse engineering framework and cli tools
crc32_small.c File Reference

CRC32 calculation (size-optimized) More...

#include "check.h"

Go to the source code of this file.

Functions

static void crc32_init (void)
 
void lzma_crc32_init (void)
 
 LZMA_API (uint32_t)
 

Variables

uint32_t lzma_crc32_table [1][256]
 

Detailed Description

CRC32 calculation (size-optimized)

Definition in file crc32_small.c.

Function Documentation

◆ crc32_init()

static void crc32_init ( void  )
static

Definition at line 20 of file crc32_small.c.

21 {
22  static const uint32_t poly32 = UINT32_C(0xEDB88320);
23 
24  for (size_t b = 0; b < 256; ++b) {
25  uint32_t r = b;
26  for (size_t i = 0; i < 8; ++i) {
27  if (r & 1)
28  r = (r >> 1) ^ poly32;
29  else
30  r >>= 1;
31  }
32 
33  lzma_crc32_table[0][b] = r;
34  }
35 
36  return;
37 }
lzma_index ** i
Definition: index.h:629
uint32_t lzma_crc32_table[1][256]
Definition: crc32_small.c:16
#define r
Definition: crypto_rc6.c:12
unsigned int uint32_t
Definition: sftypes.h:29
#define b(i)
Definition: sha256.c:42
#define UINT32_C(val)

References b, i, lzma_crc32_table, r, and UINT32_C.

Referenced by lzma_crc32_init().

◆ LZMA_API()

LZMA_API ( uint32_t  )

Definition at line 48 of file crc32_small.c.

50 {
52 
53  crc = ~crc;
54 
55  while (size != 0) {
56  crc = lzma_crc32_table[0][*buf++ ^ (crc & 0xFF)] ^ (crc >> 8);
57  --size;
58  }
59 
60  return ~crc;
61 }
void lzma_crc32_init(void)
Definition: crc32_small.c:41
voidpf void uLong size
Definition: ioapi.h:138
voidpf void * buf
Definition: ioapi.h:138

References lzma_crc32_init(), and lzma_crc32_table.

◆ lzma_crc32_init()

void lzma_crc32_init ( void  )

Definition at line 41 of file crc32_small.c.

42 {
44  return;
45 }
static void crc32_init(void)
Definition: crc32_small.c:20
#define mythread_once(func)
Definition: mythread.h:72

References crc32_init(), and mythread_once.

Referenced by LZMA_API(), and lzma_lz_encoder_init().

Variable Documentation

◆ lzma_crc32_table

uint32_t lzma_crc32_table[1][256]

lzma_crc32_table[0] is needed by LZ encoder so we need to keep the array two-dimensional.

Definition at line 16 of file crc32_small.c.

Referenced by crc32_init(), and LZMA_API().