w64xmmtest.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * check XMM registers for clobbers on Win64
  3. * Copyright (c) 2008 Ramiro Polla <ramiro.polla@gmail.com>
  4. *
  5. * This file is part of Libav.
  6. *
  7. * Libav is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * Libav is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with Libav; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. #include <inttypes.h>
  22. #include <stdint.h>
  23. #include <stdlib.h>
  24. #include <stdarg.h>
  25. #include <string.h>
  26. #include "libavutil/bswap.h"
  27. #define storexmmregs(mem) \
  28. __asm__ volatile( \
  29. "movups %%xmm6 , 0x00(%0)\n\t" \
  30. "movups %%xmm7 , 0x10(%0)\n\t" \
  31. "movups %%xmm8 , 0x20(%0)\n\t" \
  32. "movups %%xmm9 , 0x30(%0)\n\t" \
  33. "movups %%xmm10, 0x40(%0)\n\t" \
  34. "movups %%xmm11, 0x50(%0)\n\t" \
  35. "movups %%xmm12, 0x60(%0)\n\t" \
  36. "movups %%xmm13, 0x70(%0)\n\t" \
  37. "movups %%xmm14, 0x80(%0)\n\t" \
  38. "movups %%xmm15, 0x90(%0)\n\t" \
  39. :: "r"(mem) : "memory")
  40. #define testxmmclobbers(func, ctx, ...) \
  41. uint64_t xmm[2][10][2]; \
  42. int ret; \
  43. storexmmregs(xmm[0]); \
  44. ret = __real_ ## func(ctx, __VA_ARGS__); \
  45. storexmmregs(xmm[1]); \
  46. if (memcmp(xmm[0], xmm[1], sizeof(xmm[0]))) { \
  47. int i; \
  48. av_log(ctx, AV_LOG_ERROR, \
  49. "XMM REGS CLOBBERED IN %s!\n", #func); \
  50. for (i = 0; i < 10; i ++) \
  51. if (xmm[0][i][0] != xmm[1][i][0] || \
  52. xmm[0][i][1] != xmm[1][i][1]) { \
  53. av_log(ctx, AV_LOG_ERROR, \
  54. "xmm%-2d = %016"PRIx64"%016"PRIx64"\n", \
  55. 6 + i, av_bswap64(xmm[0][i][0]), \
  56. av_bswap64(xmm[0][i][1])); \
  57. av_log(ctx, AV_LOG_ERROR, \
  58. " -> %016"PRIx64"%016"PRIx64"\n", \
  59. av_bswap64(xmm[1][i][0]), \
  60. av_bswap64(xmm[1][i][1])); \
  61. } \
  62. abort(); \
  63. } \
  64. return ret
  65. #define wrap(func) \
  66. int __real_ ## func; \
  67. int __wrap_ ## func; \
  68. int __wrap_ ## func