David 'Digit' Turner | 0fec6b9 | 2011-11-16 17:37:15 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 The Android Open Source Project |
| 3 | * All rights reserved. |
| 4 | * |
| 5 | * Redistribution and use in source and binary forms, with or without |
| 6 | * modification, are permitted provided that the following conditions |
| 7 | * are met: |
| 8 | * * Redistributions of source code must retain the above copyright |
| 9 | * notice, this list of conditions and the following disclaimer. |
| 10 | * * Redistributions in binary form must reproduce the above copyright |
| 11 | * notice, this list of conditions and the following disclaimer in |
| 12 | * the documentation and/or other materials provided with the |
| 13 | * distribution. |
| 14 | * |
| 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 16 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 17 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 18 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
| 19 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
| 21 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS |
| 22 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
| 23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
| 25 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 26 | * SUCH DAMAGE. |
| 27 | */ |
Elliott Hughes | f94fd3c | 2013-02-11 15:36:59 -0800 | [diff] [blame] | 28 | |
Elliott Hughes | 8794ece | 2013-03-21 22:43:25 -0700 | [diff] [blame] | 29 | #include <asm/unistd.h> |
David 'Digit' Turner | 0fec6b9 | 2011-11-16 17:37:15 +0100 | [diff] [blame] | 30 | #include <machine/asm.h> |
David 'Digit' Turner | 0fec6b9 | 2011-11-16 17:37:15 +0100 | [diff] [blame] | 31 | |
| 32 | #define FUTEX_WAIT 0 |
| 33 | #define FUTEX_WAKE 1 |
| 34 | |
Elliott Hughes | f94fd3c | 2013-02-11 15:36:59 -0800 | [diff] [blame] | 35 | // __futex_syscall3(*ftx, op, val) |
David 'Digit' Turner | 0fec6b9 | 2011-11-16 17:37:15 +0100 | [diff] [blame] | 36 | ENTRY(__futex_syscall3) |
Elliott Hughes | da4a3e6 | 2013-07-16 11:52:24 -0700 | [diff] [blame] | 37 | mov ip, r7 |
David 'Digit' Turner | 0fec6b9 | 2011-11-16 17:37:15 +0100 | [diff] [blame] | 38 | ldr r7, =__NR_futex |
| 39 | swi #0 |
Elliott Hughes | da4a3e6 | 2013-07-16 11:52:24 -0700 | [diff] [blame] | 40 | mov r7, ip |
David 'Digit' Turner | 0fec6b9 | 2011-11-16 17:37:15 +0100 | [diff] [blame] | 41 | bx lr |
| 42 | END(__futex_syscall3) |
| 43 | |
Elliott Hughes | f94fd3c | 2013-02-11 15:36:59 -0800 | [diff] [blame] | 44 | // __futex_syscall4(*ftx, op, val, *timespec) |
David 'Digit' Turner | 0fec6b9 | 2011-11-16 17:37:15 +0100 | [diff] [blame] | 45 | ENTRY(__futex_syscall4) |
| 46 | b __futex_syscall3 |
| 47 | END(__futex_syscall4) |
Elliott Hughes | f94fd3c | 2013-02-11 15:36:59 -0800 | [diff] [blame] | 48 | |
| 49 | // __futex_wait(*ftx, val, *timespec) |
| 50 | ENTRY(__futex_wait) |
Elliott Hughes | da4a3e6 | 2013-07-16 11:52:24 -0700 | [diff] [blame] | 51 | mov ip, r7 |
Elliott Hughes | f94fd3c | 2013-02-11 15:36:59 -0800 | [diff] [blame] | 52 | mov r3, r2 |
| 53 | mov r2, r1 |
| 54 | mov r1, #FUTEX_WAIT |
| 55 | ldr r7, =__NR_futex |
| 56 | swi #0 |
Elliott Hughes | da4a3e6 | 2013-07-16 11:52:24 -0700 | [diff] [blame] | 57 | mov r7, ip |
Elliott Hughes | f94fd3c | 2013-02-11 15:36:59 -0800 | [diff] [blame] | 58 | bx lr |
| 59 | END(__futex_wait) |
| 60 | |
| 61 | // __futex_wake(*ftx, counter) |
| 62 | ENTRY(__futex_wake) |
Elliott Hughes | da4a3e6 | 2013-07-16 11:52:24 -0700 | [diff] [blame] | 63 | mov ip, r7 |
Elliott Hughes | f94fd3c | 2013-02-11 15:36:59 -0800 | [diff] [blame] | 64 | mov r2, r1 |
| 65 | mov r1, #FUTEX_WAKE |
| 66 | ldr r7, =__NR_futex |
| 67 | swi #0 |
Elliott Hughes | da4a3e6 | 2013-07-16 11:52:24 -0700 | [diff] [blame] | 68 | mov r7, ip |
Elliott Hughes | f94fd3c | 2013-02-11 15:36:59 -0800 | [diff] [blame] | 69 | bx lr |
| 70 | END(__futex_wake) |