From patchwork Wed Oct 10 08:47:15 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Vincent Lefevre X-Patchwork-Id: 12090 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 4CBB123F5F for ; Wed, 10 Oct 2012 08:47:22 +0000 (UTC) Received: from mail-ia0-f180.google.com (mail-ia0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id D328FA18408 for ; Wed, 10 Oct 2012 08:47:21 +0000 (UTC) Received: by mail-ia0-f180.google.com with SMTP id f6so184927iag.11 for ; Wed, 10 Oct 2012 01:47:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:date:from :to:cc:subject:message-id:mail-followup-to:references:mime-version :content-type:content-disposition:content-transfer-encoding :in-reply-to:x-mailer-info:user-agent:x-gm-message-state; bh=C/mvsVYScCtv0MvjdHqICpqgbNz2ZhFdMPLKauel1Bk=; b=ZO95RwN8SD36gLV/gSCaMsualruMBoG+4mPr3NgNjdBsIDPNOvc5hwfyDAi8TbhRlW DkQ3Ls6bptBrs4W8w0H+KBbdetcLDRLQrvCZf/39w9Jueafri5gGBedclnLdy9Z0ip35 J+/xUdVFRGCTxfsvsxedkx/L7IrpKBkrUDNIPXqoljFiZkXGBL8oVe+vk2KOgtXJ+9mA cpl9AlZuvM/HHkmMh1R8rMwknjw0+Y1Ft1Bi6nGDdSan5V3CObWxeBjnSXT63pJQUaMT Fcy+Lp32RWqbt4VQjCKcrG65fSPnMUXJy7SOdm5dRiV9x+ApJGWEBJyMnAlqJSfAAvxM JPkQ== Received: by 10.50.236.72 with SMTP id us8mr4473411igc.70.1349858841072; Wed, 10 Oct 2012 01:47:21 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.67.148 with SMTP id n20csp188674igt; Wed, 10 Oct 2012 01:47:20 -0700 (PDT) Received: by 10.180.8.40 with SMTP id o8mr11166546wia.9.1349858839392; Wed, 10 Oct 2012 01:47:19 -0700 (PDT) Received: from smtp-xvii.vinc17.net (vinc17.pck.nerim.net. [213.41.242.187]) by mx.google.com with ESMTP id d66si801139wej.133.2012.10.10.01.47.17; Wed, 10 Oct 2012 01:47:19 -0700 (PDT) Received-SPF: neutral (google.com: 213.41.242.187 is neither permitted nor denied by best guess record for domain of vincent@vinc17.net) client-ip=213.41.242.187; Authentication-Results: mx.google.com; spf=neutral (google.com: 213.41.242.187 is neither permitted nor denied by best guess record for domain of vincent@vinc17.net) smtp.mail=vincent@vinc17.net Received: by xvii.vinc17.org (Postfix, from userid 1000) id 6740140C015; Wed, 10 Oct 2012 10:47:15 +0200 (CEST) Date: Wed, 10 Oct 2012 10:47:15 +0200 From: Vincent Lefevre To: Bernhard =?iso-8859-1?Q?Rosenkr=E4nzer?= Cc: mpfr@inria.fr, Patch Tracking Subject: Re: [MPFR] [PATCH] Allow building for Android Message-ID: <20121010084715.GX4846@xvii.vinc17.org> Mail-Followup-To: Bernhard =?iso-8859-1?Q?Rosenkr=E4nzer?= , mpfr@inria.fr, Patch Tracking References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer-Info: http://www.vinc17.net/mutt/ User-Agent: Mutt/1.5.21-6215-vl-r53514 (2012-07-22) X-Gm-Message-State: ALoCoQnFWYXnFPXseOKsNX07xdirjg/GOMYY5bonGY5515eshjsQeOtgv+VmGNbP13eiJwZvHfu5 On 2012-10-10 02:05:34 +0200, Bernhard Rosenkränzer wrote: > mpfr 3.1.1 doesn't compile for Android hosts because it assumes it can > determine the best decimal point and thousands separator from > localeconv() if locale.h exists. > This assumption is not true for Bionic (Android's libc) as it has a > stripped down locale.h. I've patched the MPFR trunk by doing a configure test. It is also more flexible, as the user can also explicitly disable/enable decimal point and thousands separator support via CFLAGS (useful for tests). I've attached the patch. Please tell me whether this is OK. Then I'll apply it to the 3.1 branch. Note: I think that there should also be a mpfr_buildopt_lconvdpts_p function in src/buildopt.c (trunk only, for the future MPFR 3.2). A configure switch to explicitly disable/enable decimal point and thousands separator support could also be added, though I wonder whether this would be useful. Index: src/mpfr-impl.h =================================================================== --- src/mpfr-impl.h (revision 8422) +++ src/mpfr-impl.h (revision 8423) @@ -1170,8 +1170,18 @@ (r) = _size * GMP_NUMB_BITS - _cnt; \ } while (0) -/* Needs */ -#ifdef HAVE_LOCALE_H +/* MPFR_LCONV_DPTS can also be forced to 0 or 1 by the user. */ +#ifndef MPFR_LCONV_DPTS +# if defined(HAVE_LOCALE_H) && \ + defined(HAVE_STRUCT_LCONV_DECIMAL_POINT) && \ + defined(HAVE_STRUCT_LCONV_THOUSANDS_SEP) +# define MPFR_LCONV_DPTS 1 +# else +# define MPFR_LCONV_DPTS 0 +# endif +#endif + +#if MPFR_LCONV_DPTS #include /* Warning! In case of signed char, the value of MPFR_DECIMAL_POINT may be negative (the ISO C99 does not seem to forbid negative values). */ Index: tests/tsprintf.c =================================================================== --- tests/tsprintf.c (revision 8422) +++ tests/tsprintf.c (revision 8423) @@ -832,6 +832,8 @@ return 0; } +#if MPFR_LCONV_DPTS + /* Check with locale "da_DK". On most platforms, decimal point is ',' and thousands separator is '.'; the test is not performed if this is not the case or if the locale doesn't exist. */ @@ -878,6 +880,8 @@ return 0; } +#endif /* MPFR_LCONV_DPTS */ + /* check concordance between mpfr_asprintf result with a regular mpfr float and with a regular double float */ static int @@ -1201,8 +1205,10 @@ check_emax (); #if defined(HAVE_LOCALE_H) && defined(HAVE_SETLOCALE) +#if MPFR_LCONV_DPTS locale_da_DK (); - + /* Avoid a warning by doing the setlocale outside of this #if */ +#endif setlocale (LC_ALL, locale); #endif Index: acinclude.m4 =================================================================== --- acinclude.m4 (revision 8422) +++ acinclude.m4 (revision 8423) @@ -59,6 +59,10 @@ dnl sys/fpu.h - MIPS specific AC_CHECK_HEADERS([sys/time.h sys/fpu.h]) +dnl Android has a , but not the following members. +AC_CHECK_MEMBERS([struct lconv.decimal_point, struct lconv.thousands_sep],,, + [#include ]) + dnl Check how to get `alloca' AC_FUNC_ALLOCA