xref: /netbsd-src/lib/libc/arch/ia64/gen/fpsetmask.c (revision 64f11261d1dbb1659b8344c2de193fb1193063a9)
1*64f11261Scherry /*-
2*64f11261Scherry  * Copyright (c) 2001 Doug Rabson
3*64f11261Scherry  * All rights reserved.
4*64f11261Scherry  *
5*64f11261Scherry  * Redistribution and use in source and binary forms, with or without
6*64f11261Scherry  * modification, are permitted provided that the following conditions
7*64f11261Scherry  * are met:
8*64f11261Scherry  * 1. Redistributions of source code must retain the above copyright
9*64f11261Scherry  *    notice, this list of conditions and the following disclaimer.
10*64f11261Scherry  * 2. Redistributions in binary form must reproduce the above copyright
11*64f11261Scherry  *    notice, this list of conditions and the following disclaimer in the
12*64f11261Scherry  *    documentation and/or other materials provided with the distribution.
13*64f11261Scherry  *
14*64f11261Scherry  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15*64f11261Scherry  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16*64f11261Scherry  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17*64f11261Scherry  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18*64f11261Scherry  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19*64f11261Scherry  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20*64f11261Scherry  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21*64f11261Scherry  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22*64f11261Scherry  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23*64f11261Scherry  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24*64f11261Scherry  * SUCH DAMAGE.
25*64f11261Scherry  */
26*64f11261Scherry 
27*64f11261Scherry #include <sys/cdefs.h>
28*64f11261Scherry /* __FBSDID("$FreeBSD: src/lib/libc/ia64/gen/fpsetmask.c,v 1.4 2003/10/22 09:00:07 marcel Exp $"); */
29*64f11261Scherry 
30*64f11261Scherry #include <sys/types.h>
31*64f11261Scherry #include <ieeefp.h>
32*64f11261Scherry 
33*64f11261Scherry fp_except
fpsetmask(fp_except mask)34*64f11261Scherry fpsetmask(fp_except mask)
35*64f11261Scherry {
36*64f11261Scherry 	int64_t fpsr;
37*64f11261Scherry 	int64_t oldmask;
38*64f11261Scherry 
39*64f11261Scherry 	__asm __volatile("mov %0=ar.fpsr" : "=r" (fpsr));
40*64f11261Scherry 	oldmask = ~fpsr & 0x3d;
41*64f11261Scherry 	fpsr = (fpsr & ~0x3d) | (~mask & 0x3d);
42*64f11261Scherry 	__asm __volatile("mov ar.fpsr=%0" :: "r" (fpsr));
43*64f11261Scherry 	return (oldmask);
44*64f11261Scherry }
45