blob: 00d24a49c0e7e6fcc8426abe32fd5cd3b64c7847 [file] [log] [blame]
Serban Constantinescue2104882013-09-26 11:37:10 +01001/*
2 * Copyright (C) 2013 The Android Open Source Project
Elliott Hughes54a74942014-01-03 16:40:37 -08003 * All rights reserved.
Serban Constantinescue2104882013-09-26 11:37:10 +01004 *
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 */
28
Elliott Hughesda977552013-12-19 11:32:42 -080029#include <private/bionic_asm.h>
Serban Constantinescue2104882013-09-26 11:37:10 +010030
31#define FUTEX_WAIT 0
32#define FUTEX_WAKE 1
33
Elliott Hughes5eccb962013-12-20 16:58:06 -080034// int __futex_syscall4(volatile void* ftx, int op, int val, const struct timespec* timeout)
Serban Constantinescue2104882013-09-26 11:37:10 +010035ENTRY(__futex_syscall4)
Elliott Hughes5eccb962013-12-20 16:58:06 -080036 stp x29, x30, [sp, #-16]!
Christopher Ferrisdf22a122014-05-21 16:00:13 -070037 .cfi_def_cfa_offset 16
38 .cfi_rel_offset x29, 0
39 .cfi_rel_offset x30, 8
Elliott Hughes5eccb962013-12-20 16:58:06 -080040 mov x29, sp
Serban Constantinescue2104882013-09-26 11:37:10 +010041
Elliott Hughes5eccb962013-12-20 16:58:06 -080042 mov x8, __NR_futex
43 svc #0
Serban Constantinescue2104882013-09-26 11:37:10 +010044
Elliott Hughes5eccb962013-12-20 16:58:06 -080045 ldp x29, x30, [sp], #16
Christopher Ferrisdf22a122014-05-21 16:00:13 -070046 .cfi_def_cfa_offset 0
47 .cfi_restore x29
48 .cfi_restore x30
Elliott Hughes5eccb962013-12-20 16:58:06 -080049 ret
Serban Constantinescue2104882013-09-26 11:37:10 +010050END(__futex_syscall4)
51
Elliott Hughes5eccb962013-12-20 16:58:06 -080052// int __futex_syscall3(volatile void* ftx, int op, int count)
Serban Constantinescue2104882013-09-26 11:37:10 +010053ENTRY(__futex_syscall3)
Elliott Hughes5eccb962013-12-20 16:58:06 -080054 b __futex_syscall4
Serban Constantinescue2104882013-09-26 11:37:10 +010055END(__futex_syscall3)
56
Elliott Hughes5eccb962013-12-20 16:58:06 -080057// int __futex_wait(volatile void* ftx, int val, const struct timespec* timeout)
Elliott Hughes879180c2014-05-14 18:22:58 -070058ENTRY_PRIVATE(__futex_wait)
Elliott Hughes5eccb962013-12-20 16:58:06 -080059 stp x29, x30, [sp, #-16]!
Christopher Ferrisdf22a122014-05-21 16:00:13 -070060 .cfi_def_cfa_offset 16
61 .cfi_rel_offset x29, 0
62 .cfi_rel_offset x30, 8
Elliott Hughes5eccb962013-12-20 16:58:06 -080063 mov x29, sp
Serban Constantinescue2104882013-09-26 11:37:10 +010064
Elliott Hughes5eccb962013-12-20 16:58:06 -080065 mov x3, x2
66 mov x2, x1
67 mov x1, #FUTEX_WAIT
Serban Constantinescue2104882013-09-26 11:37:10 +010068
Elliott Hughes5eccb962013-12-20 16:58:06 -080069 mov x8, __NR_futex
70 svc #0
Serban Constantinescue2104882013-09-26 11:37:10 +010071
Elliott Hughes5eccb962013-12-20 16:58:06 -080072 ldp x29, x30, [sp], #16
Christopher Ferrisdf22a122014-05-21 16:00:13 -070073 .cfi_def_cfa_offset 0
74 .cfi_restore x29
75 .cfi_restore x30
Elliott Hughes5eccb962013-12-20 16:58:06 -080076 ret
Serban Constantinescue2104882013-09-26 11:37:10 +010077END(__futex_wait)
78
Elliott Hughes5eccb962013-12-20 16:58:06 -080079// int __futex_wake(volatile void* ftx, int count)
Elliott Hughes879180c2014-05-14 18:22:58 -070080ENTRY_PRIVATE(__futex_wake)
Elliott Hughes5eccb962013-12-20 16:58:06 -080081 stp x29, x30, [sp, #-16]!
Christopher Ferrisdf22a122014-05-21 16:00:13 -070082 .cfi_def_cfa_offset 16
83 .cfi_rel_offset x29, 0
84 .cfi_rel_offset x30, 8
Elliott Hughes5eccb962013-12-20 16:58:06 -080085 mov x29, sp
Serban Constantinescue2104882013-09-26 11:37:10 +010086
Elliott Hughes5eccb962013-12-20 16:58:06 -080087 mov x2, x1
88 mov x1, #FUTEX_WAKE
Serban Constantinescue2104882013-09-26 11:37:10 +010089
Elliott Hughes5eccb962013-12-20 16:58:06 -080090 mov x8, __NR_futex
91 svc #0
Serban Constantinescue2104882013-09-26 11:37:10 +010092
Elliott Hughes5eccb962013-12-20 16:58:06 -080093 ldp x29, x30, [sp], #16
Christopher Ferrisdf22a122014-05-21 16:00:13 -070094 .cfi_def_cfa_offset 0
95 .cfi_restore x29
96 .cfi_restore x30
Elliott Hughes5eccb962013-12-20 16:58:06 -080097 ret
Serban Constantinescue2104882013-09-26 11:37:10 +010098END(__futex_wake)