1 /* Test .type directives on assembler functions.
3 Copyright 2001 Free Software Foundation, Inc.
5 This file is part of the GNU MP Library.
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 3 of the License, or (at your
10 option) any later version.
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.
17 You should have received a copy of the GNU Lesser General Public License
18 along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
29 /* This apparently trivial test is designed to detect missing .type and
30 .size directives in asm code, per the problem described under
31 GMP_ASM_TYPE in acinclude.m4.
33 A failure can be provoked in a shared or shared+static build by making
34 TYPE and SIZE in config.m4 empty, either by editing it or by configuring
37 ./configure gmp_cv_asm_type= gmp_cv_asm_size=
39 mpn_add_n is used for the test because normally it's implemented in
40 assembler on a CPU that has any asm code.
42 Enhancement: As noted with GMP_ASM_TYPE, if .type is wrong but .size is
43 right then everything works, but uses code copied down to the mainline
44 data area. Maybe we could detect that if we built a test library with an
45 object that had .size deliberately disabled. */
50 static const mp_limb_t x[3] = { 1, 2, 3 };
51 static const mp_limb_t y[3] = { 4, 5, 6 };
52 static const mp_limb_t want[3] = { 5, 7, 9 };
55 mpn_add_n (got, x, y, (mp_size_t) 3);
57 if (refmpn_cmp (got, want, (mp_size_t) 3) != 0)
59 printf ("Wrong result from mpn_add_n\n");