pspinlock.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /* POSIX spinlock implementation. CRIS version.
  2. Copyright (C) 2000, 2001 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public License as
  6. published by the Free Software Foundation; either version 2.1 of the
  7. License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; see the file COPYING.LIB. If
  14. not, see <http://www.gnu.org/licenses/>. */
  15. #include <errno.h>
  16. #include <pthread.h>
  17. #include "internals.h"
  18. /* FIXME: These are just dummies. I don't know why or if they're needed;
  19. configury should default to these definitions. We just follow the
  20. crowd here. */
  21. int
  22. __pthread_spin_lock (pthread_spinlock_t *lock)
  23. {
  24. while (testandset (lock) != 0)
  25. ;
  26. return 0;
  27. }
  28. weak_alias (__pthread_spin_lock, pthread_spin_lock)
  29. int
  30. __pthread_spin_trylock (pthread_spinlock_t *lock)
  31. {
  32. return testandset (lock) != 0 ? EBUSY : 0;
  33. }
  34. weak_alias (__pthread_spin_trylock, pthread_spin_trylock)
  35. int
  36. __pthread_spin_unlock (pthread_spinlock_t *lock)
  37. {
  38. return *lock = 0;
  39. }
  40. weak_alias (__pthread_spin_unlock, pthread_spin_unlock)
  41. int
  42. __pthread_spin_init (pthread_spinlock_t *lock, int pshared)
  43. {
  44. /* We can ignore the `pshared' parameter. Since we are busy-waiting
  45. all processes which can access the memory location `lock' points
  46. to can use the spinlock. */
  47. return *lock = 0;
  48. }
  49. weak_alias (__pthread_spin_init, pthread_spin_init)
  50. int
  51. __pthread_spin_destroy (pthread_spinlock_t *lock)
  52. {
  53. /* Nothing to do. */
  54. return 0;
  55. }
  56. weak_alias (__pthread_spin_destroy, pthread_spin_destroy)