0001-fix-linuxthreads-for-coldfire-nommu.patch 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. From 45064565100b67ff2f960e93d580449b720a66c9 Mon Sep 17 00:00:00 2001
  2. From: Waldemar Brodkorb <wbx@openadk.org>
  3. Date: Sat, 6 Sep 2014 01:52:10 +0200
  4. Subject: [PATCH] fix linuxthreads for coldfire nommu
  5. Signed-off-by: Waldemar Brodkorb <wbx@openadk.org>
  6. ---
  7. libpthread/linuxthreads/sysdeps/m68k/pspinlock.c | 20 +++++++++++++++-----
  8. libpthread/linuxthreads/sysdeps/m68k/pt-machine.h | 11 +++++++++--
  9. libpthread/linuxthreads/sysdeps/pthread/herrno-loc.c | 2 ++
  10. 3 files changed, 26 insertions(+), 7 deletions(-)
  11. diff --git a/libpthread/linuxthreads/sysdeps/m68k/pspinlock.c b/libpthread/linuxthreads/sysdeps/m68k/pspinlock.c
  12. index c26a278..af77c2a 100644
  13. --- a/libpthread/linuxthreads/sysdeps/m68k/pspinlock.c
  14. +++ b/libpthread/linuxthreads/sysdeps/m68k/pspinlock.c
  15. @@ -27,10 +27,15 @@ __pthread_spin_lock (pthread_spinlock_t *lock)
  16. unsigned int val;
  17. do
  18. - __asm__ __volatile__ ("tas %1; sne %0"
  19. - : "=dm" (val), "=m" (*lock)
  20. - : "m" (*lock)
  21. - : "cc");
  22. + __asm__ __volatile__ (
  23. +#if !defined(__mcoldfire__) && !defined(__mcf5200__) && !defined(__m68000)
  24. + "tas %1; sne %0"
  25. +#else
  26. + "bset #7,%1; sne %0"
  27. +#endif
  28. + : "=dm" (val), "=m" (*lock)
  29. + : "m" (*lock)
  30. + : "cc");
  31. while (val);
  32. return 0;
  33. @@ -43,7 +48,12 @@ __pthread_spin_trylock (pthread_spinlock_t *lock)
  34. {
  35. unsigned int val;
  36. - __asm__ __volatile__ ("tas %1; sne %0"
  37. + __asm__ __volatile__ (
  38. +#if !defined(__mcoldfire__) && !defined(__mcf5200__) && !defined(__m68000)
  39. + "tas %1; sne %0"
  40. +#else
  41. + "bset #7,%1; sne %0"
  42. +#endif
  43. : "=dm" (val), "=m" (*lock)
  44. : "m" (*lock)
  45. : "cc");
  46. diff --git a/libpthread/linuxthreads/sysdeps/m68k/pt-machine.h b/libpthread/linuxthreads/sysdeps/m68k/pt-machine.h
  47. index e2d7bdc..1eb9fd5 100644
  48. --- a/libpthread/linuxthreads/sysdeps/m68k/pt-machine.h
  49. +++ b/libpthread/linuxthreads/sysdeps/m68k/pt-machine.h
  50. @@ -28,12 +28,18 @@
  51. #endif
  52. /* Spinlock implementation; required. */
  53. +PT_EI long int testandset (int *spinlock);
  54. PT_EI long int
  55. testandset (int *spinlock)
  56. {
  57. char ret;
  58. - __asm__ __volatile__("tas %1; sne %0"
  59. + __asm__ __volatile__(
  60. +#if !defined(__mcoldfire__) && !defined(__mcf5200__) && !defined(__m68000)
  61. + "tas %1; sne %0"
  62. +#else
  63. + "bset #7,%1; sne %0"
  64. +#endif
  65. : "=dm"(ret), "=m"(*spinlock)
  66. : "m"(*spinlock)
  67. : "cc");
  68. @@ -50,6 +56,7 @@ register char * stack_pointer __asm__ ("%sp");
  69. /* Compare-and-swap for semaphores. */
  70. +#if !defined(__mcoldfire__) && !defined(__mcf5200__) && !defined(__mc68000)
  71. #define HAS_COMPARE_AND_SWAP
  72. PT_EI int
  73. __compare_and_swap (long int *p, long int oldval, long int newval)
  74. @@ -63,5 +70,5 @@ __compare_and_swap (long int *p, long int oldval, long int newval)
  75. return ret;
  76. }
  77. -
  78. +#endif
  79. #endif /* pt-machine.h */
  80. diff --git a/libpthread/linuxthreads/sysdeps/pthread/herrno-loc.c b/libpthread/linuxthreads/sysdeps/pthread/herrno-loc.c
  81. index 706faef..634c752 100644
  82. --- a/libpthread/linuxthreads/sysdeps/pthread/herrno-loc.c
  83. +++ b/libpthread/linuxthreads/sysdeps/pthread/herrno-loc.c
  84. @@ -16,7 +16,9 @@
  85. <http://www.gnu.org/licenses/>. */
  86. #include <netdb.h>
  87. +#ifdef __UCLIBC_HAS_TLS__
  88. #include <tls.h>
  89. +#endif
  90. #include <linuxthreads/internals.h>
  91. #include <sysdep-cancel.h>
  92. --
  93. 2.0.1