]> git.proxmox.com Git - mirror_edk2.git/commitdiff
StdLib: Add a runtime helper function for VC++ 64-bit right shift on Ia32 target...
authorDaryl McDaniel <daryl.mcdaniel@intel.com>
Wed, 20 Aug 2014 20:38:43 +0000 (20:38 +0000)
committerdarylm503 <darylm503@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 20 Aug 2014 20:38:43 +0000 (20:38 +0000)
Add new file StdLib/LibC/CRT/Ia32/llshr.c
Add references to the new file to StdLib/LibC/LibC.inf

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Daryl McDaniel <daryl.mcdaniel@intel.com>
Reviewed-by: Erik Bjorge <erik.c.bjorge@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15855 6f19259b-4bc3-4df7-8a09-765794883524

StdLib/LibC/CRT/Ia32/llshr.c [new file with mode: 0644]
StdLib/LibC/LibC.inf

diff --git a/StdLib/LibC/CRT/Ia32/llshr.c b/StdLib/LibC/CRT/Ia32/llshr.c
new file mode 100644 (file)
index 0000000..38770ac
--- /dev/null
@@ -0,0 +1,58 @@
+/** @file\r
+  64-bit Math Worker Function.\r
+  The 32-bit versions of C compiler generate calls to library routines\r
+  to handle 64-bit math. These functions use non-standard calling conventions.\r
+\r
+  Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>\r
+  This program and the accompanying materials are licensed and made available\r
+  under the terms and conditions of the BSD License which accompanies this\r
+  distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php.\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+\r
+/*\r
+ * Shifts a 64-bit signed value right by a particular number of bits.\r
+ */\r
+__declspec(naked) void __cdecl _allshr (void)\r
+{\r
+  _asm {\r
+    ;\r
+    ; Handle shifts of 64 bits or more (if shifting 64 bits or more, the result\r
+    ; depends only on the high order bit of edx).\r
+      ;\r
+    cmp     cl,64\r
+    jae     short SIGNRETURN\r
+\r
+    ;\r
+    ; Handle shifts of between 0 and 31 bits\r
+    ;\r
+    cmp     cl, 32\r
+    jae     short MORE32\r
+    shrd    eax,edx,cl\r
+    sar     edx,cl\r
+    ret\r
+\r
+    ;\r
+    ; Handle shifts of between 32 and 63 bits\r
+    ;\r
+MORE32:\r
+    mov     eax,edx\r
+    sar     edx,31\r
+    and     cl,31\r
+    sar     eax,cl\r
+    ret\r
+\r
+    ;\r
+    ; Return double precision 0 or -1, depending on the sign of edx\r
+    ;\r
+SIGNRETURN:\r
+    sar     edx,31\r
+    mov     eax,edx\r
+    ret\r
+  }\r
+}\r
index 23647cb42851c6b1793c60d16e96b11139851bca..d8704db90727e4e3a12752c94f4d5fe48605e55b 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 #  Standard C library: Miscelaneous implementations.\r
 #\r
-#  Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
@@ -50,6 +50,7 @@
   # Compiler helper (C RunTime) functions\r
   CRT/Ia32/llmul.c          | MSFT    # __allmul\r
   CRT/Ia32/llshl.c          | MSFT    # __allshl\r
+  CRT/Ia32/llshr.c          | MSFT    # __allshr\r
   CRT/Ia32/ulldiv.c         | MSFT    # __aulldiv\r
   CRT/Ia32/ullrem.c         | MSFT    # __aullrem\r
   CRT/Ia32/ullshr.c         | MSFT    # __aullshr\r
@@ -60,6 +61,7 @@
 \r
   CRT/Ia32/llmul.c          | INTEL\r
   CRT/Ia32/llshl.c          | INTEL\r
+  CRT/Ia32/llshr.c          | INTEL\r
   CRT/Ia32/ulldiv.c         | INTEL\r
   CRT/Ia32/ullrem.c         | INTEL\r
   CRT/Ia32/ullshr.c         | INTEL\r