fix build error
[platform/upstream/openblas.git] / common_arm64.h
1 /*****************************************************************************
2 Copyright (c) 2011-2015, The OpenBLAS 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 are
7 met:
8
9    1. Redistributions of source code must retain the above copyright
10       notice, this list of conditions and the following disclaimer.
11
12    2. Redistributions in binary form must reproduce the above copyright
13       notice, this list of conditions and the following disclaimer in
14       the documentation and/or other materials provided with the
15       distribution.
16    3. Neither the name of the OpenBLAS project nor the names of 
17       its contributors may be used to endorse or promote products 
18       derived from this software without specific prior written 
19       permission.
20
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
30 USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 **********************************************************************************/
32
33 #ifndef COMMON_ARM64
34 #define COMMON_ARM64
35
36 #define MB   __asm__ __volatile__ ("dmb  ish" : : : "memory")
37 #define WMB  __asm__ __volatile__ ("dmb  ishst" : : : "memory")
38
39
40 #define INLINE inline
41
42 #ifdef F_INTERFACE_FLANG
43 #define RETURN_BY_STACK
44 #else
45 #define RETURN_BY_COMPLEX
46 #endif
47
48 #ifndef ASSEMBLER
49
50
51 static void __inline blas_lock(volatile BLASULONG *address){
52
53   BLASULONG ret;
54
55   do {
56     while (*address) {YIELDING;};
57
58     __asm__ __volatile__(
59                          "mov   x4, #1                                                  \n\t"
60                          "1:                                                            \n\t"
61                          "ldaxr x2, [%1]                                                \n\t"
62                          "cbnz  x2, 1b                                                  \n\t"
63                          "2:                                                            \n\t"
64                          "stxr  w3, x4, [%1]                                            \n\t"
65                          "cbnz  w3, 1b                                                  \n\t"
66                          "mov   %0, #0                                                  \n\t"
67                          : "=r"(ret), "=r"(address)
68                          : "1"(address)
69                          : "memory", "x2" , "x3", "x4"
70
71
72     );
73
74
75   } while (ret);
76
77 }
78
79 #define BLAS_LOCK_DEFINED
80
81
82
83 static inline int blas_quickdivide(blasint x, blasint y){
84   return x / y;
85 }
86
87 #if defined(DOUBLE)
88 #define GET_IMAGE(res)  __asm__ __volatile__("str d1, %0" : "=m"(res) : : "memory")
89 #else
90 #define GET_IMAGE(res)  __asm__ __volatile__("str s1, %0" : "=m"(res) : : "memory")
91 #endif
92
93 #define GET_IMAGE_CANCEL
94
95 #endif
96
97
98 #ifndef F_INTERFACE
99 #define REALNAME ASMNAME
100 #else
101 #define REALNAME ASMFNAME
102 #endif
103
104 #if defined(ASSEMBLER) && !defined(NEEDPARAM)
105
106 #define PROLOGUE \
107         .text ;\
108         .align  4 ;\
109         .global REALNAME ;\
110         .type   REALNAME, %function ;\
111 REALNAME:
112
113 #define EPILOGUE
114
115 #define PROFCODE
116
117 #endif
118
119
120 #define SEEK_ADDRESS
121
122 #ifndef PAGESIZE
123 #define PAGESIZE        ( 4 << 10)
124 #endif
125 #define HUGE_PAGESIZE   ( 4 << 20)
126
127 #if defined(CORTEXA57)
128 #define BUFFER_SIZE     (20 << 20)
129 #else
130 #define BUFFER_SIZE     (16 << 20)
131 #endif
132
133
134 #define BASE_ADDRESS (START_ADDRESS - BUFFER_SIZE * MAX_CPU_NUMBER)
135
136 #ifndef MAP_ANONYMOUS
137 #define MAP_ANONYMOUS MAP_ANON
138 #endif
139
140 #endif
141