pspinlock.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 not,
  14. write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  15. Boston, MA 02111-1307, USA. */
  16. #include <errno.h>
  17. #include <pthread.h>
  18. #include "internals.h"
  19. /* FIXME: These are just dummies. I don't know why or if they're needed;
  20. configury should default to these definitions. We just follow the
  21. crowd here. */
  22. int
  23. __pthread_spin_lock (pthread_spinlock_t *lock)
  24. {
  25. while (testandset (lock) != 0)
  26. ;
  27. return 0;
  28. }
  29. weak_alias (__pthread_spin_lock, pthread_spin_lock)
  30. int
  31. __pthread_spin_trylock (pthread_spinlock_t *lock)
  32. {
  33. return testandset (lock) != 0 ? EBUSY : 0;
  34. }
  35. weak_alias (__pthread_spin_trylock, pthread_spin_trylock)
  36. int
  37. __pthread_spin_unlock (pthread_spinlock_t *lock)
  38. {
  39. return *lock = 0;
  40. }
  41. weak_alias (__pthread_spin_unlock, pthread_spin_unlock)
  42. int
  43. __pthread_spin_init (pthread_spinlock_t *lock, int pshared)
  44. {
  45. /* We can ignore the `pshared' parameter. Since we are busy-waiting
  46. all processes which can access the memory location `lock' points
  47. to can use the spinlock. */
  48. return *lock = 0;
  49. }
  50. weak_alias (__pthread_spin_init, pthread_spin_init)
  51. int
  52. __pthread_spin_destroy (pthread_spinlock_t *lock)
  53. {
  54. /* Nothing to do. */
  55. return 0;
  56. }
  57. weak_alias (__pthread_spin_destroy, pthread_spin_destroy)