home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / lxapi32.zip / Lib32 / lxspinlock.c < prev    next >
C/C++ Source or Header  |  2002-04-26  |  2KB  |  74 lines

  1. /* $Id: lxspinlock.c,v 1.2 2002/04/26 23:09:25 smilcke Exp $ */
  2.  
  3. /*
  4.  * spinlock.c
  5.  * Autor:               Stefan Milcke
  6.  * Erstellt am:         08.11.2001
  7.  * Letzte Aenderung am: 14.01.2002
  8.  *
  9. */
  10. #include <linux/types.h>
  11. #include <linux/init.h>
  12. #include <linux/poll.h>
  13. #include <asm/uaccess.h>
  14. #include <asm/hardirq.h>
  15.  
  16.  
  17. //----------------------------------- __lock -----------------------------------
  18. unsigned long __lock(void);
  19. #pragma aux __lock =        \
  20.     "pushfd"        \
  21.     "cli"            \
  22.     "pop eax"        \
  23.     modify exact [eax]    \
  24.     value [eax];
  25.  
  26.  
  27. //---------------------------------- __unlock ----------------------------------
  28. void __unlock(unsigned long cpuflags);
  29. #pragma aux __unlock =        \
  30.     "push eax"        \
  31.     "popfd"            \
  32.     modify exact []        \
  33.     parm [eax];
  34.  
  35.  
  36.  
  37. //------------------------------- spin_lock_init -------------------------------
  38. void spin_lock_init(spinlock_t *lock)
  39. {
  40.   *lock = 0;
  41. }
  42.  
  43. //--------------------------------- spin_lock ----------------------------------
  44. void spin_lock(spinlock_t *lock)
  45. {
  46.   *lock = __lock();
  47. }
  48.  
  49. //------------------------------- spin_lock_flag -------------------------------
  50. void spin_lock_flag(spinlock_t *lock, unsigned long *flag)
  51. {
  52.   *lock = __lock();
  53. }
  54.  
  55. //-------------------------------- spin_trylock --------------------------------
  56. int spin_trylock(spinlock_t *lock)
  57. {
  58.   return 0;
  59. }
  60.  
  61. //------------------------------ spin_unlock_wait ------------------------------
  62. void spin_unlock_wait(spinlock_t *lock)
  63. {
  64.  
  65. }
  66.  
  67. //-------------------------------- spin_unlock ---------------------------------
  68. void spin_unlock(spinlock_t *lock)
  69. {
  70.   __unlock(*lock);
  71. }
  72.  
  73.  
  74.