fpsetmask.c revision 118696
1145519Sdarrenr/*-
2145510Sdarrenr * Copyright (c) 2001 Doug Rabson
3145510Sdarrenr * All rights reserved.
4145510Sdarrenr *
5145510Sdarrenr * Redistribution and use in source and binary forms, with or without
6145510Sdarrenr * modification, are permitted provided that the following conditions
7145510Sdarrenr * are met:
8145510Sdarrenr * 1. Redistributions of source code must retain the above copyright
9145510Sdarrenr *    notice, this list of conditions and the following disclaimer.
10145510Sdarrenr * 2. Redistributions in binary form must reproduce the above copyright
11145510Sdarrenr *    notice, this list of conditions and the following disclaimer in the
12145510Sdarrenr *    documentation and/or other materials provided with the distribution.
13145510Sdarrenr *
14145510Sdarrenr * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15145510Sdarrenr * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16145510Sdarrenr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17145510Sdarrenr * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18145510Sdarrenr * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19145510Sdarrenr * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20145510Sdarrenr * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21145510Sdarrenr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22145510Sdarrenr * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23145510Sdarrenr * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24145510Sdarrenr * SUCH DAMAGE.
25145510Sdarrenr */
26145510Sdarrenr
27145510Sdarrenr#include <sys/cdefs.h>
28145510Sdarrenr__FBSDID("$FreeBSD: head/lib/libc/ia64/gen/fpsetmask.c 118696 2003-08-09 17:07:24Z marcel $");
29145510Sdarrenr
30145510Sdarrenr#include <sys/types.h>
31145510Sdarrenr#include <ieeefp.h>
32145510Sdarrenr
33145510Sdarrenrfp_except_t
34145510Sdarrenrfpsetmask(fp_except_t mask)
35145510Sdarrenr{
36145510Sdarrenr	u_int64_t fpsr;
37145510Sdarrenr	u_int64_t oldmask;
38145510Sdarrenr
39145510Sdarrenr	__asm __volatile("mov %0=ar.fpsr" : "=r" (fpsr));
40145510Sdarrenr	oldmask = ~fpsr & 0x3f;
41145510Sdarrenr	fpsr = (fpsr & ~0x3f) | (~mask & 0x3f);
42145510Sdarrenr	__asm __volatile("mov ar.fpsr=%0" :: "r" (fpsr));
43145510Sdarrenr	return (oldmask);
44145510Sdarrenr}
45145510Sdarrenr