xref: /freebsd/lib/libc/arm/gen/fpgetsticky_vfp.c (revision bf8a3a816d4b3ca79d78c437b60bb4d169e590ad)
1*3f573009SAndrew Turner /*
2*3f573009SAndrew Turner  * Copyright (C) 2014 Andrew Turner
3*3f573009SAndrew Turner  * All rights reserved.
4*3f573009SAndrew Turner  *
5*3f573009SAndrew Turner  * Redistribution and use in source and binary forms, with or without
6*3f573009SAndrew Turner  * modification, are permitted provided that the following conditions
7*3f573009SAndrew Turner  * are met:
8*3f573009SAndrew Turner  * 1. Redistributions of source code must retain the above copyright
9*3f573009SAndrew Turner  *    notice, this list of conditions and the following disclaimer.
10*3f573009SAndrew Turner  * 2. Redistributions in binary form must reproduce the above copyright
11*3f573009SAndrew Turner  *    notice, this list of conditions and the following disclaimer in the
12*3f573009SAndrew Turner  *    documentation and/or other materials provided with the distribution.
13*3f573009SAndrew Turner  *
14*3f573009SAndrew Turner  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15*3f573009SAndrew Turner  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16*3f573009SAndrew Turner  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17*3f573009SAndrew Turner  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18*3f573009SAndrew Turner  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19*3f573009SAndrew Turner  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20*3f573009SAndrew Turner  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21*3f573009SAndrew Turner  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22*3f573009SAndrew Turner  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23*3f573009SAndrew Turner  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24*3f573009SAndrew Turner  * SUCH DAMAGE.
25*3f573009SAndrew Turner  *
26*3f573009SAndrew Turner  */
27*3f573009SAndrew Turner 
28*3f573009SAndrew Turner #include <sys/types.h>
29*3f573009SAndrew Turner #include <ieeefp.h>
30*3f573009SAndrew Turner 
31*3f573009SAndrew Turner #define FP_X_MASK	(FP_X_INV | FP_X_DZ | FP_X_OFL | FP_X_UFL | FP_X_IMP)
32*3f573009SAndrew Turner 
33*3f573009SAndrew Turner fp_except
fpgetsticky(void)34*3f573009SAndrew Turner fpgetsticky(void)
35*3f573009SAndrew Turner {
36*3f573009SAndrew Turner 	fp_except old;
37*3f573009SAndrew Turner 
38*3f573009SAndrew Turner 	__asm __volatile("vmrs %0, fpscr" : "=&r"(old));
39*3f573009SAndrew Turner 
40*3f573009SAndrew Turner 	return (old & FP_X_MASK);
41*3f573009SAndrew Turner }
42*3f573009SAndrew Turner 
43