Merge "Stop using ceill() to compute padded data size"

This commit is contained in:
Jenkins 2017-06-06 19:17:12 +00:00 committed by Gerrit Code Review
commit dd31ac647b
5 changed files with 8 additions and 11 deletions

View File

@ -88,7 +88,7 @@ dnl Check for C library headers
AC_HEADER_STDC
AC_CHECK_HEADERS(sys/types.h stdio.h stdlib.h stddef.h stdarg.h \
malloc.h memory.h string.h strings.h inttypes.h \
stdint.h ctype.h math.h iconv.h signal.h dlfcn.h \
stdint.h ctype.h iconv.h signal.h dlfcn.h \
pthread.h unistd.h limits.h errno.h syslog.h)
AC_CHECK_FUNCS(malloc calloc realloc free openlog)

View File

@ -100,9 +100,6 @@
#ifdef HAVE_ERRNO_H
# include <errno.h>
#endif
#ifdef HAVE_MATH_H
# include <math.h>
#endif
#if defined(__GNUC__) && __GNUC__ >= 4
# define DECLSPEC __attribute__ ((visibility("default")))

View File

@ -88,7 +88,7 @@ struct libphazr_descriptor {
static int get_padded_blocksize(int w, int hd, int blocksize)
{
int word_size = w / 8;
return (int) ceill((double) blocksize / (word_size - hd)) * word_size;
return ((blocksize + ((word_size - hd) - 1)) / (word_size - hd)) * word_size;
}
static int pio_matrix_encode(void *desc, char **data, char **parity, int blocksize)

View File

@ -1194,8 +1194,8 @@ int liberasurecode_verify_stripe_metadata(int desc,
/**
* This computes the aligned size of a buffer passed into
* the encode function. The encode function must pad fragments
* to be algined with the word size (w) and the last fragment also
* needs to be aligned. This computes the sum of the algined fragment
* to be aligned with the word size (w) and the last fragment also
* needs to be aligned. This computes the sum of the aligned fragment
* sizes for a given buffer to encode.
*/
int liberasurecode_get_aligned_data_size(int desc, uint64_t data_len)
@ -1218,8 +1218,8 @@ int liberasurecode_get_aligned_data_size(int desc, uint64_t data_len)
alignment_multiple = k * word_size;
ret = (int) ceill( (double)
data_len / alignment_multiple) * alignment_multiple;
ret = ((data_len + alignment_multiple - 1) / alignment_multiple)
* alignment_multiple;
out:
return ret;

View File

@ -199,8 +199,8 @@ int get_aligned_data_size(ec_backend_t instance, int data_len)
alignment_multiple = k * word_size;
}
aligned_size = (int)
ceill((double) data_len / alignment_multiple) * alignment_multiple;
aligned_size = ((data_len + alignment_multiple - 1) / alignment_multiple)
* alignment_multiple;
return aligned_size;
}