VirtualBox

source: vbox/trunk/src/VBox/Runtime/common/math/feupdateenv.asm@ 96282

Last change on this file since 96282 was 96213, checked in by vboxsync, 2 years ago

IPRT/nocrt: Implemented feraiseexcept and adjusted relevan code for X86_FSW_XCPT_MASK containg a bit more than X86_MXCSR_XCPT_FLAGS. bugref:10261

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.3 KB
Line 
1; $Id: feupdateenv.asm 96213 2022-08-15 09:36:00Z vboxsync $
2;; @file
3; IPRT - No-CRT feupdateenv - AMD64 & X86.
4;
5
6;
7; Copyright (C) 2022 Oracle Corporation
8;
9; This file is part of VirtualBox Open Source Edition (OSE), as
10; available from http://www.virtualbox.org. This file is free software;
11; you can redistribute it and/or modify it under the terms of the GNU
12; General Public License (GPL) as published by the Free Software
13; Foundation, in version 2 as it comes in the "COPYING" file of the
14; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16;
17; The contents of this file may alternatively be used under the terms
18; of the Common Development and Distribution License Version 1.0
19; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20; VirtualBox OSE distribution, in which case the provisions of the
21; CDDL are applicable instead of those of the GPL.
22;
23; You may elect to license modified versions of this file under the
24; terms and conditions of either the GPL or the CDDL or both.
25;
26
27
28%define RT_ASM_WITH_SEH64
29%include "iprt/asmdefs.mac"
30%include "iprt/x86.mac"
31
32
33BEGINCODE
34extern NAME(RT_NOCRT(fesetenv))
35extern NAME(RT_NOCRT(feraiseexcept))
36
37
38;;
39; Updates the FPU+SSE environment.
40;
41; This will restore @a pEnv and merge in pending exception flags.
42;
43; @returns eax = 0 on success, -1 on failure.
44; @param pEnv 32-bit: [xBP+8] msc64: rcx gcc64: rdi - Saved environment.
45;
46RT_NOCRT_BEGINPROC feupdateenv
47 push xBP
48 SEH64_PUSH_xBP
49 mov xBP, xSP
50 SEH64_SET_FRAME_xBP 0
51 sub xSP, 30h
52 SEH64_ALLOCATE_STACK 30h
53 SEH64_END_PROLOGUE
54
55 ;
56 ; Load the parameter into rcx.
57 ;
58%ifdef ASM_CALL64_GCC
59 mov rcx, rdi
60%elifdef RT_ARCH_X86
61 mov ecx, [xBP + xCB*2]
62%endif
63
64 ;
65 ; Save the pending exceptions.
66 ;
67%ifdef RT_ARCH_X86
68 extern NAME(rtNoCrtHasSse)
69 call NAME(rtNoCrtHasSse) ; Preserves all except xAX.
70 xor edx, edx
71 test al, al
72 jz .no_sse
73%endif
74 stmxcsr [xBP - 10h]
75 mov edx, [xBP - 10h]
76 and edx, X86_MXCSR_XCPT_FLAGS
77.no_sse:
78 fnstsw ax
79 or edx, eax
80 mov [xBP - 8h], edx ; save the pending exceptions here (will apply X86_FSW_XCPT_MASK later).
81
82 ;
83 ; Call fesetenv to update the environment.
84 ; Note! We have not yet modified the parameter registers for calling
85 ; convensions using them. So, parameters only needs to be loaded
86 ; for the stacked based convention.
87 ;
88%ifdef RT_ARCH_X86
89 mov [xSP], ecx
90%endif
91 call NAME(RT_NOCRT(fesetenv))
92
93 ;
94 ; Raise exceptions if any are pending.
95 ;
96%ifdef ASM_CALL64_GCC
97 mov edi, [xBP - 8h]
98 and edi, X86_FSW_XCPT_MASK
99%elifdef ASM_CALL64_MSC
100 mov ecx, [xBP - 8h]
101 and ecx, X86_FSW_XCPT_MASK
102%else
103 mov ecx, [xBP - 8h]
104 and ecx, X86_FSW_XCPT_MASK
105 mov [xSP], ecx
106%endif
107 jz .no_exceptions_to_raise
108 call NAME(RT_NOCRT(feraiseexcept))
109.no_exceptions_to_raise:
110
111 ;
112 ; Return success.
113 ;
114 xor eax, eax
115 leave
116 ret
117ENDPROC RT_NOCRT(feupdateenv)
118
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette