kernel: fix sanity check
[minix.git] / sys / arch / arm / include / aeabi.h
blob95083842ca05a0a8628dd34b532ffc60225731f6
1 /* $NetBSD: aeabi.h,v 1.2 2012/08/11 16:21:26 matt Exp $ */
3 /*-
4 * Copyright (c) 2012 The NetBSD Foundation, Inc.
5 * All rights reserved.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Matt Thomas of 3am Software Foundry.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
31 #ifndef _ARM_AEABI_H_
32 #define _ARM_AEABI_H_
34 #include <stddef.h>
36 #define __value_in_regs /* nothing */
39 * Standard double precision floating-point arithmetic helper functions
41 double __aeabi_dadd(double, double); // double-precision addition
42 double __aeabi_ddiv(double n, double d); // double-precision division, n / d
43 double __aeabi_dmul(double, double); // double-precision multiplication
44 double __aeabi_drsub(double x, double y); // double-precision reverse subtraction, y - x
45 double __aeabi_dsub(double x, double y); // double-precision subtraction, x - y
46 double __aeabi_dneg(double); // double-precision negation (obsolete, to be removed in r2.09)
49 * Double precision floating-point comparison helper functions
51 void __aeabi_cdcmpeq(double, double); // non-excepting equality comparison [1], result in PSR ZC flags
52 void __aeabi_cdcmple(double, double); // 3-way (<, =, >) compare [1], result in PSR ZC flags
53 void __aeabi_cdrcmple(double, double); // reversed 3-way (<, =, >) compare [1], result in PSR ZC flags
54 int __aeabi_dcmpeq(double, double); // result (1, 0) denotes (=, <>) [2], use for C == and !=
55 int __aeabi_dcmplt(double, double); // result (1, 0) denotes (<, >=) [2], use for C <
56 int __aeabi_dcmple(double, double); // result (1, 0) denotes (<=, >) [2], use for C <=
57 int __aeabi_dcmpge(double, double); // result (1, 0) denotes (>=, <) [2], use for C >=
58 int __aeabi_dcmpgt(double, double); // result (1, 0) denotes (>, <=) [2], use for C >
59 int __aeabi_dcmpun(double, double); // result (1, 0) denotes (?, <=>) [2], use for C99 isunordered()
62 * Standard single precision floating-point arithmetic helper functions
64 float __aeabi_fadd(float, float); // single-precision addition
65 float __aeabi_fdiv(float n, float d); // single-precision division, n / d
66 float __aeabi_fmul(float, float); // single-precision multiplication
67 float __aeabi_frsub(float x, float y); // single-precision reverse subtraction, y - x
68 float __aeabi_fsub(float x, float y); // single-precision subtraction, x - y
69 float __aeabi_fneg(float); // single-precision negation (obsolete, to be removed in r2.09)
72 * Standard single precision floating-point comparison helper functions
74 void __aeabi_cfcmpeq(float, float); // non-excepting equality comparison [1], result in PSR ZC flags
75 void __aeabi_cfcmple(float, float); // 3-way (<, =, ?>) compare [1], result in PSR ZC flags
76 void __aeabi_cfrcmple(float, float); // reversed 3-way (<, =, ?>) compare [1], result in PSR ZC flags
77 int __aeabi_fcmpeq(float, float); // result (1, 0) denotes (=, <>) [2], use for C == and !=
78 int __aeabi_fcmplt(float, float); // result (1, 0) denotes (<, >=) [2], use for C <
79 int __aeabi_fcmple(float, float); // result (1, 0) denotes (<=, >) [2], use for C <=
80 int __aeabi_fcmpge(float, float); // result (1, 0) denotes (>=, <) [2], use for C >=
81 int __aeabi_fcmpgt(float, float); // result (1, 0) denotes (>, <=) [2], use for C >
82 int __aeabi_fcmpun(float, float); // result (1, 0) denotes (?, <=>) [2], use for C99 isunordered()
85 * Standard conversions between floating types
87 float __aeabi_d2f(double); // double to float (single precision) conversion
88 double __aeabi_f2d(float); // float (single precision) to double conversion
89 float __aeabi_h2f(short hf); // IEEE 754 binary16 storage format (VFP half precision) to binary32 (float) conversion [4, 5]
90 short __aeabi_f2h(float f); // IEEE 754 binary32 (float) to binary16 storage format (VFP half precision) conversion [4, 6]
91 float __aeabi_h2f_alt(short hf); // __aeabi_h2f_alt converts from VFP alternative format [7].
92 short __aeabi_f2h_alt(float f); // __aeabi_f2h_alt converts to VFP alternative format [8].
95 * Standard floating-point to integer conversions
97 int __aeabi_d2iz(double); // double to integer C-style conversion [3]
98 unsigned __aeabi_d2uiz(double); // double to unsigned C-style conversion [3]
99 long long __aeabi_d2lz(double); // double to long long C-style conversion [3]
100 unsigned long long __aeabi_d2ulz(double); // double to unsigned long long C-style conversion [3]
101 int __aeabi_f2iz(float); // float (single precision) to integer C-style conversion [3]
102 unsigned __aeabi_f2uiz(float); // float (single precision) to unsigned C-style conversion [3]
103 long long __aeabi_f2lz(float); // float (single precision) to long long C-style conversion [3]
104 unsigned long long __aeabi_f2ulz(float); // float to unsigned long long C-style conversion [3]
107 * Standard integer to floating-point conversions
109 double __aeabi_i2d(int); // integer to double conversion
110 double __aeabi_ui2d(unsigned); // unsigned to double conversion
111 double __aeabi_l2d(long long); // long long to double conversion
112 double __aeabi_ul2d(unsigned long long); // unsigned long long to double conversion
113 float __aeabi_i2f(int); // integer to float (single precision) conversion
114 float __aeabi_ui2f(unsigned); // unsigned to float (single precision) conversion
115 float __aeabi_l2f(long long); // long long to float (single precision) conversion
116 float __aeabi_ul2f(unsigned long long); // unsigned long long to float (single precision) conversion
119 * Long long functions
121 long long __aeabi_lmul(long long, long long); // multiplication
124 * A pair of (unsigned) long longs is returned in {{r0, r1}, {r2, r3}},
125 * the quotient in {r0, r1}, and the remainder in {r2, r3}.
127 typedef struct { long long quot; long long rem; } lldiv_t;
128 __value_in_regs lldiv_t __aeabi_ldivmod(long long n, long long d); // signed long long division and remainder, {q, r} = n / d [2]
130 typedef struct { unsigned long long quot; unsigned long long rem; } ulldiv_t;
131 __value_in_regs ulldiv_t __aeabi_uldivmod(unsigned long long n, unsigned long long d); // unsigned signed ll division, remainder, {q, r} = n / d [2]
134 * Because of 2's complement number representation, these functions work
135 * identically with long long replaced uniformly by unsigned long long.
136 * Each returns its result in {r0, r1}, as specified by the [AAPCS].
138 long long __aeabi_llsl(long long, int); // logical shift left [1]
139 long long __aeabi_llsr(long long, int); // logical shift right [1]
140 long long __aeabi_lasr(long long, int); // arithmetic shift right [1]
143 * The comparison functions return negative, zero, or a positive integer
144 * according to whether the comparison result is <, ==, or >, respectively
145 * (like strcmp).
147 int __aeabi_lcmp(long long, long long); // signed long long comparison
148 int __aeabi_ulcmp(unsigned long long, unsigned long long); // unsigned long long comparison
150 int __aeabi_idiv(int numerator, int denominator);
151 unsigned __aeabi_uidiv(unsigned numerator, unsigned denominator);
152 typedef struct { int quot, rem; } idiv_return;
153 typedef struct { unsigned int quot, rem; } uidiv_return;
154 __value_in_regs idiv_return __aeabi_idivmod(int, int);
155 __value_in_regs uidiv_return __aeabi_uidivmod(unsigned int, unsigned int);
158 * Division by zero
160 * If an integer or long long division helper function is called upon to
161 * divide by 0, it should return as quotient the value returned by a call
162 * to __aeabi_idiv0 or __aeabi_ldiv0, respectively. A *divmod helper should
163 * return as remainder either 0 or the original numerator.
165 int __aeabi_idiv0(int);
166 long long __aeabi_ldiv0(long long);
169 * These functions read and write 4-byte and 8-byte values at arbitrarily
170 * aligned addresses. Write functions return the value written,
171 * read functions the value read.
173 int __aeabi_uread4(void *);
174 int __aeabi_uwrite4(int, void *);
175 long long __aeabi_uread8(void *);
176 long long __aeabi_uwrite8(long long, void *);
179 * Memory copying, clearing, and setting
181 void __aeabi_memcpy8(void *, const void *, size_t);
182 void __aeabi_memcpy4(void *, const void *, size_t);
183 void __aeabi_memcpy(void *, const void *, size_t);
184 void __aeabi_memmove8(void *, const void *, size_t);
185 void __aeabi_memmove4(void *, const void *, size_t);
186 void __aeabi_memmove(void *, const void *, size_t);
189 * Memory clearing and setting
191 void __aeabi_memset8(void *, size_t, int);
192 void __aeabi_memset4(void *, size_t, int);
193 void __aeabi_memset(void *, size_t, int);
194 void __aeabi_memclr8(void *, size_t);
195 void __aeabi_memclr4(void *, size_t);
196 void __aeabi_memclr(void *, size_t);
198 void *__aeabi_read_tp(void); // return the value of $tp
200 #endif /* _ARM_AEABI_H_ */