switch_ppc_unix.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * this is the internal transfer function.
  3. *
  4. * HISTORY
  5. * 07-Sep-05 (py-dev mailing list discussion)
  6. * removed 'r31' from the register-saved. !!!! WARNING !!!!
  7. * It means that this file can no longer be compiled statically!
  8. * It is now only suitable as part of a dynamic library!
  9. * 14-Jan-04 Bob Ippolito <bob@redivi.com>
  10. * added cr2-cr4 to the registers to be saved.
  11. * Open questions: Should we save FP registers?
  12. * What about vector registers?
  13. * Differences between darwin and unix?
  14. * 24-Nov-02 Christian Tismer <tismer@tismer.com>
  15. * needed to add another magic constant to insure
  16. * that f in slp_eval_frame(PyFrameObject *f)
  17. * STACK_REFPLUS will probably be 1 in most cases.
  18. * gets included into the saved stack area.
  19. * 04-Oct-02 Gustavo Niemeyer <niemeyer@conectiva.com>
  20. * Ported from MacOS version.
  21. * 17-Sep-02 Christian Tismer <tismer@tismer.com>
  22. * after virtualizing stack save/restore, the
  23. * stack size shrunk a bit. Needed to introduce
  24. * an adjustment STACK_MAGIC per platform.
  25. * 15-Sep-02 Gerd Woetzel <gerd.woetzel@GMD.DE>
  26. * slightly changed framework for sparc
  27. * 29-Jun-02 Christian Tismer <tismer@tismer.com>
  28. * Added register 13-29, 31 saves. The same way as
  29. * Armin Rigo did for the x86_unix version.
  30. * This seems to be now fully functional!
  31. * 04-Mar-02 Hye-Shik Chang <perky@fallin.lv>
  32. * Ported from i386.
  33. */
  34. #define STACK_REFPLUS 1
  35. #ifdef SLP_EVAL
  36. #define STACK_MAGIC 3
  37. /* !!!!WARNING!!!! need to add "r31" in the next line if this header file
  38. * is meant to be compiled non-dynamically!
  39. */
  40. #define REGS_TO_SAVE "r13", "r14", "r15", "r16", "r17", "r18", "r19", "r20", \
  41. "r21", "r22", "r23", "r24", "r25", "r26", "r27", "r28", "r29", \
  42. "cr2", "cr3", "cr4"
  43. static int
  44. slp_switch(void)
  45. {
  46. register int err;
  47. register int *stackref, stsizediff;
  48. __asm__ volatile ("" : : : REGS_TO_SAVE);
  49. __asm__ ("mr %0, 1" : "=g" (stackref) : );
  50. {
  51. SLP_SAVE_STATE(stackref, stsizediff);
  52. __asm__ volatile (
  53. "mr 11, %0\n"
  54. "add 1, 1, 11\n"
  55. "add 30, 30, 11\n"
  56. : /* no outputs */
  57. : "g" (stsizediff)
  58. : "11"
  59. );
  60. SLP_RESTORE_STATE();
  61. }
  62. __asm__ volatile ("" : : : REGS_TO_SAVE);
  63. __asm__ volatile ("li %0, 0" : "=r" (err));
  64. return err;
  65. }
  66. #endif
  67. /*
  68. * further self-processing support
  69. */
  70. /*
  71. * if you want to add self-inspection tools, place them
  72. * here. See the x86_msvc for the necessary defines.
  73. * These features are highly experimental und not
  74. * essential yet.
  75. */