mirror of
https://git.wownero.com/wownero/RandomWOW.git
synced 2025-01-03 05:38:54 +00:00
32d827d0a6
Fixed some undefined behavior with signed types Fixed different results on big endian systems Removed unused code files Restored FNEG_R instructions Updated documentation
68 lines
1.7 KiB
C
68 lines
1.7 KiB
C
/*
|
|
Copyright (c) 2018 tevador
|
|
|
|
This file is part of RandomX.
|
|
|
|
RandomX is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
RandomX is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with RandomX. If not, see<http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
/* Original code from Argon2 reference source code package used under CC0 Licence
|
|
* https://github.com/P-H-C/phc-winner-argon2
|
|
* Copyright 2015
|
|
* Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves
|
|
*/
|
|
|
|
#ifndef PORTABLE_BLAKE2_IMPL_H
|
|
#define PORTABLE_BLAKE2_IMPL_H
|
|
|
|
#include <stdint.h>
|
|
|
|
#include "endian.h"
|
|
|
|
static FORCE_INLINE uint64_t load48(const void *src) {
|
|
const uint8_t *p = (const uint8_t *)src;
|
|
uint64_t w = *p++;
|
|
w |= (uint64_t)(*p++) << 8;
|
|
w |= (uint64_t)(*p++) << 16;
|
|
w |= (uint64_t)(*p++) << 24;
|
|
w |= (uint64_t)(*p++) << 32;
|
|
w |= (uint64_t)(*p++) << 40;
|
|
return w;
|
|
}
|
|
|
|
static FORCE_INLINE void store48(void *dst, uint64_t w) {
|
|
uint8_t *p = (uint8_t *)dst;
|
|
*p++ = (uint8_t)w;
|
|
w >>= 8;
|
|
*p++ = (uint8_t)w;
|
|
w >>= 8;
|
|
*p++ = (uint8_t)w;
|
|
w >>= 8;
|
|
*p++ = (uint8_t)w;
|
|
w >>= 8;
|
|
*p++ = (uint8_t)w;
|
|
w >>= 8;
|
|
*p++ = (uint8_t)w;
|
|
}
|
|
|
|
static FORCE_INLINE uint32_t rotr32(const uint32_t w, const unsigned c) {
|
|
return (w >> c) | (w << (32 - c));
|
|
}
|
|
|
|
static FORCE_INLINE uint64_t rotr64(const uint64_t w, const unsigned c) {
|
|
return (w >> c) | (w << (64 - c));
|
|
}
|
|
|
|
#endif
|