large.c: replace binary_load/add() etc with uint64_t based large_load/add() etc for performance

This commit is contained in:
gitlost 2020-06-14 14:42:40 +01:00
parent 3690c19749
commit e8a238aad1
14 changed files with 1566 additions and 804 deletions

View file

@ -2,7 +2,7 @@
/*
libzint - the open source barcode library
Copyright (C) 2008-2017 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2008 - 2020 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -33,17 +33,45 @@
#ifndef __LARGE_H
#define __LARGE_H
#ifndef _MSC_VER
#include <stdint.h>
#else
#include "ms_stdint.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
INTERNAL void binary_load(short int reg[], char data[], const size_t src_len);
INTERNAL void binary_add(short int accumulator[], short int input_buffer[]);
INTERNAL void binary_subtract(short int accumulator[], short int input_buffer[]);
INTERNAL void shiftdown(short int buffer[]);
INTERNAL void shiftup(short int buffer[]);
INTERNAL short int islarger(short int accum[], short int reg[]);
INTERNAL void binary_multiply(short int reg[], char data[]);
typedef struct { uint64_t lo; uint64_t hi; } large_int;
#define large_lo(s) ((s)->lo)
#define large_hi(s) ((s)->hi)
/* Set 128-bit `t` from 128-bit `s` */
#define large_load(t, s) do { (t)->lo = (s)->lo; (t)->hi = (s)->hi; } while (0)
/* Set 128-bit `t` from 64-bit `s` */
#define large_load_u64(t, s) do { (t)->lo = (s); (t)->hi = 0; } while (0)
INTERNAL void large_load_str_u64(large_int *t, const unsigned char *s, int length);
INTERNAL void large_add(large_int *t, const large_int *s);
INTERNAL void large_add_u64(large_int *t, uint64_t s);
INTERNAL void large_sub_u64(large_int *t, uint64_t s);
INTERNAL void large_mul_u64(large_int *t, uint64_t s);
INTERNAL uint64_t large_div_u64(large_int *t, uint64_t v);
INTERNAL void large_unset_bit(large_int *t, int bit);
INTERNAL void large_uint_array(const large_int *t, unsigned int *uint_array, int size, int bits);
INTERNAL void large_uchar_array(const large_int *t, unsigned char *uchar_array, int size, int bits);
INTERNAL void large_print(large_int *t);
INTERNAL char *large_dump(large_int *t, char *buf);
#ifdef __cplusplus
}