1/* Test .type directives on assembler functions. 2 3Copyright 2001 Free Software Foundation, Inc. 4 5This file is part of the GNU MP Library. 6 7The GNU MP Library is free software; you can redistribute it and/or modify 8it under the terms of the GNU Lesser General Public License as published by 9the Free Software Foundation; either version 3 of the License, or (at your 10option) any later version. 11 12The GNU MP Library is distributed in the hope that it will be useful, but 13WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15License for more details. 16 17You should have received a copy of the GNU Lesser General Public License 18along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 20#include <stdio.h> 21#include <stdlib.h> 22 23#include "gmp.h" 24#include "gmp-impl.h" 25 26#include "tests.h" 27 28 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. 32 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 35 with 36 37 ./configure gmp_cv_asm_type= gmp_cv_asm_size= 38 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. 41 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. */ 46 47int 48main (void) 49{ 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 }; 53 mp_limb_t got[3]; 54 55 mpn_add_n (got, x, y, (mp_size_t) 3); 56 57 if (refmpn_cmp (got, want, (mp_size_t) 3) != 0) 58 { 59 printf ("Wrong result from mpn_add_n\n"); 60 abort (); 61 } 62 63 exit (0); 64} 65