Merge branch 'master' of github.com:OpenELEC/OpenELEC.tv into openelec-2.0

This commit is contained in:
Stephan Raue
2012-05-15 17:25:59 +02:00
54 changed files with 700 additions and 62 deletions

View File

@@ -1,3 +1,6 @@
2.1.4
- fixes bug in sleep control
2.1.3
- fix so python dont steal xbmc's webserver port (again)
- add option to wake up periodically

View File

@@ -3,6 +3,6 @@
<setting id="SABNZBD_PWD" value="" />
<setting id="SABNZBD_USER" value="" />
<setting id="SABNZBD_KEEP_AWAKE" value="false" />
<setting id="SABNZBD_PERIODIC_WAKE" value="true" />
<setting id="SABNZBD_PERIODIC_WAKE" value="false" />
<setting id="SABNZBD_WAKE_AT" value="1" />
</settings>

View File

@@ -58,8 +58,8 @@ sabNzbdQueue = 'http://' + sabNzbdAddress + '/sabnzbd/api?mode=queue&output
socket.setdefaulttimeout(timeout)
# perform some initial checks and log essential settings
shouldKeepAwake = __settings__.getSetting('SABNZBD_KEEP_AWAKE')
wakePeriodically = __settings__.getSetting('SABNZBD_PERIODIC_WAKE')
shouldKeepAwake = (__settings__.getSetting('SABNZBD_KEEP_AWAKE').lower() == 'true')
wakePeriodically = (__settings__.getSetting('SABNZBD_PERIODIC_WAKE').lower() == 'true')
wakeHourIdx = int(__settings__.getSetting('SABNZBD_WAKE_AT'))
if shouldKeepAwake:
xbmc.log('SABnzbd-Suite: will prevent idle sleep/shutdown while downloading')
@@ -70,8 +70,8 @@ if wakePeriodically:
while (not xbmc.abortRequested):
# reread setting in case it has changed
shouldKeepAwake = __settings__.getSetting('SABNZBD_KEEP_AWAKE')
wakePeriodically = __settings__.getSetting('SABNZBD_PERIODIC_WAKE')
shouldKeepAwake = (__settings__.getSetting('SABNZBD_KEEP_AWAKE').lower() == 'true')
wakePeriodically = (__settings__.getSetting('SABNZBD_PERIODIC_WAKE').lower() == 'true')
wakeHourIdx = int(__settings__.getSetting('SABNZBD_WAKE_AT'))
# check if SABnzbd is downloading
@@ -108,4 +108,5 @@ while (not xbmc.abortRequested):
open("/sys/class/rtc/rtc0/wakealarm", "w").write("0")
open("/sys/class/rtc/rtc0/wakealarm", "w").write(str(secondsSinceEpoch))
xbmc.sleep(checkInterval * 1000)
xbmc.sleep(checkInterval * 1000)

View File

@@ -1,5 +1,6 @@
2.1.3
- update to transmission-2.51
- added option to specify download directory
2.1.2
- update to addon version 2.1

View File

@@ -44,17 +44,17 @@ cat "$ADDON_SETTINGS" | awk -F\" '{print $2"=\""$4"\""}' | sed '/^=/d' > /var/co
. /var/config/transmission.conf.default
. /var/config/transmission.conf
mkdir -p /storage/downloads
mkdir -p /storage/downloads/incoming
mkdir -p /storage/downloads/watch
mkdir -p "$TRANSMISSION_DL_DIR"
mkdir -p "$TRANSMISSION_DL_DIR/incoming"
mkdir -p "$TRANSMISSION_DL_DIR/watch"
if [ -z "$TRANSMISSION_IP" ]; then
TRANSMISSION_IP="*.*.*.*"
fi
TRANSMISSION_ARG="$TRANSMISSION_ARG -w /storage/downloads"
TRANSMISSION_ARG="$TRANSMISSION_ARG --incomplete-dir /storage/downloads/incoming"
TRANSMISSION_ARG="$TRANSMISSION_ARG --watch-dir /storage/downloads/watch"
TRANSMISSION_ARG="$TRANSMISSION_ARG -w \"$TRANSMISSION_DL_DIR\""
TRANSMISSION_ARG="$TRANSMISSION_ARG --incomplete-dir \"$TRANSMISSION_DL_DIR/incoming\""
TRANSMISSION_ARG="$TRANSMISSION_ARG --watch-dir \"$TRANSMISSION_DL_DIR/watch\""
TRANSMISSION_ARG="$TRANSMISSION_ARG -e /var/log/transmission.log"
TRANSMISSION_ARG="$TRANSMISSION_ARG -g /storage/.cache/transmission"
@@ -83,7 +83,7 @@ if [ ! "$(pidof transmission-daemon)" ];then
if [ -f "$LOCKDIR/$LOCKFILE" ] ; then
break
fi
LD_LIBRARY_PATH="$ADDON_DIR/lib:$LD_LIBRARY_PATH" eval transmission-daemon -f $TRANSMISSION_ARG &>$LOG_FILE
EVENT_NOEPOLL=1 LD_LIBRARY_PATH="$ADDON_DIR/lib:$LD_LIBRARY_PATH" eval transmission-daemon -f $TRANSMISSION_ARG &>$LOG_FILE
sleep 1
done &
fi

View File

@@ -14,4 +14,7 @@
<string id="3021">Overall peer limit.</string>
<string id="3022">Peer limit per torrent</string>
<string id="3110">Other</string>
<string id="3121">Download Directory</string>
</strings>

View File

@@ -17,5 +17,9 @@
<setting type="sep" />
<setting id="TRANSMISSION_LIMIT_GLOBAL" type="number" label="3021" value="" default="" />
<setting id="TRANSMISSION_LIMIT_TORRENT" type="number" label="3022" value="" default="" />
<setting type="sep" />
<setting label="3110" type="lsep"/>
<setting id="TRANSMISSION_DL_DIR" type="folder" label="3121" value="" default="/storage/downloads" />
</category>
</settings>

View File

@@ -5,4 +5,5 @@
<setting id="TRANSMISSION_USER" value="openelec" />
<setting id="TRANSMISSION_LIMIT_GLOBAL" value="" />
<setting id="TRANSMISSION_LIMIT_TORRENT" value="" />
<setting id="TRANSMISSION_DL_DIR" value="/storage/downloads" />
</settings>

View File

@@ -42,6 +42,8 @@ fi
mkdir -p /var/config
cat "$ADDON_DIR/settings-default.xml" | awk -F\" '{print $2"=\""$4"\""}' | sed '/^=/d' > /var/config/vdr.conf.default
cat "$ADDON_SETTINGS" | awk -F\" '{print $2"=\""$4"\""}' | sed '/^=/d' > /var/config/vdr.conf
mkdir -p /var/lib/epgsources
cp $ADDON_DIR/config/epgsources/epgdata2xmltv/epgdata2xmltv.dist /var/lib/epgsources/epgdata2xmltv
. /var/config/vdr.conf.default
. /var/config/vdr.conf
@@ -115,6 +117,7 @@ fi
sed -i -e '/^xineliboutput.OSD.Blending.*$/d' $ADDON_CONFIG_DIR/setup.conf
sed -i -e '/^xineliboutput.OSD.Size.*$/d' $ADDON_CONFIG_DIR/setup.conf
sed -i -e '/^xineliboutput.OSD.SoftOSD.*$/d' $ADDON_CONFIG_DIR/setup.conf
sed -i -e '/^epgsearch.SVDRPPort.*$/d' $ADDON_CONFIG_DIR/setup.conf
fi
cat >>$ADDON_CONFIG_DIR/setup.conf << MYDATA
OSDHeight = 1080
@@ -123,6 +126,7 @@ OSDTheme = yabluelight
xineliboutput.OSD.Blending = 1
xineliboutput.OSD.Size = 1280x720
xineliboutput.OSD.SoftOSD = 1
epgsearch.SVDRPPort = 2004
MYDATA
)

View File

@@ -19,7 +19,7 @@
################################################################################
PKG_NAME="sqlite"
PKG_VERSION="autoconf-3071100"
PKG_VERSION="autoconf-3071200"
PKG_REV="1"
PKG_ARCH="any"
PKG_LICENSE="PublicDomain"

View File

@@ -25,7 +25,7 @@
get_graphicdrivers
DRM_CONFIG="--disable-libkms --disable-intel --disable-radeon"
DRM_CONFIG="$DRM_CONFIG --disable-nouveau-experimental-api --disable-vmwgfx-experimental-api"
DRM_CONFIG="$DRM_CONFIG --disable-nouveau --disable-vmwgfx-experimental-api"
for drv in $GRAPHIC_DRIVERS; do
[ "$drv" = "i915" -o "$drv" = "i965" ] && \

View File

@@ -19,7 +19,7 @@
################################################################################
PKG_NAME="libdrm"
PKG_VERSION="2.4.33"
PKG_VERSION="2.4.34"
PKG_REV="1"
PKG_ARCH="any"
PKG_LICENSE="GPL"

View File

@@ -29,6 +29,7 @@ if [ -n "$INITRAMFS_MODULES" ]; then
mkdir -p $INSTALL/etc
mkdir -p $INSTALL/lib/modules
rm -f $INSTALL/etc/modules
for i in $INITRAMFS_MODULES; do
module=`find $LINUX_MODULES_DIR -name $i.ko`
if [ -n "$module" ]; then

View File

@@ -319,7 +319,7 @@ NBD_DEVS="0"
for module in $(cat /etc/modules); do
progress "Loading kernel module $module"
/bin/busybox insmod "$MODULE_DIR/$module.ko" || \
error "load_modules" "Failed to load kernel module $module"
progress "... Failed to load kernel module $module, skipping"
done
}

View File

@@ -19,7 +19,7 @@
################################################################################
PKG_NAME="linux"
PKG_VERSION="3.2.16"
PKG_VERSION="3.2.17"
PKG_REV="1"
PKG_ARCH="any"
PKG_LICENSE="GPL"

View File

@@ -0,0 +1,12 @@
diff -Naur linux-3.2.17/drivers/net/wireless/brcm80211/brcmsmac/main.c linux-3.2.17.patch/drivers/net/wireless/brcm80211/brcmsmac/main.c
--- linux-3.2.17/drivers/net/wireless/brcm80211/brcmsmac/main.c 2012-05-11 14:15:38.000000000 +0200
+++ linux-3.2.17.patch/drivers/net/wireless/brcm80211/brcmsmac/main.c 2012-05-15 10:39:19.751263956 +0200
@@ -7879,7 +7879,7 @@
if (wlc->hw->suspended_fifos) {
hdr = (struct ieee80211_hdr *)p->data;
if (ieee80211_is_beacon(hdr->frame_control))
- brcms_b_mute(wlc->hw, false);
+ brcms_b_mute(wlc->hw, false, 0);
}
memcpy(IEEE80211_SKB_RXCB(p), &rx_status, sizeof(rx_status));

View File

@@ -0,0 +1,32 @@
From 5c62df65cb2ef1c7dcebbf07bd6d180960ab6715 Mon Sep 17 00:00:00 2001
From: theuni <theuni-nospam-@xbmc.org>
Date: Wed, 4 Apr 2012 14:53:51 -0400
Subject: [PATCH] ffmpeg: disable ffmpeg's crystalhd implementation for now
---
configure.in | 2 ++
1 file changed, 2 insertions(+)
diff --git a/configure.in b/configure.in
index 0d80719..40e9fb5 100755
--- a/configure.in
+++ b/configure.in
@@ -2041,6 +2041,7 @@ XB_CONFIG_MODULE([lib/ffmpeg], [
--disable-ffmpeg \
--disable-doc \
--disable-decoder=mpeg_xvmc \
+ --disable-crystalhd \
--enable-postproc \
--enable-gpl \
--enable-protocol=http \
@@ -2080,6 +2081,7 @@ XB_CONFIG_MODULE([lib/ffmpeg], [
--disable-ffplay \
--disable-ffserver \
--disable-ffmpeg \
+ --disable-crystalhd \
--enable-shared \
--disable-doc \
--enable-postproc \
--
1.7.10

View File

@@ -0,0 +1,32 @@
From 5c62df65cb2ef1c7dcebbf07bd6d180960ab6715 Mon Sep 17 00:00:00 2001
From: theuni <theuni-nospam-@xbmc.org>
Date: Wed, 4 Apr 2012 14:53:51 -0400
Subject: [PATCH] ffmpeg: disable ffmpeg's crystalhd implementation for now
---
configure.in | 2 ++
1 file changed, 2 insertions(+)
diff --git a/configure.in b/configure.in
index 0d80719..40e9fb5 100755
--- a/configure.in
+++ b/configure.in
@@ -2041,6 +2041,7 @@ XB_CONFIG_MODULE([lib/ffmpeg], [
--disable-ffmpeg \
--disable-doc \
--disable-decoder=mpeg_xvmc \
+ --disable-crystalhd \
--enable-postproc \
--enable-gpl \
--enable-protocol=http \
@@ -2080,6 +2081,7 @@ XB_CONFIG_MODULE([lib/ffmpeg], [
--disable-ffplay \
--disable-ffserver \
--disable-ffmpeg \
+ --disable-crystalhd \
--enable-shared \
--disable-doc \
--enable-postproc \
--
1.7.10

View File

@@ -19,7 +19,7 @@
################################################################################
PKG_NAME="libnl"
PKG_VERSION="3.2.4"
PKG_VERSION="3.2.9"
PKG_REV="1"
PKG_ARCH="any"
PKG_LICENSE="LGPL"

View File

@@ -29,7 +29,7 @@ cp $ROOT/$PKG_DIR/config/makefile.config .config
echo "CFLAGS += $TARGET_CFLAGS -I$SYSROOT_PREFIX/usr/include/libnl3/" >> .config
# echo "CONFIG_TLS=gnutls" >> .config
# echo "CONFIG_GNUTLS_EXTRA=y" >> .config
echo "CONFIG_LIBNL20=y" >> .config
echo "CONFIG_LIBNL32=y" >> .config
[ ! "$DEBUG" = "yes" ] && echo "CONFIG_NO_STDOUT_DEBUG=y" >> .config
make LIBDIR=/usr/lib BINDIR=/usr/bin

View File

@@ -19,7 +19,7 @@
################################################################################
PKG_NAME="wpa_supplicant"
PKG_VERSION="0.7.3"
PKG_VERSION="1.0"
PKG_REV="1"
PKG_ARCH="any"
PKG_LICENSE="GPL"

View File

@@ -1,16 +0,0 @@
diff -Naur wpa_supplicant-0.7.3/src/drivers/drivers.mak wpa_supplicant-0.7.3.patch/src/drivers/drivers.mak
--- wpa_supplicant-0.7.3/src/drivers/drivers.mak 2010-09-07 17:43:39.000000000 +0200
+++ wpa_supplicant-0.7.3.patch/src/drivers/drivers.mak 2011-11-30 13:37:22.187964539 +0100
@@ -31,10 +31,10 @@
NEED_AP_MLME=y
NEED_NETLINK=y
NEED_LINUX_IOCTL=y
-DRV_LIBS += -lnl
+DRV_LIBS += -lnl-3
ifdef CONFIG_LIBNL20
-DRV_LIBS += -lnl-genl
+DRV_LIBS += -lnl-genl-3
DRV_CFLAGS += -DCONFIG_LIBNL20
endif
endif

View File

@@ -1,18 +0,0 @@
diff -Naur wpa_supplicant-0.7.3/wpa_supplicant/dbus/fi.epitest.hostap.WPASupplicant.service wpa_supplicant-0.7.3.patch/wpa_supplicant/dbus/fi.epitest.hostap.WPASupplicant.service
--- wpa_supplicant-0.7.3/wpa_supplicant/dbus/fi.epitest.hostap.WPASupplicant.service 2010-09-07 17:43:39.000000000 +0200
+++ wpa_supplicant-0.7.3.patch/wpa_supplicant/dbus/fi.epitest.hostap.WPASupplicant.service 2011-11-06 22:34:15.331582673 +0100
@@ -1,4 +1,4 @@
[D-BUS Service]
Name=fi.epitest.hostap.WPASupplicant
-Exec=/sbin/wpa_supplicant -u
+Exec=/usr/bin/wpa_supplicant -u
User=root
diff -Naur wpa_supplicant-0.7.3/wpa_supplicant/dbus/fi.w1.wpa_supplicant1.service wpa_supplicant-0.7.3.patch/wpa_supplicant/dbus/fi.w1.wpa_supplicant1.service
--- wpa_supplicant-0.7.3/wpa_supplicant/dbus/fi.w1.wpa_supplicant1.service 2010-09-07 17:43:39.000000000 +0200
+++ wpa_supplicant-0.7.3.patch/wpa_supplicant/dbus/fi.w1.wpa_supplicant1.service 2011-11-06 22:34:24.216699484 +0100
@@ -1,4 +1,4 @@
[D-BUS Service]
Name=fi.w1.wpa_supplicant1
-Exec=/sbin/wpa_supplicant -u
+Exec=/usr/bin/wpa_supplicant -u
User=root

View File

@@ -19,7 +19,7 @@
################################################################################
PKG_NAME="openssl"
PKG_VERSION="1.0.1b"
PKG_VERSION="1.0.1c"
PKG_REV="1"
PKG_ARCH="any"
PKG_LICENSE="OSS"

View File

@@ -19,16 +19,14 @@
################################################################################
PKG_NAME="usbutils"
PKG_VERSION="004"
PKG_VERSION="005"
PKG_REV="1"
PKG_ARCH="any"
PKG_LICENSE="GPL"
PKG_SITE="http://www.linux-usb.org/"
#PKG_URL="http://www.kernel.org/pub/linux/utils/usb/usbutils/$PKG_NAME-$PKG_VERSION.tar.bz2"
#PKG_URL="ftp://ftp.pgpi.com/linux/kernel/pub/linux/utils/usb/usbutils/$PKG_NAME-$PKG_VERSION.tar.bz2"
PKG_URL="http://www.mirrorservice.org/sites/ftp.kernel.org/pub/linux/utils/usb/usbutils/$PKG_NAME-$PKG_VERSION.tar.bz2"
PKG_DEPENDS="zlib libusb-compat"
PKG_BUILD_DEPENDS="toolchain zlib libusb-compat"
PKG_URL="http://ftp.debian.org/debian/pool/main/u/usbutils/${PKG_NAME}_${PKG_VERSION}.orig.tar.gz"
PKG_DEPENDS="zlib libusb"
PKG_BUILD_DEPENDS="toolchain zlib libusb"
PKG_PRIORITY="optional"
PKG_SECTION="system"
PKG_SHORTDESC="usbutils: Linux USB Utilities"

View File

@@ -1314,3 +1314,583 @@ diff -Naurd mpfr-3.1.0-a/src/version.c mpfr-3.1.0-b/src/version.c
- return "3.1.0-p7";
+ return "3.1.0-p8";
}
diff -Naurd mpfr-3.1.0-a/PATCHES mpfr-3.1.0-b/PATCHES
--- mpfr-3.1.0-a/PATCHES 2012-04-27 01:13:15.000000000 +0000
+++ mpfr-3.1.0-b/PATCHES 2012-04-27 01:13:15.000000000 +0000
@@ -0,0 +1 @@
+gamma-underflow
diff -Naurd mpfr-3.1.0-a/VERSION mpfr-3.1.0-b/VERSION
--- mpfr-3.1.0-a/VERSION 2012-03-12 11:59:47.000000000 +0000
+++ mpfr-3.1.0-b/VERSION 2012-04-27 01:13:15.000000000 +0000
@@ -1 +1 @@
-3.1.0-p8
+3.1.0-p9
diff -Naurd mpfr-3.1.0-a/src/gamma.c mpfr-3.1.0-b/src/gamma.c
--- mpfr-3.1.0-a/src/gamma.c 2011-10-03 08:17:09.000000000 +0000
+++ mpfr-3.1.0-b/src/gamma.c 2012-04-27 01:13:15.000000000 +0000
@@ -296,7 +296,7 @@
/* we want an upper bound for x * [log(2-x)-1].
since x < 0, we need a lower bound on log(2-x) */
mpfr_ui_sub (xp, 2, x, MPFR_RNDD);
- mpfr_log2 (xp, xp, MPFR_RNDD);
+ mpfr_log (xp, xp, MPFR_RNDD);
mpfr_sub_ui (xp, xp, 1, MPFR_RNDD);
mpfr_mul (xp, xp, x, MPFR_RNDU);
diff -Naurd mpfr-3.1.0-a/src/mpfr.h mpfr-3.1.0-b/src/mpfr.h
--- mpfr-3.1.0-a/src/mpfr.h 2012-03-12 11:59:47.000000000 +0000
+++ mpfr-3.1.0-b/src/mpfr.h 2012-04-27 01:13:15.000000000 +0000
@@ -27,7 +27,7 @@
#define MPFR_VERSION_MAJOR 3
#define MPFR_VERSION_MINOR 1
#define MPFR_VERSION_PATCHLEVEL 0
-#define MPFR_VERSION_STRING "3.1.0-p8"
+#define MPFR_VERSION_STRING "3.1.0-p9"
/* Macros dealing with MPFR VERSION */
#define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
diff -Naurd mpfr-3.1.0-a/src/version.c mpfr-3.1.0-b/src/version.c
--- mpfr-3.1.0-a/src/version.c 2012-03-12 11:59:47.000000000 +0000
+++ mpfr-3.1.0-b/src/version.c 2012-04-27 01:13:15.000000000 +0000
@@ -25,5 +25,5 @@
const char *
mpfr_get_version (void)
{
- return "3.1.0-p8";
+ return "3.1.0-p9";
}
diff -Naurd mpfr-3.1.0-a/tests/tgamma.c mpfr-3.1.0-b/tests/tgamma.c
--- mpfr-3.1.0-a/tests/tgamma.c 2011-10-03 08:17:14.000000000 +0000
+++ mpfr-3.1.0-b/tests/tgamma.c 2012-04-27 01:13:15.000000000 +0000
@@ -478,6 +478,36 @@
mpfr_clear (x);
}
+/* bug found by Giridhar Tammana */
+static void
+test20120426 (void)
+{
+ mpfr_t xa, xb;
+ int i;
+ mpfr_exp_t emin;
+
+ mpfr_init2 (xa, 53);
+ mpfr_init2 (xb, 53);
+ mpfr_set_d (xb, -168.5, MPFR_RNDN);
+ emin = mpfr_get_emin ();
+ mpfr_set_emin (-1073);
+ i = mpfr_gamma (xa, xb, MPFR_RNDN);
+ i = mpfr_subnormalize (xa, i, MPFR_RNDN); /* new ternary value */
+ mpfr_set_str (xb, "-9.5737343987585366746184749943e-304", 10, MPFR_RNDN);
+ if (!((i > 0) && (mpfr_cmp (xa, xb) == 0)))
+ {
+ printf ("Error in test20120426, i=%d\n", i);
+ printf ("expected ");
+ mpfr_print_binary (xb); putchar ('\n');
+ printf ("got ");
+ mpfr_print_binary (xa); putchar ('\n');
+ exit (1);
+ }
+ mpfr_set_emin (emin);
+ mpfr_clear (xa);
+ mpfr_clear (xb);
+}
+
static void
exprange (void)
{
@@ -821,6 +851,7 @@
gamma_integer ();
test20071231 ();
test20100709 ();
+ test20120426 ();
data_check ("data/gamma", mpfr_gamma, "mpfr_gamma");
diff -Naurd mpfr-3.1.0-a/PATCHES mpfr-3.1.0-b/PATCHES
--- mpfr-3.1.0-a/PATCHES 2012-05-07 18:52:45.000000000 +0000
+++ mpfr-3.1.0-b/PATCHES 2012-05-07 18:52:45.000000000 +0000
@@ -0,0 +1 @@
+gamma-overunderflow
diff -Naurd mpfr-3.1.0-a/VERSION mpfr-3.1.0-b/VERSION
--- mpfr-3.1.0-a/VERSION 2012-04-27 01:13:15.000000000 +0000
+++ mpfr-3.1.0-b/VERSION 2012-05-07 18:52:45.000000000 +0000
@@ -1 +1 @@
-3.1.0-p9
+3.1.0-p10
diff -Naurd mpfr-3.1.0-a/src/gamma.c mpfr-3.1.0-b/src/gamma.c
--- mpfr-3.1.0-a/src/gamma.c 2012-04-27 01:13:15.000000000 +0000
+++ mpfr-3.1.0-b/src/gamma.c 2012-05-07 18:52:45.000000000 +0000
@@ -100,7 +100,8 @@
mpfr_t xp, GammaTrial, tmp, tmp2;
mpz_t fact;
mpfr_prec_t realprec;
- int compared, inex, is_integer;
+ int compared, is_integer;
+ int inex = 0; /* 0 means: result gamma not set yet */
MPFR_GROUP_DECL (group);
MPFR_SAVE_EXPO_DECL (expo);
MPFR_ZIV_DECL (loop);
@@ -377,6 +378,15 @@
mpfr_mul (GammaTrial, tmp2, xp, MPFR_RNDN); /* Pi*(2-x), error (1+u)^2 */
err_g = MPFR_GET_EXP(GammaTrial);
mpfr_sin (GammaTrial, GammaTrial, MPFR_RNDN); /* sin(Pi*(2-x)) */
+ /* If tmp is +Inf, we compute exp(lngamma(x)). */
+ if (mpfr_inf_p (tmp))
+ {
+ inex = mpfr_explgamma (gamma, x, &expo, tmp, tmp2, rnd_mode);
+ if (inex)
+ goto end;
+ else
+ goto ziv_next;
+ }
err_g = err_g + 1 - MPFR_GET_EXP(GammaTrial);
/* let g0 the true value of Pi*(2-x), g the computed value.
We have g = g0 + h with |h| <= |(1+u^2)-1|*g.
@@ -411,11 +421,16 @@
if (MPFR_LIKELY (MPFR_CAN_ROUND (GammaTrial, realprec - err_g,
MPFR_PREC(gamma), rnd_mode)))
break;
+
+ ziv_next:
MPFR_ZIV_NEXT (loop, realprec);
}
+
+ end:
MPFR_ZIV_FREE (loop);
- inex = mpfr_set (gamma, GammaTrial, rnd_mode);
+ if (inex == 0)
+ inex = mpfr_set (gamma, GammaTrial, rnd_mode);
MPFR_GROUP_CLEAR (group);
mpz_clear (fact);
diff -Naurd mpfr-3.1.0-a/src/lngamma.c mpfr-3.1.0-b/src/lngamma.c
--- mpfr-3.1.0-a/src/lngamma.c 2012-03-08 15:17:03.000000000 +0000
+++ mpfr-3.1.0-b/src/lngamma.c 2012-05-07 18:52:45.000000000 +0000
@@ -49,9 +49,72 @@
mpfr_set_ui_2exp (s, 9, -1, MPFR_RNDN); /* 4.5 */
}
-#ifndef IS_GAMMA
+#ifdef IS_GAMMA
+
+/* This function is called in case of intermediate overflow/underflow.
+ The s1 and s2 arguments are temporary MPFR numbers, having the
+ working precision. If the result could be determined, then the
+ flags are updated via pexpo, y is set to the result, and the
+ (non-zero) ternary value is returned. Otherwise 0 is returned
+ in order to perform the next Ziv iteration. */
static int
-unit_bit (mpfr_srcptr (x))
+mpfr_explgamma (mpfr_ptr y, mpfr_srcptr x, mpfr_save_expo_t *pexpo,
+ mpfr_ptr s1, mpfr_ptr s2, mpfr_rnd_t rnd)
+{
+ mpfr_t t1, t2;
+ int inex1, inex2, sign;
+ MPFR_BLOCK_DECL (flags1);
+ MPFR_BLOCK_DECL (flags2);
+ MPFR_GROUP_DECL (group);
+
+ MPFR_BLOCK (flags1, inex1 = mpfr_lgamma (s1, &sign, x, MPFR_RNDD));
+ MPFR_ASSERTN (inex1 != 0);
+ /* s1 = RNDD(lngamma(x)), inexact */
+ if (MPFR_UNLIKELY (MPFR_OVERFLOW (flags1)))
+ {
+ if (MPFR_SIGN (s1) > 0)
+ {
+ MPFR_SAVE_EXPO_UPDATE_FLAGS (*pexpo, MPFR_FLAGS_OVERFLOW);
+ return mpfr_overflow (y, rnd, sign);
+ }
+ else
+ {
+ MPFR_SAVE_EXPO_UPDATE_FLAGS (*pexpo, MPFR_FLAGS_UNDERFLOW);
+ return mpfr_underflow (y, rnd == MPFR_RNDN ? MPFR_RNDZ : rnd, sign);
+ }
+ }
+
+ mpfr_set (s2, s1, MPFR_RNDN); /* exact */
+ mpfr_nextabove (s2); /* v = RNDU(lngamma(z0)) */
+
+ if (sign < 0)
+ rnd = MPFR_INVERT_RND (rnd); /* since the result with be negated */
+ MPFR_GROUP_INIT_2 (group, MPFR_PREC (y), t1, t2);
+ MPFR_BLOCK (flags1, inex1 = mpfr_exp (t1, s1, rnd));
+ MPFR_BLOCK (flags2, inex2 = mpfr_exp (t2, s2, rnd));
+ /* t1 is the rounding with mode 'rnd' of a lower bound on |Gamma(x)|,
+ t2 is the rounding with mode 'rnd' of an upper bound, thus if both
+ are equal, so is the wanted result. If t1 and t2 differ or the flags
+ differ, at some point of Ziv's loop they should agree. */
+ if (mpfr_equal_p (t1, t2) && flags1 == flags2)
+ {
+ MPFR_ASSERTN ((inex1 > 0 && inex2 > 0) || (inex1 < 0 && inex2 < 0));
+ mpfr_set4 (y, t1, MPFR_RNDN, sign); /* exact */
+ if (sign < 0)
+ inex1 = - inex1;
+ MPFR_SAVE_EXPO_UPDATE_FLAGS (*pexpo, flags1);
+ }
+ else
+ inex1 = 0; /* couldn't determine the result */
+ MPFR_GROUP_CLEAR (group);
+
+ return inex1;
+}
+
+#else
+
+static int
+unit_bit (mpfr_srcptr x)
{
mpfr_exp_t expo;
mpfr_prec_t prec;
@@ -75,6 +138,7 @@
return (x0 >> (prec % GMP_NUMB_BITS)) & 1;
}
+
#endif
/* lngamma(x) = log(gamma(x)).
@@ -99,12 +163,14 @@
mpfr_t s, t, u, v, z;
unsigned long m, k, maxm;
mpz_t *INITIALIZED(B); /* variable B declared as initialized */
- int inexact, compared;
+ int compared;
+ int inexact = 0; /* 0 means: result y not set yet */
mpfr_exp_t err_s, err_t;
unsigned long Bm = 0; /* number of allocated B[] */
unsigned long oldBm;
double d;
MPFR_SAVE_EXPO_DECL (expo);
+ MPFR_ZIV_DECL (loop);
compared = mpfr_cmp_ui (z0, 1);
@@ -122,7 +188,7 @@
if (MPFR_EXP(z0) <= - (mpfr_exp_t) MPFR_PREC(y))
{
mpfr_t l, h, g;
- int ok, inex2;
+ int ok, inex1, inex2;
mpfr_prec_t prec = MPFR_PREC(y) + 14;
MPFR_ZIV_DECL (loop);
@@ -157,14 +223,14 @@
mpfr_sub (h, h, g, MPFR_RNDD);
mpfr_mul (g, z0, z0, MPFR_RNDU);
mpfr_add (h, h, g, MPFR_RNDU);
- inexact = mpfr_prec_round (l, MPFR_PREC(y), rnd);
+ inex1 = mpfr_prec_round (l, MPFR_PREC(y), rnd);
inex2 = mpfr_prec_round (h, MPFR_PREC(y), rnd);
/* Caution: we not only need l = h, but both inexact flags should
agree. Indeed, one of the inexact flags might be zero. In that
case if we assume lngamma(z0) cannot be exact, the other flag
should be correct. We are conservative here and request that both
inexact flags agree. */
- ok = SAME_SIGN (inexact, inex2) && mpfr_cmp (l, h) == 0;
+ ok = SAME_SIGN (inex1, inex2) && mpfr_cmp (l, h) == 0;
if (ok)
mpfr_set (y, h, rnd); /* exact */
mpfr_clear (l);
@@ -172,8 +238,9 @@
mpfr_clear (g);
if (ok)
{
+ MPFR_ZIV_FREE (loop);
MPFR_SAVE_EXPO_FREE (expo);
- return mpfr_check_range (y, inexact, rnd);
+ return mpfr_check_range (y, inex1, rnd);
}
/* since we have log|gamma(x)| = - log|x| - gamma*x + O(x^2),
if x ~ 2^(-n), then we have a n-bit approximation, thus
@@ -205,9 +272,10 @@
thus lngamma(x) = log(Pi*(x-1)/sin(Pi*(2-x))) - lngamma(2-x) */
w = precy + MPFR_INT_CEIL_LOG2 (precy);
+ w += MPFR_INT_CEIL_LOG2 (w) + 14;
+ MPFR_ZIV_INIT (loop, w);
while (1)
{
- w += MPFR_INT_CEIL_LOG2 (w) + 14;
MPFR_ASSERTD(w >= 3);
mpfr_set_prec (s, w);
mpfr_set_prec (t, w);
@@ -288,7 +356,9 @@
+ (rnd == MPFR_RNDN)))
goto end;
}
+ MPFR_ZIV_NEXT (loop, w);
}
+ MPFR_ZIV_FREE (loop);
}
/* now z0 > 1 */
@@ -298,10 +368,10 @@
/* since k is O(w), the value of log(z0*...*(z0+k-1)) is about w*log(w),
so there is a cancellation of ~log(w) in the argument reconstruction */
w = precy + MPFR_INT_CEIL_LOG2 (precy);
-
- do
+ w += MPFR_INT_CEIL_LOG2 (w) + 13;
+ MPFR_ZIV_INIT (loop, w);
+ while (1)
{
- w += MPFR_INT_CEIL_LOG2 (w) + 13;
MPFR_ASSERTD (w >= 3);
/* argument reduction: we compute gamma(z0 + k), where the series
@@ -441,6 +511,15 @@
#ifdef IS_GAMMA
err_s = MPFR_GET_EXP(s);
mpfr_exp (s, s, MPFR_RNDN);
+ /* If s is +Inf, we compute exp(lngamma(z0)). */
+ if (mpfr_inf_p (s))
+ {
+ inexact = mpfr_explgamma (y, z0, &expo, s, t, rnd);
+ if (inexact)
+ goto end0;
+ else
+ goto ziv_next;
+ }
/* before the exponential, we have s = s0 + h where
|h| <= (2m+48)*ulp(s), thus exp(s0) = exp(s) * exp(-h).
For |h| <= 1/4, we have |exp(h)-1| <= 1.2*|h| thus
@@ -480,16 +559,26 @@
err_s = (err_t == err_s) ? 1 + err_s : ((err_t > err_s) ? err_t : err_s);
err_s += 1 - MPFR_GET_EXP(s);
#endif
+ if (MPFR_LIKELY (MPFR_CAN_ROUND (s, w - err_s, precy, rnd)))
+ break;
+#ifdef IS_GAMMA
+ ziv_next:
+#endif
+ MPFR_ZIV_NEXT (loop, w);
}
- while (MPFR_UNLIKELY (!MPFR_CAN_ROUND (s, w - err_s, precy, rnd)));
+#ifdef IS_GAMMA
+ end0:
+#endif
oldBm = Bm;
while (Bm--)
mpz_clear (B[Bm]);
(*__gmp_free_func) (B, oldBm * sizeof (mpz_t));
end:
- inexact = mpfr_set (y, s, rnd);
+ if (inexact == 0)
+ inexact = mpfr_set (y, s, rnd);
+ MPFR_ZIV_FREE (loop);
mpfr_clear (s);
mpfr_clear (t);
diff -Naurd mpfr-3.1.0-a/src/mpfr.h mpfr-3.1.0-b/src/mpfr.h
--- mpfr-3.1.0-a/src/mpfr.h 2012-04-27 01:13:15.000000000 +0000
+++ mpfr-3.1.0-b/src/mpfr.h 2012-05-07 18:52:45.000000000 +0000
@@ -27,7 +27,7 @@
#define MPFR_VERSION_MAJOR 3
#define MPFR_VERSION_MINOR 1
#define MPFR_VERSION_PATCHLEVEL 0
-#define MPFR_VERSION_STRING "3.1.0-p9"
+#define MPFR_VERSION_STRING "3.1.0-p10"
/* Macros dealing with MPFR VERSION */
#define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
diff -Naurd mpfr-3.1.0-a/src/version.c mpfr-3.1.0-b/src/version.c
--- mpfr-3.1.0-a/src/version.c 2012-04-27 01:13:15.000000000 +0000
+++ mpfr-3.1.0-b/src/version.c 2012-05-07 18:52:45.000000000 +0000
@@ -25,5 +25,5 @@
const char *
mpfr_get_version (void)
{
- return "3.1.0-p9";
+ return "3.1.0-p10";
}
diff -Naurd mpfr-3.1.0-a/tests/tgamma.c mpfr-3.1.0-b/tests/tgamma.c
--- mpfr-3.1.0-a/tests/tgamma.c 2012-04-27 01:13:15.000000000 +0000
+++ mpfr-3.1.0-b/tests/tgamma.c 2012-05-07 18:52:45.000000000 +0000
@@ -838,6 +838,175 @@
exit (1);
}
+/* Test mpfr_gamma in precision p1 by comparing it with exp(lgamma(x))
+ computing with a working precision p2. Assume that x is not an
+ integer <= 2. */
+static void
+exp_lgamma (mpfr_t x, mpfr_prec_t p1, mpfr_prec_t p2)
+{
+ mpfr_t yd, yu, zd, zu;
+ int inexd, inexu, sign;
+ int underflow = -1, overflow = -1; /* -1: we don't know */
+ int got_underflow, got_overflow;
+
+ if (mpfr_integer_p (x) && mpfr_cmp_si (x, 2) <= 0)
+ {
+ printf ("Warning! x is an integer <= 2 in exp_lgamma: ");
+ mpfr_out_str (stdout, 10, 0, x, MPFR_RNDN); putchar ('\n');
+ return;
+ }
+ mpfr_inits2 (p2, yd, yu, (mpfr_ptr) 0);
+ inexd = mpfr_lgamma (yd, &sign, x, MPFR_RNDD);
+ mpfr_set (yu, yd, MPFR_RNDN); /* exact */
+ if (inexd)
+ mpfr_nextabove (yu);
+ mpfr_clear_flags ();
+ mpfr_exp (yd, yd, MPFR_RNDD);
+ if (! mpfr_underflow_p ())
+ underflow = 0;
+ if (mpfr_overflow_p ())
+ overflow = 1;
+ mpfr_clear_flags ();
+ mpfr_exp (yu, yu, MPFR_RNDU);
+ if (mpfr_underflow_p ())
+ underflow = 1;
+ if (! mpfr_overflow_p ())
+ overflow = 0;
+ if (sign < 0)
+ {
+ mpfr_neg (yd, yd, MPFR_RNDN); /* exact */
+ mpfr_neg (yu, yu, MPFR_RNDN); /* exact */
+ mpfr_swap (yd, yu);
+ }
+ /* yd < Gamma(x) < yu (strict inequalities since x != 1 and x != 2) */
+ mpfr_inits2 (p1, zd, zu, (mpfr_ptr) 0);
+ mpfr_clear_flags ();
+ inexd = mpfr_gamma (zd, x, MPFR_RNDD); /* zd <= Gamma(x) < yu */
+ got_underflow = underflow == -1 ? -1 : !! mpfr_underflow_p ();
+ got_overflow = overflow == -1 ? -1 : !! mpfr_overflow_p ();
+ if (! mpfr_less_p (zd, yu) || inexd > 0 ||
+ got_underflow != underflow ||
+ got_overflow != overflow)
+ {
+ printf ("Error in exp_lgamma on x = ");
+ mpfr_out_str (stdout, 16, 0, x, MPFR_RNDN); putchar ('\n');
+ printf ("yu = ");
+ mpfr_dump (yu);
+ printf ("zd = ");
+ mpfr_dump (zd);
+ printf ("got inexd = %d, expected <= 0\n", inexd);
+ printf ("got underflow = %d, expected %d\n", got_underflow, underflow);
+ printf ("got overflow = %d, expected %d\n", got_overflow, overflow);
+ exit (1);
+ }
+ mpfr_clear_flags ();
+ inexu = mpfr_gamma (zu, x, MPFR_RNDU); /* zu >= Gamma(x) > yd */
+ got_underflow = underflow == -1 ? -1 : !! mpfr_underflow_p ();
+ got_overflow = overflow == -1 ? -1 : !! mpfr_overflow_p ();
+ if (! mpfr_greater_p (zu, yd) || inexu < 0 ||
+ got_underflow != underflow ||
+ got_overflow != overflow)
+ {
+ printf ("Error in exp_lgamma on x = ");
+ mpfr_out_str (stdout, 16, 0, x, MPFR_RNDN); putchar ('\n');
+ printf ("yd = ");
+ mpfr_dump (yd);
+ printf ("zu = ");
+ mpfr_dump (zu);
+ printf ("got inexu = %d, expected >= 0\n", inexu);
+ printf ("got underflow = %d, expected %d\n", got_underflow, underflow);
+ printf ("got overflow = %d, expected %d\n", got_overflow, overflow);
+ exit (1);
+ }
+ if (mpfr_equal_p (zd, zu))
+ {
+ if (inexd != 0 || inexu != 0)
+ {
+ printf ("Error in exp_lgamma on x = ");
+ mpfr_out_str (stdout, 16, 0, x, MPFR_RNDN); putchar ('\n');
+ printf ("zd = zu, thus exact, but inexd = %d and inexu = %d\n",
+ inexd, inexu);
+ exit (1);
+ }
+ MPFR_ASSERTN (got_underflow == 0);
+ MPFR_ASSERTN (got_overflow == 0);
+ }
+ else if (inexd == 0 || inexu == 0)
+ {
+ printf ("Error in exp_lgamma on x = ");
+ mpfr_out_str (stdout, 16, 0, x, MPFR_RNDN); putchar ('\n');
+ printf ("zd != zu, thus inexact, but inexd = %d and inexu = %d\n",
+ inexd, inexu);
+ exit (1);
+ }
+ mpfr_clears (yd, yu, zd, zu, (mpfr_ptr) 0);
+}
+
+static void
+exp_lgamma_tests (void)
+{
+ mpfr_t x;
+ mpfr_exp_t emin, emax;
+ int i;
+
+ emin = mpfr_get_emin ();
+ emax = mpfr_get_emax ();
+ set_emin (MPFR_EMIN_MIN);
+ set_emax (MPFR_EMAX_MAX);
+
+ mpfr_init2 (x, 96);
+ for (i = 3; i <= 8; i++)
+ {
+ mpfr_set_ui (x, i, MPFR_RNDN);
+ exp_lgamma (x, 53, 64);
+ mpfr_nextbelow (x);
+ exp_lgamma (x, 53, 64);
+ mpfr_nextabove (x);
+ mpfr_nextabove (x);
+ exp_lgamma (x, 53, 64);
+ }
+ mpfr_set_str (x, "1.7", 10, MPFR_RNDN);
+ exp_lgamma (x, 53, 64);
+ mpfr_set_str (x, "-4.6308260837372266e+07", 10, MPFR_RNDN);
+ exp_lgamma (x, 53, 64);
+ mpfr_set_str (x, "-90.6308260837372266e+15", 10, MPFR_RNDN);
+ exp_lgamma (x, 53, 64);
+ /* The following test gives a large positive result < +Inf */
+ mpfr_set_str (x, "1.2b13fc45a92dea1@14", 16, MPFR_RNDN);
+ exp_lgamma (x, 53, 64);
+ /* Idem for a large negative result > -Inf */
+ mpfr_set_str (x, "-1.2b13fc45a92de81@14", 16, MPFR_RNDN);
+ exp_lgamma (x, 53, 64);
+ /* The following two tests trigger an endless loop in r8186
+ on 64-bit machines (64-bit exponent). The second one (due
+ to undetected overflow) is a direct consequence of the
+ first one, due to the call of Gamma(2-x) if x < 1. */
+ mpfr_set_str (x, "1.2b13fc45a92dec8@14", 16, MPFR_RNDN);
+ exp_lgamma (x, 53, 64);
+ mpfr_set_str (x, "-1.2b13fc45a92dea8@14", 16, MPFR_RNDN);
+ exp_lgamma (x, 53, 64);
+ /* Similar tests (overflow threshold) for 32-bit machines. */
+ mpfr_set_str (x, "2ab68d8.657542f855111c61", 16, MPFR_RNDN);
+ exp_lgamma (x, 12, 64);
+ mpfr_set_str (x, "-2ab68d6.657542f855111c61", 16, MPFR_RNDN);
+ exp_lgamma (x, 12, 64);
+ /* The following test is an overflow on 32-bit and 64-bit machines.
+ Revision r8189 fails on 64-bit machines as the flag is unset. */
+ mpfr_set_str (x, "1.2b13fc45a92ded8@14", 16, MPFR_RNDN);
+ exp_lgamma (x, 53, 64);
+ /* On the following tests, with r8196, one gets an underflow on
+ 32-bit machines, while a normal result is expected (see FIXME
+ in gamma.c:382). */
+ mpfr_set_str (x, "-2ab68d6.657542f855111c6104", 16, MPFR_RNDN);
+ exp_lgamma (x, 12, 64); /* failure on 32-bit machines */
+ mpfr_set_str (x, "-12b13fc45a92deb.1c6c5bc964", 16, MPFR_RNDN);
+ exp_lgamma (x, 12, 64); /* failure on 64-bit machines */
+ mpfr_clear (x);
+
+ set_emin (emin);
+ set_emax (emax);
+}
+
int
main (int argc, char *argv[])
{
@@ -852,6 +1021,7 @@
test20071231 ();
test20100709 ();
test20120426 ();
+ exp_lgamma_tests ();
data_check ("data/gamma", mpfr_gamma, "mpfr_gamma");