thunk.S
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:2k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*
  2.  * Save registers before calling assembly functions. This avoids
  3.  * disturbance of register allocation in some inline assembly constructs.
  4.  * Copyright 2001,2002 by Andi Kleen, SuSE Labs.
  5.  * Subject to the GNU public license, v.2. No warranty of any kind.
  6.  * $Id: thunk.S,v 1.2 2002/03/13 20:06:58 ak Exp $
  7.  */
  8. #include <linux/config.h>
  9. #include <linux/linkage.h>
  10. #include <asm/calling.h>
  11. #include <asm/rwlock.h>
  12. /* rdi: arg1 ... normal C conventions. rax is saved/restored. */ 
  13. .macro thunk name,func
  14. .globl name
  15. name:
  16. SAVE_ARGS
  17. call func
  18. jmp  restore
  19. .endm
  20. /* rdi: arg1 ... normal C conventions. rax is passed from C. */ 
  21. .macro thunk_retrax name,func
  22. .globl name
  23. name:
  24. SAVE_ARGS
  25. call func
  26. jmp  restore_norax
  27. .endm
  28. #ifdef CONFIG_RWSEM_XCHGADD_ALGORITHM
  29. thunk rwsem_down_read_failed_thunk,rwsem_down_read_failed
  30. thunk rwsem_down_write_failed_thunk,rwsem_down_write_failed
  31. thunk rwsem_wake_thunk,rwsem_wake
  32. #endif
  33. thunk do_softirq_thunk,do_softirq
  34. thunk __down_failed,__down
  35. thunk_retrax __down_failed_interruptible,__down_interruptible
  36. thunk_retrax __down_failed_trylock,__down_trylock
  37. thunk __up_wakeup,__up
  38. restore:
  39. RESTORE_ARGS
  40. ret
  41. restore_norax:
  42. RESTORE_ARGS 1
  43. ret
  44. #ifdef CONFIG_SMP
  45. /* Support for read/write spinlocks. */
  46. /* rax: pointer to rwlock_t */
  47. ENTRY(__write_lock_failed)
  48. lock
  49. addl $RW_LOCK_BIAS,(%rax)
  50. 1: rep
  51. nop
  52. cmpl $RW_LOCK_BIAS,(%rax)
  53. jne 1b
  54. lock 
  55. subl $RW_LOCK_BIAS,(%rax)
  56. jnz  __write_lock_failed
  57. ret
  58. /* rax: pointer to rwlock_t */
  59. ENTRY(__read_lock_failed)
  60. lock
  61. incl (%rax)
  62. 1: rep
  63. nop
  64. cmpl $1,(%rax)
  65. js 1b
  66. lock
  67. decl (%rax)
  68. js __read_lock_failed
  69. ret
  70. #endif