Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 3 commits
  • 3 files changed
  • 0 comments
  • 1 contributor
7  software/common.mak
@@ -35,11 +35,10 @@ endif
35 35
 
36 36
 # Toolchain options
37 37
 #
38  
-INCLUDES_NOLIBC ?= -nostdinc -I$(M2DIR)/software/include/base
39  
-INCLUDES = $(INCLUDES_NOLIBC) -I$(M2DIR)/software/include -I$(M2DIR)/common
40  
-ASFLAGS = $(INCLUDES) -nostdinc
  38
+INCLUDES = -I$(M2DIR)/software/include/base -I$(M2DIR)/software/include -I$(M2DIR)/common
  39
+ASFLAGS = -nostdinc $(INCLUDES)
41 40
 CFLAGS = -O9 -Wall -Wstrict-prototypes -Wold-style-definition -Wshadow \
42  
-	 -Wmissing-prototypes -fsigned-char $(INCLUDES)
  41
+	 -Wmissing-prototypes -fsigned-char -nostdinc $(INCLUDES)
43 42
 LDFLAGS = -nostdlib -nodefaultlibs
44 43
 
45 44
 # compile and generate dependencies, based on
200  software/libbase/softfloat-glue.c
... ...
@@ -1,14 +1,72 @@
  1
+/*	$NetBSD: fplib_glue.c,v 1.2 2000/02/22 01:18:28 mycroft Exp $	*/
  2
+
  3
+/*-
  4
+ * Copyright (c) 1997 The NetBSD Foundation, Inc.
  5
+ * All rights reserved.
  6
+ *
  7
+ * This code is derived from software contributed to The NetBSD Foundation
  8
+ * by Neil A. Carson and Mark Brinicombe
  9
+ *
  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.
  18
+ * 3. All advertising materials mentioning features or use of this software
  19
+ *    must display the following acknowledgement:
  20
+ *	This product includes software developed by the NetBSD
  21
+ *	Foundation, Inc. and its contributors.
  22
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
  23
+ *    contributors may be used to endorse or promote products derived
  24
+ *    from this software without specific prior written permission.
  25
+ *
  26
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
  27
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
  28
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  29
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
  30
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  31
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  32
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  33
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  34
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  35
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  36
+ * POSSIBILITY OF SUCH DAMAGE.
  37
+ */
  38
+
1 39
 #include "milieu.h"
2 40
 #include "softfloat.h"
3 41
 
  42
+int __eqsf2(float32 a,float32 b);
  43
+int __eqdf2(float64 a,float64 b);
  44
+int __nesf2(float32 a,float32 b);
  45
+int __nedf2(float64 a,float64 b);
  46
+int __gtsf2(float32 a,float32 b);
  47
+int __gtdf2(float64 a,float64 b);
  48
+int __gesf2(float32 a,float32 b);
  49
+int __gedf2(float64 a,float64 b);
  50
+int __ltsf2(float32 a,float32 b);
  51
+int __ltdf2(float64 a,float64 b);
  52
+int __lesf2(float32 a,float32 b);
  53
+int __ledf2(float64 a,float64 b);
  54
+float32 __negsf2(float32 a);
  55
+float64 __negdf2(float64 a);
  56
+
  57
+/********************************* COMPARISONS ********************************/
  58
+
4 59
 /*
5 60
  * 'Equal' wrapper. This returns 0 if the numbers are equal, or (1 | -1)
6 61
  * otherwise. So we need to invert the output.
7 62
  */
8  
-flag __eqsf2(float32 a, float32 b);
9  
-flag __eqsf2(float32 a, float32 b)
10  
-{
11  
-	return !float32_eq(a, b);
  63
+
  64
+int __eqsf2(float32 a,float32 b) {
  65
+	return float32_eq(a,b)?0:1;
  66
+}
  67
+
  68
+int __eqdf2(float64 a,float64 b) {
  69
+	return float64_eq(a,b)?0:1;
12 70
 }
13 71
 
14 72
 /*
@@ -17,10 +75,12 @@ flag __eqsf2(float32 a, float32 b)
17 75
  * to use an 'equal' call and invert the result. The result is already
18 76
  * inverted though! Confusing?!
19 77
  */
20  
-flag __nesf2(float32 a, float32 b);
21  
-flag __nesf2(float32 a, float32 b)
22  
-{
23  
-	return !float32_eq(a, b);
  78
+int __nesf2(float32 a,float32 b) {
  79
+	return float32_eq(a,b)?0:-1;
  80
+}
  81
+
  82
+int __nedf2(float64 a,float64 b) {
  83
+	return float64_eq(a,b)?0:-1;
24 84
 }
25 85
 
26 86
 /*
@@ -30,38 +90,46 @@ flag __nesf2(float32 a, float32 b)
30 90
  * make up our mind. This means that we can call 'less than or equal' and
31 91
  * invert the result.
32 92
  */
33  
-flag __gtsf2(float32 a, float32 b);
34  
-flag __gtsf2(float32 a, float32 b)
35  
-{
36  
-	return !float32_le(a, b);
  93
+int __gtsf2(float32 a,float32 b) {
  94
+	return float32_le(a,b)?0:1;
  95
+}
  96
+
  97
+int __gtdf2(float64 a,float64 b) {
  98
+	return float64_le(a,b)?0:1;
37 99
 }
38 100
 
39 101
 /*
40 102
  * 'Greater Than or Equal' wrapper. We emulate this by inverting the result
41 103
  * of a 'less than' call.
42 104
  */
43  
-flag __gesf2(float32 a, float32 b);
44  
-flag __gesf2(float32 a, float32 b)
45  
-{
46  
-	return !float32_lt(a, b);
  105
+int __gesf2(float32 a,float32 b) {
  106
+	return float32_lt(a,b)?-1:0;
  107
+}
  108
+
  109
+int __gedf2(float64 a,float64 b) {
  110
+	return float64_lt(a,b)?-1:0;
47 111
 }
48 112
 
49 113
 /*
50  
- * 'Less Than' wrapper.
  114
+ * 'Less Than' wrapper. A 1 from the ARM code needs to be turned into -1.
51 115
  */
52  
-flag __ltsf2(float32 a, float32 b);
53  
-flag __ltsf2(float32 a, float32 b)
54  
-{
55  
-	return float32_lt(a, b);
  116
+int __ltsf2(float32 a,float32 b) {
  117
+	return float32_lt(a,b)?-1:0;
  118
+}
  119
+
  120
+int __ltdf2(float64 a,float64 b) {
  121
+	return float64_lt(a,b)?-1:0;
56 122
 }
57 123
 
58 124
 /*
59 125
  * 'Less Than or Equal' wrapper. A 0 must turn into a 1, and a 1 into a 0.
60 126
  */
61  
-flag __lesf2(float32 a, float32 b);
62  
-flag __lesf2(float32 a, float32 b)
63  
-{
64  
-	return !float32_le(a, b);
  127
+int __lesf2(float32 a,float32 b) {
  128
+	return float32_le(a,b)?0:1;
  129
+}
  130
+
  131
+int __ledf2(float64 a,float64 b) {
  132
+	return float64_le(a,b)?0:1;
65 133
 }
66 134
 
67 135
 /*
@@ -70,14 +138,17 @@ flag __lesf2(float32 a, float32 b)
70 138
  * position in the registers of arguments, the double precision version can
71 139
  * go here too ;-)
72 140
  */
73  
-float32 __negsf2(float32 x);
74  
-float32 __negsf2(float32 x)
75  
-{
76  
-	return x ^ 0x80000000;
  141
+float32 __negsf2(float32 a) {
  142
+	return (a ^ 0x80000000);
  143
+}
  144
+
  145
+float64 __negdf2(float64 a) {
  146
+	a.high ^= 0x80000000;
  147
+	return a;
77 148
 }
78 149
 
79 150
 /*
80  
- * 32-bit operations.
  151
+ * 32-bit operations. This is not BSD code.
81 152
  */
82 153
 float32 __addsf3(float32 a, float32 b);
83 154
 float32 __addsf3(float32 a, float32 b)
@@ -103,20 +174,20 @@ float32 __divsf3(float32 a, float32 b)
103 174
 	return float32_div(a, b);
104 175
 }
105 176
 
106  
-float32 __floatsisf(int x);
107  
-float32 __floatsisf(int x)
  177
+float32 __floatsisf(int32 x);
  178
+float32 __floatsisf(int32 x)
108 179
 {
109 180
 	return int32_to_float32(x);
110 181
 }
111 182
 
112  
-int __fixsfsi(float32 x);
113  
-int __fixsfsi(float32 x)
  183
+int32 __fixsfsi(float32 x);
  184
+int32 __fixsfsi(float32 x)
114 185
 {
115 186
 	return float32_to_int32_round_to_zero(x);
116 187
 }
117 188
 
118  
-unsigned int __fixunssfsi(float32 x);
119  
-unsigned int __fixunssfsi(float32 x)
  189
+uint32 __fixunssfsi(float32 x);
  190
+uint32 __fixunssfsi(float32 x)
120 191
 {
121 192
 	return float32_to_int32_round_to_zero(x); // XXX
122 193
 }
@@ -132,3 +203,60 @@ flag __unordsf2(float32 a, float32 b)
132 203
 	 */
133 204
 	return 1 ^ (float32_eq(a, a) & float32_eq(b, b));
134 205
 }
  206
+
  207
+/*
  208
+ * 64-bit operations. This is not BSD code.
  209
+ */
  210
+float64 __adddf3(float64 a, float64 b);
  211
+float64 __adddf3(float64 a, float64 b)
  212
+{
  213
+	return float64_add(a, b);
  214
+}
  215
+
  216
+float64 __subdf3(float64 a, float64 b);
  217
+float64 __subdf3(float64 a, float64 b)
  218
+{
  219
+	return float64_sub(a, b);
  220
+}
  221
+
  222
+float64 __muldf3(float64 a, float64 b);
  223
+float64 __muldf3(float64 a, float64 b)
  224
+{
  225
+	return float64_mul(a, b);
  226
+}
  227
+
  228
+float64 __divdf3(float64 a, float64 b);
  229
+float64 __divdf3(float64 a, float64 b)
  230
+{
  231
+	return float64_div(a, b);
  232
+}
  233
+
  234
+float64 __floatsidf(int32 x);
  235
+float64 __floatsidf(int32 x)
  236
+{
  237
+	return int32_to_float64(x);
  238
+}
  239
+
  240
+int32 __fixdfsi(float64 x);
  241
+int32 __fixdfsi(float64 x)
  242
+{
  243
+	return float64_to_int32_round_to_zero(x);
  244
+}
  245
+
  246
+uint32 __fixunsdfsi(float64 x);
  247
+uint32 __fixunsdfsi(float64 x)
  248
+{
  249
+	return float64_to_int32_round_to_zero(x); // XXX
  250
+}
  251
+
  252
+flag __unorddf2(float64 a, float64 b);
  253
+flag __unorddf2(float64 a, float64 b)
  254
+{
  255
+	/*
  256
+	 * The comparison is unordered if either input is a NaN.
  257
+	 * Test for this by comparing each operand with itself.
  258
+	 * We must perform both comparisons to correctly check for
  259
+	 * signalling NaNs.
  260
+	 */
  261
+	return 1 ^ (float64_eq(a, a) & float64_eq(b, b));
  262
+}
9  software/libbase/vsnprintf.c
@@ -196,12 +196,11 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
196 196
 
197 197
 			case 'f': {
198 198
 				int m;
199  
-				float f;
  199
+				double f;
200 200
 				int integer;
201 201
 				
202  
-				/* until I sort out how to disable this stupid promotion to double ... */
203  
-				f = *(va_arg(args, float *));
204  
-				if((f <= 0.0f) && (f != 0.0f)) { /* TODO: fix that |[#{'"é! '<' operator */
  202
+				f = va_arg(args, double);
  203
+				if(f < 0.0) {
205 204
 					*str = '-';
206 205
 					str++;
207 206
 					f = -f;
@@ -233,7 +232,7 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
233 232
 				for(i=0;i<6;i++) {
234 233
 					int n;
235 234
 
236  
-					f = f*10.0f;
  235
+					f = f*10.0;
237 236
 					n = f;
238 237
 					f = f - n;
239 238
 					if(str >= end) break;

No commit comments for this range

Something went wrong with that request. Please try again.