--- /dev/null
+#------------------------------------------------------------------------------\r
+#\r
+# Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
+# This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this 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
+# Module Name:\r
+#\r
+# Alloca.S\r
+#\r
+# Abstract:\r
+#\r
+# Implementation for allocation of automatically reclaimed memory, which is\r
+# used to allocate space off the runtime stack.\r
+# (NOTE: There is a assumption in this code that the page size equal to 4K)\r
+#\r
+#------------------------------------------------------------------------------\r
+\r
+\r
+ .686:\r
+ .code:\r
+\r
+ASM_GLOBAL ASM_PFX(_alloca)\r
+\r
+#------------------------------------------------------------------------------\r
+#\r
+# void __cdecl _alloca (unsigned size)\r
+#\r
+#------------------------------------------------------------------------------\r
+ASM_PFX(_alloca):\r
+\r
+ pushl %ecx\r
+ cmpl $0x1000, %eax\r
+ leal 8(%esp), %ecx\r
+ jb LastPage\r
+\r
+ProbePages:\r
+ subl $0x1000, %ecx\r
+ subl $0x1000, %eax\r
+ testl %eax, 0(%ecx)\r
+ cmpl $0x1000, %eax\r
+ jae ProbePages\r
+\r
+LastPage:\r
+ subl %eax, %ecx\r
+ movl %esp, %eax\r
+ testl %eax, 0(%ecx)\r
+\r
+ movl %ecx, %esp\r
+ movl 0(%eax), %ecx\r
+ movl 4(%eax), %eax\r
+ pushl %eax\r
+\r
+ ret\r