Instead of writing directly to file_hashes.txt, hash_workers now are using a local arena, writing everything once at the end using #pragma once to ensure that a given header file is included only once in a single compilation unit
93 lines
2.2 KiB
C
93 lines
2.2 KiB
C
#pragma once
|
|
|
|
#include <assert.h>
|
|
#include <immintrin.h>
|
|
#include <stdatomic.h>
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <time.h>
|
|
|
|
#if defined(_WIN32) || defined(_WIN64)
|
|
#define PLATFORM_WINDOWS 1
|
|
#include <aclapi.h>
|
|
#include <fcntl.h>
|
|
#include <io.h>
|
|
#include <sys/stat.h>
|
|
#include <sys/types.h>
|
|
#include <windows.h>
|
|
|
|
#define strdup _strdup
|
|
#else
|
|
#include <dirent.h>
|
|
#include <fcntl.h>
|
|
#include <pthread.h>
|
|
#include <pwd.h>
|
|
#include <sys/stat.h>
|
|
#include <unistd.h>
|
|
#endif
|
|
|
|
#define XXH_VECTOR \
|
|
XXH_AVX2 // not recommanded to compile with gcc see xxhash.h line 4082
|
|
// Must compile with /arch:AVX2 in clang-cl or -mavx2 in clang/gcc
|
|
#define XXH_INLINE_ALL
|
|
#include "xxhash.c"
|
|
#include "xxhash.h"
|
|
|
|
/* ------------------------------------------------------------
|
|
Base types
|
|
------------------------------------------------------------ */
|
|
|
|
typedef uint8_t u8;
|
|
typedef uint16_t u16;
|
|
typedef uint32_t u32;
|
|
typedef uint64_t u64;
|
|
typedef int8_t i8;
|
|
typedef int16_t i16;
|
|
typedef int32_t i32;
|
|
typedef int64_t i64;
|
|
|
|
typedef i8 b8;
|
|
typedef int b32;
|
|
|
|
typedef float f32;
|
|
typedef double f64;
|
|
|
|
/* ------------------------------------------------------------
|
|
Size helpers
|
|
------------------------------------------------------------ */
|
|
|
|
#define KiB(x) ((u64)(x) * 1024ULL)
|
|
#define MiB(x) (KiB(x) * 1024ULL)
|
|
#define GiB(x) (MiB(x) * 1024ULL)
|
|
|
|
/* ------------------------------------------------------------
|
|
Min / Max helpers
|
|
------------------------------------------------------------ */
|
|
|
|
#ifndef MIN
|
|
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
|
#endif
|
|
|
|
#ifndef MAX
|
|
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
|
#endif
|
|
|
|
/* ------------------------------------------------------------
|
|
Alignment helpers
|
|
------------------------------------------------------------ */
|
|
|
|
#define ALIGN_UP_POW2(x, a) ((a) ? (((x) + ((a) - 1)) & ~((a) - 1)) : (x))
|
|
|
|
/* ------------------------------------------------------------
|
|
Assert
|
|
------------------------------------------------------------ */
|
|
|
|
#ifndef ASSERT
|
|
#define ASSERT(x) assert(x)
|
|
#endif
|
|
|
|
#define NDEBUG // Comment to enable asserts
|