diff options
author | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2013-10-20 12:41:09 +0000 |
---|---|---|
committer | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2013-10-20 12:41:09 +0000 |
commit | 5dc25cbe5b65ee4ad62ed81dfdcc8d6baef415de (patch) | |
tree | 3ac2974afbc70cfdf8482d1e6f0f8d000346101c | |
parent | f35fa0e0d5d22c7b2f7ca3e733f7c2fbe977e4de (diff) |
Use arc4random
-rw-r--r-- | app/ico/Makefile.in | 2 | ||||
-rw-r--r-- | app/ico/aclocal.m4 | 104 | ||||
-rw-r--r-- | app/ico/config.h.in | 3 | ||||
-rw-r--r-- | app/ico/configure | 139 | ||||
-rw-r--r-- | app/ico/configure.ac | 3 | ||||
-rw-r--r-- | app/ico/ico.c | 7 | ||||
-rw-r--r-- | app/ico/man/Makefile.in | 2 |
7 files changed, 204 insertions, 56 deletions
diff --git a/app/ico/Makefile.in b/app/ico/Makefile.in index e5636ba0c..79e6baa26 100644 --- a/app/ico/Makefile.in +++ b/app/ico/Makefile.in @@ -248,6 +248,8 @@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ diff --git a/app/ico/aclocal.m4 b/app/ico/aclocal.m4 index 342604fe9..97d3815f6 100644 --- a/app/ico/aclocal.m4 +++ b/app/ico/aclocal.m4 @@ -20,6 +20,7 @@ If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically 'autoreconf'.])]) # pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- +# serial 1 (pkg-config-0.24) # # Copyright © 2004 Scott James Remnant <scott@netsplit.com>. # @@ -46,8 +47,12 @@ To do so, use the procedure documented by the package, typically 'autoreconf'.]) # ---------------------------------- AC_DEFUN([PKG_PROG_PKG_CONFIG], [m4_pattern_forbid([^_?PKG_[A-Z_]+$]) -m4_pattern_allow([^PKG_CONFIG(_PATH)?$]) -AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl +m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$]) +m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$]) +AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility]) +AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path]) +AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path]) + if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) fi @@ -60,7 +65,6 @@ if test -n "$PKG_CONFIG"; then AC_MSG_RESULT([no]) PKG_CONFIG="" fi - fi[]dnl ])# PKG_PROG_PKG_CONFIG @@ -69,34 +73,32 @@ fi[]dnl # Check to see whether a particular set of modules exists. Similar # to PKG_CHECK_MODULES(), but does not set variables or print errors. # -# -# Similar to PKG_CHECK_MODULES, make sure that the first instance of -# this or PKG_CHECK_MODULES is called, or make sure to call -# PKG_CHECK_EXISTS manually +# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) +# only at the first occurence in configure.ac, so if the first place +# it's called might be skipped (such as if it is within an "if", you +# have to call PKG_CHECK_EXISTS manually # -------------------------------------------------------------- AC_DEFUN([PKG_CHECK_EXISTS], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl if test -n "$PKG_CONFIG" && \ AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then - m4_ifval([$2], [$2], [:]) + m4_default([$2], [:]) m4_ifvaln([$3], [else $3])dnl fi]) - # _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) # --------------------------------------------- m4_define([_PKG_CONFIG], -[if test -n "$PKG_CONFIG"; then - if test -n "$$1"; then - pkg_cv_[]$1="$$1" - else - PKG_CHECK_EXISTS([$3], - [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`], - [pkg_failed=yes]) - fi -else - pkg_failed=untried +[if test -n "$$1"; then + pkg_cv_[]$1="$$1" + elif test -n "$PKG_CONFIG"; then + PKG_CHECK_EXISTS([$3], + [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes ], + [pkg_failed=yes]) + else + pkg_failed=untried fi[]dnl ])# _PKG_CONFIG @@ -138,16 +140,17 @@ and $1[]_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details.]) if test $pkg_failed = yes; then + AC_MSG_RESULT([no]) _PKG_SHORT_ERRORS_SUPPORTED if test $_pkg_short_errors_supported = yes; then - $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "$2"` + $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1` else - $1[]_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"` + $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD - ifelse([$4], , [AC_MSG_ERROR(dnl + m4_default([$4], [AC_MSG_ERROR( [Package requirements ($2) were not met: $$1_PKG_ERRORS @@ -155,28 +158,67 @@ $$1_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. -_PKG_TEXT -])], - [AC_MSG_RESULT([no]) - $4]) +_PKG_TEXT])[]dnl + ]) elif test $pkg_failed = untried; then - ifelse([$4], , [AC_MSG_FAILURE(dnl + AC_MSG_RESULT([no]) + m4_default([$4], [AC_MSG_FAILURE( [The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. _PKG_TEXT -To get pkg-config, see <http://www.freedesktop.org/software/pkgconfig>.])], - [$4]) +To get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl + ]) else $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS $1[]_LIBS=$pkg_cv_[]$1[]_LIBS AC_MSG_RESULT([yes]) - ifelse([$3], , :, [$3]) + $3 fi[]dnl ])# PKG_CHECK_MODULES + +# PKG_INSTALLDIR(DIRECTORY) +# ------------------------- +# Substitutes the variable pkgconfigdir as the location where a module +# should install pkg-config .pc files. By default the directory is +# $libdir/pkgconfig, but the default can be changed by passing +# DIRECTORY. The user can override through the --with-pkgconfigdir +# parameter. +AC_DEFUN([PKG_INSTALLDIR], +[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])]) +m4_pushdef([pkg_description], + [pkg-config installation directory @<:@]pkg_default[@:>@]) +AC_ARG_WITH([pkgconfigdir], + [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],, + [with_pkgconfigdir=]pkg_default) +AC_SUBST([pkgconfigdir], [$with_pkgconfigdir]) +m4_popdef([pkg_default]) +m4_popdef([pkg_description]) +]) dnl PKG_INSTALLDIR + + +# PKG_NOARCH_INSTALLDIR(DIRECTORY) +# ------------------------- +# Substitutes the variable noarch_pkgconfigdir as the location where a +# module should install arch-independent pkg-config .pc files. By +# default the directory is $datadir/pkgconfig, but the default can be +# changed by passing DIRECTORY. The user can override through the +# --with-noarch-pkgconfigdir parameter. +AC_DEFUN([PKG_NOARCH_INSTALLDIR], +[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])]) +m4_pushdef([pkg_description], + [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@]) +AC_ARG_WITH([noarch-pkgconfigdir], + [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],, + [with_noarch_pkgconfigdir=]pkg_default) +AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir]) +m4_popdef([pkg_default]) +m4_popdef([pkg_description]) +]) dnl PKG_NOARCH_INSTALLDIR + # Copyright (C) 2002-2012 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation @@ -1237,7 +1279,7 @@ dnl DEALINGS IN THE SOFTWARE. # See the "minimum version" comment for each macro you use to see what # version you require. m4_defun([XORG_MACROS_VERSION],[ -m4_define([vers_have], [1.17]) +m4_define([vers_have], [1.16.2]) m4_define([maj_have], m4_substr(vers_have, 0, m4_index(vers_have, [.]))) m4_define([maj_needed], m4_substr([$1], 0, m4_index([$1], [.]))) m4_if(m4_cmp(maj_have, maj_needed), 0,, diff --git a/app/ico/config.h.in b/app/ico/config.h.in index 7c9cfb1c0..e3f89f553 100644 --- a/app/ico/config.h.in +++ b/app/ico/config.h.in @@ -1,5 +1,8 @@ /* config.h.in. Generated from configure.ac by autoheader. */ +/* Define to 1 if you have the `arc4random_uniform' function. */ +#undef HAVE_ARC4RANDOM_UNIFORM + /* Define to 1 if you have the <inttypes.h> header file. */ #undef HAVE_INTTYPES_H diff --git a/app/ico/configure b/app/ico/configure index 8e8804743..74334d30c 100644 --- a/app/ico/configure +++ b/app/ico/configure @@ -657,6 +657,8 @@ build_vendor build_cpu build INSTALL_CMD +PKG_CONFIG_LIBDIR +PKG_CONFIG_PATH PKG_CONFIG CHANGELOG_CMD STRICT_CFLAGS @@ -765,6 +767,8 @@ LIBS CPPFLAGS CPP PKG_CONFIG +PKG_CONFIG_PATH +PKG_CONFIG_LIBDIR ICO_CFLAGS ICO_LIBS' @@ -1411,6 +1415,10 @@ Some influential environment variables: you have headers in a nonstandard directory <include dir> CPP C preprocessor PKG_CONFIG path to pkg-config utility + PKG_CONFIG_PATH + directories to add to pkg-config's search path + PKG_CONFIG_LIBDIR + path overriding pkg-config's built-in search path ICO_CFLAGS C compiler flags for ICO, overriding pkg-config ICO_LIBS linker flags for ICO, overriding pkg-config @@ -1733,6 +1741,73 @@ fi as_fn_set_status $ac_retval } # ac_fn_c_try_link + +# ac_fn_c_check_func LINENO FUNC VAR +# ---------------------------------- +# Tests whether FUNC exists, setting the cache variable VAR accordingly +ac_fn_c_check_func () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +/* Define $2 to an innocuous variant, in case <limits.h> declares $2. + For example, HP-UX 11i <limits.h> declares gettimeofday. */ +#define $2 innocuous_$2 + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $2 (); below. + Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + <limits.h> exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif + +#undef $2 + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $2 (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$2 || defined __stub___$2 +choke me +#endif + +int +main () +{ +return $2 (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_func cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. @@ -4226,6 +4301,11 @@ fi + + + + + if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. @@ -4338,7 +4418,6 @@ $as_echo "yes" >&6; } $as_echo "no" >&6; } PKG_CONFIG="" fi - fi # Make sure we can run config.sub. $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || @@ -10300,52 +10379,65 @@ AM_BACKSLASH='\' ac_config_headers="$ac_config_headers config.h" +# Checks for library functions. +for ac_func in arc4random_uniform +do : + ac_fn_c_check_func "$LINENO" "arc4random_uniform" "ac_cv_func_arc4random_uniform" +if test "x$ac_cv_func_arc4random_uniform" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_ARC4RANDOM_UNIFORM 1 +_ACEOF + +fi +done + + # Checks for pkg-config packages pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ICO" >&5 $as_echo_n "checking for ICO... " >&6; } -if test -n "$PKG_CONFIG"; then - if test -n "$ICO_CFLAGS"; then - pkg_cv_ICO_CFLAGS="$ICO_CFLAGS" - else - if test -n "$PKG_CONFIG" && \ +if test -n "$ICO_CFLAGS"; then + pkg_cv_ICO_CFLAGS="$ICO_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"x11 >= 0.99.1 xproto >= 7.0.22\""; } >&5 ($PKG_CONFIG --exists --print-errors "x11 >= 0.99.1 xproto >= 7.0.22") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_ICO_CFLAGS=`$PKG_CONFIG --cflags "x11 >= 0.99.1 xproto >= 7.0.22" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi - fi -else - pkg_failed=untried + else + pkg_failed=untried fi -if test -n "$PKG_CONFIG"; then - if test -n "$ICO_LIBS"; then - pkg_cv_ICO_LIBS="$ICO_LIBS" - else - if test -n "$PKG_CONFIG" && \ +if test -n "$ICO_LIBS"; then + pkg_cv_ICO_LIBS="$ICO_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"x11 >= 0.99.1 xproto >= 7.0.22\""; } >&5 ($PKG_CONFIG --exists --print-errors "x11 >= 0.99.1 xproto >= 7.0.22") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_ICO_LIBS=`$PKG_CONFIG --libs "x11 >= 0.99.1 xproto >= 7.0.22" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi - fi -else - pkg_failed=untried + else + pkg_failed=untried fi if test $pkg_failed = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes @@ -10353,9 +10445,9 @@ else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then - ICO_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "x11 >= 0.99.1 xproto >= 7.0.22"` + ICO_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "x11 >= 0.99.1 xproto >= 7.0.22" 2>&1` else - ICO_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "x11 >= 0.99.1 xproto >= 7.0.22"` + ICO_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "x11 >= 0.99.1 xproto >= 7.0.22" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$ICO_PKG_ERRORS" >&5 @@ -10369,9 +10461,10 @@ installed software in a non-standard prefix. Alternatively, you may set the environment variables ICO_CFLAGS and ICO_LIBS to avoid the need to call pkg-config. -See the pkg-config man page for more details. -" "$LINENO" 5 +See the pkg-config man page for more details." "$LINENO" 5 elif test $pkg_failed = untried; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it @@ -10382,14 +10475,14 @@ Alternatively, you may set the environment variables ICO_CFLAGS and ICO_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. -To get pkg-config, see <http://www.freedesktop.org/software/pkgconfig>. +To get pkg-config, see <http://pkg-config.freedesktop.org/>. See \`config.log' for more details" "$LINENO" 5; } else ICO_CFLAGS=$pkg_cv_ICO_CFLAGS ICO_LIBS=$pkg_cv_ICO_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } - : + fi XTHREADLIB=`$PKG_CONFIG --variable=xthreadlib x11` diff --git a/app/ico/configure.ac b/app/ico/configure.ac index f7db44ce0..d48ba0538 100644 --- a/app/ico/configure.ac +++ b/app/ico/configure.ac @@ -35,6 +35,9 @@ XORG_DEFAULT_OPTIONS AC_CONFIG_HEADERS([config.h]) +# Checks for library functions. +AC_CHECK_FUNCS([arc4random_uniform]) + # Checks for pkg-config packages PKG_CHECK_MODULES(ICO, [x11 >= 0.99.1 xproto >= 7.0.22]) diff --git a/app/ico/ico.c b/app/ico/ico.c index 059ee0ef1..5eb26c91c 100644 --- a/app/ico/ico.c +++ b/app/ico/ico.c @@ -1008,11 +1008,14 @@ do_ico_window(void *ptr) /* Get the initial position, size, and speed of the bounding-box */ +#ifndef HAVE_ARC4RANDOM_UNIFORM srand((int) time((time_t *)0) % 231); icoX = ((closure->winW - icoW) * (rand() & 0xFF)) >> 8; icoY = ((closure->winH - icoH) * (rand() & 0xFF)) >> 8; - - +#else + icoX = ((closure->winW - icoW) * arc4random_uniform(0xFF)) >> 8; + icoY = ((closure->winH - icoH) * arc4random_uniform(0xFF)) >> 8; +#endif /* Bounce the box in the window */ icodeltax2 = icoDeltaX * 2; diff --git a/app/ico/man/Makefile.in b/app/ico/man/Makefile.in index 033f29b28..7c9c26c0c 100644 --- a/app/ico/man/Makefile.in +++ b/app/ico/man/Makefile.in @@ -171,6 +171,8 @@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ |