fpsetmask.c revision 121332
185974Sdfr/*- 285974Sdfr * Copyright (c) 2001 Doug Rabson 385974Sdfr * All rights reserved. 485974Sdfr * 585974Sdfr * Redistribution and use in source and binary forms, with or without 685974Sdfr * modification, are permitted provided that the following conditions 785974Sdfr * are met: 885974Sdfr * 1. Redistributions of source code must retain the above copyright 985974Sdfr * notice, this list of conditions and the following disclaimer. 1085974Sdfr * 2. Redistributions in binary form must reproduce the above copyright 1185974Sdfr * notice, this list of conditions and the following disclaimer in the 1285974Sdfr * documentation and/or other materials provided with the distribution. 1385974Sdfr * 1485974Sdfr * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1585974Sdfr * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1685974Sdfr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1785974Sdfr * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1885974Sdfr * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1985974Sdfr * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2085974Sdfr * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2185974Sdfr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2285974Sdfr * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2385974Sdfr * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2485974Sdfr * SUCH DAMAGE. 2585974Sdfr */ 2685974Sdfr 2792986Sobrien#include <sys/cdefs.h> 2892986Sobrien__FBSDID("$FreeBSD: head/lib/libc/ia64/gen/fpsetmask.c 121332 2003-10-22 09:00:07Z marcel $"); 2992986Sobrien 3085974Sdfr#include <sys/types.h> 3185974Sdfr#include <ieeefp.h> 3285974Sdfr 3385974Sdfrfp_except_t 3485974Sdfrfpsetmask(fp_except_t mask) 3585974Sdfr{ 3685974Sdfr u_int64_t fpsr; 3785974Sdfr u_int64_t oldmask; 3885974Sdfr 3985974Sdfr __asm __volatile("mov %0=ar.fpsr" : "=r" (fpsr)); 40121332Smarcel oldmask = ~fpsr & 0x3d; 41121332Smarcel fpsr = (fpsr & ~0x3d) | (~mask & 0x3d); 4285974Sdfr __asm __volatile("mov ar.fpsr=%0" :: "r" (fpsr)); 43118696Smarcel return (oldmask); 4485974Sdfr} 45