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 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 13 | Index: db-6.0.30/src/dbinc/mutex_int.h |
| 14 | =================================================================== |
| 15 | --- db-6.0.30.orig/src/dbinc/mutex_int.h |
| 16 | +++ db-6.0.30/src/dbinc/mutex_int.h |
| 17 | @@ -474,6 +474,25 @@ typedef unsigned char tsl_t; |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 18 | |
| 19 | #ifdef LOAD_ACTUAL_MUTEX_CODE |
| 20 | /* gcc/arm: 0 is clear, 1 is set. */ |
| 21 | +#if defined __thumb__ |
| 22 | +#define MUTEX_SET(tsl) ({ \ |
| 23 | + int __r, __p; \ |
| 24 | + __asm__ volatile( \ |
| 25 | + ".align 2\n\t" \ |
| 26 | + "bx pc\n\t" \ |
| 27 | + "nop\n\t" \ |
| 28 | + ".arm\n\t" \ |
| 29 | + "swpb %0, %2, [%3]\n\t" \ |
| 30 | + "eor %0, %0, #1\n\t" \ |
| 31 | + "orr %1, pc, #1\n\t" \ |
| 32 | + "bx %1\n\t" \ |
| 33 | + ".force_thumb" \ |
| 34 | + : "=&r" (__r), "=r" (__p) \ |
| 35 | + : "r" (1), "r" (tsl) \ |
| 36 | + ); \ |
| 37 | + __r & 1; \ |
| 38 | +}) |
| 39 | +#else |
| 40 | #define MUTEX_SET(tsl) ({ \ |
| 41 | int __r; \ |
| 42 | __asm__ volatile( \ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 43 | @@ -484,6 +503,7 @@ typedef unsigned char tsl_t; |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 44 | ); \ |
| 45 | __r & 1; \ |
| 46 | }) |
| 47 | +#endif |
| 48 | |
| 49 | #define MUTEX_UNSET(tsl) (*(volatile tsl_t *)(tsl) = 0) |
| 50 | #define MUTEX_INIT(tsl) (MUTEX_UNSET(tsl), 0) |