[BACK]Return to t-asmtype.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / gmp / tests / mpn

Annotation of OpenXM_contrib/gmp/tests/mpn/t-asmtype.c, Revision 1.1

1.1     ! ohara       1: /* Test .type directives on assembler functions.
        !             2:
        !             3: Copyright 2001 Free Software Foundation, Inc.
        !             4:
        !             5: This file is part of the GNU MP Library.
        !             6:
        !             7: The GNU MP Library is free software; you can redistribute it and/or modify
        !             8: it under the terms of the GNU Lesser General Public License as published by
        !             9: the Free Software Foundation; either version 2.1 of the License, or (at your
        !            10: option) any later version.
        !            11:
        !            12: The GNU MP Library is distributed in the hope that it will be useful, but
        !            13: WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
        !            14: or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
        !            15: License for more details.
        !            16:
        !            17: You should have received a copy of the GNU Lesser General Public License
        !            18: along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
        !            19: the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
        !            20: MA 02111-1307, USA.
        !            21: */
        !            22:
        !            23: #include <stdio.h>
        !            24: #include <stdlib.h>
        !            25:
        !            26: #include "gmp.h"
        !            27: #include "gmp-impl.h"
        !            28:
        !            29: #include "tests.h"
        !            30:
        !            31:
        !            32: /* This apparently trivial test is designed to detect missing .type and
        !            33:    .size directives in asm code, per the problem described under
        !            34:    GMP_ASM_TYPE in acinclude.m4.
        !            35:
        !            36:    A failure can be provoked in a shared or shared+static build by making
        !            37:    TYPE and SIZE in config.m4 empty, either by editing it or by configuring
        !            38:    with
        !            39:
        !            40:        ./configure gmp_cv_asm_type= gmp_cv_asm_size=
        !            41:
        !            42:    mpn_add_n is used for the test because normally it's implemented in
        !            43:    assembler on a CPU that has any asm code.
        !            44:
        !            45:    Enhancement: As noted with GMP_ASM_TYPE, if .type is wrong but .size is
        !            46:    right then everything works, but uses code copied down to the mainline
        !            47:    data area.  Maybe we could detect that if we built a test library with an
        !            48:    object that had .size deliberately disabled.  */
        !            49:
        !            50: int
        !            51: main (void)
        !            52: {
        !            53:   static const mp_limb_t x[3]    = { 1, 2, 3 };
        !            54:   static const mp_limb_t y[3]    = { 4, 5, 6 };
        !            55:   static const mp_limb_t want[3] = { 5, 7, 9 };
        !            56:   mp_limb_t  got[3];
        !            57:
        !            58:   mpn_add_n (got, x, y, (mp_size_t) 3);
        !            59:
        !            60:   if (refmpn_cmp (got, want, (mp_size_t) 3) != 0)
        !            61:     {
        !            62:       printf ("Wrong result from mpn_add_n\n");
        !            63:       abort ();
        !            64:     }
        !            65:
        !            66:   exit (0);
        !            67: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>