Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Debian Package on CPACK #4

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
7d6045f
Added Debian Package on CPACK
racerxdl Jan 16, 2017
43a8733
I hate VS not saving everything when closing
racerxdl Jan 27, 2017
c815ad9
Merge branch 'master' of github.com:racerxdl/libcorrect
racerxdl Jan 27, 2017
08c90e4
Now compiles and links in MSVC:wq
racerxdl Feb 6, 2017
5e56ac7
Fixed Release build
racerxdl Feb 6, 2017
e2176d5
Updated VS Solution. Now fully working and tested.
racerxdl Feb 11, 2017
bc1a5ec
Removed MFC Requirement
racerxdl Jan 21, 2018
d999eeb
Forgot to remove MFC from x64 builds
racerxdl Jan 22, 2018
7ca0526
Merge remote-tracking branch 'upstream/master'
racerxdl Jun 6, 2018
018054d
Small fixes from bad merging
racerxdl Jun 6, 2018
15a9b48
Added PPA Base
racerxdl Jun 6, 2018
d7c9b41
Made changes to PPA work
racerxdl Jun 6, 2018
5b67689
Changes for PPA
racerxdl Jun 6, 2018
5c39677
Correct a spelling mistake.
EdwardBetts Sep 26, 2018
01d358b
Merge pull request #21 from EdwardBetts/patch-1
brian-armstrong Sep 26, 2018
823f9e1
CMakeLists.txt: fixes for various toolchains
JoelsonCarl Oct 9, 2018
ce6c17f
Merge pull request #22 from JoelsonCarl/various-toolchain-fixes
brian-armstrong Oct 9, 2018
6d68fde
Fixes for SSE detection and propagation
pietern Oct 10, 2018
0ba9330
Merge pull request #24 from pietern/sse41-check
brian-armstrong Oct 10, 2018
76f8121
CMakeLists.txt: conditionally use -Wpedantic
tpetazzoni Oct 10, 2018
f5a28c7
Merge pull request #25 from tpetazzoni/conditional-wpedantic
brian-armstrong Oct 10, 2018
0c21f31
Updated few settings for VS2017
racerxdl Nov 18, 2018
7d3f671
Removed Cross Compile block for SSE build
racerxdl Feb 18, 2019
fc398ce
Merge branch 'master' of github.com:racerxdl/libcorrect
racerxdl Feb 18, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
build
.vs
Debug
Release
x86
x64
libcorrect.VC.db
49 changes: 37 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
cmake_minimum_required(VERSION 2.8)
project(Correct)
project(Correct C)
include(CheckLibraryExists)
include(CheckIncludeFiles)
include(CheckCXXSourceCompiles)
include(CheckCSourceCompiles)
include(CMakePushCheckState)
include(CheckCCompilerFlag)

if(MSVC)
set(LIBM "")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4")
else(MSVC)
set(LIBM "m")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -std=c99 -Wpedantic -Wall")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -std=c99 -Wall")
check_c_compiler_flag(-Wpedantic COMPILER_SUPPORTS_WPEDANTIC)
if(COMPILER_SUPPORTS_WPEDANTIC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wpedantic")
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g3 -O0 -march=native -fsanitize=address")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g3 -O0 -fsanitize=address")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-no_pie,")
else()
if("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
Expand All @@ -27,15 +33,22 @@ endif(MSVC)

find_library(FEC fec)
CHECK_LIBRARY_EXISTS(FEC dotprod "" HAVE_LIBFEC)
check_cxx_source_compiles("
#include <x86intrin.h>
int main() {
__m128i vec;
return 0;
}" HAVE_SSE)

# Check if host machine can compile with SSE 4.1 intrinsic
cmake_push_check_state(RESET)
set(CMAKE_REQUIRED_DEFINITIONS -march=native)
check_c_source_compiles("
#include <x86intrin.h>
int main() {
__m128i a;
__m128i b;
__m128i c = _mm_min_epu16(a, b);
return 0;
}" HAVE_SSE)
cmake_pop_check_state()

if(HAVE_SSE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.2")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.1")
endif()

set(CMAKE_CXX_VISIBILITY_PRESET hidden)
Expand All @@ -54,13 +67,16 @@ if(HAVE_SSE)
set(correct_obj_files $<TARGET_OBJECTS:correct-reed-solomon> $<TARGET_OBJECTS:correct-convolutional> $<TARGET_OBJECTS:correct-convolutional-sse>)
set(INSTALL_HEADERS ${INSTALL_HEADERS} ${PROJECT_BINARY_DIR}/include/correct-sse.h)
add_custom_target(correct-sse-h ALL COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/include/correct-sse.h ${PROJECT_BINARY_DIR}/include/correct-sse.h)
add_definitions(-DHAVE_SSE=1)
else()
set(correct_obj_files $<TARGET_OBJECTS:correct-reed-solomon> $<TARGET_OBJECTS:correct-convolutional>)
endif()
add_library(correct SHARED ${correct_obj_files})
add_library(correct_static ${correct_obj_files})
set_target_properties(correct_static PROPERTIES OUTPUT_NAME "correct")
if(HAVE_SSE)
target_compile_definitions(correct PUBLIC HAVE_SSE=1)
target_compile_definitions(correct_static PUBLIC HAVE_SSE=1)
endif()

add_subdirectory(util)
add_subdirectory(tests)
Expand All @@ -81,4 +97,13 @@ add_custom_target(shim DEPENDS fec_shim_static fec_shim_shared fec-shim-h)
install(TARGETS fec_shim_static fec_shim_shared
DESTINATION lib
OPTIONAL)

install(FILES ${PROJECT_BINARY_DIR}/include/fec.h DESTINATION "${CMAKE_INSTALL_PREFIX}/include" OPTIONAL)

# Debian Package
SET(CPACK_GENERATOR "DEB")
SET(CPACK_PACKAGE_NAME "libcorrect")
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Brian Armstrong <[email protected]>")
SET(CPACK_DEBIAN_PACKAGE_DESCRIPTION "C library for Convolutional codes and Reed-Solomon")
INCLUDE(CPack)

5 changes: 5 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
libcorrect (1.0-0ppa0) xenial; urgency=low

* First PPA Package

-- Lucas Teske <[email protected]> Tue, 05 Jun 2018 21:52:07 -0300
13 changes: 13 additions & 0 deletions debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Source: libcorrect
Section: devel
Priority: optional
Maintainer: Brian Armstrong <[email protected]>
Build-Depends: cmake, build-essential
Homepage: https://github.com/quiet/libcorrect

Package: libcorrect
Architecture: any
Depends:
Description: libcorrect is a library for Forward Error Correction.
By using libcorrect, you can encode extra redundancy into a packet of data and then send it across a lossy channel.
When the packet is received, it can be decoded to recover the original, pre-encoded data.
12 changes: 12 additions & 0 deletions debian/copyright
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Copyright (c) 2016, Brian Armstrong
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1 change: 1 addition & 0 deletions debian/files
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
libcorrect_1.0-0ppa0_source.buildinfo devel optional
28 changes: 28 additions & 0 deletions debian/rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/make -f

BUILDDIR = build_dir

# secondly called by launchpad
build:
mkdir $(BUILDDIR);
cd $(BUILDDIR); cmake -DCMAKE_INSTALL_PREFIX=../debian/tmp/usr ..
make -C $(BUILDDIR)

# thirdly called by launchpad
binary: binary-indep binary-arch

binary-indep:
# nothing to be done

binary-arch:
cd $(BUILDDIR); cmake -P cmake_install.cmake
mkdir debian/tmp/DEBIAN
dpkg-gencontrol -plibcorrect
dpkg --build debian/tmp ..

# firstly called by launchpad
clean:
rm -rf build
rm -rf $(BUILDDIR)

.PHONY: binary binary-arch binary-indep clean
35 changes: 20 additions & 15 deletions include/correct.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@
#include <stdint.h>

#ifndef _MSC_VER
#include <unistd.h>
# include <unistd.h>
# ifdef __MINGW32__
# define ssize_t int
# endif
# define DLL_EXPORT
#else
#include <stddef.h>
# define DLL_EXPORT extern __declspec(dllexport)
# include <intrin.h>
# define __builtin_popcount __popcnt
# include <stddef.h>
typedef ptrdiff_t ssize_t;
#endif



// Convolutional Codes

// Convolutional polynomials are 16 bits wide
Expand Down Expand Up @@ -41,14 +46,14 @@ typedef struct correct_convolutional correct_convolutional;
*
* If this call is successful, it returns a non-NULL pointer.
*/
correct_convolutional *correct_convolutional_create(size_t inv_rate, size_t order,
DLL_EXPORT correct_convolutional *correct_convolutional_create(size_t inv_rate, size_t order,
const correct_convolutional_polynomial_t *poly);

/* correct_convolutional_destroy releases all resources associated
* with conv. This pointer should not be used for further calls
* after calling destroy.
*/
void correct_convolutional_destroy(correct_convolutional *conv);
DLL_EXPORT void correct_convolutional_destroy(correct_convolutional *conv);

/* correct_convolutional_encode_len returns the number of *bits*
* in a msg_len of given size, in *bytes*. In order to convert
Expand All @@ -57,7 +62,7 @@ void correct_convolutional_destroy(correct_convolutional *conv);
* length/8 + 1. If it is zero, then the length is just
* length/8.
*/
size_t correct_convolutional_encode_len(correct_convolutional *conv, size_t msg_len);
DLL_EXPORT size_t correct_convolutional_encode_len(correct_convolutional *conv, size_t msg_len);

/* correct_convolutional_encode uses the given conv instance to
* encode a block of data and write it to encoded. The length of
Expand All @@ -70,7 +75,7 @@ size_t correct_convolutional_encode_len(correct_convolutional *conv, size_t msg_
* this is not an exact multiple of 8, then it occupies an additional
* byte.
*/
size_t correct_convolutional_encode(correct_convolutional *conv, const uint8_t *msg, size_t msg_len,
DLL_EXPORT size_t correct_convolutional_encode(correct_convolutional *conv, const uint8_t *msg, size_t msg_len,
uint8_t *encoded);

/* correct_convolutional_decode uses the given conv instance to
Expand All @@ -96,7 +101,7 @@ size_t correct_convolutional_encode(correct_convolutional *conv, const uint8_t *
* This function returns the number of bytes written to msg. If
* it fails, it returns -1.
*/
ssize_t correct_convolutional_decode(correct_convolutional *conv, const uint8_t *encoded,
DLL_EXPORT ssize_t correct_convolutional_decode(correct_convolutional *conv, const uint8_t *encoded,
size_t num_encoded_bits, uint8_t *msg);

/* correct_convolutional_decode_soft uses the given conv instance
Expand All @@ -120,7 +125,7 @@ ssize_t correct_convolutional_decode(correct_convolutional *conv, const uint8_t
* This function returns the number of bytes written to msg. If
* it fails, it returns -1.
*/
ssize_t correct_convolutional_decode_soft(correct_convolutional *conv,
DLL_EXPORT ssize_t correct_convolutional_decode_soft(correct_convolutional *conv,
const correct_convolutional_soft_t *encoded,
size_t num_encoded_bits, uint8_t *msg);

Expand Down Expand Up @@ -195,7 +200,7 @@ static const uint16_t correct_rs_primitive_polynomial_ccsds =
* generator_root_gap are 1 and 1. Not all combinations of
* values produce valid codes.
*/
correct_reed_solomon *correct_reed_solomon_create(uint16_t primitive_polynomial,
DLL_EXPORT correct_reed_solomon *correct_reed_solomon_create(uint16_t primitive_polynomial,
uint8_t first_consecutive_root,
uint8_t generator_root_gap,
size_t num_roots);
Expand All @@ -214,7 +219,7 @@ correct_reed_solomon *correct_reed_solomon_create(uint16_t primitive_polynomial,
*
* This function returns the number of bytes written to encoded.
*/
ssize_t correct_reed_solomon_encode(correct_reed_solomon *rs, const uint8_t *msg, size_t msg_length,
DLL_EXPORT ssize_t correct_reed_solomon_encode(correct_reed_solomon *rs, const uint8_t *msg, size_t msg_length,
uint8_t *encoded);

/* correct_reed_solomon_decode uses the rs instance to decode
Expand All @@ -232,7 +237,7 @@ ssize_t correct_reed_solomon_encode(correct_reed_solomon *rs, const uint8_t *msg
* This function returns a positive number of bytes written to msg
* if it has decoded or -1 if it has encountered an error.
*/
ssize_t correct_reed_solomon_decode(correct_reed_solomon *rs, const uint8_t *encoded,
DLL_EXPORT ssize_t correct_reed_solomon_decode(correct_reed_solomon *rs, const uint8_t *encoded,
size_t encoded_length, uint8_t *msg);

/* correct_reed_solomon_decode_with_erasures uses the rs
Expand Down Expand Up @@ -262,7 +267,7 @@ ssize_t correct_reed_solomon_decode(correct_reed_solomon *rs, const uint8_t *enc
* This function returns a positive number of bytes written to msg
* if it has decoded or -1 if it has encountered an error.
*/
ssize_t correct_reed_solomon_decode_with_erasures(correct_reed_solomon *rs, const uint8_t *encoded,
DLL_EXPORT ssize_t correct_reed_solomon_decode_with_erasures(correct_reed_solomon *rs, const uint8_t *encoded,
size_t encoded_length,
const uint8_t *erasure_locations,
size_t erasure_length, uint8_t *msg);
Expand All @@ -271,7 +276,7 @@ ssize_t correct_reed_solomon_decode_with_erasures(correct_reed_solomon *rs, cons
* associated with rs. This pointer should not be
* used for any functions after this call.
*/
void correct_reed_solomon_destroy(correct_reed_solomon *rs);
DLL_EXPORT void correct_reed_solomon_destroy(correct_reed_solomon *rs);

#endif

22 changes: 11 additions & 11 deletions include/correct/convolutional/bit.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ typedef struct {
size_t len;
} bit_writer_t;

bit_writer_t *bit_writer_create(uint8_t *bytes, size_t len);
DLL_EXPORT bit_writer_t *bit_writer_create(uint8_t *bytes, size_t len);

void bit_writer_reconfigure(bit_writer_t *w, uint8_t *bytes, size_t len);
DLL_EXPORT void bit_writer_reconfigure(bit_writer_t *w, uint8_t *bytes, size_t len);

void bit_writer_destroy(bit_writer_t *w);
DLL_EXPORT void bit_writer_destroy(bit_writer_t *w);

void bit_writer_write(bit_writer_t *w, uint8_t val, unsigned int n);
DLL_EXPORT void bit_writer_write(bit_writer_t *w, uint8_t val, unsigned int n);

void bit_writer_write_1(bit_writer_t *w, uint8_t val);
DLL_EXPORT void bit_writer_write_1(bit_writer_t *w, uint8_t val);

void bit_writer_write_bitlist_reversed(bit_writer_t *w, uint8_t *l, size_t len);
DLL_EXPORT void bit_writer_write_bitlist_reversed(bit_writer_t *w, uint8_t *l, size_t len);

void bit_writer_flush_byte(bit_writer_t *w);
DLL_EXPORT void bit_writer_flush_byte(bit_writer_t *w);

size_t bit_writer_length(bit_writer_t *w);

Expand All @@ -34,11 +34,11 @@ typedef struct {
const uint8_t *bytes;
} bit_reader_t;

bit_reader_t *bit_reader_create(const uint8_t *bytes, size_t len);
DLL_EXPORT bit_reader_t *bit_reader_create(const uint8_t *bytes, size_t len);

void bit_reader_reconfigure(bit_reader_t *r, const uint8_t *bytes, size_t len);
DLL_EXPORT void bit_reader_reconfigure(bit_reader_t *r, const uint8_t *bytes, size_t len);

void bit_reader_destroy(bit_reader_t *r);
DLL_EXPORT void bit_reader_destroy(bit_reader_t *r);

uint8_t bit_reader_read(bit_reader_t *r, unsigned int n);
DLL_EXPORT uint8_t bit_reader_read(bit_reader_t *r, unsigned int n);
#endif
17 changes: 11 additions & 6 deletions include/correct/convolutional/convolutional.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
#include "correct/convolutional/history_buffer.h"
#include "correct/convolutional/error_buffer.h"

#ifdef _MSC_VER
# include <intrin.h>
# define __builtin_popcount __popcnt
#endif

struct correct_convolutional {
const unsigned int *table; // size 2**order
size_t rate; // e.g. 2, 3...
Expand All @@ -23,18 +28,18 @@ struct correct_convolutional {
error_buffer_t *errors;
};

correct_convolutional *_correct_convolutional_init(correct_convolutional *conv,
DLL_EXPORT correct_convolutional *_correct_convolutional_init(correct_convolutional *conv,
size_t rate, size_t order,
const polynomial_t *poly);
void _correct_convolutional_teardown(correct_convolutional *conv);
DLL_EXPORT void _correct_convolutional_teardown(correct_convolutional *conv);

// portable versions
void _convolutional_decode_init(correct_convolutional *conv, unsigned int min_traceback, unsigned int traceback_length, unsigned int renormalize_interval);
void convolutional_decode_warmup(correct_convolutional *conv, unsigned int sets,
DLL_EXPORT void _convolutional_decode_init(correct_convolutional *conv, unsigned int min_traceback, unsigned int traceback_length, unsigned int renormalize_interval);
DLL_EXPORT void convolutional_decode_warmup(correct_convolutional *conv, unsigned int sets,
const uint8_t *soft);
void convolutional_decode_inner(correct_convolutional *conv, unsigned int sets,
DLL_EXPORT void convolutional_decode_inner(correct_convolutional *conv, unsigned int sets,
const uint8_t *soft);
void convolutional_decode_tail(correct_convolutional *conv, unsigned int sets,
DLL_EXPORT void convolutional_decode_tail(correct_convolutional *conv, unsigned int sets,
const uint8_t *soft);
#endif

8 changes: 4 additions & 4 deletions include/correct/convolutional/error_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ typedef struct {
distance_t *write_errors;
} error_buffer_t;

error_buffer_t *error_buffer_create(unsigned int num_states);
void error_buffer_destroy(error_buffer_t *buf);
void error_buffer_reset(error_buffer_t *buf);
void error_buffer_swap(error_buffer_t *buf);
DLL_EXPORT error_buffer_t *error_buffer_create(unsigned int num_states);
DLL_EXPORT void error_buffer_destroy(error_buffer_t *buf);
DLL_EXPORT void error_buffer_reset(error_buffer_t *buf);
DLL_EXPORT void error_buffer_swap(error_buffer_t *buf);
Loading