You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
1.7 KiB

  1. /* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of the GNU General Public License as published by
  4. the Free Software Foundation; version 2 of the License.
  5. This program is distributed in the hope that it will be useful,
  6. but WITHOUT ANY WARRANTY; without even the implied warranty of
  7. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  8. GNU General Public License for more details.
  9. You should have received a copy of the GNU General Public License
  10. along with this program; if not, write to the Free Software
  11. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
  12. #include <my_global.h>
  13. #include <my_sys.h>
  14. #include <my_atomic.h>
  15. /*
  16. checks that the current build of atomic ops
  17. can run on this machine
  18. RETURN
  19. ATOMIC_xxx values, see my_atomic.h
  20. */
  21. int my_atomic_initialize()
  22. {
  23. compile_time_assert(sizeof(intptr) == sizeof(void *));
  24. /* currently the only thing worth checking is SMP/UP issue */
  25. #ifdef MY_ATOMIC_MODE_DUMMY
  26. return my_getncpus() == 1 ? MY_ATOMIC_OK : MY_ATOMIC_NOT_1CPU;
  27. #else
  28. return MY_ATOMIC_OK;
  29. #endif
  30. }
  31. #ifdef SAFE_MUTEX
  32. #undef pthread_mutex_init
  33. #undef pthread_mutex_destroy
  34. #undef pthread_mutex_lock
  35. #undef pthread_mutex_unlock
  36. void plain_pthread_mutex_init(safe_mutex_t *m)
  37. {
  38. pthread_mutex_init(& m->mutex, NULL);
  39. }
  40. void plain_pthread_mutex_destroy(safe_mutex_t *m)
  41. {
  42. pthread_mutex_destroy(& m->mutex);
  43. }
  44. void plain_pthread_mutex_lock(safe_mutex_t *m)
  45. {
  46. pthread_mutex_lock(& m->mutex);
  47. }
  48. void plain_pthread_mutex_unlock(safe_mutex_t *m)
  49. {
  50. pthread_mutex_unlock(& m->mutex);
  51. }
  52. #endif