my_no_pthread.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /* Copyright (C) 2000 MySQL AB
  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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
  12. #if !defined(_my_no_pthread_h) && !defined(THREAD)
  13. #define _my_no_pthread_h
  14. /*
  15. This block is to access some thread-related type definitions
  16. even in builds which do not need thread functions,
  17. as some variables (based on these types) are declared
  18. even in non-threaded builds.
  19. Case in point: 'mf_keycache.c'
  20. */
  21. #if defined(__WIN__)
  22. #else /* Normal threads */
  23. #include <pthread.h>
  24. #endif /* defined(__WIN__) */
  25. /*
  26. This undefs some pthread mutex locks when one isn't using threads
  27. to make thread safe code, that should also work in single thread
  28. environment, easier to use.
  29. */
  30. #define pthread_mutex_init(A,B)
  31. #define pthread_mutex_lock(A)
  32. #define pthread_mutex_unlock(A)
  33. #define pthread_mutex_destroy(A)
  34. #define my_rwlock_init(A,B)
  35. #define rw_rdlock(A)
  36. #define rw_wrlock(A)
  37. #define rw_unlock(A)
  38. #define rwlock_destroy(A)
  39. typedef int my_pthread_once_t;
  40. #define MY_PTHREAD_ONCE_INIT 0
  41. #define MY_PTHREAD_ONCE_DONE 1
  42. #define my_pthread_once(C,F) do { \
  43. if (*(C) != MY_PTHREAD_ONCE_DONE) { F(); *(C)= MY_PTHREAD_ONCE_DONE; } \
  44. } while(0)
  45. #endif