Loading...
Searching...
No Matches
xor.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2021 Benjamin Valentin <benjamin.valentin@ml-pa.com>
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser
5 * General Public License v2.1. See the file LICENSE in the top level
6 * directory for more details.
7 */
8
9#pragma once
10
28
29#include <stddef.h>
30#include <stdint.h>
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
39#ifndef CONFIG_CODING_XOR_CHECK_BYTES
40#define CONFIG_CODING_XOR_CHECK_BYTES 3U
41#endif
42
48#define CODING_XOR_PARITY_LEN(in) (((in) + CONFIG_CODING_XOR_CHECK_BYTES - 1) \
49 / CONFIG_CODING_XOR_CHECK_BYTES)
50
64void coding_xor_generate(void *data, size_t len, uint8_t *parity);
65
85bool coding_xor_recover(void *data, size_t len, uint8_t *parity,
86 uint8_t *blocks, size_t block_size, bool recover_parity);
87#ifdef __cplusplus
88}
89#endif
90
void coding_xor_generate(void *data, size_t len, uint8_t *parity)
Generate parity and mix data buffer.
bool coding_xor_recover(void *data, size_t len, uint8_t *parity, uint8_t *blocks, size_t block_size, bool recover_parity)
Restore and unmix buffer.