Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | Original patch submitted by jbowler@nslu2-linux.org on 2005-11-17: |
| 2 | |
| 3 | db: fix thumb uclibc operation in 4.3.29 |
| 4 | - uclibc thumb builds were using libpthread to implement mutexes, the |
| 5 | - uclibc version seems to be a stub (at least on thumb). This commit |
| 6 | - fixes the ARM/gcc-assembly mutex implementation so that it has thumb |
| 7 | - support and the resultant db4 works (tested on LE Thumb uclibc) |
| 8 | |
| 9 | Upstream-Status: Inappropriate [embedded specific] |
| 10 | |
| 11 | Author: jbowler@nslu2-linux.org |
| 12 | |
| 13 | --- db-5.1.19/src/dbinc/mutex_int.h.orig 2011-01-05 19:21:42.181805366 -0600 |
| 14 | +++ db-5.1.19/src/dbinc/mutex_int.h 2011-01-05 19:24:53.141853117 -0600 |
| 15 | @@ -474,6 +474,25 @@ |
| 16 | |
| 17 | #ifdef LOAD_ACTUAL_MUTEX_CODE |
| 18 | /* gcc/arm: 0 is clear, 1 is set. */ |
| 19 | +#if defined __thumb__ |
| 20 | +#define MUTEX_SET(tsl) ({ \ |
| 21 | + int __r, __p; \ |
| 22 | + __asm__ volatile( \ |
| 23 | + ".align 2\n\t" \ |
| 24 | + "bx pc\n\t" \ |
| 25 | + "nop\n\t" \ |
| 26 | + ".arm\n\t" \ |
| 27 | + "swpb %0, %2, [%3]\n\t" \ |
| 28 | + "eor %0, %0, #1\n\t" \ |
| 29 | + "orr %1, pc, #1\n\t" \ |
| 30 | + "bx %1\n\t" \ |
| 31 | + ".force_thumb" \ |
| 32 | + : "=&r" (__r), "=r" (__p) \ |
| 33 | + : "r" (1), "r" (tsl) \ |
| 34 | + ); \ |
| 35 | + __r & 1; \ |
| 36 | +}) |
| 37 | +#else |
| 38 | #define MUTEX_SET(tsl) ({ \ |
| 39 | int __r; \ |
| 40 | __asm__ volatile( \ |
| 41 | @@ -484,6 +503,7 @@ |
| 42 | ); \ |
| 43 | __r & 1; \ |
| 44 | }) |
| 45 | +#endif |
| 46 | |
| 47 | #define MUTEX_UNSET(tsl) (*(volatile tsl_t *)(tsl) = 0) |
| 48 | #define MUTEX_INIT(tsl) (MUTEX_UNSET(tsl), 0) |