amx_jit.inc 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // Copyright (C) 2012 Zeex
  2. //
  3. // Permission is hereby granted, free of charge, to any person obtaining a
  4. // copy of this software and associated documentation files (the "Software"),
  5. // to deal in the Software without restriction, including without limitation
  6. // the rights to use, copy, modify, merge, publish, distribute, sublicense,
  7. // and/or sell copies of the Software, and to permit persons to whom the
  8. // Software is furnished to do so, subject to the following conditions:
  9. //
  10. // The above copyright notice and this permission notice shall be included in
  11. // all copies or substantial portions of the Software.
  12. //
  13. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  14. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  18. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  19. // DEALINGS IN THE SOFTWARE.
  20. #if defined AMX_JIT_INC
  21. #endinput
  22. #endif
  23. #define AMX_JIT_INC
  24. stock GetJITGeneratorVersion() {
  25. #emit zero.pri
  26. #emit lctrl 7
  27. #emit retn
  28. return 0;
  29. }
  30. stock GetAmxJITBaseAddress() {
  31. // Only works when the jit is installed, otherwise returns 0. The code is
  32. // so short, checking if it had been done before would have been longer than
  33. // just repeating the calculation.
  34. #emit zero.pri
  35. #emit lctrl 8
  36. #emit retn
  37. return 0;
  38. }
  39. stock ResolveJITAddress(addr) {
  40. // Converts an address to a JIT address, if there is a JIT. Otherwise does
  41. // nothing. Could make it try detect if this is already JIT resolved, i.e.
  42. // is a return address.
  43. #emit load.s.pri addr
  44. #emit lctrl 8
  45. #emit retn
  46. return 0;
  47. }