some minor fixes

- version number was 1.1.0 instead of 1.1.2
- renamed mem.h to fix compiling the windows binaries
- changes (rv < 0) to (rv != 0)
This commit is contained in:
Tino Reichardt
2016-12-26 11:04:47 +01:00
parent e123752e09
commit b351c1a3fb
10 changed files with 46 additions and 60 deletions

View File

@@ -2,10 +2,9 @@
# Multithreading Library for [LZ4], [LZ5] and [ZStandard]
- this library is a temporary solution to the threading problem with zstd, lz4 and lz5
- future version will support threading in some way, I think ;)
- future versions of that compression libs will support threading in some way, I think ;)
- it's based on my zstdmt version @ github...
zstdmt_compress.c
/TR 2016-12-22
/TR 2016-12-26

View File

@@ -17,7 +17,7 @@
#define LZ4F_DISABLE_OBSOLETE_ENUMS
#include "lz4frame.h"
#include "mem.h"
#include "memmt.h"
#include "threading.h"
#include "list.h"
#include "lz4mt.h"
@@ -193,7 +193,7 @@ static size_t pt_write(LZ4MT_CCtx * ctx, struct writelist *wl)
wl = list_entry(entry, struct writelist, node);
if (wl->frame == ctx->curframe) {
int rv = ctx->fn_write(ctx->arg_write, &wl->out);
if (rv < 0)
if (rv != 0)
return mt_error(rv);
ctx->outsize += wl->out.size;
ctx->curframe++;
@@ -257,7 +257,7 @@ static void *pt_compress(void *arg)
pthread_mutex_lock(&ctx->read_mutex);
in.size = ctx->inputsize;
rv = ctx->fn_read(ctx->arg_read, &in);
if (rv < 0) {
if (rv != 0) {
pthread_mutex_unlock(&ctx->read_mutex);
return (void*)mt_error(rv);
}

View File

@@ -17,7 +17,7 @@
#define LZ4F_DISABLE_OBSOLETE_ENUMS
#include "lz4frame.h"
#include "mem.h"
#include "memmt.h"
#include "threading.h"
#include "list.h"
#include "lz4mt.h"
@@ -174,7 +174,7 @@ static size_t pt_write(LZ4MT_DCtx * ctx, struct writelist *wl)
wl = list_entry(entry, struct writelist, node);
if (wl->frame == ctx->curframe) {
int rv = ctx->fn_write(ctx->arg_write, &wl->out);
if (rv < 0)
if (rv != 0)
return mt_error(rv);
ctx->outsize += wl->out.size;
ctx->curframe++;
@@ -203,7 +203,7 @@ static size_t pt_read(LZ4MT_DCtx * ctx, LZ4MT_Buffer * in, size_t * frame)
hdr.buf = hdrbuf + 4;
hdr.size = 8;
rv = ctx->fn_read(ctx->arg_read, &hdr);
if (rv < 0) {
if (rv != 0) {
pthread_mutex_unlock(&ctx->read_mutex);
return mt_error(rv);
}
@@ -214,7 +214,7 @@ static size_t pt_read(LZ4MT_DCtx * ctx, LZ4MT_Buffer * in, size_t * frame)
hdr.buf = hdrbuf;
hdr.size = 12;
rv = ctx->fn_read(ctx->arg_read, &hdr);
if (rv < 0) {
if (rv != 0) {
pthread_mutex_unlock(&ctx->read_mutex);
return mt_error(rv);
}
@@ -253,7 +253,7 @@ static size_t pt_read(LZ4MT_DCtx * ctx, LZ4MT_Buffer * in, size_t * frame)
in->size = toRead;
rv = ctx->fn_read(ctx->arg_read, in);
/* generic read failure! */
if (rv < 0) {
if (rv != 0) {
pthread_mutex_unlock(&ctx->read_mutex);
return mt_error(rv);
}
@@ -430,7 +430,7 @@ static size_t st_decompress(void *arg)
/* read new input */
in->size = nextToLoad;
rv = ctx->fn_read(ctx->arg_read, in);
if (rv < 0) {
if (rv != 0) {
free(in->buf);
free(out->buf);
return mt_error(rv);
@@ -459,7 +459,7 @@ static size_t st_decompress(void *arg)
/* have some output */
if (out->size) {
rv = ctx->fn_write(ctx->arg_write, out);
if (rv < 0) {
if (rv != 0) {
free(in->buf);
free(out->buf);
return mt_error(rv);
@@ -499,7 +499,7 @@ size_t LZ4MT_decompressDCtx(LZ4MT_DCtx * ctx, LZ4MT_RdWr_t * rdwr)
in->buf = buf;
in->size = 4;
rv = ctx->fn_read(ctx->arg_read, in);
if (rv < 0)
if (rv != 0)
return mt_error(rv);
if (in->size != 4)
return ERROR(data_error);

View File

@@ -17,7 +17,7 @@
#define LZ5F_DISABLE_OBSOLETE_ENUMS
#include "lz5frame.h"
#include "mem.h"
#include "memmt.h"
#include "threading.h"
#include "list.h"
#include "lz5mt.h"
@@ -193,7 +193,7 @@ static size_t pt_write(LZ5MT_CCtx * ctx, struct writelist *wl)
wl = list_entry(entry, struct writelist, node);
if (wl->frame == ctx->curframe) {
int rv = ctx->fn_write(ctx->arg_write, &wl->out);
if (rv < 0)
if (rv != 0)
return mt_error(rv);
ctx->outsize += wl->out.size;
ctx->curframe++;
@@ -257,7 +257,7 @@ static void *pt_compress(void *arg)
pthread_mutex_lock(&ctx->read_mutex);
in.size = ctx->inputsize;
rv = ctx->fn_read(ctx->arg_read, &in);
if (rv < 0) {
if (rv != 0) {
pthread_mutex_unlock(&ctx->read_mutex);
return (void*)mt_error(rv);
}

View File

@@ -17,7 +17,7 @@
#define LZ5F_DISABLE_OBSOLETE_ENUMS
#include "lz5frame.h"
#include "mem.h"
#include "memmt.h"
#include "threading.h"
#include "list.h"
#include "lz5mt.h"
@@ -174,7 +174,7 @@ static size_t pt_write(LZ5MT_DCtx * ctx, struct writelist *wl)
wl = list_entry(entry, struct writelist, node);
if (wl->frame == ctx->curframe) {
int rv = ctx->fn_write(ctx->arg_write, &wl->out);
if (rv < 0)
if (rv != 0)
return mt_error(rv);
ctx->outsize += wl->out.size;
ctx->curframe++;
@@ -203,7 +203,7 @@ static size_t pt_read(LZ5MT_DCtx * ctx, LZ5MT_Buffer * in, size_t * frame)
hdr.buf = hdrbuf + 4;
hdr.size = 8;
rv = ctx->fn_read(ctx->arg_read, &hdr);
if (rv < 0) {
if (rv != 0) {
pthread_mutex_unlock(&ctx->read_mutex);
return mt_error(rv);
}
@@ -214,7 +214,7 @@ static size_t pt_read(LZ5MT_DCtx * ctx, LZ5MT_Buffer * in, size_t * frame)
hdr.buf = hdrbuf;
hdr.size = 12;
rv = ctx->fn_read(ctx->arg_read, &hdr);
if (rv < 0) {
if (rv != 0) {
pthread_mutex_unlock(&ctx->read_mutex);
return mt_error(rv);
}
@@ -253,7 +253,7 @@ static size_t pt_read(LZ5MT_DCtx * ctx, LZ5MT_Buffer * in, size_t * frame)
in->size = toRead;
rv = ctx->fn_read(ctx->arg_read, in);
/* generic read failure! */
if (rv < 0) {
if (rv != 0) {
pthread_mutex_unlock(&ctx->read_mutex);
return mt_error(rv);
}
@@ -430,7 +430,7 @@ static size_t st_decompress(void *arg)
/* read new input */
in->size = nextToLoad;
rv = ctx->fn_read(ctx->arg_read, in);
if (rv < 0) {
if (rv != 0) {
free(in->buf);
free(out->buf);
return mt_error(rv);
@@ -459,7 +459,7 @@ static size_t st_decompress(void *arg)
/* have some output */
if (out->size) {
rv = ctx->fn_write(ctx->arg_write, out);
if (rv < 0) {
if (rv != 0) {
free(in->buf);
free(out->buf);
return mt_error(rv);
@@ -499,7 +499,7 @@ size_t LZ5MT_decompressDCtx(LZ5MT_DCtx * ctx, LZ5MT_RdWr_t * rdwr)
in->buf = buf;
in->size = 4;
rv = ctx->fn_read(ctx->arg_read, in);
if (rv < 0)
if (rv != 0)
return mt_error(rv);
if (in->size != 4)
return ERROR(data_error);

View File

View File

@@ -17,7 +17,7 @@
#define ZSTD_STATIC_LINKING_ONLY
#include "zstd.h"
#include "mem.h"
#include "memmt.h"
#include "threading.h"
#include "list.h"
#include "zstdmt.h"
@@ -198,7 +198,7 @@ static size_t pt_write(ZSTDMT_CCtx * ctx, struct writelist *wl)
wl = list_entry(entry, struct writelist, node);
if (wl->frame == ctx->curframe) {
rv = ctx->fn_write(ctx->arg_write, &wl->out);
if (rv < 0)
if (rv != 0)
return mt_error(rv);
ctx->outsize += wl->out.size;
ctx->curframe++;
@@ -263,7 +263,7 @@ static void *pt_compress(void *arg)
pthread_mutex_lock(&ctx->read_mutex);
in.size = ctx->inputsize;
rv = ctx->fn_read(ctx->arg_read, &in);
if (rv < 0) {
if (rv != 0) {
pthread_mutex_unlock(&ctx->read_mutex);
result = mt_error(rv);
goto error;
@@ -310,7 +310,6 @@ static void *pt_compress(void *arg)
/* write result */
pthread_mutex_lock(&ctx->write_mutex);
result = pt_write(ctx, wl);
printf("pt_write() = %d\n", result);
pthread_mutex_unlock(&ctx->write_mutex);
if (ZSTDMT_isError(result))
goto error;

View File

@@ -17,7 +17,7 @@
#define ZSTD_STATIC_LINKING_ONLY
#include "zstd.h"
#include "mem.h"
#include "memmt.h"
#include "threading.h"
#include "list.h"
#include "zstdmt.h"
@@ -191,7 +191,7 @@ static size_t pt_write(ZSTDMT_DCtx * ctx, struct writelist *wl)
wl = list_entry(entry, struct writelist, node);
if (wl->frame == ctx->curframe) {
int rv = ctx->fn_write(ctx->arg_write, &wl->out);
if (rv < 0)
if (rv != 0)
return mt_error(rv);
ctx->outsize += wl->out.size;
ctx->curframe++;
@@ -233,7 +233,7 @@ static size_t pt_read(ZSTDMT_DCtx * ctx, ZSTDMT_Buffer * in, size_t * frame)
hdr.buf = hdrbuf + 7;
hdr.size = 5;
rv = ctx->fn_read(ctx->arg_read, &hdr);
if (rv < 0) {
if (rv != 0) {
pthread_mutex_unlock(&ctx->read_mutex);
return mt_error(rv);
}
@@ -250,7 +250,7 @@ static size_t pt_read(ZSTDMT_DCtx * ctx, ZSTDMT_Buffer * in, size_t * frame)
goto error_nomem;
in->allocated = in->size;
rv = ctx->fn_read(ctx->arg_read, in);
if (rv < 0) {
if (rv != 0) {
pthread_mutex_unlock(&ctx->read_mutex);
return mt_error(rv);
}
@@ -282,7 +282,7 @@ static size_t pt_read(ZSTDMT_DCtx * ctx, ZSTDMT_Buffer * in, size_t * frame)
in->buf = start + 4;
in->size = toRead - 4;
rv = ctx->fn_read(ctx->arg_read, in);
if (rv < 0) {
if (rv != 0) {
pthread_mutex_unlock(&ctx->read_mutex);
return mt_error(rv);
}
@@ -306,7 +306,7 @@ static size_t pt_read(ZSTDMT_DCtx * ctx, ZSTDMT_Buffer * in, size_t * frame)
hdr.buf = hdrbuf;
hdr.size = 12;
rv = ctx->fn_read(ctx->arg_read, &hdr);
if (rv < 0) {
if (rv != 0) {
pthread_mutex_unlock(&ctx->read_mutex);
return mt_error(rv);
}
@@ -341,11 +341,10 @@ static size_t pt_read(ZSTDMT_DCtx * ctx, ZSTDMT_Buffer * in, size_t * frame)
in->size = toRead;
rv = ctx->fn_read(ctx->arg_read, in);
/* generic read failure! */
if (rv == -1)
goto error_read;
if (rv == -2)
goto error_canceled;
if (rv != 0) {
pthread_mutex_unlock(&ctx->read_mutex);
return mt_error(rv);
}
/* needed more bytes! */
if (in->size != toRead)
goto error_data;
@@ -358,9 +357,6 @@ static size_t pt_read(ZSTDMT_DCtx * ctx, ZSTDMT_Buffer * in, size_t * frame)
/* done, no error */
return 0;
error_canceled:
pthread_mutex_unlock(&ctx->read_mutex);
return ZSTDMT_ERROR(canceled);
error_data:
pthread_mutex_unlock(&ctx->read_mutex);
return ZSTDMT_ERROR(data_error);
@@ -603,7 +599,7 @@ static size_t st_decompress(void *arg)
/* read more bytes, to fill buffer */
rv = ctx->fn_read(ctx->arg_read, in);
if (rv < 0) {
if (rv != 0) {
result = mt_error(rv);
goto error;
}
@@ -635,17 +631,9 @@ static size_t st_decompress(void *arg)
w.size = zOut.pos;
w.buf = zOut.dst;
rv = ctx->fn_write(ctx->arg_write, &w);
if (rv == -1) {
return ZSTDMT_ERROR(write_fail);
goto error_clib;
}
if (rv == -2) {
return ZSTDMT_ERROR(canceled);
goto error_clib;
}
if (rv == -3) {
return ZSTDMT_ERROR(memory_allocation);
goto error_clib;
if (rv != 0) {
result = mt_error(rv);
goto error;
}
ctx->outsize += zOut.pos;
}
@@ -669,7 +657,7 @@ static size_t st_decompress(void *arg)
/* read next input */
in->size = in->allocated;
rv = ctx->fn_read(ctx->arg_read, in);
if (rv < 0) {
if (rv != 0) {
result = mt_error(rv);
goto error;
}
@@ -732,7 +720,7 @@ size_t ZSTDMT_decompressDCtx(ZSTDMT_DCtx * ctx, ZSTDMT_RdWr_t * rdwr)
in->buf = buf;
in->size = 16;
rv = ctx->fn_read(ctx->arg_read, in);
if (rv < 0)
if (rv != 0)
return mt_error(rv);
/* must be single threaded standard zstd, when smaller 16 bytes */