Fin compiler warnings
This commit is contained in:
parent
ce26e523dd
commit
38ffbbe42e
|
@ -227,14 +227,14 @@ OPJ_TEST_LARGE_FILES(OPJ_HAVE_LARGEFILES)
|
||||||
|
|
||||||
# Allocating Aligned Memory Blocks
|
# Allocating Aligned Memory Blocks
|
||||||
include(CheckIncludeFiles)
|
include(CheckIncludeFiles)
|
||||||
check_include_files(malloc.h HAVE_MALLOC_H)
|
check_include_files(malloc.h OPJ_HAVE_MALLOC_H)
|
||||||
include(CheckSymbolExists)
|
include(CheckSymbolExists)
|
||||||
# _aligned_alloc https://msdn.microsoft.com/en-us/library/8z34s9c6.aspx
|
# _aligned_alloc https://msdn.microsoft.com/en-us/library/8z34s9c6.aspx
|
||||||
check_symbol_exists(_aligned_malloc malloc.h HAVE__ALIGNED_MALLOC)
|
check_symbol_exists(_aligned_malloc malloc.h OPJ_HAVE__ALIGNED_MALLOC)
|
||||||
# posix_memalign
|
# posix_memalign
|
||||||
check_symbol_exists(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN)
|
check_symbol_exists(posix_memalign stdlib.h OPJ_HAVE_POSIX_MEMALIGN)
|
||||||
# memalign (obsolete)
|
# memalign (obsolete)
|
||||||
check_symbol_exists(memalign malloc.h HAVE_MEMALIGN)
|
check_symbol_exists(memalign malloc.h OPJ_HAVE_MEMALIGN)
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# Build Library
|
# Build Library
|
||||||
if(BUILD_JPIP_SERVER)
|
if(BUILD_JPIP_SERVER)
|
||||||
|
|
|
@ -18,15 +18,15 @@
|
||||||
#cmakedefine OPJ_HAVE_FSEEKO @OPJ_HAVE_FSEEKO@
|
#cmakedefine OPJ_HAVE_FSEEKO @OPJ_HAVE_FSEEKO@
|
||||||
|
|
||||||
/* find whether or not have <malloc.h> */
|
/* find whether or not have <malloc.h> */
|
||||||
#cmakedefine HAVE_MALLOC_H
|
#cmakedefine OPJ_HAVE_MALLOC_H
|
||||||
/* check if function `aligned_alloc` exists */
|
/* check if function `aligned_alloc` exists */
|
||||||
#cmakedefine HAVE_ALIGNED_ALLOC
|
#cmakedefine OPJ_HAVE_ALIGNED_ALLOC
|
||||||
/* check if function `_aligned_malloc` exists */
|
/* check if function `_aligned_malloc` exists */
|
||||||
#cmakedefine HAVE__ALIGNED_MALLOC
|
#cmakedefine OPJ_HAVE__ALIGNED_MALLOC
|
||||||
/* check if function `memalign` exists */
|
/* check if function `memalign` exists */
|
||||||
#cmakedefine HAVE_MEMALIGN
|
#cmakedefine OPJ_HAVE_MEMALIGN
|
||||||
/* check if function `posix_memalign` exists */
|
/* check if function `posix_memalign` exists */
|
||||||
#cmakedefine HAVE_POSIX_MEMALIGN
|
#cmakedefine OPJ_HAVE_POSIX_MEMALIGN
|
||||||
|
|
||||||
/* Byte order. */
|
/* Byte order. */
|
||||||
/* All compilers that support Mac OS X define either __BIG_ENDIAN__ or
|
/* All compilers that support Mac OS X define either __BIG_ENDIAN__ or
|
||||||
|
|
|
@ -49,7 +49,7 @@ static INLINE void *opj_aligned_alloc_n(size_t alignment, size_t size)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HAVE_POSIX_MEMALIGN)
|
#if defined(OPJ_HAVE_POSIX_MEMALIGN)
|
||||||
/* aligned_alloc requires c11, restrict to posix_memalign for now. Quote:
|
/* aligned_alloc requires c11, restrict to posix_memalign for now. Quote:
|
||||||
* This function was introduced in POSIX 1003.1d. Although this function is
|
* This function was introduced in POSIX 1003.1d. Although this function is
|
||||||
* superseded by aligned_alloc, it is more portable to older POSIX systems
|
* superseded by aligned_alloc, it is more portable to older POSIX systems
|
||||||
|
@ -59,10 +59,10 @@ static INLINE void *opj_aligned_alloc_n(size_t alignment, size_t size)
|
||||||
ptr = NULL;
|
ptr = NULL;
|
||||||
}
|
}
|
||||||
/* older linux */
|
/* older linux */
|
||||||
#elif defined(HAVE_MEMALIGN)
|
#elif defined(OPJ_HAVE_MEMALIGN)
|
||||||
ptr = memalign( alignment, size );
|
ptr = memalign( alignment, size );
|
||||||
/* _MSC_VER */
|
/* _MSC_VER */
|
||||||
#elif defined(HAVE__ALIGNED_MALLOC)
|
#elif defined(OPJ_HAVE__ALIGNED_MALLOC)
|
||||||
ptr = _aligned_malloc(size, alignment);
|
ptr = _aligned_malloc(size, alignment);
|
||||||
#else
|
#else
|
||||||
/*
|
/*
|
||||||
|
@ -114,7 +114,7 @@ static INLINE void *opj_aligned_realloc_n(void *ptr, size_t alignment, size_t ne
|
||||||
}
|
}
|
||||||
|
|
||||||
/* no portable aligned realloc */
|
/* no portable aligned realloc */
|
||||||
#if defined(HAVE_POSIX_MEMALIGN) || defined(HAVE_MEMALIGN)
|
#if defined(OPJ_HAVE_POSIX_MEMALIGN) || defined(OPJ_HAVE_MEMALIGN)
|
||||||
/* glibc doc states one can mixed aligned malloc with realloc */
|
/* glibc doc states one can mixed aligned malloc with realloc */
|
||||||
r_ptr = realloc( ptr, new_size ); /* fast path */
|
r_ptr = realloc( ptr, new_size ); /* fast path */
|
||||||
/* we simply use `size_t` to cast, since we are only interest in binary AND
|
/* we simply use `size_t` to cast, since we are only interest in binary AND
|
||||||
|
@ -132,7 +132,7 @@ static INLINE void *opj_aligned_realloc_n(void *ptr, size_t alignment, size_t ne
|
||||||
r_ptr = a_ptr;
|
r_ptr = a_ptr;
|
||||||
}
|
}
|
||||||
/* _MSC_VER */
|
/* _MSC_VER */
|
||||||
#elif defined(HAVE__ALIGNED_MALLOC)
|
#elif defined(OPJ_HAVE__ALIGNED_MALLOC)
|
||||||
r_ptr = _aligned_realloc( ptr, new_size, alignment );
|
r_ptr = _aligned_realloc( ptr, new_size, alignment );
|
||||||
#else
|
#else
|
||||||
if (ptr == NULL) {
|
if (ptr == NULL) {
|
||||||
|
@ -210,9 +210,9 @@ void * opj_aligned_realloc(void *ptr, size_t size)
|
||||||
|
|
||||||
void opj_aligned_free(void* ptr)
|
void opj_aligned_free(void* ptr)
|
||||||
{
|
{
|
||||||
#if defined(HAVE_POSIX_MEMALIGN) || defined(HAVE_MEMALIGN)
|
#if defined(OPJ_HAVE_POSIX_MEMALIGN) || defined(OPJ_HAVE_MEMALIGN)
|
||||||
free( ptr );
|
free( ptr );
|
||||||
#elif defined(HAVE__ALIGNED_MALLOC)
|
#elif defined(OPJ_HAVE__ALIGNED_MALLOC)
|
||||||
_aligned_free( ptr );
|
_aligned_free( ptr );
|
||||||
#else
|
#else
|
||||||
/* Generic implementation has malloced pointer stored in front of used area */
|
/* Generic implementation has malloced pointer stored in front of used area */
|
||||||
|
|
Loading…
Reference in New Issue