1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-11-26 07:55:01 +00:00
freebsd/lib/libproc/crc32.h
Mark Johnston 76c6531c65 libproc: Improve .gnu_debuglink support.
As of r278658 libproc looks for debug files under /usr/lib/debug and will
use them if available. This change fleshes out that support a bit further:
- Check for a .gnu_debuglink section and use the file name specified
  there if one is present.
- Validate external debug files with the CRC in the .gnu_debuglink
  section so as to avoid using stale or corrupt debug files.
- Search for debug files in the directory containing the referencing
  object or in the .debug subdirectory, as GDB does.
2016-12-06 04:18:09 +00:00

29 lines
532 B
C

/*-
* COPYRIGHT (C) 1986 Gary S. Brown. You may use this program, or
* code or tables extracted from it, as desired without restriction.
*
* $FreeBSD$
*/
#ifndef _CRC32_H_
#define _CRC32_H_
#include <stdint.h> /* uint32_t */
#include <stdlib.h> /* size_t */
extern uint32_t crc32_tab[];
static __inline uint32_t
crc32(const void *buf, size_t size)
{
const uint8_t *p = buf;
uint32_t crc;
crc = ~0U;
while (size--)
crc = crc32_tab[(crc ^ *p++) & 0xFF] ^ (crc >> 8);
return (crc ^ ~0U);
}
#endif /* !_CRC32_H_ */