From 9dffe5df04949a0dd0f37832415009bf84d882b6 Mon Sep 17 00:00:00 2001 From: joseph Date: Thu, 5 May 2011 11:06:02 +0000 Subject: Merge changes between r13354 and r13697 from /fsf/trunk. git-svn-id: svn://svn.eglibc.org/trunk@13698 7b3dc134-2b1b-0410-93df-9e9f96275f8d --- libc/stdlib/Makefile | 11 ++++++++-- libc/stdlib/bug-getcontext.c | 48 ++++++++++++++++++++++++++++++++++++++++++++ libc/stdlib/gmp-impl.h | 4 ++-- 3 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 libc/stdlib/bug-getcontext.c (limited to 'libc/stdlib') diff --git a/libc/stdlib/Makefile b/libc/stdlib/Makefile index 8881c7dab..60f23f35b 100644 --- a/libc/stdlib/Makefile +++ b/libc/stdlib/Makefile @@ -1,4 +1,4 @@ -# Copyright (C) 1991-2006, 2007, 2008, 2009 Free Software Foundation, Inc. +# Copyright (C) 1991-2009, 2011 Free Software Foundation, Inc. # This file is part of the GNU C Library. # The GNU C Library is free software; you can redistribute it and/or @@ -80,7 +80,7 @@ tests := tst-strtol tst-strtod testrand testsort testdiv \ test-a64l tst-qsort tst-system bug-strtod2 \ tst-atof1 tst-atof2 tst-strtod2 tst-rand48-2 \ tst-makecontext tst-qsort2 tst-makecontext2 tst-strtod6 \ - tst-unsetenv1 tst-makecontext3 + tst-unsetenv1 tst-makecontext3 bug-getcontext tests-$(OPTION_EGLIBC_LOCALE_CODE) \ += tst-strtod3 tst-strtod4 tst-strtod5 testmb2 tests-$(OPTION_POSIX_C_LANG_WIDE_CHAR) \ @@ -159,3 +159,10 @@ $(objpfx)tst-putenv: $(objpfx)tst-putenvmod.so $(objpfx)tst-putenvmod.so: $(objpfx)tst-putenvmod.os $(build-module) CFLAGS-tst-putenvmod.c = -DNOT_IN_libc=1 + +ifeq ($(build-shared),yes) +link-libm = $(common-objpfx)math/libm.so +else +link-libm = $(common-objpfx)math/libm.a +endif +$(objpfx)bug-getcontext: $(link-libm) diff --git a/libc/stdlib/bug-getcontext.c b/libc/stdlib/bug-getcontext.c new file mode 100644 index 000000000..745aa1f20 --- /dev/null +++ b/libc/stdlib/bug-getcontext.c @@ -0,0 +1,48 @@ +/* BZ 12420 */ + +#include +#include +#include +#include +#include + +static int +do_test (void) +{ + int except_mask = FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW; + int status = feenableexcept (except_mask); + + except_mask = fegetexcept (); + if (except_mask == -1) + { + printf("\nBefore getcontext(): fegetexcept returned: %d\n", + except_mask); + return 1; + } + + ucontext_t ctx; + status = getcontext(&ctx); + if (status) + { + printf("\ngetcontext failed, errno: %d.\n", errno); + return 1; + } + + printf ("\nDone with getcontext()!\n"); + fflush (NULL); + + int mask = fegetexcept (); + if (mask != except_mask) + { + printf("\nAfter getcontext(): fegetexcept returned: %d, expected: %d.\n", + mask, except_mask); + return 1; + } + + printf("\nAt end fegetexcept() returned %d, expected: %d.\n", + mask, except_mask); + return 0; +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" diff --git a/libc/stdlib/gmp-impl.h b/libc/stdlib/gmp-impl.h index 85e419d36..984885d05 100644 --- a/libc/stdlib/gmp-impl.h +++ b/libc/stdlib/gmp-impl.h @@ -1,6 +1,6 @@ /* Include file for internal GNU MP types and definitions. -Copyright (C) 1991, 1993, 1994, 1995, 1996 Free Software Foundation, Inc. +Copyright (C) 1991, 1993, 1994, 1995, 1996, 2011 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -241,7 +241,7 @@ extern mp_size_t __gmp_default_fp_limb_precision; (r) = _r; \ (q) = _q; \ } while (0) -/* Like udiv_qrnnd_preinv, but for for any value D. DNORM is D shifted left +/* Like udiv_qrnnd_preinv, but for any value D. DNORM is D shifted left so that its most significant bit is set. LGUP is ceil(log2(D)). */ #define udiv_qrnnd_preinv2gen(q, r, nh, nl, d, di, dnorm, lgup) \ do { \ -- cgit v1.2.3