starpu_spinlock.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * StarPU
  3. * Copyright (C) INRIA 2008-2009 (see AUTHORS file)
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU Lesser General Public License as published by
  7. * the Free Software Foundation; either version 2.1 of the License, or (at
  8. * your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. *
  14. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  15. */
  16. #ifndef __STARPU_SPINLOCK_H__
  17. #define __STARPU_SPINLOCK_H__
  18. #include <errno.h>
  19. #include <stdint.h>
  20. #include <pthread.h>
  21. #include <common/config.h>
  22. typedef struct starpu_spinlock_s {
  23. #ifdef HAVE_PTHREAD_SPIN_LOCK
  24. pthread_spinlock_t lock;
  25. #else
  26. /* we only have a trivial implementation yet ! */
  27. uint32_t taken __attribute__ ((aligned(16)));
  28. #endif
  29. } starpu_spinlock_t;
  30. int _starpu_spin_init(starpu_spinlock_t *lock);
  31. int _starpu_spin_destroy(starpu_spinlock_t *lock);
  32. int _starpu_spin_lock(starpu_spinlock_t *lock);
  33. int _starpu_spin_trylock(starpu_spinlock_t *lock);
  34. int _starpu_spin_unlock(starpu_spinlock_t *lock);
  35. #endif // __STARPU_SPINLOCK_H__