| 
									
										
										
										
											2009-05-02 05:04:19 -04:00
										 |  |  | #include <ucontext.h>
 | 
					
						
							| 
									
										
										
										
											2009-09-14 00:37:28 -04:00
										 |  |  | #include <machine/fpu.h>
 | 
					
						
							| 
									
										
										
										
											2009-05-02 05:04:19 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-04 02:46:13 -04:00
										 |  |  | namespace factor | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-14 00:37:28 -04:00
										 |  |  | inline static unsigned int uap_fpu_status(void *uap) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-02-06 02:06:26 -05:00
										 |  |  | 	ucontext_t *ucontext = (ucontext_t *)uap; | 
					
						
							|  |  |  | 	if (ucontext->uc_mcontext.mc_fpformat == _MC_FPFMT_XMM) | 
					
						
							| 
									
										
										
										
											2009-09-14 04:09:03 -04:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2009-09-14 10:56:38 -04:00
										 |  |  | 		struct savefpu *xmm = (struct savefpu *)(&ucontext->uc_mcontext.mc_fpstate); | 
					
						
							| 
									
										
										
										
											2009-09-14 04:09:03 -04:00
										 |  |  | 		return xmm->sv_env.en_sw | xmm->sv_env.en_mxcsr; | 
					
						
							| 
									
										
										
										
											2010-02-06 02:06:26 -05:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-09-14 04:09:03 -04:00
										 |  |  | 	else | 
					
						
							|  |  |  | 		return 0; | 
					
						
							| 
									
										
										
										
											2009-09-14 00:37:28 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | inline static void uap_clear_fpu_status(void *uap) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-02-06 02:06:26 -05:00
										 |  |  | 	ucontext_t *ucontext = (ucontext_t *)uap; | 
					
						
							|  |  |  | 	if (ucontext->uc_mcontext.mc_fpformat == _MC_FPFMT_XMM) | 
					
						
							| 
									
										
										
										
											2009-09-14 04:09:03 -04:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2009-09-14 10:56:38 -04:00
										 |  |  | 		struct savefpu *xmm = (struct savefpu *)(&ucontext->uc_mcontext.mc_fpstate); | 
					
						
							| 
									
										
										
										
											2009-09-14 04:09:03 -04:00
										 |  |  | 		xmm->sv_env.en_sw = 0; | 
					
						
							|  |  |  | 		xmm->sv_env.en_mxcsr &= 0xffffffc0; | 
					
						
							| 
									
										
										
										
											2010-02-06 02:06:26 -05:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-09-14 00:37:28 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-22 06:22:59 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | #define UAP_STACK_POINTER(ucontext) (((ucontext_t *)ucontext)->uc_mcontext.mc_rsp)
 | 
					
						
							|  |  |  | #define UAP_PROGRAM_COUNTER(ucontext) (((ucontext_t *)ucontext)->uc_mcontext.mc_rip)
 | 
					
						
							| 
									
										
										
										
											2009-05-04 02:46:13 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | } |