diff options
author | yuta.256 <yuta.256@b7c3aa3b-274f-0410-ae0b-edc9d07c929d> | 2008-07-27 21:14:31 +0000 |
---|---|---|
committer | yuta.256 <yuta.256@b7c3aa3b-274f-0410-ae0b-edc9d07c929d> | 2008-07-27 21:14:31 +0000 |
commit | a844abd2925b6820947c8887e314a44435b884da (patch) | |
tree | 3f4538393d4db9075001ec8af99205812d197c09 /lib | |
parent | f6a102a6c865e0c593e3d296d11ad340a581711b (diff) | |
download | platform_external_libdivsufsort-a844abd2925b6820947c8887e314a44435b884da.tar.gz platform_external_libdivsufsort-a844abd2925b6820947c8887e314a44435b884da.tar.bz2 platform_external_libdivsufsort-a844abd2925b6820947c8887e314a44435b884da.zip |
Added 64-bit version of divsufsort.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/CMakeLists.txt | 19 | ||||
-rw-r--r-- | lib/divsufsort.c | 10 | ||||
-rw-r--r-- | lib/trsort.c | 14 | ||||
-rw-r--r-- | lib/utils.c | 2 |
4 files changed, 31 insertions, 14 deletions
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index cbcb427..56e7942 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -1,8 +1,10 @@ include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../include" "${CMAKE_CURRENT_BINARY_DIR}/../include") +set(divsufsort_SRCS divsufsort.c sssort.c trsort.c utils.c) + ## libdivsufsort ## -add_library(divsufsort divsufsort.c sssort.c trsort.c utils.c) +add_library(divsufsort ${divsufsort_SRCS}) install(TARGETS divsufsort RUNTIME DESTINATION bin LIBRARY DESTINATION lib @@ -12,3 +14,18 @@ set_target_properties(divsufsort PROPERTIES SOVERSION "${LIBRARY_VERSION_MAJOR}" DEFINE_SYMBOL DIVSUFSORT_BUILD_DLL RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/../examples") + +## libdivsufsort64 ## +if(BUILD_DIVSUFSORT64) + add_library(divsufsort64 ${divsufsort_SRCS}) + install(TARGETS divsufsort64 + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib) + set_target_properties(divsufsort64 PROPERTIES + VERSION "${LIBRARY_VERSION_FULL}" + SOVERSION "${LIBRARY_VERSION_MAJOR}" + DEFINE_SYMBOL DIVSUFSORT_BUILD_DLL + COMPILE_FLAGS "-DBUILD_DIVSUFSORT64" + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/../examples") +endif(BUILD_DIVSUFSORT64) diff --git a/lib/divsufsort.c b/lib/divsufsort.c index 568803f..85c3c43 100644 --- a/lib/divsufsort.c +++ b/lib/divsufsort.c @@ -340,8 +340,8 @@ divsufsort(const sauchar_t *T, saidx_t *SA, saidx_t n) { else if(n == 1) { SA[0] = 0; return 0; } else if(n == 2) { m = (T[0] < T[1]); SA[m ^ 1] = 0, SA[m] = 1; return 0; } - bucket_A = malloc(BUCKET_A_SIZE * sizeof(saidx_t)); - bucket_B = malloc(BUCKET_B_SIZE * sizeof(saidx_t)); + bucket_A = (saidx_t *)malloc(BUCKET_A_SIZE * sizeof(saidx_t)); + bucket_B = (saidx_t *)malloc(BUCKET_B_SIZE * sizeof(saidx_t)); /* Suffixsort. */ if((bucket_A != NULL) && (bucket_B != NULL)) { @@ -367,9 +367,9 @@ divbwt(const sauchar_t *T, sauchar_t *U, saidx_t *A, saidx_t n) { if((T == NULL) || (U == NULL) || (n < 0)) { return -1; } else if(n <= 1) { if(n == 1) { U[0] = T[0]; } return n; } - if((B = A) == NULL) { B = malloc((n + 1) * sizeof(saidx_t)); } - bucket_A = malloc(BUCKET_A_SIZE * sizeof(saidx_t)); - bucket_B = malloc(BUCKET_B_SIZE * sizeof(saidx_t)); + if((B = A) == NULL) { B = (saidx_t *)malloc((size_t)(n + 1) * sizeof(saidx_t)); } + bucket_A = (saidx_t *)malloc(BUCKET_A_SIZE * sizeof(saidx_t)); + bucket_B = (saidx_t *)malloc(BUCKET_B_SIZE * sizeof(saidx_t)); /* Burrows-Wheeler Transform. */ if((B != NULL) && (bucket_A != NULL) && (bucket_B != NULL)) { diff --git a/lib/trsort.c b/lib/trsort.c index 4ec6a17..6fe3e67 100644 --- a/lib/trsort.c +++ b/lib/trsort.c @@ -44,19 +44,19 @@ static INLINE saint_t tr_ilg(saidx_t n) { #if defined(BUILD_DIVSUFSORT64) - return (n & 0xffffffff00000000) ? - ((n & 0xffff000000000000) ? - ((n & 0xff00000000000000) ? + return (n >> 32) ? + ((n >> 48) ? + ((n >> 56) ? 56 + lg_table[(n >> 56) & 0xff] : 48 + lg_table[(n >> 48) & 0xff]) : - ((n & 0x0000ff0000000000) ? + ((n >> 40) ? 40 + lg_table[(n >> 40) & 0xff] : 32 + lg_table[(n >> 32) & 0xff])) : - ((n & 0x00000000ffff0000) ? - ((n & 0x00000000ff000000) ? + ((n & 0xffff0000) ? + ((n & 0xff000000) ? 24 + lg_table[(n >> 24) & 0xff] : 16 + lg_table[(n >> 16) & 0xff]) : - ((n & 0x000000000000ff00) ? + ((n & 0x0000ff00) ? 8 + lg_table[(n >> 8) & 0xff] : 0 + lg_table[(n >> 0) & 0xff])); #else diff --git a/lib/utils.c b/lib/utils.c index 75bd274..90fb23e 100644 --- a/lib/utils.c +++ b/lib/utils.c @@ -126,7 +126,7 @@ inverse_bw_transform(const sauchar_t *T, sauchar_t *U, saidx_t *A, if((B = A) == NULL) { /* Allocate n*sizeof(saidx_t) bytes of memory. */ - if((B = malloc(n * sizeof(saidx_t))) == NULL) { return -2; } + if((B = (saidx_t *)malloc((size_t)n * sizeof(saidx_t))) == NULL) { return -2; } } /* Inverse BW transform. */ |