mirror of
https://github.com/Karaka-Management/cOMS.git
synced 2026-01-27 10:08:39 +00:00
fix style
This commit is contained in:
parent
6d3dda5a2f
commit
146dc9afdc
33
.github/workflows/main.yml
vendored
33
.github/workflows/main.yml
vendored
|
|
@ -30,30 +30,9 @@ jobs:
|
|||
run: |
|
||||
chmod +x ./tests/test.sh
|
||||
./tests/test.sh
|
||||
codestyle-tests:
|
||||
runs-on: ubuntu-latest
|
||||
if: "!contains(github.event.head_commit.message, 'NO_CI')"
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@main
|
||||
with:
|
||||
fetch-depth: 0
|
||||
submodules: recursive
|
||||
token: ${{ secrets.GH_TOKEN }}
|
||||
- name: Checkout Build Repository
|
||||
uses: actions/checkout@main
|
||||
with:
|
||||
fetch-depth: 1
|
||||
ref: develop
|
||||
repository: Karaka-Management/Build
|
||||
path: Build
|
||||
- name: Copy config file
|
||||
run: |
|
||||
cp ./Build/Config/.clang-format ./.clang-format
|
||||
- name: Lint Code Base
|
||||
uses: super-linter/super-linter@v6.4.0
|
||||
env:
|
||||
VALIDATE_ALL_CODEBASE: false
|
||||
VALIDATE_CLANG_FORMAT : true
|
||||
DEFAULT_BRANCH: develop
|
||||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
|
||||
general_module_workflow_c:
|
||||
uses: Karaka-Management/Karaka/.github/workflows/c_template.yml@develop
|
||||
secrets:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
GH_PAT: ${{ secrets.GH_PAT }}
|
||||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
||||
|
|
@ -14,8 +14,8 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
#include "../DataStorage/Database/Connection/ConnectionAbstract.h"
|
||||
#include "../Utils/Parser/Json.h"
|
||||
#include "../Threads/Thread.h"
|
||||
#include "../Utils/Parser/Json.h"
|
||||
|
||||
namespace Application
|
||||
{
|
||||
|
|
@ -24,6 +24,6 @@ namespace Application
|
|||
nlohmann::json config;
|
||||
Threads::ThreadPool *pool;
|
||||
} ApplicationAbstract;
|
||||
}
|
||||
} // namespace Application
|
||||
|
||||
#endif
|
||||
|
|
|
|||
72
Hash/MD5.h
72
Hash/MD5.h
|
|
@ -1,9 +1,9 @@
|
|||
#ifndef HASH_MD5_H
|
||||
#define HASH_MD5_H
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
// https://www.rfc-editor.org/rfc/rfc1321
|
||||
|
||||
|
|
@ -12,19 +12,17 @@
|
|||
#define H(x, y, z) ((x) ^ (y) ^ (z))
|
||||
#define I(x, y, z) ((y) ^ ((x) | ~(z)))
|
||||
|
||||
#define ROUND_OP(f, a, b, c, d, x, t, s) \
|
||||
(a) += f((b), (c), (d)) + (x) + (t); \
|
||||
(a) = (((a) << (s)) | (((a) & 0xffffffff) >> (32 - (s)))); \
|
||||
#define ROUND_OP(f, a, b, c, d, x, t, s) \
|
||||
(a) += f((b), (c), (d)) + (x) + (t); \
|
||||
(a) = (((a) << (s)) | (((a) & 0xffffffff) >> (32 - (s)))); \
|
||||
(a) += (b);
|
||||
|
||||
#define SET_BLOCK(n) \
|
||||
(ctx->block[(n)] = \
|
||||
(uint32_t)ptr[(n) * 4] | \
|
||||
((uint32_t)ptr[(n) * 4 + 1] << 8) | \
|
||||
((uint32_t)ptr[(n) * 4 + 2] << 16) | \
|
||||
((uint32_t)ptr[(n) * 4 + 3] << 24))
|
||||
#define SET_BLOCK(n) \
|
||||
(ctx->block[(n)] = (uint32_t) ptr[(n) * 4] | ((uint32_t) ptr[(n) * 4 + 1] << 8) | \
|
||||
((uint32_t) ptr[(n) * 4 + 2] << 16) | ((uint32_t) ptr[(n) * 4 + 3] << 24))
|
||||
|
||||
namespace Hash {
|
||||
namespace Hash
|
||||
{
|
||||
typedef struct {
|
||||
uint32_t lo, hi;
|
||||
uint32_t a, b, c, d;
|
||||
|
|
@ -173,13 +171,13 @@ namespace Hash {
|
|||
}
|
||||
|
||||
memcpy(&ctx->buffer[used], data, free);
|
||||
data = (unsigned char *) data + free;
|
||||
data = (unsigned char *) data + free;
|
||||
size -= free;
|
||||
body(ctx, ctx->buffer, 64);
|
||||
}
|
||||
|
||||
if (size >= 64) {
|
||||
data = body(ctx, data, size & ~(size_t) 0x3f);
|
||||
data = body(ctx, data, size & ~(size_t) 0x3f);
|
||||
size &= 0x3f;
|
||||
}
|
||||
|
||||
|
|
@ -190,9 +188,9 @@ namespace Hash {
|
|||
{
|
||||
uint32_t used, free;
|
||||
|
||||
used = ctx->lo & 0x3f;
|
||||
used = ctx->lo & 0x3f;
|
||||
ctx->buffer[used++] = 0x80;
|
||||
free = 64 - used;
|
||||
free = 64 - used;
|
||||
|
||||
if (free < 8) {
|
||||
memset(&ctx->buffer[used], 0, free);
|
||||
|
|
@ -203,28 +201,28 @@ namespace Hash {
|
|||
|
||||
memset(&ctx->buffer[used], 0, free - 8);
|
||||
|
||||
ctx->lo <<= 3;
|
||||
ctx->buffer[56] = ctx->lo;
|
||||
ctx->buffer[57] = ctx->lo >> 8;
|
||||
ctx->buffer[58] = ctx->lo >> 16;
|
||||
ctx->buffer[59] = ctx->lo >> 24;
|
||||
ctx->buffer[60] = ctx->hi;
|
||||
ctx->buffer[61] = ctx->hi >> 8;
|
||||
ctx->buffer[62] = ctx->hi >> 16;
|
||||
ctx->buffer[63] = ctx->hi >> 24;
|
||||
ctx->lo <<= 3;
|
||||
ctx->buffer[56] = ctx->lo;
|
||||
ctx->buffer[57] = ctx->lo >> 8;
|
||||
ctx->buffer[58] = ctx->lo >> 16;
|
||||
ctx->buffer[59] = ctx->lo >> 24;
|
||||
ctx->buffer[60] = ctx->hi;
|
||||
ctx->buffer[61] = ctx->hi >> 8;
|
||||
ctx->buffer[62] = ctx->hi >> 16;
|
||||
ctx->buffer[63] = ctx->hi >> 24;
|
||||
|
||||
body(ctx, ctx->buffer, 64);
|
||||
|
||||
result[0] = ctx->a;
|
||||
result[1] = ctx->a >> 8;
|
||||
result[2] = ctx->a >> 16;
|
||||
result[3] = ctx->a >> 24;
|
||||
result[4] = ctx->b;
|
||||
result[5] = ctx->b >> 8;
|
||||
result[6] = ctx->b >> 16;
|
||||
result[7] = ctx->b >> 24;
|
||||
result[8] = ctx->c;
|
||||
result[9] = ctx->c >> 8;
|
||||
result[0] = ctx->a;
|
||||
result[1] = ctx->a >> 8;
|
||||
result[2] = ctx->a >> 16;
|
||||
result[3] = ctx->a >> 24;
|
||||
result[4] = ctx->b;
|
||||
result[5] = ctx->b >> 8;
|
||||
result[6] = ctx->b >> 16;
|
||||
result[7] = ctx->b >> 24;
|
||||
result[8] = ctx->c;
|
||||
result[9] = ctx->c >> 8;
|
||||
result[10] = ctx->c >> 16;
|
||||
result[11] = ctx->c >> 24;
|
||||
result[12] = ctx->d;
|
||||
|
|
@ -254,7 +252,7 @@ namespace Hash {
|
|||
|
||||
for (int i = 0; i < 16; ++i) {
|
||||
hexHash[i * 2] = hexChars[hash[i] >> 4];
|
||||
hexHash[(i * 2) + 1] = hexChars[hash[i] & 0x0F];
|
||||
hexHash[(i * 2) + 1] = hexChars[hash[i] & 0x0F];
|
||||
}
|
||||
|
||||
hexHash[16 * 2] = '\0';
|
||||
|
|
@ -262,7 +260,7 @@ namespace Hash {
|
|||
|
||||
return hexHash;
|
||||
}
|
||||
};
|
||||
}; // namespace Hash
|
||||
|
||||
#undef F
|
||||
#undef G
|
||||
|
|
|
|||
435
Hash/MeowHash.h
435
Hash/MeowHash.h
|
|
@ -140,9 +140,9 @@
|
|||
#if __x86_64__ || _M_AMD64
|
||||
#define meow_umm long long unsigned
|
||||
#define MeowU64From(A, I) (_mm_extract_epi64((A), (I)))
|
||||
#elif __i386__ || _M_IX86
|
||||
#elif __i386__ || _M_IX86
|
||||
#define meow_umm int unsigned
|
||||
#define MeowU64From(A, I) (*(meow_u64 *)&(A))
|
||||
#define MeowU64From(A, I) (*(meow_u64 *) &(A))
|
||||
#else
|
||||
#error Cannot determine architecture to use!
|
||||
#endif
|
||||
|
|
@ -166,106 +166,102 @@
|
|||
#define MEOW_PREFETCH_LIMIT 0x3ff
|
||||
#endif
|
||||
|
||||
#define prefetcht0(A) _mm_prefetch((char *)(A), _MM_HINT_T0)
|
||||
#define movdqu(A, B) A = _mm_loadu_si128((__m128i *)(B))
|
||||
#define movdqu_mem(A, B) _mm_storeu_si128((__m128i *)(A), B)
|
||||
#define prefetcht0(A) _mm_prefetch((char *) (A), _MM_HINT_T0)
|
||||
#define movdqu(A, B) A = _mm_loadu_si128((__m128i *) (B))
|
||||
#define movdqu_mem(A, B) _mm_storeu_si128((__m128i *) (A), B)
|
||||
#define movq(A, B) A = _mm_set_epi64x(0, B);
|
||||
#define aesdec(A, B) A = _mm_aesdec_si128(A, B)
|
||||
#define pshufb(A, B) A = _mm_shuffle_epi8(A, B)
|
||||
#define pxor(A, B) A = _mm_xor_si128(A, B)
|
||||
#define aesdec(A, B) A = _mm_aesdec_si128(A, B)
|
||||
#define pshufb(A, B) A = _mm_shuffle_epi8(A, B)
|
||||
#define pxor(A, B) A = _mm_xor_si128(A, B)
|
||||
#define paddq(A, B) A = _mm_add_epi64(A, B)
|
||||
#define pand(A, B) A = _mm_and_si128(A, B)
|
||||
#define pand(A, B) A = _mm_and_si128(A, B)
|
||||
#define palignr(A, B, i) A = _mm_alignr_epi8(A, B, i)
|
||||
#define pxor_clear(A, B) A = _mm_setzero_si128(); // NOTE(casey): pxor_clear is a nonsense thing that is only here because compilers don't detect xor(a, a) is clearing a :(
|
||||
#define pxor_clear(A, B) \
|
||||
A = _mm_setzero_si128(); // NOTE(casey): pxor_clear is a nonsense thing that is only here because compilers
|
||||
// don't detect xor(a, a) is clearing a :(
|
||||
|
||||
#define MEOW_MIX_REG(r1, r2, r3, r4, r5, i1, i2, i3, i4) \
|
||||
aesdec(r1, r2); \
|
||||
INSTRUCTION_REORDER_BARRIER; \
|
||||
paddq(r3, i1); \
|
||||
pxor(r2, i2); \
|
||||
aesdec(r2, r4); \
|
||||
INSTRUCTION_REORDER_BARRIER; \
|
||||
paddq(r5, i3); \
|
||||
#define MEOW_MIX_REG(r1, r2, r3, r4, r5, i1, i2, i3, i4) \
|
||||
aesdec(r1, r2); \
|
||||
INSTRUCTION_REORDER_BARRIER; \
|
||||
paddq(r3, i1); \
|
||||
pxor(r2, i2); \
|
||||
aesdec(r2, r4); \
|
||||
INSTRUCTION_REORDER_BARRIER; \
|
||||
paddq(r5, i3); \
|
||||
pxor(r4, i4);
|
||||
|
||||
#define MEOW_MIX(r1, r2, r3, r4, r5, ptr) \
|
||||
MEOW_MIX_REG(r1, r2, r3, r4, r5, _mm_loadu_si128( (__m128i *) ((ptr) + 15) ), _mm_loadu_si128( (__m128i *) ((ptr) + 0) ), _mm_loadu_si128( (__m128i *) ((ptr) + 1) ), _mm_loadu_si128( (__m128i *) ((ptr) + 16) ))
|
||||
#define MEOW_MIX(r1, r2, r3, r4, r5, ptr) \
|
||||
MEOW_MIX_REG(r1, r2, r3, r4, r5, _mm_loadu_si128((__m128i *) ((ptr) + 15)), \
|
||||
_mm_loadu_si128((__m128i *) ((ptr) + 0)), _mm_loadu_si128((__m128i *) ((ptr) + 1)), \
|
||||
_mm_loadu_si128((__m128i *) ((ptr) + 16)))
|
||||
|
||||
#define MEOW_SHUFFLE(r1, r2, r3, r4, r5, r6) \
|
||||
aesdec(r1, r4); \
|
||||
paddq(r2, r5); \
|
||||
pxor(r4, r6); \
|
||||
aesdec(r4, r2); \
|
||||
paddq(r5, r6); \
|
||||
aesdec(r1, r4); \
|
||||
paddq(r2, r5); \
|
||||
pxor(r4, r6); \
|
||||
aesdec(r4, r2); \
|
||||
paddq(r5, r6); \
|
||||
pxor(r2, r3)
|
||||
#endif
|
||||
|
||||
namespace Hash::Meow
|
||||
{
|
||||
#if MEOW_DUMP
|
||||
struct meow_dump
|
||||
{
|
||||
meow_u128 xmm[8];
|
||||
void *Ptr;
|
||||
char const *Title;
|
||||
};
|
||||
extern "C" meow_dump *MeowDumpTo;
|
||||
meow_dump *MeowDumpTo;
|
||||
#define MEOW_DUMP_STATE(T, xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, ptr) \
|
||||
if(MeowDumpTo) \
|
||||
{ \
|
||||
MeowDumpTo->xmm[0] = xmm0; \
|
||||
MeowDumpTo->xmm[1] = xmm1; \
|
||||
MeowDumpTo->xmm[2] = xmm2; \
|
||||
MeowDumpTo->xmm[3] = xmm3; \
|
||||
MeowDumpTo->xmm[4] = xmm4; \
|
||||
MeowDumpTo->xmm[5] = xmm5; \
|
||||
MeowDumpTo->xmm[6] = xmm6; \
|
||||
MeowDumpTo->xmm[7] = xmm7; \
|
||||
MeowDumpTo->Ptr = ptr; \
|
||||
MeowDumpTo->Title = T; \
|
||||
++MeowDumpTo; \
|
||||
}
|
||||
#else
|
||||
#define MEOW_DUMP_STATE(...)
|
||||
#endif
|
||||
|
||||
static meow_u8 MeowShiftAdjust[32] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
|
||||
static meow_u8 MeowMaskLen[32] = {255,255,255,255, 255,255,255,255, 255,255,255,255, 255,255,255,255, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0};
|
||||
|
||||
// NOTE(casey): The default seed is now a "nothing-up-our-sleeves" number for good measure. You may verify that it is just an encoding of Pi.
|
||||
static meow_u8 MeowDefaultSeed[128] =
|
||||
{
|
||||
0x32, 0x43, 0xF6, 0xA8, 0x88, 0x5A, 0x30, 0x8D,
|
||||
0x31, 0x31, 0x98, 0xA2, 0xE0, 0x37, 0x07, 0x34,
|
||||
0x4A, 0x40, 0x93, 0x82, 0x22, 0x99, 0xF3, 0x1D,
|
||||
0x00, 0x82, 0xEF, 0xA9, 0x8E, 0xC4, 0xE6, 0xC8,
|
||||
0x94, 0x52, 0x82, 0x1E, 0x63, 0x8D, 0x01, 0x37,
|
||||
0x7B, 0xE5, 0x46, 0x6C, 0xF3, 0x4E, 0x90, 0xC6,
|
||||
0xCC, 0x0A, 0xC2, 0x9B, 0x7C, 0x97, 0xC5, 0x0D,
|
||||
0xD3, 0xF8, 0x4D, 0x5B, 0x5B, 0x54, 0x70, 0x91,
|
||||
0x79, 0x21, 0x6D, 0x5D, 0x98, 0x97, 0x9F, 0xB1,
|
||||
0xBD, 0x13, 0x10, 0xBA, 0x69, 0x8D, 0xFB, 0x5A,
|
||||
0xC2, 0xFF, 0xD7, 0x2D, 0xBD, 0x01, 0xAD, 0xFB,
|
||||
0x7B, 0x8E, 0x1A, 0xFE, 0xD6, 0xA2, 0x67, 0xE9,
|
||||
0x6B, 0xA7, 0xC9, 0x04, 0x5F, 0x12, 0xC7, 0xF9,
|
||||
0x92, 0x4A, 0x19, 0x94, 0x7B, 0x39, 0x16, 0xCF,
|
||||
0x70, 0x80, 0x1F, 0x2E, 0x28, 0x58, 0xEF, 0xC1,
|
||||
0x66, 0x36, 0x92, 0x0D, 0x87, 0x15, 0x74, 0xE6
|
||||
#if MEOW_DUMP
|
||||
struct meow_dump {
|
||||
meow_u128 xmm[8];
|
||||
void *Ptr;
|
||||
char const *Title;
|
||||
};
|
||||
extern "C" meow_dump *MeowDumpTo;
|
||||
meow_dump *MeowDumpTo;
|
||||
#define MEOW_DUMP_STATE(T, xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, ptr) \
|
||||
if (MeowDumpTo) { \
|
||||
MeowDumpTo->xmm[0] = xmm0; \
|
||||
MeowDumpTo->xmm[1] = xmm1; \
|
||||
MeowDumpTo->xmm[2] = xmm2; \
|
||||
MeowDumpTo->xmm[3] = xmm3; \
|
||||
MeowDumpTo->xmm[4] = xmm4; \
|
||||
MeowDumpTo->xmm[5] = xmm5; \
|
||||
MeowDumpTo->xmm[6] = xmm6; \
|
||||
MeowDumpTo->xmm[7] = xmm7; \
|
||||
MeowDumpTo->Ptr = ptr; \
|
||||
MeowDumpTo->Title = T; \
|
||||
++MeowDumpTo; \
|
||||
}
|
||||
#else
|
||||
#define MEOW_DUMP_STATE(...)
|
||||
#endif
|
||||
|
||||
static meow_u8 MeowShiftAdjust[32] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
|
||||
static meow_u8 MeowMaskLen[32] = {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
|
||||
// NOTE(casey): The default seed is now a "nothing-up-our-sleeves" number for good measure. You may verify that it
|
||||
// is just an encoding of Pi.
|
||||
static meow_u8 MeowDefaultSeed[128] = {
|
||||
0x32, 0x43, 0xF6, 0xA8, 0x88, 0x5A, 0x30, 0x8D, 0x31, 0x31, 0x98, 0xA2, 0xE0, 0x37, 0x07, 0x34,
|
||||
0x4A, 0x40, 0x93, 0x82, 0x22, 0x99, 0xF3, 0x1D, 0x00, 0x82, 0xEF, 0xA9, 0x8E, 0xC4, 0xE6, 0xC8,
|
||||
0x94, 0x52, 0x82, 0x1E, 0x63, 0x8D, 0x01, 0x37, 0x7B, 0xE5, 0x46, 0x6C, 0xF3, 0x4E, 0x90, 0xC6,
|
||||
0xCC, 0x0A, 0xC2, 0x9B, 0x7C, 0x97, 0xC5, 0x0D, 0xD3, 0xF8, 0x4D, 0x5B, 0x5B, 0x54, 0x70, 0x91,
|
||||
0x79, 0x21, 0x6D, 0x5D, 0x98, 0x97, 0x9F, 0xB1, 0xBD, 0x13, 0x10, 0xBA, 0x69, 0x8D, 0xFB, 0x5A,
|
||||
0xC2, 0xFF, 0xD7, 0x2D, 0xBD, 0x01, 0xAD, 0xFB, 0x7B, 0x8E, 0x1A, 0xFE, 0xD6, 0xA2, 0x67, 0xE9,
|
||||
0x6B, 0xA7, 0xC9, 0x04, 0x5F, 0x12, 0xC7, 0xF9, 0x92, 0x4A, 0x19, 0x94, 0x7B, 0x39, 0x16, 0xCF,
|
||||
0x70, 0x80, 0x1F, 0x2E, 0x28, 0x58, 0xEF, 0xC1, 0x66, 0x36, 0x92, 0x0D, 0x87, 0x15, 0x74, 0xE6};
|
||||
|
||||
//
|
||||
// NOTE(casey): Single block version
|
||||
//
|
||||
|
||||
static meow_u128
|
||||
MeowHash(void *Seed128Init, meow_umm Len, void *SourceInit)
|
||||
static meow_u128 MeowHash(void *Seed128Init, meow_umm Len, void *SourceInit)
|
||||
{
|
||||
meow_u128 xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7; // NOTE(casey): xmm0-xmm7 are the hash accumulation lanes
|
||||
meow_u128 xmm8, xmm9, xmm10, xmm11, xmm12, xmm13, xmm14, xmm15; // NOTE(casey): xmm8-xmm15 hold values to be appended (residual, length)
|
||||
meow_u128 xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6,
|
||||
xmm7; // NOTE(casey): xmm0-xmm7 are the hash accumulation lanes
|
||||
meow_u128 xmm8, xmm9, xmm10, xmm11, xmm12, xmm13, xmm14,
|
||||
xmm15; // NOTE(casey): xmm8-xmm15 hold values to be appended (residual, length)
|
||||
|
||||
meow_u8 *rax = (meow_u8 *)SourceInit;
|
||||
meow_u8 *rcx = (meow_u8 *)Seed128Init;
|
||||
meow_u8 *rax = (meow_u8 *) SourceInit;
|
||||
meow_u8 *rcx = (meow_u8 *) Seed128Init;
|
||||
|
||||
//
|
||||
// NOTE(casey): Seed the eight hash registers
|
||||
|
|
@ -288,41 +284,38 @@ namespace Hash::Meow
|
|||
//
|
||||
|
||||
meow_umm BlockCount = (Len >> 8);
|
||||
if(BlockCount > MEOW_PREFETCH_LIMIT)
|
||||
{
|
||||
// NOTE(casey): For large input, modern Intel x64's can't hit full speed without prefetching, so we use this loop
|
||||
while(BlockCount--)
|
||||
{
|
||||
if (BlockCount > MEOW_PREFETCH_LIMIT) {
|
||||
// NOTE(casey): For large input, modern Intel x64's can't hit full speed without prefetching, so we use this
|
||||
// loop
|
||||
while (BlockCount--) {
|
||||
prefetcht0(rax + MEOW_PREFETCH + 0x00);
|
||||
prefetcht0(rax + MEOW_PREFETCH + 0x40);
|
||||
prefetcht0(rax + MEOW_PREFETCH + 0x80);
|
||||
prefetcht0(rax + MEOW_PREFETCH + 0xc0);
|
||||
|
||||
MEOW_MIX(xmm0,xmm4,xmm6,xmm1,xmm2, rax + 0x00);
|
||||
MEOW_MIX(xmm1,xmm5,xmm7,xmm2,xmm3, rax + 0x20);
|
||||
MEOW_MIX(xmm2,xmm6,xmm0,xmm3,xmm4, rax + 0x40);
|
||||
MEOW_MIX(xmm3,xmm7,xmm1,xmm4,xmm5, rax + 0x60);
|
||||
MEOW_MIX(xmm4,xmm0,xmm2,xmm5,xmm6, rax + 0x80);
|
||||
MEOW_MIX(xmm5,xmm1,xmm3,xmm6,xmm7, rax + 0xa0);
|
||||
MEOW_MIX(xmm6,xmm2,xmm4,xmm7,xmm0, rax + 0xc0);
|
||||
MEOW_MIX(xmm7,xmm3,xmm5,xmm0,xmm1, rax + 0xe0);
|
||||
MEOW_MIX(xmm0, xmm4, xmm6, xmm1, xmm2, rax + 0x00);
|
||||
MEOW_MIX(xmm1, xmm5, xmm7, xmm2, xmm3, rax + 0x20);
|
||||
MEOW_MIX(xmm2, xmm6, xmm0, xmm3, xmm4, rax + 0x40);
|
||||
MEOW_MIX(xmm3, xmm7, xmm1, xmm4, xmm5, rax + 0x60);
|
||||
MEOW_MIX(xmm4, xmm0, xmm2, xmm5, xmm6, rax + 0x80);
|
||||
MEOW_MIX(xmm5, xmm1, xmm3, xmm6, xmm7, rax + 0xa0);
|
||||
MEOW_MIX(xmm6, xmm2, xmm4, xmm7, xmm0, rax + 0xc0);
|
||||
MEOW_MIX(xmm7, xmm3, xmm5, xmm0, xmm1, rax + 0xe0);
|
||||
|
||||
rax += 0x100;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// NOTE(casey): For small input, modern Intel x64's can't hit full speed _with_ prefetching (because of port pressure), so we use this loop.
|
||||
while(BlockCount--)
|
||||
{
|
||||
MEOW_MIX(xmm0,xmm4,xmm6,xmm1,xmm2, rax + 0x00);
|
||||
MEOW_MIX(xmm1,xmm5,xmm7,xmm2,xmm3, rax + 0x20);
|
||||
MEOW_MIX(xmm2,xmm6,xmm0,xmm3,xmm4, rax + 0x40);
|
||||
MEOW_MIX(xmm3,xmm7,xmm1,xmm4,xmm5, rax + 0x60);
|
||||
MEOW_MIX(xmm4,xmm0,xmm2,xmm5,xmm6, rax + 0x80);
|
||||
MEOW_MIX(xmm5,xmm1,xmm3,xmm6,xmm7, rax + 0xa0);
|
||||
MEOW_MIX(xmm6,xmm2,xmm4,xmm7,xmm0, rax + 0xc0);
|
||||
MEOW_MIX(xmm7,xmm3,xmm5,xmm0,xmm1, rax + 0xe0);
|
||||
} else {
|
||||
// NOTE(casey): For small input, modern Intel x64's can't hit full speed _with_ prefetching (because of port
|
||||
// pressure), so we use this loop.
|
||||
while (BlockCount--) {
|
||||
MEOW_MIX(xmm0, xmm4, xmm6, xmm1, xmm2, rax + 0x00);
|
||||
MEOW_MIX(xmm1, xmm5, xmm7, xmm2, xmm3, rax + 0x20);
|
||||
MEOW_MIX(xmm2, xmm6, xmm0, xmm3, xmm4, rax + 0x40);
|
||||
MEOW_MIX(xmm3, xmm7, xmm1, xmm4, xmm5, rax + 0x60);
|
||||
MEOW_MIX(xmm4, xmm0, xmm2, xmm5, xmm6, rax + 0x80);
|
||||
MEOW_MIX(xmm5, xmm1, xmm3, xmm6, xmm7, rax + 0xa0);
|
||||
MEOW_MIX(xmm6, xmm2, xmm4, xmm7, xmm0, rax + 0xc0);
|
||||
MEOW_MIX(xmm7, xmm3, xmm5, xmm0, xmm1, rax + 0xe0);
|
||||
|
||||
rax += 0x100;
|
||||
}
|
||||
|
|
@ -345,15 +338,15 @@ namespace Hash::Meow
|
|||
//
|
||||
|
||||
// NOTE(casey): First, we have to load the part that is _not_ 16-byte aligned
|
||||
meow_u8 *Last = (meow_u8 *)SourceInit + (Len & ~0xf);
|
||||
meow_u8 *Last = (meow_u8 *) SourceInit + (Len & ~0xf);
|
||||
int unsigned Len8 = (Len & 0xf);
|
||||
if(Len8)
|
||||
{
|
||||
if (Len8) {
|
||||
// NOTE(casey): Load the mask early
|
||||
movdqu(xmm8, &MeowMaskLen[0x10 - Len8]);
|
||||
|
||||
meow_u8 *LastOk = (meow_u8*)((((meow_umm)(((meow_u8 *)SourceInit)+Len - 1)) | (MEOW_PAGESIZE - 1)) - 16);
|
||||
int Align = (Last > LastOk) ? ((int)(meow_umm)Last) & 0xf : 0;
|
||||
meow_u8 *LastOk =
|
||||
(meow_u8 *) ((((meow_umm) (((meow_u8 *) SourceInit) + Len - 1)) | (MEOW_PAGESIZE - 1)) - 16);
|
||||
int Align = (Last > LastOk) ? ((int) (meow_umm) Last) & 0xf : 0;
|
||||
movdqu(xmm10, &MeowShiftAdjust[Align]);
|
||||
movdqu(xmm9, Last - Align);
|
||||
pshufb(xmm9, xmm10);
|
||||
|
|
@ -363,8 +356,7 @@ namespace Hash::Meow
|
|||
}
|
||||
|
||||
// NOTE(casey): Next, we have to load the part that _is_ 16-byte aligned
|
||||
if(Len & 0x10)
|
||||
{
|
||||
if (Len & 0x10) {
|
||||
xmm11 = xmm9;
|
||||
movdqu(xmm9, Last - 0x10);
|
||||
}
|
||||
|
|
@ -373,7 +365,7 @@ namespace Hash::Meow
|
|||
// NOTE(casey): Construct the residual and length injests
|
||||
//
|
||||
|
||||
xmm8 = xmm9;
|
||||
xmm8 = xmm9;
|
||||
xmm10 = xmm9;
|
||||
palignr(xmm8, xmm11, 15);
|
||||
palignr(xmm10, xmm11, 1);
|
||||
|
|
@ -390,11 +382,12 @@ namespace Hash::Meow
|
|||
|
||||
MEOW_DUMP_STATE("Residuals", xmm8, xmm9, xmm10, xmm11, xmm12, xmm13, xmm14, xmm15, 0);
|
||||
|
||||
// NOTE(casey): To maintain the mix-down pattern, we always Meow Mix the less-than-32-byte residual, even if it was empty
|
||||
MEOW_MIX_REG(xmm0, xmm4, xmm6, xmm1, xmm2, xmm8, xmm9, xmm10, xmm11);
|
||||
// NOTE(casey): To maintain the mix-down pattern, we always Meow Mix the less-than-32-byte residual, even if it
|
||||
// was empty
|
||||
MEOW_MIX_REG(xmm0, xmm4, xmm6, xmm1, xmm2, xmm8, xmm9, xmm10, xmm11);
|
||||
|
||||
// NOTE(casey): Append the length, to avoid problems with our 32-byte padding
|
||||
MEOW_MIX_REG(xmm1, xmm5, xmm7, xmm2, xmm3, xmm12, xmm13, xmm14, xmm15);
|
||||
MEOW_MIX_REG(xmm1, xmm5, xmm7, xmm2, xmm3, xmm12, xmm13, xmm14, xmm15);
|
||||
|
||||
MEOW_DUMP_STATE("PostAppend", xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, 0);
|
||||
|
||||
|
|
@ -402,19 +395,40 @@ namespace Hash::Meow
|
|||
// NOTE(casey): Hash all full 32-byte blocks
|
||||
//
|
||||
int unsigned LaneCount = (Len >> 5) & 0x7;
|
||||
if(LaneCount == 0) goto MixDown; MEOW_MIX(xmm2,xmm6,xmm0,xmm3,xmm4, rax + 0x00); --LaneCount;
|
||||
if(LaneCount == 0) goto MixDown; MEOW_MIX(xmm3,xmm7,xmm1,xmm4,xmm5, rax + 0x20); --LaneCount;
|
||||
if(LaneCount == 0) goto MixDown; MEOW_MIX(xmm4,xmm0,xmm2,xmm5,xmm6, rax + 0x40); --LaneCount;
|
||||
if(LaneCount == 0) goto MixDown; MEOW_MIX(xmm5,xmm1,xmm3,xmm6,xmm7, rax + 0x60); --LaneCount;
|
||||
if(LaneCount == 0) goto MixDown; MEOW_MIX(xmm6,xmm2,xmm4,xmm7,xmm0, rax + 0x80); --LaneCount;
|
||||
if(LaneCount == 0) goto MixDown; MEOW_MIX(xmm7,xmm3,xmm5,xmm0,xmm1, rax + 0xa0); --LaneCount;
|
||||
if(LaneCount == 0) goto MixDown; MEOW_MIX(xmm0,xmm4,xmm6,xmm1,xmm2, rax + 0xc0); --LaneCount;
|
||||
if (LaneCount == 0)
|
||||
goto MixDown;
|
||||
MEOW_MIX(xmm2, xmm6, xmm0, xmm3, xmm4, rax + 0x00);
|
||||
--LaneCount;
|
||||
if (LaneCount == 0)
|
||||
goto MixDown;
|
||||
MEOW_MIX(xmm3, xmm7, xmm1, xmm4, xmm5, rax + 0x20);
|
||||
--LaneCount;
|
||||
if (LaneCount == 0)
|
||||
goto MixDown;
|
||||
MEOW_MIX(xmm4, xmm0, xmm2, xmm5, xmm6, rax + 0x40);
|
||||
--LaneCount;
|
||||
if (LaneCount == 0)
|
||||
goto MixDown;
|
||||
MEOW_MIX(xmm5, xmm1, xmm3, xmm6, xmm7, rax + 0x60);
|
||||
--LaneCount;
|
||||
if (LaneCount == 0)
|
||||
goto MixDown;
|
||||
MEOW_MIX(xmm6, xmm2, xmm4, xmm7, xmm0, rax + 0x80);
|
||||
--LaneCount;
|
||||
if (LaneCount == 0)
|
||||
goto MixDown;
|
||||
MEOW_MIX(xmm7, xmm3, xmm5, xmm0, xmm1, rax + 0xa0);
|
||||
--LaneCount;
|
||||
if (LaneCount == 0)
|
||||
goto MixDown;
|
||||
MEOW_MIX(xmm0, xmm4, xmm6, xmm1, xmm2, rax + 0xc0);
|
||||
--LaneCount;
|
||||
|
||||
//
|
||||
// NOTE(casey): Mix the eight lanes down to one 128-bit hash
|
||||
//
|
||||
|
||||
MixDown:
|
||||
MixDown:
|
||||
|
||||
MEOW_DUMP_STATE("PostLanes", xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, 0);
|
||||
|
||||
|
|
@ -443,15 +457,14 @@ namespace Hash::Meow
|
|||
|
||||
MEOW_DUMP_STATE("PostFold", xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, 0);
|
||||
|
||||
return(xmm0);
|
||||
return (xmm0);
|
||||
}
|
||||
|
||||
//
|
||||
// NOTE(casey): Streaming construction
|
||||
//
|
||||
|
||||
typedef struct meow_state
|
||||
{
|
||||
typedef struct meow_state {
|
||||
meow_u128 xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7;
|
||||
meow_u64 TotalLengthInBytes;
|
||||
|
||||
|
|
@ -461,10 +474,9 @@ namespace Hash::Meow
|
|||
meow_u128 Pad[2]; // NOTE(casey): So we know we can over-read Buffer as necessary
|
||||
} meow_state;
|
||||
|
||||
static void
|
||||
MeowBegin(meow_state *State, void *Seed128)
|
||||
static void MeowBegin(meow_state *State, void *Seed128)
|
||||
{
|
||||
meow_u8 *rcx = (meow_u8 *)Seed128;
|
||||
meow_u8 *rcx = (meow_u8 *) Seed128;
|
||||
|
||||
movdqu(State->xmm0, rcx + 0x00);
|
||||
movdqu(State->xmm1, rcx + 0x10);
|
||||
|
|
@ -475,14 +487,14 @@ namespace Hash::Meow
|
|||
movdqu(State->xmm6, rcx + 0x60);
|
||||
movdqu(State->xmm7, rcx + 0x70);
|
||||
|
||||
MEOW_DUMP_STATE("Seed", State->xmm0, State->xmm1, State->xmm2, State->xmm3, State->xmm4, State->xmm5, State->xmm6, State->xmm7, 0);
|
||||
MEOW_DUMP_STATE("Seed", State->xmm0, State->xmm1, State->xmm2, State->xmm3, State->xmm4, State->xmm5,
|
||||
State->xmm6, State->xmm7, 0);
|
||||
|
||||
State->BufferLen = 0;
|
||||
State->BufferLen = 0;
|
||||
State->TotalLengthInBytes = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
MeowAbsorbBlocks(meow_state *State, meow_umm BlockCount, meow_u8 *rax)
|
||||
static void MeowAbsorbBlocks(meow_state *State, meow_umm BlockCount, meow_u8 *rax)
|
||||
{
|
||||
meow_u128 xmm0 = State->xmm0;
|
||||
meow_u128 xmm1 = State->xmm1;
|
||||
|
|
@ -493,39 +505,34 @@ namespace Hash::Meow
|
|||
meow_u128 xmm6 = State->xmm6;
|
||||
meow_u128 xmm7 = State->xmm7;
|
||||
|
||||
if(BlockCount > MEOW_PREFETCH_LIMIT)
|
||||
{
|
||||
while(BlockCount--)
|
||||
{
|
||||
if (BlockCount > MEOW_PREFETCH_LIMIT) {
|
||||
while (BlockCount--) {
|
||||
prefetcht0(rax + MEOW_PREFETCH + 0x00);
|
||||
prefetcht0(rax + MEOW_PREFETCH + 0x40);
|
||||
prefetcht0(rax + MEOW_PREFETCH + 0x80);
|
||||
prefetcht0(rax + MEOW_PREFETCH + 0xc0);
|
||||
|
||||
MEOW_MIX(xmm0,xmm4,xmm6,xmm1,xmm2, rax + 0x00);
|
||||
MEOW_MIX(xmm1,xmm5,xmm7,xmm2,xmm3, rax + 0x20);
|
||||
MEOW_MIX(xmm2,xmm6,xmm0,xmm3,xmm4, rax + 0x40);
|
||||
MEOW_MIX(xmm3,xmm7,xmm1,xmm4,xmm5, rax + 0x60);
|
||||
MEOW_MIX(xmm4,xmm0,xmm2,xmm5,xmm6, rax + 0x80);
|
||||
MEOW_MIX(xmm5,xmm1,xmm3,xmm6,xmm7, rax + 0xa0);
|
||||
MEOW_MIX(xmm6,xmm2,xmm4,xmm7,xmm0, rax + 0xc0);
|
||||
MEOW_MIX(xmm7,xmm3,xmm5,xmm0,xmm1, rax + 0xe0);
|
||||
MEOW_MIX(xmm0, xmm4, xmm6, xmm1, xmm2, rax + 0x00);
|
||||
MEOW_MIX(xmm1, xmm5, xmm7, xmm2, xmm3, rax + 0x20);
|
||||
MEOW_MIX(xmm2, xmm6, xmm0, xmm3, xmm4, rax + 0x40);
|
||||
MEOW_MIX(xmm3, xmm7, xmm1, xmm4, xmm5, rax + 0x60);
|
||||
MEOW_MIX(xmm4, xmm0, xmm2, xmm5, xmm6, rax + 0x80);
|
||||
MEOW_MIX(xmm5, xmm1, xmm3, xmm6, xmm7, rax + 0xa0);
|
||||
MEOW_MIX(xmm6, xmm2, xmm4, xmm7, xmm0, rax + 0xc0);
|
||||
MEOW_MIX(xmm7, xmm3, xmm5, xmm0, xmm1, rax + 0xe0);
|
||||
|
||||
rax += 0x100;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while(BlockCount--)
|
||||
{
|
||||
MEOW_MIX(xmm0,xmm4,xmm6,xmm1,xmm2, rax + 0x00);
|
||||
MEOW_MIX(xmm1,xmm5,xmm7,xmm2,xmm3, rax + 0x20);
|
||||
MEOW_MIX(xmm2,xmm6,xmm0,xmm3,xmm4, rax + 0x40);
|
||||
MEOW_MIX(xmm3,xmm7,xmm1,xmm4,xmm5, rax + 0x60);
|
||||
MEOW_MIX(xmm4,xmm0,xmm2,xmm5,xmm6, rax + 0x80);
|
||||
MEOW_MIX(xmm5,xmm1,xmm3,xmm6,xmm7, rax + 0xa0);
|
||||
MEOW_MIX(xmm6,xmm2,xmm4,xmm7,xmm0, rax + 0xc0);
|
||||
MEOW_MIX(xmm7,xmm3,xmm5,xmm0,xmm1, rax + 0xe0);
|
||||
} else {
|
||||
while (BlockCount--) {
|
||||
MEOW_MIX(xmm0, xmm4, xmm6, xmm1, xmm2, rax + 0x00);
|
||||
MEOW_MIX(xmm1, xmm5, xmm7, xmm2, xmm3, rax + 0x20);
|
||||
MEOW_MIX(xmm2, xmm6, xmm0, xmm3, xmm4, rax + 0x40);
|
||||
MEOW_MIX(xmm3, xmm7, xmm1, xmm4, xmm5, rax + 0x60);
|
||||
MEOW_MIX(xmm4, xmm0, xmm2, xmm5, xmm6, rax + 0x80);
|
||||
MEOW_MIX(xmm5, xmm1, xmm3, xmm6, xmm7, rax + 0xa0);
|
||||
MEOW_MIX(xmm6, xmm2, xmm4, xmm7, xmm0, rax + 0xc0);
|
||||
MEOW_MIX(xmm7, xmm3, xmm5, xmm0, xmm1, rax + 0xe0);
|
||||
|
||||
rax += 0x100;
|
||||
}
|
||||
|
|
@ -541,29 +548,24 @@ namespace Hash::Meow
|
|||
State->xmm7 = xmm7;
|
||||
}
|
||||
|
||||
static void
|
||||
MeowAbsorb(meow_state *State, meow_umm Len, void *SourceInit)
|
||||
static void MeowAbsorb(meow_state *State, meow_umm Len, void *SourceInit)
|
||||
{
|
||||
State->TotalLengthInBytes += Len;
|
||||
meow_u8 *Source = (meow_u8 *)SourceInit;
|
||||
meow_u8 *Source = (meow_u8 *) SourceInit;
|
||||
|
||||
// NOTE(casey): Handle any buffered residual
|
||||
if(State->BufferLen)
|
||||
{
|
||||
if (State->BufferLen) {
|
||||
int unsigned Fill = (sizeof(State->Buffer) - State->BufferLen);
|
||||
if(Fill > Len)
|
||||
{
|
||||
Fill = (int unsigned)Len;
|
||||
if (Fill > Len) {
|
||||
Fill = (int unsigned) Len;
|
||||
}
|
||||
|
||||
Len -= Fill;
|
||||
while(Fill--)
|
||||
{
|
||||
while (Fill--) {
|
||||
State->Buffer[State->BufferLen++] = *Source++;
|
||||
}
|
||||
|
||||
if(State->BufferLen == sizeof(State->Buffer))
|
||||
{
|
||||
if (State->BufferLen == sizeof(State->Buffer)) {
|
||||
MeowAbsorbBlocks(State, 1, State->Buffer);
|
||||
State->BufferLen = 0;
|
||||
}
|
||||
|
|
@ -571,21 +573,19 @@ namespace Hash::Meow
|
|||
|
||||
// NOTE(casey): Handle any full blocks
|
||||
meow_u64 BlockCount = (Len >> 8);
|
||||
meow_u64 Advance = (BlockCount << 8);
|
||||
meow_u64 Advance = (BlockCount << 8);
|
||||
MeowAbsorbBlocks(State, BlockCount, Source);
|
||||
|
||||
Len -= Advance;
|
||||
Len -= Advance;
|
||||
Source += Advance;
|
||||
|
||||
// NOTE(casey): Store residual
|
||||
while(Len--)
|
||||
{
|
||||
while (Len--) {
|
||||
State->Buffer[State->BufferLen++] = *Source++;
|
||||
}
|
||||
}
|
||||
|
||||
static meow_u128
|
||||
MeowEnd(meow_state *State, meow_u8 *Store128)
|
||||
static meow_u128 MeowEnd(meow_state *State, meow_u8 *Store128)
|
||||
{
|
||||
meow_umm Len = State->TotalLengthInBytes;
|
||||
|
||||
|
|
@ -605,22 +605,20 @@ namespace Hash::Meow
|
|||
pxor_clear(xmm9, xmm9);
|
||||
pxor_clear(xmm11, xmm11);
|
||||
|
||||
meow_u8 *Last = (meow_u8 *)rax + (Len & 0xf0);
|
||||
meow_u8 *Last = (meow_u8 *) rax + (Len & 0xf0);
|
||||
int unsigned Len8 = (Len & 0xf);
|
||||
if(Len8)
|
||||
{
|
||||
if (Len8) {
|
||||
movdqu(xmm8, &MeowMaskLen[0x10 - Len8]);
|
||||
movdqu(xmm9, Last);
|
||||
pand(xmm9, xmm8);
|
||||
}
|
||||
|
||||
if(Len & 0x10)
|
||||
{
|
||||
if (Len & 0x10) {
|
||||
xmm11 = xmm9;
|
||||
movdqu(xmm9, Last - 0x10);
|
||||
}
|
||||
|
||||
xmm8 = xmm9;
|
||||
xmm8 = xmm9;
|
||||
xmm10 = xmm9;
|
||||
palignr(xmm8, xmm11, 15);
|
||||
palignr(xmm10, xmm11, 1);
|
||||
|
|
@ -635,11 +633,12 @@ namespace Hash::Meow
|
|||
MEOW_DUMP_STATE("PostBlocks", xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, 0);
|
||||
MEOW_DUMP_STATE("Residuals", xmm8, xmm9, xmm10, xmm11, xmm12, xmm13, xmm14, xmm15, 0);
|
||||
|
||||
// NOTE(casey): To maintain the mix-down pattern, we always Meow Mix the less-than-32-byte residual, even if it was empty
|
||||
MEOW_MIX_REG(xmm0, xmm4, xmm6, xmm1, xmm2, xmm8, xmm9, xmm10, xmm11);
|
||||
// NOTE(casey): To maintain the mix-down pattern, we always Meow Mix the less-than-32-byte residual, even if it
|
||||
// was empty
|
||||
MEOW_MIX_REG(xmm0, xmm4, xmm6, xmm1, xmm2, xmm8, xmm9, xmm10, xmm11);
|
||||
|
||||
// NOTE(casey): Append the length, to avoid problems with our 32-byte padding
|
||||
MEOW_MIX_REG(xmm1, xmm5, xmm7, xmm2, xmm3, xmm12, xmm13, xmm14, xmm15);
|
||||
MEOW_MIX_REG(xmm1, xmm5, xmm7, xmm2, xmm3, xmm12, xmm13, xmm14, xmm15);
|
||||
|
||||
MEOW_DUMP_STATE("PostAppend", xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, 0);
|
||||
|
||||
|
|
@ -647,19 +646,40 @@ namespace Hash::Meow
|
|||
// NOTE(casey): Hash all full 32-byte blocks
|
||||
//
|
||||
int unsigned LaneCount = (Len >> 5) & 0x7;
|
||||
if(LaneCount == 0) goto MixDown; MEOW_MIX(xmm2,xmm6,xmm0,xmm3,xmm4, rax + 0x00); --LaneCount;
|
||||
if(LaneCount == 0) goto MixDown; MEOW_MIX(xmm3,xmm7,xmm1,xmm4,xmm5, rax + 0x20); --LaneCount;
|
||||
if(LaneCount == 0) goto MixDown; MEOW_MIX(xmm4,xmm0,xmm2,xmm5,xmm6, rax + 0x40); --LaneCount;
|
||||
if(LaneCount == 0) goto MixDown; MEOW_MIX(xmm5,xmm1,xmm3,xmm6,xmm7, rax + 0x60); --LaneCount;
|
||||
if(LaneCount == 0) goto MixDown; MEOW_MIX(xmm6,xmm2,xmm4,xmm7,xmm0, rax + 0x80); --LaneCount;
|
||||
if(LaneCount == 0) goto MixDown; MEOW_MIX(xmm7,xmm3,xmm5,xmm0,xmm1, rax + 0xa0); --LaneCount;
|
||||
if(LaneCount == 0) goto MixDown; MEOW_MIX(xmm0,xmm4,xmm6,xmm1,xmm2, rax + 0xc0); --LaneCount;
|
||||
if (LaneCount == 0)
|
||||
goto MixDown;
|
||||
MEOW_MIX(xmm2, xmm6, xmm0, xmm3, xmm4, rax + 0x00);
|
||||
--LaneCount;
|
||||
if (LaneCount == 0)
|
||||
goto MixDown;
|
||||
MEOW_MIX(xmm3, xmm7, xmm1, xmm4, xmm5, rax + 0x20);
|
||||
--LaneCount;
|
||||
if (LaneCount == 0)
|
||||
goto MixDown;
|
||||
MEOW_MIX(xmm4, xmm0, xmm2, xmm5, xmm6, rax + 0x40);
|
||||
--LaneCount;
|
||||
if (LaneCount == 0)
|
||||
goto MixDown;
|
||||
MEOW_MIX(xmm5, xmm1, xmm3, xmm6, xmm7, rax + 0x60);
|
||||
--LaneCount;
|
||||
if (LaneCount == 0)
|
||||
goto MixDown;
|
||||
MEOW_MIX(xmm6, xmm2, xmm4, xmm7, xmm0, rax + 0x80);
|
||||
--LaneCount;
|
||||
if (LaneCount == 0)
|
||||
goto MixDown;
|
||||
MEOW_MIX(xmm7, xmm3, xmm5, xmm0, xmm1, rax + 0xa0);
|
||||
--LaneCount;
|
||||
if (LaneCount == 0)
|
||||
goto MixDown;
|
||||
MEOW_MIX(xmm0, xmm4, xmm6, xmm1, xmm2, rax + 0xc0);
|
||||
--LaneCount;
|
||||
|
||||
//
|
||||
// NOTE(casey): Mix the eight lanes down to one 128-bit hash
|
||||
//
|
||||
|
||||
MixDown:
|
||||
MixDown:
|
||||
|
||||
MEOW_DUMP_STATE("PostLanes", xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, 0);
|
||||
|
||||
|
|
@ -678,8 +698,7 @@ namespace Hash::Meow
|
|||
|
||||
MEOW_DUMP_STATE("PostMix", xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, 0);
|
||||
|
||||
if(Store128)
|
||||
{
|
||||
if (Store128) {
|
||||
movdqu_mem(Store128 + 0x00, xmm0);
|
||||
movdqu_mem(Store128 + 0x10, xmm1);
|
||||
movdqu_mem(Store128 + 0x20, xmm2);
|
||||
|
|
@ -700,7 +719,7 @@ namespace Hash::Meow
|
|||
|
||||
MEOW_DUMP_STATE("PostFold", xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, 0);
|
||||
|
||||
return(xmm0);
|
||||
return (xmm0);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
@ -710,17 +729,16 @@ namespace Hash::Meow
|
|||
// need to create a new seed.
|
||||
//
|
||||
|
||||
static void
|
||||
MeowExpandSeed(meow_umm InputLen, void *Input, meow_u8 *SeedResult)
|
||||
static void MeowExpandSeed(meow_umm InputLen, void *Input, meow_u8 *SeedResult)
|
||||
{
|
||||
meow_state State;
|
||||
meow_u64 LengthTab = (meow_u64)InputLen; // NOTE(casey): We need to always injest 8-byte lengths exactly, even on 32-bit builds, to ensure identical results
|
||||
meow_u64 LengthTab = (meow_u64) InputLen; // NOTE(casey): We need to always injest 8-byte lengths exactly, even
|
||||
// on 32-bit builds, to ensure identical results
|
||||
meow_umm InjestCount = (256 / InputLen) + 2;
|
||||
|
||||
MeowBegin(&State, MeowDefaultSeed);
|
||||
MeowAbsorb(&State, sizeof(LengthTab), &LengthTab);
|
||||
while(InjestCount--)
|
||||
{
|
||||
while (InjestCount--) {
|
||||
MeowAbsorb(&State, InputLen, Input);
|
||||
}
|
||||
MeowEnd(&State, SeedResult);
|
||||
|
|
@ -730,15 +748,12 @@ namespace Hash::Meow
|
|||
{
|
||||
char *str = (char *) malloc((4 * 8 + 4 + 1) * sizeof(char));
|
||||
|
||||
sprintf(str, "%08X-%08X-%08X-%08X",
|
||||
MeowU32From(Hash, 3),
|
||||
MeowU32From(Hash, 2),
|
||||
MeowU32From(Hash, 1),
|
||||
sprintf(str, "%08X-%08X-%08X-%08X", MeowU32From(Hash, 3), MeowU32From(Hash, 2), MeowU32From(Hash, 1),
|
||||
MeowU32From(Hash, 0));
|
||||
|
||||
return (const char *) str;
|
||||
}
|
||||
}
|
||||
} // namespace Hash::Meow
|
||||
|
||||
#undef INSTRUCTION_REORDER_BARRIER
|
||||
#undef prefetcht0
|
||||
|
|
|
|||
111
Hash/SHA256.h
111
Hash/SHA256.h
|
|
@ -10,25 +10,38 @@ extern "C" {
|
|||
|
||||
// Licensing Information
|
||||
//
|
||||
// Except as otherwise noted (below and/or in individual files), this project is licensed under the Unlicense (https://opensource.org/licenses/unlicense) or the Zero Clause BSD license (https://opensource.org/licenses/0bsd), at your option.
|
||||
// The Unlicense
|
||||
// Except as otherwise noted (below and/or in individual files), this project is licensed under the Unlicense
|
||||
// (https://opensource.org/licenses/unlicense) or the Zero Clause BSD license (https://opensource.org/licenses/0bsd), at
|
||||
// your option. The Unlicense
|
||||
//
|
||||
// This is free and unencumbered software released into the public domain.
|
||||
//
|
||||
// Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.
|
||||
// Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form
|
||||
// or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.
|
||||
//
|
||||
// In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.
|
||||
// In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright
|
||||
// interest in the software to the public domain. We make this dedication for the benefit of the public at large and to
|
||||
// the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in
|
||||
// perpetuity of all present and future rights to this software under copyright law.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||
// WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// For more information, please refer to http://unlicense.org
|
||||
// Zero Clause BSD License
|
||||
//
|
||||
// © 2021 Alain Mosnier
|
||||
//
|
||||
// Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted.
|
||||
// Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby
|
||||
// granted.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
// AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
// PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
/*
|
||||
* @brief Size of the SHA-256 sum. This times eight is 256 bits.
|
||||
|
|
@ -96,16 +109,15 @@ static inline void consume_chunk(uint32_t *h, const uint8_t *p)
|
|||
for (i = 0; i < 4; i++) {
|
||||
for (j = 0; j < 16; j++) {
|
||||
if (i == 0) {
|
||||
w[j] =
|
||||
(uint32_t)p[0] << 24 | (uint32_t)p[1] << 16 | (uint32_t)p[2] << 8 | (uint32_t)p[3];
|
||||
p += 4;
|
||||
w[j] = (uint32_t) p[0] << 24 | (uint32_t) p[1] << 16 | (uint32_t) p[2] << 8 | (uint32_t) p[3];
|
||||
p += 4;
|
||||
} else {
|
||||
/* Extend the first 16 words into the remaining 48 words w[16..63] of the
|
||||
* message schedule array: */
|
||||
const uint32_t s0 = right_rot(w[(j + 1) & 0xf], 7) ^ right_rot(w[(j + 1) & 0xf], 18) ^
|
||||
(w[(j + 1) & 0xf] >> 3);
|
||||
const uint32_t s1 = right_rot(w[(j + 14) & 0xf], 17) ^
|
||||
right_rot(w[(j + 14) & 0xf], 19) ^ (w[(j + 14) & 0xf] >> 10);
|
||||
const uint32_t s0 =
|
||||
right_rot(w[(j + 1) & 0xf], 7) ^ right_rot(w[(j + 1) & 0xf], 18) ^ (w[(j + 1) & 0xf] >> 3);
|
||||
const uint32_t s1 =
|
||||
right_rot(w[(j + 14) & 0xf], 17) ^ right_rot(w[(j + 14) & 0xf], 19) ^ (w[(j + 14) & 0xf] >> 10);
|
||||
w[j] = w[j] + s0 + w[(j + 9) & 0xf] + s1;
|
||||
}
|
||||
const uint32_t s1 = right_rot(ah[4], 6) ^ right_rot(ah[4], 11) ^ right_rot(ah[4], 25);
|
||||
|
|
@ -116,20 +128,18 @@ static inline void consume_chunk(uint32_t *h, const uint8_t *p)
|
|||
* (first 32 bits of the fractional parts of the cube roots of the first 64 primes 2..311):
|
||||
*/
|
||||
static const uint32_t k[] = {
|
||||
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4,
|
||||
0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe,
|
||||
0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f,
|
||||
0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
|
||||
0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc,
|
||||
0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b,
|
||||
0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116,
|
||||
0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
|
||||
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7,
|
||||
0xc67178f2};
|
||||
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
||||
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
|
||||
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
||||
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
|
||||
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
|
||||
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
|
||||
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
|
||||
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2};
|
||||
|
||||
const uint32_t temp1 = ah[7] + s1 + ch + k[i << 4 | j] + w[j];
|
||||
const uint32_t s0 = right_rot(ah[0], 2) ^ right_rot(ah[0], 13) ^ right_rot(ah[0], 22);
|
||||
const uint32_t maj = (ah[0] & ah[1]) ^ (ah[0] & ah[2]) ^ (ah[1] & ah[2]);
|
||||
const uint32_t s0 = right_rot(ah[0], 2) ^ right_rot(ah[0], 13) ^ right_rot(ah[0], 22);
|
||||
const uint32_t maj = (ah[0] & ah[1]) ^ (ah[0] & ah[2]) ^ (ah[1] & ah[2]);
|
||||
const uint32_t temp2 = s0 + maj;
|
||||
|
||||
ah[7] = ah[6];
|
||||
|
|
@ -148,25 +158,24 @@ static inline void consume_chunk(uint32_t *h, const uint8_t *p)
|
|||
h[i] += ah[i];
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @brief Initialize a SHA-256 streaming calculation.
|
||||
* @param sha_256 A pointer to a SHA-256 structure.
|
||||
* @param hash Hash array, where the result will be delivered.
|
||||
*
|
||||
* @note If all of the data you are calculating the hash value on is not available in a contiguous buffer in memory, this is
|
||||
* where you should start. Instantiate a SHA-256 structure, for instance by simply declaring it locally, make your hash
|
||||
* buffer available, and invoke this function. Once a SHA-256 hash has been calculated (see further below) a SHA-256
|
||||
* structure can be initialized again for the next calculation.
|
||||
* @note If all of the data you are calculating the hash value on is not available in a contiguous buffer in memory,
|
||||
* this is where you should start. Instantiate a SHA-256 structure, for instance by simply declaring it locally, make
|
||||
* your hash buffer available, and invoke this function. Once a SHA-256 hash has been calculated (see further below) a
|
||||
* SHA-256 structure can be initialized again for the next calculation.
|
||||
*
|
||||
* @note If either of the passed pointers is NULL, the results are unpredictable.
|
||||
*/
|
||||
void sha_256_init(struct Sha_256 *sha_256, uint8_t hash[SIZE_OF_SHA_256_HASH])
|
||||
{
|
||||
sha_256->hash = hash;
|
||||
sha_256->chunk_pos = sha_256->chunk;
|
||||
sha_256->hash = hash;
|
||||
sha_256->chunk_pos = sha_256->chunk;
|
||||
sha_256->space_left = SIZE_OF_SHA_256_CHUNK;
|
||||
sha_256->total_len = 0;
|
||||
sha_256->total_len = 0;
|
||||
/*
|
||||
* Initialize hash values (first 32 bits of the fractional parts of the square roots of the first 8 primes
|
||||
* 2..19):
|
||||
|
|
@ -210,18 +219,18 @@ void sha_256_write(struct Sha_256 *sha_256, const void *data, size_t len)
|
|||
if (sha_256->space_left == SIZE_OF_SHA_256_CHUNK && len >= SIZE_OF_SHA_256_CHUNK) {
|
||||
consume_chunk(sha_256->h, p);
|
||||
len -= SIZE_OF_SHA_256_CHUNK;
|
||||
p += SIZE_OF_SHA_256_CHUNK;
|
||||
p += SIZE_OF_SHA_256_CHUNK;
|
||||
continue;
|
||||
}
|
||||
/* General case, no particular optimization. */
|
||||
const size_t consumed_len = len < sha_256->space_left ? len : sha_256->space_left;
|
||||
memcpy(sha_256->chunk_pos, p, consumed_len);
|
||||
sha_256->space_left -= consumed_len;
|
||||
len -= consumed_len;
|
||||
p += consumed_len;
|
||||
len -= consumed_len;
|
||||
p += consumed_len;
|
||||
if (sha_256->space_left == 0) {
|
||||
consume_chunk(sha_256->h, sha_256->chunk);
|
||||
sha_256->chunk_pos = sha_256->chunk;
|
||||
sha_256->chunk_pos = sha_256->chunk;
|
||||
sha_256->space_left = SIZE_OF_SHA_256_CHUNK;
|
||||
} else {
|
||||
sha_256->chunk_pos += consumed_len;
|
||||
|
|
@ -245,7 +254,7 @@ void sha_256_write(struct Sha_256 *sha_256, const void *data, size_t len)
|
|||
*/
|
||||
uint8_t *sha_256_close(struct Sha_256 *sha_256)
|
||||
{
|
||||
uint8_t *pos = sha_256->chunk_pos;
|
||||
uint8_t *pos = sha_256->chunk_pos;
|
||||
size_t space_left = sha_256->space_left;
|
||||
uint32_t *const h = sha_256->h;
|
||||
|
||||
|
|
@ -264,29 +273,29 @@ uint8_t *sha_256_close(struct Sha_256 *sha_256)
|
|||
if (space_left < TOTAL_LEN_LEN) {
|
||||
memset(pos, 0x00, space_left);
|
||||
consume_chunk(h, sha_256->chunk);
|
||||
pos = sha_256->chunk;
|
||||
pos = sha_256->chunk;
|
||||
space_left = SIZE_OF_SHA_256_CHUNK;
|
||||
}
|
||||
const size_t left = space_left - TOTAL_LEN_LEN;
|
||||
memset(pos, 0x00, left);
|
||||
pos += left;
|
||||
size_t len = sha_256->total_len;
|
||||
pos[7] = (uint8_t)(len << 3);
|
||||
len >>= 5;
|
||||
pos += left;
|
||||
size_t len = sha_256->total_len;
|
||||
pos[7] = (uint8_t) (len << 3);
|
||||
len >>= 5;
|
||||
int i;
|
||||
for (i = 6; i >= 0; --i) {
|
||||
pos[i] = (uint8_t)len;
|
||||
len >>= 8;
|
||||
pos[i] = (uint8_t) len;
|
||||
len >>= 8;
|
||||
}
|
||||
consume_chunk(h, sha_256->chunk);
|
||||
/* Produce the final hash value (big-endian): */
|
||||
int j;
|
||||
uint8_t *const hash = sha_256->hash;
|
||||
for (i = 0, j = 0; i < 8; i++) {
|
||||
hash[j++] = (uint8_t)(h[i] >> 24);
|
||||
hash[j++] = (uint8_t)(h[i] >> 16);
|
||||
hash[j++] = (uint8_t)(h[i] >> 8);
|
||||
hash[j++] = (uint8_t)h[i];
|
||||
hash[j++] = (uint8_t) (h[i] >> 24);
|
||||
hash[j++] = (uint8_t) (h[i] >> 16);
|
||||
hash[j++] = (uint8_t) (h[i] >> 8);
|
||||
hash[j++] = (uint8_t) h[i];
|
||||
}
|
||||
return sha_256->hash;
|
||||
}
|
||||
|
|
@ -307,7 +316,7 @@ void calc_sha_256(uint8_t hash[SIZE_OF_SHA_256_HASH], const void *input, size_t
|
|||
struct Sha_256 sha_256;
|
||||
sha_256_init(&sha_256, hash);
|
||||
sha_256_write(&sha_256, input, len);
|
||||
(void)sha_256_close(&sha_256);
|
||||
(void) sha_256_close(&sha_256);
|
||||
}
|
||||
|
||||
#undef TOTAL_LEN_LEN
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
#ifndef IMAGE_BILL_DETECTION_H
|
||||
#define IMAGE_BILL_DETECTION_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <opencv2/opencv.hpp>
|
||||
#include <stdio.h>
|
||||
#include <vector>
|
||||
|
||||
namespace Image::BillDetection
|
||||
|
|
@ -33,12 +33,12 @@ namespace Image::BillDetection
|
|||
std::vector<cv::Vec4i> lines;
|
||||
lines.clear();
|
||||
|
||||
cv::HoughLinesP(edges, lines, 1, CV_PI/180, 25);
|
||||
cv::HoughLinesP(edges, lines, 1, CV_PI / 180, 25);
|
||||
|
||||
std::vector<cv::Vec4i>::iterator it = lines.begin();
|
||||
for(; it != lines.end(); ++it) {
|
||||
for (; it != lines.end(); ++it) {
|
||||
cv::Vec4i l = *it;
|
||||
cv::line(edges, cv::Point(l[0], l[1]), cv::Point(l[2], l[3]), cv::Scalar(255,0,0), 2, 8);
|
||||
cv::line(edges, cv::Point(l[0], l[1]), cv::Point(l[2], l[3]), cv::Scalar(255, 0, 0), 2, 8);
|
||||
}
|
||||
|
||||
std::vector<std::vector<cv::Point>> contours;
|
||||
|
|
@ -60,8 +60,8 @@ namespace Image::BillDetection
|
|||
// Approximate polygon
|
||||
/* Question: we probably don't want a polygon all the time?! */
|
||||
// @todo bad implementation, focus on single square
|
||||
std::vector<std::vector<cv::Point> > contoursDraw (contoursArea.size());
|
||||
for (int i = 0; i < contoursArea.size(); ++i){
|
||||
std::vector<std::vector<cv::Point>> contoursDraw(contoursArea.size());
|
||||
for (int i = 0; i < contoursArea.size(); ++i) {
|
||||
cv::approxPolyDP(cv::Mat(contoursArea[i]), contoursDraw[i], 40, true);
|
||||
}
|
||||
|
||||
|
|
@ -73,6 +73,6 @@ namespace Image::BillDetection
|
|||
|
||||
return out;
|
||||
}
|
||||
}
|
||||
} // namespace Image::BillDetection
|
||||
|
||||
#endif
|
||||
|
|
@ -10,8 +10,8 @@
|
|||
#ifndef IMAGE_DIFF_H
|
||||
#define IMAGE_DIFF_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <opencv2/opencv.hpp>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "../Utils/MathUtils.h"
|
||||
|
||||
|
|
@ -19,7 +19,7 @@ namespace Image
|
|||
{
|
||||
namespace ImageUtils
|
||||
{
|
||||
cv::Mat find_diff (cv::Mat in1, cv::Mat in2)
|
||||
cv::Mat find_diff(cv::Mat in1, cv::Mat in2)
|
||||
{
|
||||
cv::Mat diff;
|
||||
cv::absdiff(in1, in2, diff);
|
||||
|
|
@ -43,7 +43,7 @@ namespace Image
|
|||
|
||||
return out;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace ImageUtils
|
||||
} // namespace Image
|
||||
|
||||
#endif
|
||||
|
|
@ -10,13 +10,12 @@
|
|||
#ifndef IMAGE_IMAGE_UTILS_H
|
||||
#define IMAGE_IMAGE_UTILS_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
|
||||
namespace Image::ImageUtils
|
||||
{
|
||||
inline
|
||||
float lightnessFromRgb(int r, int g, int b)
|
||||
inline float lightnessFromRgb(int r, int g, int b)
|
||||
{
|
||||
float vR = r / 255.0;
|
||||
float vG = g / 255.0;
|
||||
|
|
@ -31,6 +30,6 @@ namespace Image::ImageUtils
|
|||
|
||||
return lStar / 100.0;
|
||||
}
|
||||
}
|
||||
} // namespace Image::ImageUtils
|
||||
|
||||
#endif
|
||||
|
|
@ -10,60 +10,38 @@
|
|||
#ifndef IMAGE_KERNEL_H
|
||||
#define IMAGE_KERNEL_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <opencv2/opencv.hpp>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "ImageUtils.h"
|
||||
#include "../Utils/MathUtils.h"
|
||||
#include "ImageUtils.h"
|
||||
|
||||
namespace Image::Kernel
|
||||
{
|
||||
const float KERNEL_RIDGE_1[3][3] = {
|
||||
{0.0, -1.0, 0.0},
|
||||
{-1.0, 4.0, -1.0},
|
||||
{0.0, -1.0, 0.0}
|
||||
};
|
||||
const float KERNEL_RIDGE_1[3][3] = {{0.0, -1.0, 0.0}, {-1.0, 4.0, -1.0}, {0.0, -1.0, 0.0}};
|
||||
|
||||
const float KERNEL_RIDGE_2[3][3] = {
|
||||
{-1.0, -1.0, -1.0},
|
||||
{-1.0, 8.0, -1.0},
|
||||
{-1.0, -1.0, -1.0}
|
||||
};
|
||||
const float KERNEL_RIDGE_2[3][3] = {{-1.0, -1.0, -1.0}, {-1.0, 8.0, -1.0}, {-1.0, -1.0, -1.0}};
|
||||
|
||||
const float KERNEL_SHARPEN[3][3] = {
|
||||
{0.0, -1.0, 0.0},
|
||||
{-1.0, 5.0, -1.0},
|
||||
{0.0, -1.0, 0.0}
|
||||
};
|
||||
const float KERNEL_SHARPEN[3][3] = {{0.0, -1.0, 0.0}, {-1.0, 5.0, -1.0}, {0.0, -1.0, 0.0}};
|
||||
|
||||
const float KERNEL_BOX_BLUR[3][3] = {
|
||||
{1.0 / 9.0, 1.0 / 9.0, 1.0 / 9.0},
|
||||
{1.0 / 9.0, 1.0 / 9.0, 1.0 / 9.0},
|
||||
{1.0 / 9.0, 1.0 / 9.0, 1.0 / 9.0}
|
||||
};
|
||||
{1.0 / 9.0, 1.0 / 9.0, 1.0 / 9.0}, {1.0 / 9.0, 1.0 / 9.0, 1.0 / 9.0}, {1.0 / 9.0, 1.0 / 9.0, 1.0 / 9.0}};
|
||||
|
||||
const float KERNEL_GAUSSUAN_BLUR_3[3][3] = {
|
||||
{1.0 / 16.0, 2.0 / 16.0, 1.0 / 16.0},
|
||||
{2.0 / 16.0, 4.0 / 16.0, 2.0 / 16.0},
|
||||
{1.0 / 16.0, 2.0 / 16.0, 1.0 / 16.0}
|
||||
};
|
||||
const float KERNEL_GAUSSUAN_BLUR_3[3][3] = {{1.0 / 16.0, 2.0 / 16.0, 1.0 / 16.0},
|
||||
{2.0 / 16.0, 4.0 / 16.0, 2.0 / 16.0},
|
||||
{1.0 / 16.0, 2.0 / 16.0, 1.0 / 16.0}};
|
||||
|
||||
const float KERNEL_EMBOSS[3][3] = {
|
||||
{-2.0, -1.0, 0.0},
|
||||
{-1.0, 1.0, 1.0},
|
||||
{0.0, 1.0, 2.0}
|
||||
};
|
||||
const float KERNEL_EMBOSS[3][3] = {{-2.0, -1.0, 0.0}, {-1.0, 1.0, 1.0}, {0.0, 1.0, 2.0}};
|
||||
|
||||
const float KERNEL_UNSHARP_MASKING[5][5] = {
|
||||
{-1.0 / 256.0, -4.0 / 256.0, -6.0 / 256.0, -4.0 / 256.0, -1.0 / 256.0},
|
||||
{-4.0 / 256.0, -16.0 / 256.0, -24.0 / 256.0, -16.0 / 256.0, -4.0 / 256.0},
|
||||
{-6.0 / 256.0, -24.0 / 256.0, 476.0 / 256.0, -24.0 / 256.0, -6.0 / 256.0},
|
||||
{-4.0 / 256.0, -16.0 / 256.0, -24.0 / 256.0, -16.0 / 256.0, -4.0 / 256.0},
|
||||
{-1.0 / 256.0, -4.0 / 256.0, -6.0 / 256.0, -4.0 / 256.0, -1.0 / 256.0},
|
||||
{-1.0 / 256.0, -4.0 / 256.0, -6.0 / 256.0, -4.0 / 256.0, -1.0 / 256.0},
|
||||
{-4.0 / 256.0, -16.0 / 256.0, -24.0 / 256.0, -16.0 / 256.0, -4.0 / 256.0},
|
||||
{-6.0 / 256.0, -24.0 / 256.0, 476.0 / 256.0, -24.0 / 256.0, -6.0 / 256.0},
|
||||
{-4.0 / 256.0, -16.0 / 256.0, -24.0 / 256.0, -16.0 / 256.0, -4.0 / 256.0},
|
||||
{-1.0 / 256.0, -4.0 / 256.0, -6.0 / 256.0, -4.0 / 256.0, -1.0 / 256.0},
|
||||
};
|
||||
|
||||
inline
|
||||
cv::Mat convolve(cv::Mat in, const float kernel[][3])
|
||||
inline cv::Mat convolve(cv::Mat in, const float kernel[][3])
|
||||
{
|
||||
cv::Size dim = in.size();
|
||||
cv::Mat out(in.size(), in.type());
|
||||
|
|
@ -73,6 +51,6 @@ namespace Image::Kernel
|
|||
|
||||
return out;
|
||||
}
|
||||
}
|
||||
} // namespace Image::Kernel
|
||||
|
||||
#endif
|
||||
|
|
@ -10,8 +10,8 @@
|
|||
#ifndef IMAGE_SKEW_H
|
||||
#define IMAGE_SKEW_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <opencv2/opencv.hpp>
|
||||
#include <stdio.h>
|
||||
#include <vector>
|
||||
|
||||
#include "../Utils/MathUtils.h"
|
||||
|
|
@ -42,7 +42,8 @@ namespace Image::Skew
|
|||
std::vector<float> angles;
|
||||
for (int i = 0; i < tmpAngles.size(); ++i) {
|
||||
if (imageOrientation > 0) {
|
||||
if (oms_deg2rad(90 - maxDegree) < oms_abs(tmpAngles[i]) && oms_abs(tmpAngles[i]) < oms_deg2rad(90 + maxDegree)) {
|
||||
if (oms_deg2rad(90 - maxDegree) < oms_abs(tmpAngles[i]) &&
|
||||
oms_abs(tmpAngles[i]) < oms_deg2rad(90 + maxDegree)) {
|
||||
angles.push_back(tmpAngles[i]);
|
||||
}
|
||||
} else {
|
||||
|
|
@ -85,6 +86,6 @@ namespace Image::Skew
|
|||
|
||||
return out;
|
||||
}
|
||||
}
|
||||
} // namespace Image::Skew
|
||||
|
||||
#endif
|
||||
|
|
@ -10,11 +10,11 @@
|
|||
#ifndef IMAGE_THRESHOLDING_H
|
||||
#define IMAGE_THRESHOLDING_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <opencv2/opencv.hpp>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "ImageUtils.h"
|
||||
#include "../Utils/MathUtils.h"
|
||||
#include "ImageUtils.h"
|
||||
|
||||
namespace Image::Thresholding
|
||||
{
|
||||
|
|
@ -58,7 +58,7 @@ namespace Image::Thresholding
|
|||
count = (x2 - x1) * (y2 - y1);
|
||||
sum = intImg[x2 * y2] - intImg[x2 * (y1 - 1)] - intImg[(x1 - 1) * y2] + intImg[(x1 - 1) * (y1 - 1)];
|
||||
|
||||
bgr = in.at<cv::Vec3b>(j, i);
|
||||
bgr = in.at<cv::Vec3b>(j, i);
|
||||
brightness = Image::ImageUtils::lightnessFromRgb(bgr[2], bgr[1], bgr[0]);
|
||||
|
||||
color = brightness * count <= (sum * (100.0 - t) / 100.0) && brightness < 0.95 ? 0 : 255;
|
||||
|
|
@ -73,6 +73,6 @@ namespace Image::Thresholding
|
|||
|
||||
return out;
|
||||
}
|
||||
}
|
||||
} // namespace Image::Thresholding
|
||||
|
||||
#endif
|
||||
|
|
@ -18,25 +18,16 @@
|
|||
|
||||
#include "../Stdlib/Types.h"
|
||||
|
||||
uint32 find_joysticks()
|
||||
{
|
||||
uint32 find_joysticks() {}
|
||||
|
||||
}
|
||||
|
||||
void destory_joysticks()
|
||||
{
|
||||
|
||||
}
|
||||
void destory_joysticks() {}
|
||||
|
||||
void handle_controller_input()
|
||||
{
|
||||
|
||||
for (uint32 controller_index = 0; controller_index < XUSER_MAX_COUNT; ++controller_index) {
|
||||
XINPUT_STATE controller_state;
|
||||
if (XInputGetState(controller_index, &controller_state) == ERROR_SUCCESS) {
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
// Remarks: sizes for the second matrix/vector are often implied by the first parameter and the rules for matrix/vector multiplication.
|
||||
// Remarks: sizes for the second matrix/vector are often implied by the first parameter and the rules for matrix/vector
|
||||
// multiplication.
|
||||
|
||||
// First element is always a matrix of int64_t
|
||||
/////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -149,6 +149,6 @@ namespace Math::Matrix::VectorFloat32
|
|||
f32_16_simd v[4];
|
||||
};
|
||||
};
|
||||
}
|
||||
} // namespace Math::Matrix::VectorFloat32
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@
|
|||
#define MATH_MATRIX_VECTORFLOAT32_H
|
||||
|
||||
#include "Types.h"
|
||||
#include <xmmintrin.h>
|
||||
#include <immintrin.h>
|
||||
#include <xmmintrin.h>
|
||||
|
||||
struct simd_int32_4 {
|
||||
union {
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@
|
|||
#define MATH_MATRIX_VECTORFLOAT32_H
|
||||
|
||||
#include "Types.h"
|
||||
#include <xmmintrin.h>
|
||||
#include <immintrin.h>
|
||||
#include <xmmintrin.h>
|
||||
|
||||
struct simd_int64_2 {
|
||||
union {
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@
|
|||
#include <iostream>
|
||||
#include <regex>
|
||||
|
||||
#include "../Stdlib/HashTable.h"
|
||||
#include "../Hash/MeowHash.h"
|
||||
#include "../Stdlib/HashTable.h"
|
||||
|
||||
namespace Router
|
||||
{
|
||||
|
|
@ -36,14 +36,14 @@ namespace Router
|
|||
return router;
|
||||
}
|
||||
|
||||
void set(const Router *router, const char* route, void *endpoint)
|
||||
void set(const Router *router, const char *route, void *endpoint)
|
||||
{
|
||||
Stdlib::HashTable::set_entry(router->routes, route, endpoint);
|
||||
}
|
||||
|
||||
RouterFunc match_route(const Router *router, const char *uri)
|
||||
{
|
||||
RouterFunc ptr = NULL;
|
||||
RouterFunc ptr = NULL;
|
||||
Stdlib::HashTable::it itr = Stdlib::HashTable::table_iterator(router->routes);
|
||||
|
||||
std::regex regex;
|
||||
|
|
@ -66,6 +66,6 @@ namespace Router
|
|||
Stdlib::HashTable::free_table(router->routes);
|
||||
router->routes = NULL;
|
||||
}
|
||||
}
|
||||
} // namespace Router
|
||||
|
||||
#endif
|
||||
|
|
@ -38,15 +38,10 @@ namespace Stdlib::HashTable
|
|||
size_t index;
|
||||
} it;
|
||||
|
||||
inline
|
||||
unsigned long long hash_key(const char *key)
|
||||
inline unsigned long long hash_key(const char *key)
|
||||
{
|
||||
return (unsigned long long) MeowU64From(
|
||||
Hash::Meow::MeowHash(Hash::Meow::MeowDefaultSeed,
|
||||
strlen(key),
|
||||
(void *) key),
|
||||
0
|
||||
);
|
||||
Hash::Meow::MeowHash(Hash::Meow::MeowDefaultSeed, strlen(key), (void *) key), 0);
|
||||
}
|
||||
|
||||
ht *create_table(int max = 0, bool is_fixed = false)
|
||||
|
|
@ -56,8 +51,8 @@ namespace Stdlib::HashTable
|
|||
return NULL;
|
||||
}
|
||||
|
||||
table->size = 0;
|
||||
table->max = max == 0 ? 16 : max;
|
||||
table->size = 0;
|
||||
table->max = max == 0 ? 16 : max;
|
||||
table->is_fixed = is_fixed;
|
||||
|
||||
table->entries = (entry *) calloc(table->max, sizeof(entry));
|
||||
|
|
@ -72,7 +67,7 @@ namespace Stdlib::HashTable
|
|||
void *get_entry(ht *table, const char *key)
|
||||
{
|
||||
unsigned long long hash = hash_key(key);
|
||||
size_t index = (size_t) (hash & (unsigned long long)(table->max - 1));
|
||||
size_t index = (size_t) (hash & (unsigned long long) (table->max - 1));
|
||||
|
||||
while (table->entries[index].key != NULL) {
|
||||
if (strcmp(key, table->entries[index].key) == 0) {
|
||||
|
|
@ -91,7 +86,7 @@ namespace Stdlib::HashTable
|
|||
const char *_set_entry(entry *entries, size_t max, const char *key, void *value, size_t *size)
|
||||
{
|
||||
unsigned long long hash = hash_key(key);
|
||||
size_t index = (size_t) (hash & (unsigned long long)(max - 1));
|
||||
size_t index = (size_t) (hash & (unsigned long long) (max - 1));
|
||||
|
||||
while (entries[index].key != NULL) {
|
||||
if (strcmp(key, entries[index].key) == 0) {
|
||||
|
|
@ -107,11 +102,11 @@ namespace Stdlib::HashTable
|
|||
}
|
||||
|
||||
if (size != NULL) {
|
||||
#ifdef _WIN32
|
||||
key = _strdup(key);
|
||||
#else
|
||||
key = strdup(key);
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
key = _strdup(key);
|
||||
#else
|
||||
key = strdup(key);
|
||||
#endif
|
||||
|
||||
if (key == NULL) {
|
||||
return NULL;
|
||||
|
|
@ -120,7 +115,7 @@ namespace Stdlib::HashTable
|
|||
++(*size);
|
||||
}
|
||||
|
||||
entries[index].key = (char *) key;
|
||||
entries[index].key = (char *) key;
|
||||
entries[index].value = value;
|
||||
|
||||
return key;
|
||||
|
|
@ -213,6 +208,6 @@ namespace Stdlib::HashTable
|
|||
|
||||
free(table->entries);
|
||||
}
|
||||
}
|
||||
} // namespace Stdlib::HashTable
|
||||
|
||||
#endif
|
||||
|
|
@ -10,61 +10,41 @@
|
|||
#ifndef STDLIB_INTRINSICS_H
|
||||
#define STDLIB_INTRINSICS_H
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <xmmintrin.h>
|
||||
#include <immintrin.h>
|
||||
#include <inttypes.h>
|
||||
#include <x86intrin.h>
|
||||
#include <xmmintrin.h>
|
||||
|
||||
#include "Types.h"
|
||||
|
||||
namespace Stdlib::Intrinsics
|
||||
{
|
||||
inline
|
||||
f32 sqrt(f32 a) {
|
||||
return _mm_cvtss_f32(_mm_sqrt_ss(_mm_set_ss(a)));
|
||||
}
|
||||
inline f32 sqrt(f32 a) { return _mm_cvtss_f32(_mm_sqrt_ss(_mm_set_ss(a))); }
|
||||
|
||||
inline
|
||||
f32 round(f32 a) {
|
||||
inline f32 round(f32 a)
|
||||
{
|
||||
return _mm_cvtss_f32(
|
||||
_mm_round_ss(
|
||||
_mm_setzero_ps(),
|
||||
_mm_set_ss(a),
|
||||
(_MM_FROUND_TO_NEAREST_INT |_MM_FROUND_NO_EXC)
|
||||
)
|
||||
);
|
||||
_mm_round_ss(_mm_setzero_ps(), _mm_set_ss(a), (_MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC)));
|
||||
}
|
||||
|
||||
inline
|
||||
uint32 round_to_int(f32 a) {
|
||||
return (uint32) _mm_cvtss_si32(_mm_set_ss(a));
|
||||
}
|
||||
inline uint32 round_to_int(f32 a) { return (uint32) _mm_cvtss_si32(_mm_set_ss(a)); }
|
||||
|
||||
inline
|
||||
f32 floor(f32 a) {
|
||||
return _mm_cvtss_f32(_mm_floor_ss(_mm_setzero_ps(), _mm_set_ss(a)));
|
||||
}
|
||||
inline f32 floor(f32 a) { return _mm_cvtss_f32(_mm_floor_ss(_mm_setzero_ps(), _mm_set_ss(a))); }
|
||||
|
||||
inline
|
||||
f32 ceil(f32 a) {
|
||||
return _mm_cvtss_f32(_mm_ceil_ss(_mm_setzero_ps(), _mm_set_ss(a)));
|
||||
}
|
||||
inline f32 ceil(f32 a) { return _mm_cvtss_f32(_mm_ceil_ss(_mm_setzero_ps(), _mm_set_ss(a))); }
|
||||
|
||||
inline
|
||||
uint32 hash(uint64 a, uint64 b = 0) {
|
||||
inline uint32 hash(uint64 a, uint64 b = 0)
|
||||
{
|
||||
uint8 seed[16] = {
|
||||
0xaa, 0x9b, 0xbd, 0xb8,
|
||||
0xa1, 0x98, 0xac, 0x3f,
|
||||
0x1f, 0x94, 0x07, 0xb3,
|
||||
0x8c, 0x27, 0x93, 0x69,
|
||||
0xaa, 0x9b, 0xbd, 0xb8, 0xa1, 0x98, 0xac, 0x3f, 0x1f, 0x94, 0x07, 0xb3, 0x8c, 0x27, 0x93, 0x69,
|
||||
};
|
||||
|
||||
__m128i hash = _mm_set_epi64x(a, b);
|
||||
hash = _mm_aesdec_si128(hash, _mm_loadu_si128((__m128i *) seed));
|
||||
hash = _mm_aesdec_si128(hash, _mm_loadu_si128((__m128i *) seed));
|
||||
hash = _mm_aesdec_si128(hash, _mm_loadu_si128((__m128i *) seed));
|
||||
hash = _mm_aesdec_si128(hash, _mm_loadu_si128((__m128i *) seed));
|
||||
|
||||
return _mm_extract_epi32(hash, 0);
|
||||
}
|
||||
}
|
||||
} // namespace Stdlib::Intrinsics
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -10,9 +10,9 @@
|
|||
#ifndef STDLIB_SIMD_HELPER_H
|
||||
#define STDLIB_SIMD_HELPER_H
|
||||
|
||||
#include <immintrin.h>
|
||||
#include <stdint.h>
|
||||
#include <xmmintrin.h>
|
||||
#include <immintrin.h>
|
||||
|
||||
namespace Stdlib::SIMD
|
||||
{
|
||||
|
|
@ -22,11 +22,7 @@ namespace Stdlib::SIMD
|
|||
|
||||
eax = 1; // CPUID function 1
|
||||
|
||||
__asm__ __volatile__(
|
||||
"cpuid;"
|
||||
: "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx)
|
||||
: "a" (eax)
|
||||
);
|
||||
__asm__ __volatile__("cpuid;" : "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx) : "a"(eax));
|
||||
|
||||
// Check the AVX feature bit in ECX
|
||||
return (ecx >> 28) & 1;
|
||||
|
|
@ -39,11 +35,7 @@ namespace Stdlib::SIMD
|
|||
eax = 7; // CPUID function 7
|
||||
ecx = 0; // Sub-function 0
|
||||
|
||||
__asm__ __volatile__(
|
||||
"cpuid;"
|
||||
: "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx)
|
||||
: "a" (eax), "c" (ecx)
|
||||
);
|
||||
__asm__ __volatile__("cpuid;" : "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx) : "a"(eax), "c"(ecx));
|
||||
|
||||
// Check the AVX-256 (AVX2) feature bit in EBX
|
||||
return (ebx >> 5) & 1;
|
||||
|
|
@ -56,15 +48,11 @@ namespace Stdlib::SIMD
|
|||
eax = 7; // CPUID function 7
|
||||
ecx = 0; // Sub-function 0
|
||||
|
||||
__asm__ __volatile__(
|
||||
"cpuid;"
|
||||
: "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx)
|
||||
: "a" (eax), "c" (ecx)
|
||||
);
|
||||
__asm__ __volatile__("cpuid;" : "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx) : "a"(eax), "c"(ecx));
|
||||
|
||||
// Check the AVX-512 feature bit in EBX
|
||||
return (ebx >> 16) & 1;
|
||||
}
|
||||
}
|
||||
} // namespace Stdlib::SIMD
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -10,8 +10,8 @@
|
|||
#ifndef STDLIB_TYPES_H
|
||||
#define STDLIB_TYPES_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <float.h>
|
||||
#include <stdint.h>
|
||||
|
||||
typedef int8_t int8;
|
||||
typedef int16_t int16;
|
||||
|
|
|
|||
|
|
@ -20,28 +20,26 @@ namespace Utils
|
|||
{
|
||||
namespace ApplicationUtils
|
||||
{
|
||||
inline
|
||||
char *cwd()
|
||||
inline char *cwd()
|
||||
{
|
||||
char *cwd = (char *) malloc(4096 * sizeof(char));
|
||||
if (cwd == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
getcwd(cwd, 4096 * sizeof(char));
|
||||
getcwd(cwd, 4096 * sizeof(char));
|
||||
|
||||
return cwd;
|
||||
}
|
||||
|
||||
inline
|
||||
void chdir_application(const char *cwd, const char *arg)
|
||||
inline void chdir_application(const char *cwd, const char *arg)
|
||||
{
|
||||
char *pos = strrchr((char *) arg, '/');
|
||||
if (pos == NULL) {
|
||||
pos = strrchr((char *) arg, '\\');
|
||||
}
|
||||
|
||||
char* dir = (char *) calloc((pos - arg + 1), sizeof(char));
|
||||
char *dir = (char *) calloc((pos - arg + 1), sizeof(char));
|
||||
if (!dir) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -53,8 +51,7 @@ namespace Utils
|
|||
}
|
||||
}
|
||||
|
||||
inline
|
||||
const char *compile_arg_line(int argc, const char **argv)
|
||||
inline const char *compile_arg_line(int argc, const char **argv)
|
||||
{
|
||||
size_t max = 512;
|
||||
size_t length = 0;
|
||||
|
|
@ -79,17 +76,17 @@ namespace Utils
|
|||
max += 128;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
strcat_s(arg, max * sizeof(char), argv[i]);
|
||||
#else
|
||||
strcat(arg, argv[i]);
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
strcat_s(arg, max * sizeof(char), argv[i]);
|
||||
#else
|
||||
strcat(arg, argv[i]);
|
||||
#endif
|
||||
length += argv_length;
|
||||
}
|
||||
|
||||
return arg;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace ApplicationUtils
|
||||
} // namespace Utils
|
||||
|
||||
#endif
|
||||
|
|
@ -18,8 +18,7 @@
|
|||
|
||||
namespace Utils::ArrayUtils
|
||||
{
|
||||
inline
|
||||
const char* get_arg(const char *id, const char **argv, size_t size)
|
||||
inline const char *get_arg(const char *id, const char **argv, size_t size)
|
||||
{
|
||||
if (Utils::StringUtils::is_number(id)) {
|
||||
return argv[atoi(id)];
|
||||
|
|
@ -34,8 +33,7 @@ namespace Utils::ArrayUtils
|
|||
return NULL;
|
||||
}
|
||||
|
||||
inline
|
||||
bool has_arg(const char *id, const char **argv, size_t size)
|
||||
inline bool has_arg(const char *id, const char **argv, size_t size)
|
||||
{
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
if (strcmp(id, argv[i]) == 0) {
|
||||
|
|
@ -46,8 +44,7 @@ namespace Utils::ArrayUtils
|
|||
return false;
|
||||
}
|
||||
|
||||
inline
|
||||
double array_sum_double(const double *array, size_t size)
|
||||
inline double array_sum_double(const double *array, size_t size)
|
||||
{
|
||||
double sum = 0.0;
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
|
|
@ -57,8 +54,7 @@ namespace Utils::ArrayUtils
|
|||
return sum;
|
||||
}
|
||||
|
||||
inline
|
||||
float array_sum_float(const float *array, size_t size)
|
||||
inline float array_sum_float(const float *array, size_t size)
|
||||
{
|
||||
float sum = 0.0;
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
|
|
@ -68,8 +64,7 @@ namespace Utils::ArrayUtils
|
|||
return sum;
|
||||
}
|
||||
|
||||
inline
|
||||
int64_t array_sum_int(const int64_t *array, size_t size)
|
||||
inline int64_t array_sum_int(const int64_t *array, size_t size)
|
||||
{
|
||||
int64_t sum = 0;
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
|
|
@ -79,8 +74,7 @@ namespace Utils::ArrayUtils
|
|||
return sum;
|
||||
}
|
||||
|
||||
inline
|
||||
size_t find_in_array_string(const char *element, const char **array, size_t size)
|
||||
inline size_t find_in_array_string(const char *element, const char **array, size_t size)
|
||||
{
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
if (strcmp(element, array[i]) == 0) {
|
||||
|
|
@ -91,8 +85,7 @@ namespace Utils::ArrayUtils
|
|||
return -1;
|
||||
}
|
||||
|
||||
inline
|
||||
size_t find_in_array_double(double element, const double *array, size_t size)
|
||||
inline size_t find_in_array_double(double element, const double *array, size_t size)
|
||||
{
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
if (array[i] == element) {
|
||||
|
|
@ -103,8 +96,7 @@ namespace Utils::ArrayUtils
|
|||
return -1;
|
||||
}
|
||||
|
||||
inline
|
||||
size_t find_in_array_float(float element, const float *array, size_t size)
|
||||
inline size_t find_in_array_float(float element, const float *array, size_t size)
|
||||
{
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
if (array[i] == element) {
|
||||
|
|
@ -115,8 +107,7 @@ namespace Utils::ArrayUtils
|
|||
return -1;
|
||||
}
|
||||
|
||||
inline
|
||||
size_t find_in_array_int(int64_t element, const int64_t *array, size_t size)
|
||||
inline size_t find_in_array_int(int64_t element, const int64_t *array, size_t size)
|
||||
{
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
if (array[i] == element) {
|
||||
|
|
@ -127,10 +118,9 @@ namespace Utils::ArrayUtils
|
|||
return -1;
|
||||
}
|
||||
|
||||
inline
|
||||
double* merge_arrays_double(const double* array1, size_t size1, const double* array2, size_t size2)
|
||||
inline double *merge_arrays_double(const double *array1, size_t size1, const double *array2, size_t size2)
|
||||
{
|
||||
double* merged = (double*) malloc((size1 + size2) * sizeof(double));
|
||||
double *merged = (double *) malloc((size1 + size2) * sizeof(double));
|
||||
if (merged == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -146,10 +136,9 @@ namespace Utils::ArrayUtils
|
|||
return merged;
|
||||
}
|
||||
|
||||
inline
|
||||
float* merge_arrays_float(const float* array1, size_t size1, const float* array2, size_t size2)
|
||||
inline float *merge_arrays_float(const float *array1, size_t size1, const float *array2, size_t size2)
|
||||
{
|
||||
float* merged = (float*) malloc((size1 + size2) * sizeof(float));
|
||||
float *merged = (float *) malloc((size1 + size2) * sizeof(float));
|
||||
if (merged == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -165,10 +154,9 @@ namespace Utils::ArrayUtils
|
|||
return merged;
|
||||
}
|
||||
|
||||
inline
|
||||
int64_t* merge_arrays_int(const int64_t* array1, size_t size1, const int64_t* array2, size_t size2)
|
||||
inline int64_t *merge_arrays_int(const int64_t *array1, size_t size1, const int64_t *array2, size_t size2)
|
||||
{
|
||||
int64_t* merged = (int64_t*) malloc((size1 + size2) * sizeof(int64_t));
|
||||
int64_t *merged = (int64_t *) malloc((size1 + size2) * sizeof(int64_t));
|
||||
if (merged == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -184,26 +172,25 @@ namespace Utils::ArrayUtils
|
|||
return merged;
|
||||
}
|
||||
|
||||
inline
|
||||
char** merge_arrays_char(const char** array1, size_t size1, const char** array2, size_t size2)
|
||||
inline char **merge_arrays_char(const char **array1, size_t size1, const char **array2, size_t size2)
|
||||
{
|
||||
char** merged = (char**) malloc((size1 + size2) * sizeof(char*));
|
||||
char **merged = (char **) malloc((size1 + size2) * sizeof(char *));
|
||||
if (merged == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < size1; ++i) {
|
||||
merged[i] = (char*) malloc((strlen(array1[i]) + 1) * sizeof(char));
|
||||
merged[i] = (char *) malloc((strlen(array1[i]) + 1) * sizeof(char));
|
||||
strcpy(merged[i], array1[i]);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < size2; ++i) {
|
||||
merged[i] = (char*) malloc((strlen(array2[i]) + 1) * sizeof(char));
|
||||
merged[i] = (char *) malloc((strlen(array2[i]) + 1) * sizeof(char));
|
||||
strcpy(merged[i], array2[i]);
|
||||
}
|
||||
|
||||
return merged;
|
||||
}
|
||||
}
|
||||
} // namespace Utils::ArrayUtils
|
||||
|
||||
#endif
|
||||
|
|
@ -21,10 +21,9 @@ namespace Utils::ColorUtils
|
|||
unsigned char b = 0;
|
||||
} RGB;
|
||||
|
||||
inline
|
||||
RGB* int_to_rgb(int rgb)
|
||||
inline RGB *int_to_rgb(int rgb)
|
||||
{
|
||||
RGB* result = (RGB*) malloc(1 * sizeof(RGB));
|
||||
RGB *result = (RGB *) malloc(1 * sizeof(RGB));
|
||||
|
||||
result->r = rgb & 255;
|
||||
result->g = (rgb >> 8) & 255;
|
||||
|
|
@ -33,25 +32,23 @@ namespace Utils::ColorUtils
|
|||
return result;
|
||||
}
|
||||
|
||||
inline
|
||||
int rgb_to_int(const RGB* rgb)
|
||||
inline int rgb_to_int(const RGB *rgb)
|
||||
{
|
||||
int i = (255 & rgb->r) << 16;
|
||||
i += (255 & rgb->g) << 8;
|
||||
i += (255 & rgb->b);
|
||||
int i = (255 & rgb->r) << 16;
|
||||
i += (255 & rgb->g) << 8;
|
||||
i += (255 & rgb->b);
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
inline
|
||||
int rgb_to_int(char r, char g, char b)
|
||||
inline int rgb_to_int(char r, char g, char b)
|
||||
{
|
||||
int i = (255 & r) << 16;
|
||||
i += (255 & g) << 8;
|
||||
i += (255 & b);
|
||||
int i = (255 & r) << 16;
|
||||
i += (255 & g) << 8;
|
||||
i += (255 & b);
|
||||
|
||||
return i;
|
||||
}
|
||||
}
|
||||
} // namespace Utils::ColorUtils
|
||||
|
||||
#endif
|
||||
|
|
@ -15,8 +15,8 @@
|
|||
#include <string.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#include <wchar.h>
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
|
@ -25,65 +25,62 @@
|
|||
|
||||
namespace Utils::FileUtils
|
||||
{
|
||||
inline
|
||||
bool file_exists (const char *filename)
|
||||
inline bool file_exists(const char *filename)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
return access(filename, 0) == 0;
|
||||
#else
|
||||
struct stat buffer;
|
||||
return stat(filename, &buffer) == 0;
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
return access(filename, 0) == 0;
|
||||
#else
|
||||
struct stat buffer;
|
||||
return stat(filename, &buffer) == 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
inline
|
||||
time_t last_modification (const char *filename)
|
||||
inline time_t last_modification(const char *filename)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
FILETIME modtime;
|
||||
HANDLE h;
|
||||
#ifdef _WIN32
|
||||
FILETIME modtime;
|
||||
HANDLE h;
|
||||
|
||||
size_t nameLength = strlen(filename);
|
||||
size_t nameLength = strlen(filename);
|
||||
|
||||
wchar_t *wtext = (wchar_t *) calloc(nameLength, sizeof(char));
|
||||
mbstowcs_s(NULL, wtext, nameLength, filename, nameLength);
|
||||
LPWSTR pFilename = wtext;
|
||||
|
||||
if (!pFilename) {
|
||||
free(wtext);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
h = CreateFileW(pFilename, GENERIC_READ | FILE_WRITE_ATTRIBUTES, 0, NULL, OPEN_EXISTING, 0, NULL);
|
||||
wchar_t *wtext = (wchar_t *) calloc(nameLength, sizeof(char));
|
||||
mbstowcs_s(NULL, wtext, nameLength, filename, nameLength);
|
||||
LPWSTR pFilename = wtext;
|
||||
|
||||
if (!pFilename) {
|
||||
free(wtext);
|
||||
free(pFilename);
|
||||
|
||||
if (h == INVALID_HANDLE_VALUE) {
|
||||
return (time_t) 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (GetFileTime(h, NULL, NULL, &modtime) == 0) {
|
||||
return (time_t) 0;
|
||||
}
|
||||
h = CreateFileW(pFilename, GENERIC_READ | FILE_WRITE_ATTRIBUTES, 0, NULL, OPEN_EXISTING, 0, NULL);
|
||||
|
||||
unsigned long long seconds = ((unsigned long long) (modtime.dwHighDateTime)) << 32;
|
||||
seconds |= modtime.dwLowDateTime;
|
||||
free(wtext);
|
||||
free(pFilename);
|
||||
|
||||
return (seconds - 116444736000000000) / 10000000;
|
||||
#else
|
||||
struct stat buffer;
|
||||
stat(filename, &buffer);
|
||||
if (h == INVALID_HANDLE_VALUE) {
|
||||
return (time_t) 0;
|
||||
}
|
||||
|
||||
return (time_t) buffer.st_mtim.tv_sec;
|
||||
#endif
|
||||
if (GetFileTime(h, NULL, NULL, &modtime) == 0) {
|
||||
return (time_t) 0;
|
||||
}
|
||||
|
||||
unsigned long long seconds = ((unsigned long long) (modtime.dwHighDateTime)) << 32;
|
||||
seconds |= modtime.dwLowDateTime;
|
||||
|
||||
return (seconds - 116444736000000000) / 10000000;
|
||||
#else
|
||||
struct stat buffer;
|
||||
stat(filename, &buffer);
|
||||
|
||||
return (time_t) buffer.st_mtim.tv_sec;
|
||||
#endif
|
||||
|
||||
return (time_t) 0;
|
||||
}
|
||||
|
||||
inline
|
||||
const char* file_extension (const char *filename)
|
||||
inline const char *file_extension(const char *filename)
|
||||
{
|
||||
char *dot = strrchr((char *) filename, '.');
|
||||
|
||||
|
|
@ -99,7 +96,7 @@ namespace Utils::FileUtils
|
|||
int size = 0; // doesn't include null termination (same as strlen)
|
||||
} file_body;
|
||||
|
||||
file_body read_file (const char *filename)
|
||||
file_body read_file(const char *filename)
|
||||
{
|
||||
file_body file = {0};
|
||||
|
||||
|
|
@ -126,6 +123,6 @@ namespace Utils::FileUtils
|
|||
|
||||
return file;
|
||||
}
|
||||
}
|
||||
} // namespace Utils::FileUtils
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -15,25 +15,37 @@
|
|||
|
||||
/*
|
||||
MMX
|
||||
Introduce eight 64 bit registers (MM0-MM7) and instructions to work with eight signed/unsigned bytes, four signed/unsigned words, two signed/unsigned dwords.
|
||||
Introduce eight 64 bit registers (MM0-MM7) and instructions to work with eight signed/unsigned bytes, four
|
||||
signed/unsigned words, two signed/unsigned dwords.
|
||||
|
||||
3DNow!
|
||||
Add support for single precision floating point operand to MMX. Few operation supported, for example addition, subtraction, multiplication.
|
||||
Add support for single precision floating point operand to MMX. Few operation supported, for example addition,
|
||||
subtraction, multiplication.
|
||||
|
||||
SSE
|
||||
Introduce eight/sixteen 128 bit registers (XMM0-XMM7/15) and instruction to work with four single precision floating point operands. Add integer operations on MMX registers too. (The MMX-integer part of SSE is sometimes called MMXEXT, and was implemented on a few non-Intel CPUs without xmm registers and the floating point part of SSE.)
|
||||
Introduce eight/sixteen 128 bit registers (XMM0-XMM7/15) and instruction to work with four single precision floating
|
||||
point operands. Add integer operations on MMX registers too. (The MMX-integer part of SSE is sometimes called MMXEXT,
|
||||
and was implemented on a few non-Intel CPUs without xmm registers and the floating point part of SSE.)
|
||||
|
||||
SSE2
|
||||
Introduces instruction to work with 2 double precision floating point operands, and with packed byte/word/dword/qword integers in 128-bit xmm registers.
|
||||
Introduces instruction to work with 2 double precision floating point operands, and with packed byte/word/dword/qword
|
||||
integers in 128-bit xmm registers.
|
||||
|
||||
SSE3
|
||||
Add a few varied instructions (mostly floating point), including a special kind of unaligned load (lddqu) that was better on Pentium 4, synchronization instruction, horizontal add/sub.
|
||||
Add a few varied instructions (mostly floating point), including a special kind of unaligned load (lddqu) that was
|
||||
better on Pentium 4, synchronization instruction, horizontal add/sub.
|
||||
|
||||
SSSE3
|
||||
Again a varied set of instructions, mostly integer. The first shuffle that takes its control operand from a register instead of hard-coded (pshufb). More horizontal processing, shuffle, packing/unpacking, mul+add on bytes, and some specialized integer add/mul stuff.
|
||||
Again a varied set of instructions, mostly integer. The first shuffle that takes its control operand from a register
|
||||
instead of hard-coded (pshufb). More horizontal processing, shuffle, packing/unpacking, mul+add on bytes, and some
|
||||
specialized integer add/mul stuff.
|
||||
|
||||
SSE4 (SSE4.1, SSE4.2)
|
||||
Add a lot of instructions: Filling in a lot of the gaps by providing min and max and other operations for all integer data types (especially 32-bit integer had been lacking), where previously integer min was only available for unsigned bytes and signed 16-bit. Also scaling, FP rounding, blending, linear algebra operation, text processing, comparisons. Also a non temporal load for reading video memory, or copying it back to main memory. (Previously only NT stores were available.)
|
||||
Add a lot of instructions: Filling in a lot of the gaps by providing min and max and other operations for all integer
|
||||
data types (especially 32-bit integer had been lacking), where previously integer min was only available for unsigned
|
||||
bytes and signed 16-bit. Also scaling, FP rounding, blending, linear algebra operation, text processing, comparisons.
|
||||
Also a non temporal load for reading video memory, or copying it back to main memory. (Previously only NT stores were
|
||||
available.)
|
||||
|
||||
AESNI
|
||||
Add support for accelerating AES symmetric encryption/decryption.
|
||||
|
|
@ -48,7 +60,9 @@ AVX2
|
|||
Add support for integer data types.
|
||||
|
||||
AVX512F
|
||||
Add eight/thirty-two 512 bit registers (ZMM0-ZMM7/31) and eight 64-bit mask register (k0-k7). Promote most previous instruction to 512 bit wide. Optional parts of AVX512 add instruction for exponentials & reciprocals (AVX512ER), scatter/gather prefetching (AVX512PF), scatter conflict detection (AVX512CD), compress, expand.
|
||||
Add eight/thirty-two 512 bit registers (ZMM0-ZMM7/31) and eight 64-bit mask register (k0-k7). Promote most previous
|
||||
instruction to 512 bit wide. Optional parts of AVX512 add instruction for exponentials & reciprocals (AVX512ER),
|
||||
scatter/gather prefetching (AVX512PF), scatter conflict detection (AVX512CD), compress, expand.
|
||||
|
||||
IMCI (Intel Xeon Phi)
|
||||
Early development of AVX512 for the first-gen Intel Xeon Phi (Knight's Corner) coprocessor.
|
||||
|
|
|
|||
|
|
@ -16,14 +16,13 @@
|
|||
|
||||
namespace Utils::Rng::StringUtils
|
||||
{
|
||||
inline
|
||||
char* generate_string(
|
||||
size_t min = 10, size_t max = 10,
|
||||
const char *charset = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", int charsetLength = 62
|
||||
) {
|
||||
inline char *generate_string(size_t min = 10, size_t max = 10,
|
||||
const char *charset = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
||||
int charsetLength = 62)
|
||||
{
|
||||
srand(time(0));
|
||||
|
||||
size_t length = (rand() % (max - min + 1)) + min;
|
||||
size_t length = (rand() % (max - min + 1)) + min;
|
||||
char *randomString = (char *) malloc(length + 1);
|
||||
|
||||
for (size_t i = 0; i < length; ++i) {
|
||||
|
|
@ -34,6 +33,6 @@ namespace Utils::Rng::StringUtils
|
|||
|
||||
return randomString;
|
||||
}
|
||||
}
|
||||
} // namespace Utils::Rng::StringUtils
|
||||
|
||||
#endif
|
||||
|
|
@ -10,12 +10,12 @@
|
|||
#ifndef UTILS_STRING_UTILS_H
|
||||
#define UTILS_STRING_UTILS_H
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "MathUtils.h"
|
||||
#include "ArraySort.h"
|
||||
#include "MathUtils.h"
|
||||
|
||||
namespace Utils::StringUtils
|
||||
{
|
||||
|
|
@ -62,8 +62,7 @@ namespace Utils::StringUtils
|
|||
return result;
|
||||
}
|
||||
|
||||
inline
|
||||
bool is_number(const char *s)
|
||||
inline bool is_number(const char *s)
|
||||
{
|
||||
while (*s != '\0') {
|
||||
if (!isdigit(*s)) {
|
||||
|
|
@ -76,8 +75,7 @@ namespace Utils::StringUtils
|
|||
return true;
|
||||
}
|
||||
|
||||
inline
|
||||
size_t str_count(const char *str, const char *substr)
|
||||
inline size_t str_count(const char *str, const char *substr)
|
||||
{
|
||||
size_t l1 = strlen(str);
|
||||
size_t l2 = strlen(substr);
|
||||
|
|
@ -94,13 +92,12 @@ namespace Utils::StringUtils
|
|||
return count;
|
||||
}
|
||||
|
||||
inline
|
||||
char *strsep(const char **sp, const char *sep)
|
||||
inline char *strsep(const char **sp, const char *sep)
|
||||
{
|
||||
char *p, *s;
|
||||
|
||||
if (sp == NULL || *sp == NULL || **sp == '\0') {
|
||||
return(NULL);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
s = (char *) *sp;
|
||||
|
|
@ -116,8 +113,7 @@ namespace Utils::StringUtils
|
|||
}
|
||||
|
||||
// @todo Implement delim as const char* (also allow \0 length)
|
||||
inline
|
||||
int str_split(char **list, const char *str, const char delim)
|
||||
inline int str_split(char **list, const char *str, const char delim)
|
||||
{
|
||||
size_t splits = str_count(str, (char *) &delim) + 1;
|
||||
list = (char **) malloc(splits * sizeof(char *));
|
||||
|
|
@ -136,8 +132,7 @@ namespace Utils::StringUtils
|
|||
}
|
||||
|
||||
// @todo Implement delim as const char* (also allow \0 length)
|
||||
inline
|
||||
char* str_combine(const char **str, size_t size, const char delim)
|
||||
inline char *str_combine(const char **str, size_t size, const char delim)
|
||||
{
|
||||
if (size < 1) {
|
||||
return NULL;
|
||||
|
|
@ -199,8 +194,8 @@ namespace Utils::StringUtils
|
|||
for (i = 1; i <= fromSize; ++i) {
|
||||
for (j = 1; j <= toSize; ++j) {
|
||||
dm[i * fromSize + j] = strcmp(from[i - 1], to[j - 1]) == 0
|
||||
? dm[(i - 1) * fromSize + (j - 1)] + 1
|
||||
: oms_max(dm[(i - 1) * fromSize + j], dm[i * fromSize + (j - 1)]);
|
||||
? dm[(i - 1) * fromSize + (j - 1)] + 1
|
||||
: oms_max(dm[(i - 1) * fromSize + j], dm[i * fromSize + (j - 1)]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -218,11 +213,11 @@ namespace Utils::StringUtils
|
|||
continue;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
strcpy_s(diffValues[diffIndex], (strlen(to[j - 1]) + 1) * sizeof(char), to[j - 1]);
|
||||
#else
|
||||
strcpy(diffValues[diffIndex], to[j - 1]);
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
strcpy_s(diffValues[diffIndex], (strlen(to[j - 1]) + 1) * sizeof(char), to[j - 1]);
|
||||
#else
|
||||
strcpy(diffValues[diffIndex], to[j - 1]);
|
||||
#endif
|
||||
|
||||
diffMasks[diffIndex] = 1;
|
||||
|
||||
|
|
@ -240,11 +235,11 @@ namespace Utils::StringUtils
|
|||
continue;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
strcpy_s(diffValues[diffIndex], (strlen(from[i - 1]) + 1) * sizeof(char), from[i - 1]);
|
||||
#else
|
||||
strcpy(diffValues[diffIndex], from[i - 1]);
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
strcpy_s(diffValues[diffIndex], (strlen(from[i - 1]) + 1) * sizeof(char), from[i - 1]);
|
||||
#else
|
||||
strcpy(diffValues[diffIndex], from[i - 1]);
|
||||
#endif
|
||||
|
||||
diffMasks[diffIndex] = -1;
|
||||
|
||||
|
|
@ -261,11 +256,11 @@ namespace Utils::StringUtils
|
|||
continue;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
strcpy_s(diffValues[diffIndex], (strlen(from[i - 1]) + 1) * sizeof(char), from[i - 1]);
|
||||
#else
|
||||
strcpy(diffValues[diffIndex], from[i - 1]);
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
strcpy_s(diffValues[diffIndex], (strlen(from[i - 1]) + 1) * sizeof(char), from[i - 1]);
|
||||
#else
|
||||
strcpy(diffValues[diffIndex], from[i - 1]);
|
||||
#endif
|
||||
|
||||
/* Handled with calloc
|
||||
diffMasks[diffIndex] = 0;
|
||||
|
|
@ -303,7 +298,8 @@ namespace Utils::StringUtils
|
|||
return text_diff{diffValues, diffMasks, diffIndex};
|
||||
}
|
||||
|
||||
char *strtok(char *str, const char *delim, char **saveptr) {
|
||||
char *strtok(char *str, const char *delim, char **saveptr)
|
||||
{
|
||||
if (str == NULL) {
|
||||
str = *saveptr;
|
||||
}
|
||||
|
|
@ -313,17 +309,17 @@ namespace Utils::StringUtils
|
|||
}
|
||||
|
||||
char *token_start = str;
|
||||
char *token_end = strpbrk(token_start, delim);
|
||||
char *token_end = strpbrk(token_start, delim);
|
||||
|
||||
if (token_end == NULL) {
|
||||
*saveptr = NULL;
|
||||
} else {
|
||||
*token_end = '\0';
|
||||
*saveptr = token_end + 1;
|
||||
*saveptr = token_end + 1;
|
||||
}
|
||||
|
||||
return token_start;
|
||||
}
|
||||
}
|
||||
} // namespace Utils::StringUtils
|
||||
|
||||
#endif
|
||||
|
|
@ -10,67 +10,97 @@
|
|||
#ifndef UTILS_TEST_UTILS_H
|
||||
#define UTILS_TEST_UTILS_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include "MathUtils.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#define ASSERT_EQUALS(a, b, t1, t2) ({\
|
||||
if ((a) == (b)) { \
|
||||
printf("."); \
|
||||
} else { \
|
||||
printf("\033[31m[F]\033[0m"); \
|
||||
#define ASSERT_EQUALS(a, b, t1, t2) \
|
||||
({ \
|
||||
if ((a) == (b)) { \
|
||||
printf("."); \
|
||||
} else { \
|
||||
printf("\033[31m[F]\033[0m"); \
|
||||
printf("\n\n%s - %i: ", __FILE__, __LINE__); \
|
||||
printf((t1), (a)); printf(" != "); printf((t2), (b)); printf("\n"); \
|
||||
return 0; } \
|
||||
printf((t1), (a)); \
|
||||
printf(" != "); \
|
||||
printf((t2), (b)); \
|
||||
printf("\n"); \
|
||||
return 0; \
|
||||
} \
|
||||
})
|
||||
|
||||
#define ASSERT_NOT_EQUALS(a, b, t1, t2) ({\
|
||||
if ((a) != (b)) { \
|
||||
printf("."); \
|
||||
} else { \
|
||||
printf("\033[31m[F]\033[0m"); \
|
||||
#define ASSERT_NOT_EQUALS(a, b, t1, t2) \
|
||||
({ \
|
||||
if ((a) != (b)) { \
|
||||
printf("."); \
|
||||
} else { \
|
||||
printf("\033[31m[F]\033[0m"); \
|
||||
printf("\n\n%s - %i: ", __FILE__, __LINE__); \
|
||||
printf((t1), (a)); printf(" == "); printf((t2), (b)); printf("\n"); \
|
||||
return 0; } \
|
||||
printf((t1), (a)); \
|
||||
printf(" == "); \
|
||||
printf((t2), (b)); \
|
||||
printf("\n"); \
|
||||
return 0; \
|
||||
} \
|
||||
})
|
||||
|
||||
#define ASSERT_EQUALS_WITH_DELTA(a, b, delta, t1, t2) ({\
|
||||
if (oms_abs((a) - (b)) <= (delta)) { \
|
||||
printf("."); \
|
||||
} else { \
|
||||
printf("\033[31m[F]\033[0m"); \
|
||||
#define ASSERT_EQUALS_WITH_DELTA(a, b, delta, t1, t2) \
|
||||
({ \
|
||||
if (oms_abs((a) - (b)) <= (delta)) { \
|
||||
printf("."); \
|
||||
} else { \
|
||||
printf("\033[31m[F]\033[0m"); \
|
||||
printf("\n\n%s - %i: ", __FILE__, __LINE__); \
|
||||
printf((t1), (a)); printf(" != "); printf((t2), (b)); printf("\n"); \
|
||||
return 0; } \
|
||||
printf((t1), (a)); \
|
||||
printf(" != "); \
|
||||
printf((t2), (b)); \
|
||||
printf("\n"); \
|
||||
return 0; \
|
||||
} \
|
||||
})
|
||||
|
||||
#define ASSERT_CONTAINS(a, b) ({\
|
||||
if (strstr((a), (b)) != NULL) { \
|
||||
printf("."); \
|
||||
} else { \
|
||||
printf("\033[31m[F]\033[0m"); \
|
||||
#define ASSERT_CONTAINS(a, b) \
|
||||
({ \
|
||||
if (strstr((a), (b)) != NULL) { \
|
||||
printf("."); \
|
||||
} else { \
|
||||
printf("\033[31m[F]\033[0m"); \
|
||||
printf("\n\n%s - %i: ", __FILE__, __LINE__); \
|
||||
printf("%s", (a)); printf(" !contains "); printf("%s", (b)); printf("\n"); \
|
||||
return 0; } \
|
||||
printf("%s", (a)); \
|
||||
printf(" !contains "); \
|
||||
printf("%s", (b)); \
|
||||
printf("\n"); \
|
||||
return 0; \
|
||||
} \
|
||||
})
|
||||
|
||||
#define ASSERT_TRUE(a) ({\
|
||||
if ((a) == true) { \
|
||||
printf("."); \
|
||||
} else { \
|
||||
printf("\033[31m[F]\033[0m"); \
|
||||
#define ASSERT_TRUE(a) \
|
||||
({ \
|
||||
if ((a) == true) { \
|
||||
printf("."); \
|
||||
} else { \
|
||||
printf("\033[31m[F]\033[0m"); \
|
||||
printf("\n\n%s - %i: ", __FILE__, __LINE__); \
|
||||
printf("%d", (a)); printf(" != "); printf("1"); printf("\n"); \
|
||||
return 0; } \
|
||||
printf("%d", (a)); \
|
||||
printf(" != "); \
|
||||
printf("1"); \
|
||||
printf("\n"); \
|
||||
return 0; \
|
||||
} \
|
||||
})
|
||||
|
||||
#define ASSERT_FALSE(a) ({\
|
||||
if ((a) == false) { \
|
||||
printf("."); \
|
||||
} else { \
|
||||
printf("\033[31m[F]\033[0m"); \
|
||||
#define ASSERT_FALSE(a) \
|
||||
({ \
|
||||
if ((a) == false) { \
|
||||
printf("."); \
|
||||
} else { \
|
||||
printf("\033[31m[F]\033[0m"); \
|
||||
printf("\n\n%s - %i: ", __FILE__, __LINE__); \
|
||||
printf("%d", (a)); printf(" != "); printf("1"); printf("\n"); \
|
||||
return 0; } \
|
||||
printf("%d", (a)); \
|
||||
printf(" != "); \
|
||||
printf("1"); \
|
||||
printf("\n"); \
|
||||
return 0; \
|
||||
} \
|
||||
})
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@
|
|||
*/
|
||||
#include <stdio.h>
|
||||
|
||||
#include "../../Utils/TestUtils.h"
|
||||
#include "../../Image/ImageUtils.h"
|
||||
#include "../../Utils/TestUtils.h"
|
||||
|
||||
int main(int argc, char** argv)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
printf("ImageUtils:\n\n");
|
||||
|
||||
|
|
|
|||
|
|
@ -7,22 +7,22 @@
|
|||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "../../Utils/TestUtils.h"
|
||||
#include "../../Stdlib/Intrinsics.h"
|
||||
#include "../../Utils/TestUtils.h"
|
||||
|
||||
int main(int argc, char** argv)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
printf("Intrinsics:\n\n");
|
||||
|
||||
ASSERT_EQUALS_WITH_DELTA(Stdlib::Intrinsics::sqrt(1.234f), sqrt(1.234f), 0.01, "%f", "%f");
|
||||
ASSERT_EQUALS_WITH_DELTA((int) Stdlib::Intrinsics::round_to_int(1.234f), (int) roundf(1.234f), 0.01, "%d", "%d");
|
||||
|
||||
//ASSERT_EQUALS_WITH_DELTA(Stdlib::Intrinsics::floor(1.234f), 1.0f, 0.01, "%f", "%f");
|
||||
//ASSERT_EQUALS_WITH_DELTA(Stdlib::Intrinsics::round(1.234f), roundf(1.234f), 0.01, "%f", "%f");
|
||||
// ASSERT_EQUALS_WITH_DELTA(Stdlib::Intrinsics::floor(1.234f), 1.0f, 0.01, "%f", "%f");
|
||||
// ASSERT_EQUALS_WITH_DELTA(Stdlib::Intrinsics::round(1.234f), roundf(1.234f), 0.01, "%f", "%f");
|
||||
|
||||
ASSERT_NOT_EQUALS(Stdlib::Intrinsics::hash(123456), Stdlib::Intrinsics::hash(654321), "%d", "%d");
|
||||
|
||||
|
|
|
|||
|
|
@ -10,30 +10,30 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "../../../Utils/TestUtils.h"
|
||||
#include "../../../Stdlib/SIMD/SIMD_F32.h"
|
||||
#include "../../../Stdlib/SIMD/SIMD_Helper.h"
|
||||
#include "../../../Utils/TestUtils.h"
|
||||
|
||||
float* a_array_4 = (float *) aligned_alloc(32, 4 * sizeof(float));
|
||||
float* b_array_4 = (float *) aligned_alloc(32, 4 * sizeof(float));
|
||||
float* expected_array_4 = (float *) aligned_alloc(32, 4 * sizeof(float));
|
||||
float* result_array_4 = (float *) aligned_alloc(32, 4 * sizeof(float));
|
||||
float *a_array_4 = (float *) aligned_alloc(32, 4 * sizeof(float));
|
||||
float *b_array_4 = (float *) aligned_alloc(32, 4 * sizeof(float));
|
||||
float *expected_array_4 = (float *) aligned_alloc(32, 4 * sizeof(float));
|
||||
float *result_array_4 = (float *) aligned_alloc(32, 4 * sizeof(float));
|
||||
|
||||
float* a_array_8 = (float *) aligned_alloc(32, 8 * sizeof(float));
|
||||
float* b_array_8 = (float *) aligned_alloc(32, 8 * sizeof(float));
|
||||
float* expected_array_8 = (float *) aligned_alloc(32, 8 * sizeof(float));
|
||||
float* result_array_8 = (float *) aligned_alloc(32, 8 * sizeof(float));
|
||||
float *a_array_8 = (float *) aligned_alloc(32, 8 * sizeof(float));
|
||||
float *b_array_8 = (float *) aligned_alloc(32, 8 * sizeof(float));
|
||||
float *expected_array_8 = (float *) aligned_alloc(32, 8 * sizeof(float));
|
||||
float *result_array_8 = (float *) aligned_alloc(32, 8 * sizeof(float));
|
||||
|
||||
float* a_array_16 = (float *) aligned_alloc(32, 16 * sizeof(float));
|
||||
float* b_array_16 = (float *) aligned_alloc(32, 16 * sizeof(float));
|
||||
float* expected_array_16 = (float *) aligned_alloc(32, 16 * sizeof(float));
|
||||
float* result_array_16 = (float *) aligned_alloc(32, 16 * sizeof(float));
|
||||
float *a_array_16 = (float *) aligned_alloc(32, 16 * sizeof(float));
|
||||
float *b_array_16 = (float *) aligned_alloc(32, 16 * sizeof(float));
|
||||
float *expected_array_16 = (float *) aligned_alloc(32, 16 * sizeof(float));
|
||||
float *result_array_16 = (float *) aligned_alloc(32, 16 * sizeof(float));
|
||||
|
||||
int test_operator_plus();
|
||||
int test_operator_minus();
|
||||
int test_operator_mul();
|
||||
|
||||
int main(int argc, char** argv)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
printf("SIMD_F32:\n");
|
||||
|
||||
|
|
@ -56,10 +56,19 @@ int test_operator_plus()
|
|||
return 0;
|
||||
}
|
||||
|
||||
a_array_4[0] = 0.0f; a_array_4[1] = 1.0f; a_array_4[2] = 2.0f; a_array_4[3] = 3.0f;
|
||||
b_array_4[0] = 0.0f; b_array_4[1] = 1.0f; b_array_4[2] = 2.0f; b_array_4[3] = 3.0f;
|
||||
a_array_4[0] = 0.0f;
|
||||
a_array_4[1] = 1.0f;
|
||||
a_array_4[2] = 2.0f;
|
||||
a_array_4[3] = 3.0f;
|
||||
b_array_4[0] = 0.0f;
|
||||
b_array_4[1] = 1.0f;
|
||||
b_array_4[2] = 2.0f;
|
||||
b_array_4[3] = 3.0f;
|
||||
|
||||
expected_array_4[0] = 0.0f; expected_array_4[1] = 2.0f; expected_array_4[2] = 4.0f; expected_array_4[3] = 6.0f;
|
||||
expected_array_4[0] = 0.0f;
|
||||
expected_array_4[1] = 2.0f;
|
||||
expected_array_4[2] = 4.0f;
|
||||
expected_array_4[3] = 6.0f;
|
||||
Stdlib::SIMD::f32_4_simd expected_simd_4 = Stdlib::SIMD::load_f32_4_simd(expected_array_4);
|
||||
|
||||
Stdlib::SIMD::f32_4_simd a_simd_4 = Stdlib::SIMD::load_f32_4_simd(a_array_4);
|
||||
|
|
@ -82,14 +91,32 @@ int test_operator_plus()
|
|||
return 0;
|
||||
}
|
||||
|
||||
a_array_8[0] = 0.0f; a_array_8[1] = 1.0f; a_array_8[2] = 2.0f; a_array_8[3] = 3.0f;
|
||||
a_array_8[4] = 0.0f; a_array_8[5] = 1.0f; a_array_8[6] = 2.0f; a_array_8[7] = 3.0f;
|
||||
a_array_8[0] = 0.0f;
|
||||
a_array_8[1] = 1.0f;
|
||||
a_array_8[2] = 2.0f;
|
||||
a_array_8[3] = 3.0f;
|
||||
a_array_8[4] = 0.0f;
|
||||
a_array_8[5] = 1.0f;
|
||||
a_array_8[6] = 2.0f;
|
||||
a_array_8[7] = 3.0f;
|
||||
|
||||
b_array_8[0] = 0.0f; b_array_8[1] = 1.0f; b_array_8[2] = 2.0f; b_array_8[3] = 3.0f;
|
||||
b_array_8[4] = 0.0f; b_array_8[5] = 1.0f; b_array_8[6] = 2.0f; b_array_8[7] = 3.0f;
|
||||
b_array_8[0] = 0.0f;
|
||||
b_array_8[1] = 1.0f;
|
||||
b_array_8[2] = 2.0f;
|
||||
b_array_8[3] = 3.0f;
|
||||
b_array_8[4] = 0.0f;
|
||||
b_array_8[5] = 1.0f;
|
||||
b_array_8[6] = 2.0f;
|
||||
b_array_8[7] = 3.0f;
|
||||
|
||||
expected_array_8[0] = 0.0f; expected_array_8[1] = 2.0f; expected_array_8[2] = 4.0f; expected_array_8[3] = 6.0f;
|
||||
expected_array_8[4] = 0.0f; expected_array_8[5] = 2.0f; expected_array_8[6] = 4.0f; expected_array_8[7] = 6.0f;
|
||||
expected_array_8[0] = 0.0f;
|
||||
expected_array_8[1] = 2.0f;
|
||||
expected_array_8[2] = 4.0f;
|
||||
expected_array_8[3] = 6.0f;
|
||||
expected_array_8[4] = 0.0f;
|
||||
expected_array_8[5] = 2.0f;
|
||||
expected_array_8[6] = 4.0f;
|
||||
expected_array_8[7] = 6.0f;
|
||||
Stdlib::SIMD::f32_8_simd expected_simd_8 = Stdlib::SIMD::load_f32_8_simd(expected_array_8);
|
||||
|
||||
Stdlib::SIMD::f32_8_simd a_simd_8 = Stdlib::SIMD::load_f32_8_simd(a_array_8);
|
||||
|
|
@ -116,20 +143,56 @@ int test_operator_plus()
|
|||
return 0;
|
||||
}
|
||||
|
||||
a_array_16[0] = 0.0f; a_array_16[1] = 1.0f; a_array_16[2] = 2.0f; a_array_16[3] = 3.0f;
|
||||
a_array_16[4] = 0.0f; a_array_16[5] = 1.0f; a_array_16[6] = 2.0f; a_array_16[7] = 3.0f;
|
||||
a_array_16[8] = 0.0f; a_array_16[9] = 1.0f; a_array_16[10] = 2.0f; a_array_16[11] = 3.0f;
|
||||
a_array_16[12] = 0.0f; a_array_16[13] = 1.0f; a_array_16[14] = 2.0f; a_array_16[15] = 3.0f;
|
||||
a_array_16[0] = 0.0f;
|
||||
a_array_16[1] = 1.0f;
|
||||
a_array_16[2] = 2.0f;
|
||||
a_array_16[3] = 3.0f;
|
||||
a_array_16[4] = 0.0f;
|
||||
a_array_16[5] = 1.0f;
|
||||
a_array_16[6] = 2.0f;
|
||||
a_array_16[7] = 3.0f;
|
||||
a_array_16[8] = 0.0f;
|
||||
a_array_16[9] = 1.0f;
|
||||
a_array_16[10] = 2.0f;
|
||||
a_array_16[11] = 3.0f;
|
||||
a_array_16[12] = 0.0f;
|
||||
a_array_16[13] = 1.0f;
|
||||
a_array_16[14] = 2.0f;
|
||||
a_array_16[15] = 3.0f;
|
||||
|
||||
b_array_16[0] = 0.0f; b_array_16[1] = 1.0f; b_array_16[2] = 2.0f; b_array_16[3] = 3.0f;
|
||||
b_array_16[4] = 0.0f; b_array_16[5] = 1.0f; b_array_16[6] = 2.0f; b_array_16[7] = 3.0f;
|
||||
b_array_16[8] = 0.0f; b_array_16[9] = 1.0f; b_array_16[10] = 2.0f; b_array_16[11] = 3.0f;
|
||||
b_array_16[12] = 0.0f; b_array_16[13] = 1.0f; b_array_16[14] = 2.0f; b_array_16[15] = 3.0f;
|
||||
b_array_16[0] = 0.0f;
|
||||
b_array_16[1] = 1.0f;
|
||||
b_array_16[2] = 2.0f;
|
||||
b_array_16[3] = 3.0f;
|
||||
b_array_16[4] = 0.0f;
|
||||
b_array_16[5] = 1.0f;
|
||||
b_array_16[6] = 2.0f;
|
||||
b_array_16[7] = 3.0f;
|
||||
b_array_16[8] = 0.0f;
|
||||
b_array_16[9] = 1.0f;
|
||||
b_array_16[10] = 2.0f;
|
||||
b_array_16[11] = 3.0f;
|
||||
b_array_16[12] = 0.0f;
|
||||
b_array_16[13] = 1.0f;
|
||||
b_array_16[14] = 2.0f;
|
||||
b_array_16[15] = 3.0f;
|
||||
|
||||
expected_array_16[0] = 0.0f; expected_array_16[1] = 2.0f; expected_array_16[2] = 4.0f; expected_array_16[3] = 6.0f;
|
||||
expected_array_16[4] = 0.0f; expected_array_16[5] = 2.0f; expected_array_16[6] = 4.0f; expected_array_16[7] = 6.0f;
|
||||
expected_array_16[8] = 0.0f; expected_array_16[9] = 2.0f; expected_array_16[10] = 4.0f; expected_array_16[11] = 6.0f;
|
||||
expected_array_16[12] = 0.0f; expected_array_16[13] = 2.0f; expected_array_16[14] = 4.0f; expected_array_16[15] = 6.0f;
|
||||
expected_array_16[0] = 0.0f;
|
||||
expected_array_16[1] = 2.0f;
|
||||
expected_array_16[2] = 4.0f;
|
||||
expected_array_16[3] = 6.0f;
|
||||
expected_array_16[4] = 0.0f;
|
||||
expected_array_16[5] = 2.0f;
|
||||
expected_array_16[6] = 4.0f;
|
||||
expected_array_16[7] = 6.0f;
|
||||
expected_array_16[8] = 0.0f;
|
||||
expected_array_16[9] = 2.0f;
|
||||
expected_array_16[10] = 4.0f;
|
||||
expected_array_16[11] = 6.0f;
|
||||
expected_array_16[12] = 0.0f;
|
||||
expected_array_16[13] = 2.0f;
|
||||
expected_array_16[14] = 4.0f;
|
||||
expected_array_16[15] = 6.0f;
|
||||
Stdlib::SIMD::f32_16_simd expected_simd_16 = Stdlib::SIMD::load_f32_16_simd(expected_array_16);
|
||||
|
||||
Stdlib::SIMD::f32_16_simd a_simd_16 = Stdlib::SIMD::load_f32_16_simd(a_array_16);
|
||||
|
|
@ -169,10 +232,19 @@ int test_operator_minus()
|
|||
return 0;
|
||||
}
|
||||
|
||||
a_array_4[0] = 0.0f; a_array_4[1] = 1.0f; a_array_4[2] = 2.0f; a_array_4[3] = 3.0f;
|
||||
b_array_4[0] = 1.0f; b_array_4[1] = 1.0f; b_array_4[2] = 1.0f; b_array_4[3] = 1.0f;
|
||||
a_array_4[0] = 0.0f;
|
||||
a_array_4[1] = 1.0f;
|
||||
a_array_4[2] = 2.0f;
|
||||
a_array_4[3] = 3.0f;
|
||||
b_array_4[0] = 1.0f;
|
||||
b_array_4[1] = 1.0f;
|
||||
b_array_4[2] = 1.0f;
|
||||
b_array_4[3] = 1.0f;
|
||||
|
||||
expected_array_4[0] = -1.0f; expected_array_4[1] = 0.0f; expected_array_4[2] = 1.0f; expected_array_4[3] = 2.0f;
|
||||
expected_array_4[0] = -1.0f;
|
||||
expected_array_4[1] = 0.0f;
|
||||
expected_array_4[2] = 1.0f;
|
||||
expected_array_4[3] = 2.0f;
|
||||
Stdlib::SIMD::f32_4_simd expected_simd_4 = Stdlib::SIMD::load_f32_4_simd(expected_array_4);
|
||||
|
||||
Stdlib::SIMD::f32_4_simd a_simd_4 = Stdlib::SIMD::load_f32_4_simd(a_array_4);
|
||||
|
|
@ -195,14 +267,32 @@ int test_operator_minus()
|
|||
return 0;
|
||||
}
|
||||
|
||||
a_array_8[0] = 0.0f; a_array_8[1] = 1.0f; a_array_8[2] = 2.0f; a_array_8[3] = 3.0f;
|
||||
a_array_8[4] = 0.0f; a_array_8[5] = 1.0f; a_array_8[6] = 2.0f; a_array_8[7] = 3.0f;
|
||||
a_array_8[0] = 0.0f;
|
||||
a_array_8[1] = 1.0f;
|
||||
a_array_8[2] = 2.0f;
|
||||
a_array_8[3] = 3.0f;
|
||||
a_array_8[4] = 0.0f;
|
||||
a_array_8[5] = 1.0f;
|
||||
a_array_8[6] = 2.0f;
|
||||
a_array_8[7] = 3.0f;
|
||||
|
||||
b_array_8[0] = 1.0f; b_array_8[1] = 1.0f; b_array_8[2] = 1.0f; b_array_8[3] = 1.0f;
|
||||
b_array_8[4] = 1.0f; b_array_8[5] = 1.0f; b_array_8[6] = 1.0f; b_array_8[7] = 1.0f;
|
||||
b_array_8[0] = 1.0f;
|
||||
b_array_8[1] = 1.0f;
|
||||
b_array_8[2] = 1.0f;
|
||||
b_array_8[3] = 1.0f;
|
||||
b_array_8[4] = 1.0f;
|
||||
b_array_8[5] = 1.0f;
|
||||
b_array_8[6] = 1.0f;
|
||||
b_array_8[7] = 1.0f;
|
||||
|
||||
expected_array_8[0] = -1.0f; expected_array_8[1] = 0.0f; expected_array_8[2] = 1.0f; expected_array_8[3] = 2.0f;
|
||||
expected_array_8[4] = -1.0f; expected_array_8[5] = 0.0f; expected_array_8[6] = 1.0f; expected_array_8[7] = 2.0f;
|
||||
expected_array_8[0] = -1.0f;
|
||||
expected_array_8[1] = 0.0f;
|
||||
expected_array_8[2] = 1.0f;
|
||||
expected_array_8[3] = 2.0f;
|
||||
expected_array_8[4] = -1.0f;
|
||||
expected_array_8[5] = 0.0f;
|
||||
expected_array_8[6] = 1.0f;
|
||||
expected_array_8[7] = 2.0f;
|
||||
Stdlib::SIMD::f32_8_simd expected_simd_8 = Stdlib::SIMD::load_f32_8_simd(expected_array_8);
|
||||
|
||||
Stdlib::SIMD::f32_8_simd a_simd_8 = Stdlib::SIMD::load_f32_8_simd(a_array_8);
|
||||
|
|
@ -229,20 +319,56 @@ int test_operator_minus()
|
|||
return 0;
|
||||
}
|
||||
|
||||
a_array_16[0] = 0.0f; a_array_16[1] = 1.0f; a_array_16[2] = 2.0f; a_array_16[3] = 3.0f;
|
||||
a_array_16[4] = 0.0f; a_array_16[5] = 1.0f; a_array_16[6] = 2.0f; a_array_16[7] = 3.0f;
|
||||
a_array_16[8] = 0.0f; a_array_16[9] = 1.0f; a_array_16[10] = 2.0f; a_array_16[11] = 3.0f;
|
||||
a_array_16[12] = 0.0f; a_array_16[13] = 1.0f; a_array_16[14] = 2.0f; a_array_16[15] = 3.0f;
|
||||
a_array_16[0] = 0.0f;
|
||||
a_array_16[1] = 1.0f;
|
||||
a_array_16[2] = 2.0f;
|
||||
a_array_16[3] = 3.0f;
|
||||
a_array_16[4] = 0.0f;
|
||||
a_array_16[5] = 1.0f;
|
||||
a_array_16[6] = 2.0f;
|
||||
a_array_16[7] = 3.0f;
|
||||
a_array_16[8] = 0.0f;
|
||||
a_array_16[9] = 1.0f;
|
||||
a_array_16[10] = 2.0f;
|
||||
a_array_16[11] = 3.0f;
|
||||
a_array_16[12] = 0.0f;
|
||||
a_array_16[13] = 1.0f;
|
||||
a_array_16[14] = 2.0f;
|
||||
a_array_16[15] = 3.0f;
|
||||
|
||||
b_array_16[0] = 1.0f; b_array_16[1] = 1.0f; b_array_16[2] = 1.0f; b_array_16[3] = 1.0f;
|
||||
b_array_16[4] = 1.0f; b_array_16[5] = 1.0f; b_array_16[6] = 1.0f; b_array_16[7] = 1.0f;
|
||||
b_array_16[8] = 1.0f; b_array_16[9] = 1.0f; b_array_16[10] = 1.0f; b_array_16[11] = 1.0f;
|
||||
b_array_16[12] = 1.0f; b_array_16[13] = 1.0f; b_array_16[14] = 1.0f; b_array_16[15] = 1.0f;
|
||||
b_array_16[0] = 1.0f;
|
||||
b_array_16[1] = 1.0f;
|
||||
b_array_16[2] = 1.0f;
|
||||
b_array_16[3] = 1.0f;
|
||||
b_array_16[4] = 1.0f;
|
||||
b_array_16[5] = 1.0f;
|
||||
b_array_16[6] = 1.0f;
|
||||
b_array_16[7] = 1.0f;
|
||||
b_array_16[8] = 1.0f;
|
||||
b_array_16[9] = 1.0f;
|
||||
b_array_16[10] = 1.0f;
|
||||
b_array_16[11] = 1.0f;
|
||||
b_array_16[12] = 1.0f;
|
||||
b_array_16[13] = 1.0f;
|
||||
b_array_16[14] = 1.0f;
|
||||
b_array_16[15] = 1.0f;
|
||||
|
||||
expected_array_16[0] = -1.0f; expected_array_16[1] = 0.0f; expected_array_16[2] = 1.0f; expected_array_16[3] = 2.0f;
|
||||
expected_array_16[4] = -1.0f; expected_array_16[5] = 0.0f; expected_array_16[6] = 1.0f; expected_array_16[7] = 2.0f;
|
||||
expected_array_16[8] = -1.0f; expected_array_16[9] = 0.0f; expected_array_16[10] = 1.0f; expected_array_16[11] = 2.0f;
|
||||
expected_array_16[12] = -1.0f; expected_array_16[13] = 0.0f; expected_array_16[14] = 1.0f; expected_array_16[15] = 2.0f;
|
||||
expected_array_16[0] = -1.0f;
|
||||
expected_array_16[1] = 0.0f;
|
||||
expected_array_16[2] = 1.0f;
|
||||
expected_array_16[3] = 2.0f;
|
||||
expected_array_16[4] = -1.0f;
|
||||
expected_array_16[5] = 0.0f;
|
||||
expected_array_16[6] = 1.0f;
|
||||
expected_array_16[7] = 2.0f;
|
||||
expected_array_16[8] = -1.0f;
|
||||
expected_array_16[9] = 0.0f;
|
||||
expected_array_16[10] = 1.0f;
|
||||
expected_array_16[11] = 2.0f;
|
||||
expected_array_16[12] = -1.0f;
|
||||
expected_array_16[13] = 0.0f;
|
||||
expected_array_16[14] = 1.0f;
|
||||
expected_array_16[15] = 2.0f;
|
||||
Stdlib::SIMD::f32_16_simd expected_simd_16 = Stdlib::SIMD::load_f32_16_simd(expected_array_16);
|
||||
|
||||
Stdlib::SIMD::f32_16_simd a_simd_16 = Stdlib::SIMD::load_f32_16_simd(a_array_16);
|
||||
|
|
@ -282,10 +408,19 @@ int test_operator_mul()
|
|||
return 0;
|
||||
}
|
||||
|
||||
a_array_4[0] = 0.0f; a_array_4[1] = 1.0f; a_array_4[2] = 2.0f; a_array_4[3] = 3.0f;
|
||||
b_array_4[0] = 0.0f; b_array_4[1] = 1.0f; b_array_4[2] = 2.0f; b_array_4[3] = 3.0f;
|
||||
a_array_4[0] = 0.0f;
|
||||
a_array_4[1] = 1.0f;
|
||||
a_array_4[2] = 2.0f;
|
||||
a_array_4[3] = 3.0f;
|
||||
b_array_4[0] = 0.0f;
|
||||
b_array_4[1] = 1.0f;
|
||||
b_array_4[2] = 2.0f;
|
||||
b_array_4[3] = 3.0f;
|
||||
|
||||
expected_array_4[0] = 0.0f; expected_array_4[1] = 1.0f; expected_array_4[2] = 4.0f; expected_array_4[3] = 9.0f;
|
||||
expected_array_4[0] = 0.0f;
|
||||
expected_array_4[1] = 1.0f;
|
||||
expected_array_4[2] = 4.0f;
|
||||
expected_array_4[3] = 9.0f;
|
||||
Stdlib::SIMD::f32_4_simd expected_simd_4 = Stdlib::SIMD::load_f32_4_simd(expected_array_4);
|
||||
|
||||
Stdlib::SIMD::f32_4_simd a_simd_4 = Stdlib::SIMD::load_f32_4_simd(a_array_4);
|
||||
|
|
@ -308,14 +443,32 @@ int test_operator_mul()
|
|||
return 0;
|
||||
}
|
||||
|
||||
a_array_8[0] = 0.0f; a_array_8[1] = 1.0f; a_array_8[2] = 2.0f; a_array_8[3] = 3.0f;
|
||||
a_array_8[4] = 0.0f; a_array_8[5] = 1.0f; a_array_8[6] = 2.0f; a_array_8[7] = 3.0f;
|
||||
a_array_8[0] = 0.0f;
|
||||
a_array_8[1] = 1.0f;
|
||||
a_array_8[2] = 2.0f;
|
||||
a_array_8[3] = 3.0f;
|
||||
a_array_8[4] = 0.0f;
|
||||
a_array_8[5] = 1.0f;
|
||||
a_array_8[6] = 2.0f;
|
||||
a_array_8[7] = 3.0f;
|
||||
|
||||
b_array_8[0] = 0.0f; b_array_8[1] = 1.0f; b_array_8[2] = 2.0f; b_array_8[3] = 3.0f;
|
||||
b_array_8[4] = 0.0f; b_array_8[5] = 1.0f; b_array_8[6] = 2.0f; b_array_8[7] = 3.0f;
|
||||
b_array_8[0] = 0.0f;
|
||||
b_array_8[1] = 1.0f;
|
||||
b_array_8[2] = 2.0f;
|
||||
b_array_8[3] = 3.0f;
|
||||
b_array_8[4] = 0.0f;
|
||||
b_array_8[5] = 1.0f;
|
||||
b_array_8[6] = 2.0f;
|
||||
b_array_8[7] = 3.0f;
|
||||
|
||||
expected_array_8[0] = 0.0f; expected_array_8[1] = 1.0f; expected_array_8[2] = 4.0f; expected_array_8[3] = 9.0f;
|
||||
expected_array_8[4] = 0.0f; expected_array_8[5] = 1.0f; expected_array_8[6] = 4.0f; expected_array_8[7] = 9.0f;
|
||||
expected_array_8[0] = 0.0f;
|
||||
expected_array_8[1] = 1.0f;
|
||||
expected_array_8[2] = 4.0f;
|
||||
expected_array_8[3] = 9.0f;
|
||||
expected_array_8[4] = 0.0f;
|
||||
expected_array_8[5] = 1.0f;
|
||||
expected_array_8[6] = 4.0f;
|
||||
expected_array_8[7] = 9.0f;
|
||||
Stdlib::SIMD::f32_8_simd expected_simd_8 = Stdlib::SIMD::load_f32_8_simd(expected_array_8);
|
||||
|
||||
Stdlib::SIMD::f32_8_simd a_simd_8 = Stdlib::SIMD::load_f32_8_simd(a_array_8);
|
||||
|
|
@ -342,20 +495,56 @@ int test_operator_mul()
|
|||
return 0;
|
||||
}
|
||||
|
||||
a_array_16[0] = 0.0f; a_array_16[1] = 1.0f; a_array_16[2] = 2.0f; a_array_16[3] = 3.0f;
|
||||
a_array_16[4] = 0.0f; a_array_16[5] = 1.0f; a_array_16[6] = 2.0f; a_array_16[7] = 3.0f;
|
||||
a_array_16[8] = 0.0f; a_array_16[9] = 1.0f; a_array_16[10] = 2.0f; a_array_16[11] = 3.0f;
|
||||
a_array_16[12] = 0.0f; a_array_16[13] = 1.0f; a_array_16[14] = 2.0f; a_array_16[15] = 3.0f;
|
||||
a_array_16[0] = 0.0f;
|
||||
a_array_16[1] = 1.0f;
|
||||
a_array_16[2] = 2.0f;
|
||||
a_array_16[3] = 3.0f;
|
||||
a_array_16[4] = 0.0f;
|
||||
a_array_16[5] = 1.0f;
|
||||
a_array_16[6] = 2.0f;
|
||||
a_array_16[7] = 3.0f;
|
||||
a_array_16[8] = 0.0f;
|
||||
a_array_16[9] = 1.0f;
|
||||
a_array_16[10] = 2.0f;
|
||||
a_array_16[11] = 3.0f;
|
||||
a_array_16[12] = 0.0f;
|
||||
a_array_16[13] = 1.0f;
|
||||
a_array_16[14] = 2.0f;
|
||||
a_array_16[15] = 3.0f;
|
||||
|
||||
b_array_16[0] = 0.0f; b_array_16[1] = 1.0f; b_array_16[2] = 2.0f; b_array_16[3] = 3.0f;
|
||||
b_array_16[4] = 0.0f; b_array_16[5] = 1.0f; b_array_16[6] = 2.0f; b_array_16[7] = 3.0f;
|
||||
b_array_16[8] = 0.0f; b_array_16[9] = 1.0f; b_array_16[10] = 2.0f; b_array_16[11] = 3.0f;
|
||||
b_array_16[12] = 0.0f; b_array_16[13] = 1.0f; b_array_16[14] = 2.0f; b_array_16[15] = 3.0f;
|
||||
b_array_16[0] = 0.0f;
|
||||
b_array_16[1] = 1.0f;
|
||||
b_array_16[2] = 2.0f;
|
||||
b_array_16[3] = 3.0f;
|
||||
b_array_16[4] = 0.0f;
|
||||
b_array_16[5] = 1.0f;
|
||||
b_array_16[6] = 2.0f;
|
||||
b_array_16[7] = 3.0f;
|
||||
b_array_16[8] = 0.0f;
|
||||
b_array_16[9] = 1.0f;
|
||||
b_array_16[10] = 2.0f;
|
||||
b_array_16[11] = 3.0f;
|
||||
b_array_16[12] = 0.0f;
|
||||
b_array_16[13] = 1.0f;
|
||||
b_array_16[14] = 2.0f;
|
||||
b_array_16[15] = 3.0f;
|
||||
|
||||
expected_array_16[0] = 0.0f; expected_array_16[1] = 1.0f; expected_array_16[2] = 4.0f; expected_array_16[3] = 9.0f;
|
||||
expected_array_16[4] = 0.0f; expected_array_16[5] = 1.0f; expected_array_16[6] = 4.0f; expected_array_16[7] = 9.0f;
|
||||
expected_array_16[8] = 0.0f; expected_array_16[9] = 1.0f; expected_array_16[10] = 4.0f; expected_array_16[11] = 9.0f;
|
||||
expected_array_16[12] = 0.0f; expected_array_16[13] = 1.0f; expected_array_16[14] = 4.0f; expected_array_16[15] = 9.0f;
|
||||
expected_array_16[0] = 0.0f;
|
||||
expected_array_16[1] = 1.0f;
|
||||
expected_array_16[2] = 4.0f;
|
||||
expected_array_16[3] = 9.0f;
|
||||
expected_array_16[4] = 0.0f;
|
||||
expected_array_16[5] = 1.0f;
|
||||
expected_array_16[6] = 4.0f;
|
||||
expected_array_16[7] = 9.0f;
|
||||
expected_array_16[8] = 0.0f;
|
||||
expected_array_16[9] = 1.0f;
|
||||
expected_array_16[10] = 4.0f;
|
||||
expected_array_16[11] = 9.0f;
|
||||
expected_array_16[12] = 0.0f;
|
||||
expected_array_16[13] = 1.0f;
|
||||
expected_array_16[14] = 4.0f;
|
||||
expected_array_16[15] = 9.0f;
|
||||
Stdlib::SIMD::f32_16_simd expected_simd_16 = Stdlib::SIMD::load_f32_16_simd(expected_array_16);
|
||||
|
||||
Stdlib::SIMD::f32_16_simd a_simd_16 = Stdlib::SIMD::load_f32_16_simd(a_array_16);
|
||||
|
|
|
|||
|
|
@ -10,11 +10,10 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "../../../Utils/TestUtils.h"
|
||||
#include "../../../Stdlib/SIMD/SIMD_Helper.h"
|
||||
#include "../../../Utils/TestUtils.h"
|
||||
|
||||
|
||||
int main(int argc, char** argv)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
printf("SIMD_Helper:\n");
|
||||
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@
|
|||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "../../Threads/Thread.h"
|
||||
#include "../../Utils/TestUtils.h"
|
||||
|
|
@ -21,8 +21,8 @@ void worker(void *arg)
|
|||
{
|
||||
Threads::Job *job = (Threads::Job *) arg;
|
||||
|
||||
int *val = (int *) job->arg;
|
||||
*val += 100;
|
||||
int *val = (int *) job->arg;
|
||||
*val += 100;
|
||||
|
||||
if (*val % 2) {
|
||||
sleep(1);
|
||||
|
|
@ -31,24 +31,24 @@ void worker(void *arg)
|
|||
job->state = 1;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
printf("Threads:\n\n");
|
||||
printf("ThreadPool:\n");
|
||||
|
||||
int i;
|
||||
Threads::ThreadPool *pool = Threads::pool_create(num_threads);
|
||||
int *vals = (int *) calloc(num_items, sizeof(int));
|
||||
Threads::Job **works = (Threads::Job **) calloc(num_items, sizeof(Threads::Job));
|
||||
int *vals = (int *) calloc(num_items, sizeof(int));
|
||||
Threads::Job **works = (Threads::Job **) calloc(num_items, sizeof(Threads::Job));
|
||||
|
||||
for (i = 0; i < num_items; ++i) {
|
||||
vals[i] = i;
|
||||
vals[i] = i;
|
||||
works[i] = Threads::pool_add_work(pool, worker, vals + i);
|
||||
}
|
||||
|
||||
// @bug wait is not working as expected
|
||||
// I thought wait works similarly to what the do/while construct below does
|
||||
//Threads::pool_wait(pool);
|
||||
// Threads::pool_wait(pool);
|
||||
|
||||
bool finished = false;
|
||||
do {
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@
|
|||
*/
|
||||
#include <stdio.h>
|
||||
|
||||
#include "../../Utils/WebUtils.h"
|
||||
#include "../../Utils/TestUtils.h"
|
||||
#include "../../Utils/WebUtils.h"
|
||||
|
||||
int main(int argc, char** argv)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
printf("Utils:\n\n");
|
||||
printf("WebUtils:\n");
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user