Skip to content

Commit

Permalink
Merge branch 'feature-m4macro-ax_gcc_builtin' into release-1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
saitoha committed Dec 19, 2019
2 parents 36d7be3 + 291c259 commit 56e0fb8
Show file tree
Hide file tree
Showing 13 changed files with 240 additions and 11 deletions.
3 changes: 2 additions & 1 deletion Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ build_triplet = @build@
host_triplet = @host@
subdir = .
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_gcc_builtin.m4 \
$(top_srcdir)/m4/ax_gcc_func_attribute.m4 \
$(top_srcdir)/m4/ax_gcc_var_attribute.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
Expand Down
1 change: 1 addition & 0 deletions aclocal.m4
Original file line number Diff line number Diff line change
Expand Up @@ -1647,6 +1647,7 @@ AC_SUBST([am__tar])
AC_SUBST([am__untar])
]) # _AM_PROG_TAR

m4_include([m4/ax_gcc_builtin.m4])
m4_include([m4/ax_gcc_func_attribute.m4])
m4_include([m4/ax_gcc_var_attribute.m4])
m4_include([m4/libtool.m4])
Expand Down
45 changes: 44 additions & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -12217,7 +12217,50 @@ if test x$ax_cv_have_func_attribute_deprecated != x; then

fi

AX_GCC_BUILTIN(__builtin_unreachable)



{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __builtin_unreachable" >&5
$as_echo_n "checking for __builtin_unreachable... " >&6; }
if ${ax_cv_have___builtin_unreachable+:} false; then :
$as_echo_n "(cached) " >&6
else

cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */

int
main ()
{

__builtin_unreachable()

;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ax_cv_have___builtin_unreachable=yes
else
ax_cv_have___builtin_unreachable=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext

fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_have___builtin_unreachable" >&5
$as_echo "$ax_cv_have___builtin_unreachable" >&6; }

if test yes = $ax_cv_have___builtin_unreachable; then :

cat >>confdefs.h <<_ACEOF
#define HAVE___BUILTIN_UNREACHABLE 1
_ACEOF

fi




CFLAGS_BACKUP=$CFLAGS
CFLAGS="$CFLAGS -Werror"
Expand Down
3 changes: 2 additions & 1 deletion converters/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ bin_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2)
subdir = converters
SUBDIRS =
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_gcc_builtin.m4 \
$(top_srcdir)/m4/ax_gcc_func_attribute.m4 \
$(top_srcdir)/m4/ax_gcc_var_attribute.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
Expand Down
3 changes: 2 additions & 1 deletion include/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ build_triplet = @build@
host_triplet = @host@
subdir = include
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_gcc_builtin.m4 \
$(top_srcdir)/m4/ax_gcc_func_attribute.m4 \
$(top_srcdir)/m4/ax_gcc_var_attribute.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
Expand Down
170 changes: 170 additions & 0 deletions m4/ax_gcc_builtin.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_gcc_builtin.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_GCC_BUILTIN(BUILTIN)
#
# DESCRIPTION
#
# This macro checks if the compiler supports one of GCC's built-in
# functions; many other compilers also provide those same built-ins.
#
# The BUILTIN parameter is the name of the built-in function.
#
# If BUILTIN is supported define HAVE_<BUILTIN>. Keep in mind that since
# builtins usually start with two underscores they will be copied over
# into the HAVE_<BUILTIN> definition (e.g. HAVE___BUILTIN_EXPECT for
# __builtin_expect()).
#
# The macro caches its result in the ax_cv_have_<BUILTIN> variable (e.g.
# ax_cv_have___builtin_expect).
#
# The macro currently supports the following built-in functions:
#
# __builtin_assume_aligned
# __builtin_bswap16
# __builtin_bswap32
# __builtin_bswap64
# __builtin_choose_expr
# __builtin___clear_cache
# __builtin_clrsb
# __builtin_clrsbl
# __builtin_clrsbll
# __builtin_clz
# __builtin_clzl
# __builtin_clzll
# __builtin_complex
# __builtin_constant_p
# __builtin_ctz
# __builtin_ctzl
# __builtin_ctzll
# __builtin_expect
# __builtin_ffs
# __builtin_ffsl
# __builtin_ffsll
# __builtin_fpclassify
# __builtin_huge_val
# __builtin_huge_valf
# __builtin_huge_vall
# __builtin_inf
# __builtin_infd128
# __builtin_infd32
# __builtin_infd64
# __builtin_inff
# __builtin_infl
# __builtin_isinf_sign
# __builtin_nan
# __builtin_nand128
# __builtin_nand32
# __builtin_nand64
# __builtin_nanf
# __builtin_nanl
# __builtin_nans
# __builtin_nansf
# __builtin_nansl
# __builtin_object_size
# __builtin_parity
# __builtin_parityl
# __builtin_parityll
# __builtin_popcount
# __builtin_popcountl
# __builtin_popcountll
# __builtin_powi
# __builtin_powif
# __builtin_powil
# __builtin_prefetch
# __builtin_trap
# __builtin_types_compatible_p
# __builtin_unreachable
#
# Unsupported built-ins will be tested with an empty parameter set and the
# result of the check might be wrong or meaningless so use with care.
#
# LICENSE
#
# Copyright (c) 2013 Gabriele Svelto <gabriele.svelto@gmail.com>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.

#serial 6

AC_DEFUN([AX_GCC_BUILTIN], [
AS_VAR_PUSHDEF([ac_var], [ax_cv_have_$1])
AC_CACHE_CHECK([for $1], [ac_var], [
AC_LINK_IFELSE([AC_LANG_PROGRAM([], [
m4_case([$1],
[__builtin_assume_aligned], [$1("", 0)],
[__builtin_bswap16], [$1(0)],
[__builtin_bswap32], [$1(0)],
[__builtin_bswap64], [$1(0)],
[__builtin_choose_expr], [$1(0, 0, 0)],
[__builtin___clear_cache], [$1("", "")],
[__builtin_clrsb], [$1(0)],
[__builtin_clrsbl], [$1(0)],
[__builtin_clrsbll], [$1(0)],
[__builtin_clz], [$1(0)],
[__builtin_clzl], [$1(0)],
[__builtin_clzll], [$1(0)],
[__builtin_complex], [$1(0.0, 0.0)],
[__builtin_constant_p], [$1(0)],
[__builtin_ctz], [$1(0)],
[__builtin_ctzl], [$1(0)],
[__builtin_ctzll], [$1(0)],
[__builtin_expect], [$1(0, 0)],
[__builtin_ffs], [$1(0)],
[__builtin_ffsl], [$1(0)],
[__builtin_ffsll], [$1(0)],
[__builtin_fpclassify], [$1(0, 1, 2, 3, 4, 0.0)],
[__builtin_huge_val], [$1()],
[__builtin_huge_valf], [$1()],
[__builtin_huge_vall], [$1()],
[__builtin_inf], [$1()],
[__builtin_infd128], [$1()],
[__builtin_infd32], [$1()],
[__builtin_infd64], [$1()],
[__builtin_inff], [$1()],
[__builtin_infl], [$1()],
[__builtin_isinf_sign], [$1(0.0)],
[__builtin_nan], [$1("")],
[__builtin_nand128], [$1("")],
[__builtin_nand32], [$1("")],
[__builtin_nand64], [$1("")],
[__builtin_nanf], [$1("")],
[__builtin_nanl], [$1("")],
[__builtin_nans], [$1("")],
[__builtin_nansf], [$1("")],
[__builtin_nansl], [$1("")],
[__builtin_object_size], [$1("", 0)],
[__builtin_parity], [$1(0)],
[__builtin_parityl], [$1(0)],
[__builtin_parityll], [$1(0)],
[__builtin_popcount], [$1(0)],
[__builtin_popcountl], [$1(0)],
[__builtin_popcountll], [$1(0)],
[__builtin_powi], [$1(0, 0)],
[__builtin_powif], [$1(0, 0)],
[__builtin_powil], [$1(0, 0)],
[__builtin_prefetch], [$1("")],
[__builtin_trap], [$1()],
[__builtin_types_compatible_p], [$1(int, int)],
[__builtin_unreachable], [$1()],
[m4_warn([syntax], [Unsupported built-in $1, the test may fail])
$1()]
)
])],
[AS_VAR_SET([ac_var], [yes])],
[AS_VAR_SET([ac_var], [no])])
])
AS_IF([test yes = AS_VAR_GET([ac_var])],
[AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_$1), 1,
[Define to 1 if the system has the `$1' built-in function])], [])
AS_VAR_POPDEF([ac_var])
])
3 changes: 2 additions & 1 deletion python/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ build_triplet = @build@
host_triplet = @host@
subdir = python
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_gcc_builtin.m4 \
$(top_srcdir)/m4/ax_gcc_func_attribute.m4 \
$(top_srcdir)/m4/ax_gcc_var_attribute.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
Expand Down
3 changes: 2 additions & 1 deletion src/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ host_triplet = @host@
@COND_TESTS_TRUE@noinst_PROGRAMS = tests$(EXEEXT)
subdir = src
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_gcc_builtin.m4 \
$(top_srcdir)/m4/ax_gcc_func_attribute.m4 \
$(top_srcdir)/m4/ax_gcc_var_attribute.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
Expand Down
7 changes: 7 additions & 0 deletions src/dither.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ sixel_dither_new(
size_t wholesize;
int quality_mode;

/* ensure given pointer is not null */
if (ppdither == NULL) {
sixel_helper_set_additional_message(
"sixel_dither_new: ppdither is null.");
Expand Down Expand Up @@ -522,13 +523,15 @@ sixel_dither_initialize(
unsigned char *input_pixels;
SIXELSTATUS status = SIXEL_FALSE;

/* ensure dither object is not null */
if (dither == NULL) {
sixel_helper_set_additional_message(
"sixel_dither_new: dither is null.");
status = SIXEL_BAD_ARGUMENT;
goto end;
}

/* increment ref count */
sixel_dither_ref(dither);

sixel_dither_set_pixelformat(dither, pixelformat);
Expand Down Expand Up @@ -592,7 +595,10 @@ sixel_dither_initialize(

end:
free(normalized_pixels);

/* decrement ref count */
sixel_dither_unref(dither);

return status;
}

Expand Down Expand Up @@ -727,6 +733,7 @@ sixel_dither_apply_palette(
unsigned char *normalized_pixels = NULL;
unsigned char *input_pixels;

/* ensure dither object is not null */
if (dither == NULL) {
sixel_helper_set_additional_message(
"sixel_dither_apply_palette: dither is null.");
Expand Down
1 change: 1 addition & 0 deletions src/encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@ sixel_encoder_prepare_palette(
if (SIXEL_FAILED(status)) {
goto end;
}

status = sixel_dither_initialize(*dither,
sixel_frame_get_pixels(frame),
sixel_frame_get_width(frame),
Expand Down
1 change: 1 addition & 0 deletions src/quant.c
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,7 @@ computeHistogram(unsigned char const /* in */ *data,
}

colorfreqtableP->size = (unsigned int)(ref - refmap);

status = alloctupletable(&colorfreqtableP->table, depth, (unsigned int)(ref - refmap), allocator);
if (SIXEL_FAILED(status)) {
goto end;
Expand Down
8 changes: 4 additions & 4 deletions src/tosixel.c
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ sixel_encode_body(
int len;
int pix;
int check_integer_overflow;
unsigned char *map = NULL;
char *map = NULL;
sixel_node_t *np, *tp, top;
int fillable;

Expand All @@ -515,9 +515,9 @@ sixel_encode_body(
len = ncolors * width;
output->active_palette = (-1);

map = (unsigned char *)sixel_allocator_calloc(allocator,
(size_t)len,
sizeof(char));
map = (char *)sixel_allocator_calloc(allocator,
(size_t)len,
sizeof(char));
if (map == NULL) {
sixel_helper_set_additional_message(
"sixel_encode_body: sixel_allocator_calloc() failed.");
Expand Down
3 changes: 2 additions & 1 deletion tools/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ build_triplet = @build@
host_triplet = @host@
subdir = tools
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_gcc_builtin.m4 \
$(top_srcdir)/m4/ax_gcc_func_attribute.m4 \
$(top_srcdir)/m4/ax_gcc_var_attribute.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
Expand Down

0 comments on commit 56e0fb8

Please sign in to comment.