Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.7 KiB

  1. // -*- mode: C++; tab-width: 4; indent-tabs-mode: nil -*- (for GNU Emacs)
  2. //
  3. // Copyright (c) 1985-2000 Microsoft Corporation
  4. //
  5. // This file is part of the Microsoft Research IPv6 Network Protocol Stack.
  6. // You should have received a copy of the Microsoft End-User License Agreement
  7. // for this software along with this release; see the file "license.txt".
  8. // If not, please see http://www.research.microsoft.com/msripv6/license.htm,
  9. // or write to Microsoft Research, One Microsoft Way, Redmond, WA 98052-6399.
  10. //
  11. // Abstract:
  12. //
  13. // This module implements support for the alloca compiler intrinsic.
  14. //
  15. //* _alloca_probe
  16. //
  17. // Routine Description:
  18. //
  19. // The compiler uses this function to implement alloca.
  20. // It adjusts the stack frame for new stack-allocated storage.
  21. // This implementation is only intended to handle small allocations
  22. // (big allocations should be heap-allocated), so it does no
  23. // stack probing.
  24. //
  25. // Arguments:
  26. //
  27. // eax - Number of bytes to allocate
  28. //
  29. __declspec(naked) void __cdecl
  30. _alloca_probe(void)
  31. {
  32. __asm {
  33. push ecx ; save ecx
  34. mov ecx,esp ; compute new stack pointer in ecx
  35. add ecx,8 ; correct for return address and
  36. ; saved ecx value
  37. sub ecx,eax ; move stack down by eax
  38. mov eax,esp ; save pointer to current tos
  39. mov esp,ecx ; set the new stack pointer
  40. mov ecx,dword ptr [eax] ; recover ecx
  41. mov eax,dword ptr [eax + 4] ; recover return address
  42. jmp eax ; return
  43. }
  44. }