Changes in / [90924df:d9f53877] in mainline
- Files:
-
- 16 added
- 8 deleted
- 54 edited
Legend:
- Unmodified
- Added
- Removed
-
boot/arch/arm32/Makefile.inc
r90924df rd9f53877 49 49 SOURCES = \ 50 50 arch/$(BARCH)/src/asm.S \ 51 arch/$(BARCH)/src/eabi.S \52 51 arch/$(BARCH)/src/main.c \ 53 52 arch/$(BARCH)/src/mm.c \ -
boot/genarch/include/division.h
r90924df rd9f53877 33 33 #define BOOT_DIVISION_H_ 34 34 35 /* 32bit integer division */ 35 36 extern int __divsi3(int, int); 37 38 /* 64bit integer division */ 36 39 extern long long __divdi3(long long, long long); 37 40 41 /* 32bit unsigned integer division */ 38 42 extern unsigned int __udivsi3(unsigned int, unsigned int); 43 44 /* 64bit unsigned integer division */ 39 45 extern unsigned long long __udivdi3(unsigned long long, unsigned long long); 40 46 47 /* 32bit remainder of the signed division */ 41 48 extern int __modsi3(int, int); 49 50 /* 64bit remainder of the signed division */ 42 51 extern long long __moddi3(long long, long long); 43 52 53 /* 32bit remainder of the unsigned division */ 44 54 extern unsigned int __umodsi3(unsigned int, unsigned int); 55 56 /* 64bit remainder of the unsigned division */ 45 57 extern unsigned long long __umoddi3(unsigned long long, unsigned long long); 46 58 47 extern int __divmodsi3(int, int, int *);48 extern unsigned int __udivmodsi3(unsigned int, unsigned int, unsigned int *);49 50 extern long long __divmoddi3(long long, long long, long long *);51 59 extern unsigned long long __udivmoddi3(unsigned long long, unsigned long long, 52 60 unsigned long long *); -
boot/genarch/src/division.c
r90924df rd9f53877 73 73 { 74 74 unsigned long long result; 75 int steps = sizeof(unsigned long long) * 8; 75 int steps = sizeof(unsigned long long) * 8; 76 76 77 77 *remainder = 0; … … 104 104 105 105 /* 32bit integer division */ 106 int __divsi3(int a, int b) 106 int __divsi3(int a, int b) 107 107 { 108 108 unsigned int rem; … … 116 116 117 117 /* 64bit integer division */ 118 long long __divdi3(long long a, long long b) 118 long long __divdi3(long long a, long long b) 119 119 { 120 120 unsigned long long rem; … … 155 155 156 156 /* 64bit remainder of the signed division */ 157 long long __moddi3(long long a, longlong b)157 long long __moddi3(long long a,long long b) 158 158 { 159 159 unsigned long long rem; … … 183 183 } 184 184 185 int __divmodsi3(int a, int b, int *c)186 {187 unsigned int rem;188 int result = (int) divandmod32(ABSVAL(a), ABSVAL(b), &rem);189 190 if (SGN(a) == SGN(b)) {191 *c = rem;192 return result;193 }194 195 *c = -rem;196 return -result;197 }198 199 unsigned int __udivmodsi3(unsigned int a, unsigned int b,200 unsigned int *c)201 {202 return divandmod32(a, b, c);203 }204 205 long long __divmoddi3(long long a, long long b, long long *c)206 {207 unsigned long long rem;208 long long result = (int) divandmod64(ABSVAL(a), ABSVAL(b), &rem);209 210 if (SGN(a) == SGN(b)) {211 *c = rem;212 return result;213 }214 215 *c = -rem;216 return -result;217 }218 219 185 unsigned long long __udivmoddi3(unsigned long long a, unsigned long long b, 220 186 unsigned long long *c) -
boot/generic/src/str.c
r90924df rd9f53877 100 100 #include <str.h> 101 101 #include <errno.h> 102 103 /** Check the condition if wchar_t is signed */104 #ifdef WCHAR_IS_UNSIGNED105 #define WCHAR_SIGNED_CHECK(cond) (true)106 #else107 #define WCHAR_SIGNED_CHECK(cond) (cond)108 #endif109 102 110 103 /** Byte mask consisting of lowest @n bits (out of 8) */ … … 205 198 * code was invalid. 206 199 */ 207 int chr_encode( constwchar_t ch, char *str, size_t *offset, size_t size)200 int chr_encode(wchar_t ch, char *str, size_t *offset, size_t size) 208 201 { 209 202 if (*offset >= size) … … 332 325 bool ascii_check(wchar_t ch) 333 326 { 334 if ( WCHAR_SIGNED_CHECK(ch >= 0) && (ch <= 127))327 if ((ch >= 0) && (ch <= 127)) 335 328 return true; 336 329 … … 345 338 bool chr_check(wchar_t ch) 346 339 { 347 if ( WCHAR_SIGNED_CHECK(ch >= 0) && (ch <= 1114111))340 if ((ch >= 0) && (ch <= 1114111)) 348 341 return true; 349 342 -
kernel/arch/arm32/Makefile.inc
r90924df rd9f53877 41 41 arch/$(KARCH)/src/start.S \ 42 42 arch/$(KARCH)/src/asm.S \ 43 arch/$(KARCH)/src/eabi.S \44 43 arch/$(KARCH)/src/exc_handler.S \ 45 44 arch/$(KARCH)/src/arm32.c \ -
kernel/genarch/include/softint/division.h
r90924df rd9f53877 36 36 #define KERN_DIVISION_H_ 37 37 38 extern int __divsi3(int, int); 39 extern long long __divdi3(long long, long long);38 /* 32bit integer division */ 39 int __divsi3(int a, int b); 40 40 41 extern unsigned int __udivsi3(unsigned int, unsigned int); 42 extern unsigned long long __udivdi3(unsigned long long, unsigned long long);41 /* 64bit integer division */ 42 long long __divdi3(long long a, long long b); 43 43 44 extern int __modsi3(int, int); 45 extern long long __moddi3(long long, long long);44 /* 32bit unsigned integer division */ 45 unsigned int __udivsi3(unsigned int a, unsigned int b); 46 46 47 extern unsigned int __umodsi3(unsigned int, unsigned int); 48 extern unsigned long long __umoddi3(unsigned long long, unsigned long long);47 /* 64bit unsigned integer division */ 48 unsigned long long __udivdi3(unsigned long long a, unsigned long long b); 49 49 50 extern int __divmodsi3(int, int, int *); 51 extern unsigned int __udivmodsi3(unsigned int, unsigned int, unsigned int *);50 /* 32bit remainder of the signed division */ 51 int __modsi3(int a, int b); 52 52 53 extern long long __divmoddi3(long long, long long, long long *); 54 extern unsigned long long __udivmoddi3(unsigned long long, unsigned long long, 55 unsigned long long *); 53 /* 64bit remainder of the signed division */ 54 long long __moddi3(long long a, long long b); 55 56 /* 32bit remainder of the unsigned division */ 57 unsigned int __umodsi3(unsigned int a, unsigned int b); 58 59 /* 64bit remainder of the unsigned division */ 60 unsigned long long __umoddi3(unsigned long long a, unsigned long long b); 61 62 unsigned long long __udivmoddi3(unsigned long long a, unsigned long long b, unsigned long long *c); 56 63 57 64 #endif -
kernel/genarch/include/softint/multiplication.h
r90924df rd9f53877 29 29 /** @addtogroup genarch 30 30 * @{ 31 */ 31 */ 32 32 /** 33 33 * @file 34 34 */ 35 35 36 #ifndef KERN_MULTIPLICATION_H_37 #define KERN_MULTIPLICATION_H_36 #ifndef __SOFTINT_MULTIPLICATION_H__ 37 #define __SOFTINT_MULTIPLICATION_H__ 38 38 39 39 /* 64 bit multiplication */ 40 extern long long __muldi3(long long, long long);40 long long __muldi3(long long a, long long b); 41 41 42 42 #endif … … 44 44 /** @} 45 45 */ 46 47 -
kernel/genarch/src/softint/division.c
r90924df rd9f53877 27 27 */ 28 28 29 /** @addtogroup genarch 29 /** @addtogroup genarch 30 30 * @{ 31 31 */ … … 35 35 #include <genarch/softint/division.h> 36 36 37 #define ABSVAL(x) 38 #define SGN(x) 39 37 #define ABSVAL(x) ((x) > 0 ? (x) : -(x)) 38 #define SGN(x) ((x) >= 0 ? 1 : 0) 39 40 40 static unsigned int divandmod32(unsigned int a, unsigned int b, 41 41 unsigned int *remainder) … … 56 56 return 0; 57 57 } 58 58 59 59 for (; steps > 0; steps--) { 60 60 /* shift one bit to remainder */ … … 68 68 a <<= 1; 69 69 } 70 70 71 71 return result; 72 72 } 73 73 74 74 75 static unsigned long long divandmod64(unsigned long long a, … … 76 77 { 77 78 unsigned long long result; 78 int steps = sizeof(unsigned long long) * 8; 79 int steps = sizeof(unsigned long long) * 8; 79 80 80 81 *remainder = 0; … … 90 91 return 0; 91 92 } 92 93 93 94 for (; steps > 0; steps--) { 94 95 /* shift one bit to remainder */ … … 102 103 a <<= 1; 103 104 } 104 105 105 106 return result; 106 107 } 107 108 108 109 /* 32bit integer division */ 109 int __divsi3(int a, int b) 110 { 111 unsigned int rem; 112 int result = (int) divandmod32(ABSVAL(a), ABSVAL(b), &rem); 113 110 int __divsi3(int a, int b) 111 { 112 unsigned int rem; 113 int result; 114 115 result = (int) divandmod32(ABSVAL(a), ABSVAL(b), &rem); 116 114 117 if (SGN(a) == SGN(b)) 115 118 return result; 116 117 119 return -result; 118 120 } 119 121 120 122 /* 64bit integer division */ 121 long long __divdi3(long long a, long long b) 123 long long __divdi3(long long a, long long b) 122 124 { 123 125 unsigned long long rem; 124 long long result = (long long) divandmod64(ABSVAL(a), ABSVAL(b), &rem); 125 126 long long result; 127 128 result = (long long) divandmod64(ABSVAL(a), ABSVAL(b), &rem); 129 126 130 if (SGN(a) == SGN(b)) 127 131 return result; 128 129 132 return -result; 130 133 } … … 140 143 unsigned long long __udivdi3(unsigned long long a, unsigned long long b) 141 144 { 142 unsigned long long rem;145 unsigned long long rem; 143 146 return divandmod64(a, b, &rem); 144 147 } … … 151 154 152 155 /* if divident is negative, remainder must be too */ 153 if (!(SGN(a))) 156 if (!(SGN(a))) { 154 157 return -((int) rem); 158 } 155 159 156 160 return (int) rem; … … 158 162 159 163 /* 64bit remainder of the signed division */ 160 long long __moddi3(long long a, longlong b)164 long long __moddi3(long long a,long long b) 161 165 { 162 166 unsigned long long rem; … … 164 168 165 169 /* if divident is negative, remainder must be too */ 166 if (!(SGN(a))) 170 if (!(SGN(a))) { 167 171 return -((long long) rem); 172 } 168 173 169 174 return (long long) rem; … … 186 191 } 187 192 188 int __divmodsi3(int a, int b, int *c)189 {190 unsigned int rem;191 int result = (int) divandmod32(ABSVAL(a), ABSVAL(b), &rem);192 193 if (SGN(a) == SGN(b)) {194 *c = rem;195 return result;196 }197 198 *c = -rem;199 return -result;200 }201 202 unsigned int __udivmodsi3(unsigned int a, unsigned int b,203 unsigned int *c)204 {205 return divandmod32(a, b, c);206 }207 208 long long __divmoddi3(long long a, long long b, long long *c)209 {210 unsigned long long rem;211 long long result = (int) divandmod64(ABSVAL(a), ABSVAL(b), &rem);212 213 if (SGN(a) == SGN(b)) {214 *c = rem;215 return result;216 }217 218 *c = -rem;219 return -result;220 }221 222 193 unsigned long long __udivmoddi3(unsigned long long a, unsigned long long b, 223 194 unsigned long long *c) -
kernel/genarch/src/softint/multiplication.c
r90924df rd9f53877 29 29 /** @addtogroup genarch 30 30 * @{ 31 */ 31 */ 32 32 /** 33 33 * @file … … 130 130 131 131 return result; 132 } 132 } 133 133 134 134 /** @} -
kernel/generic/src/lib/str.c
r90924df rd9f53877 111 111 #include <debug.h> 112 112 #include <macros.h> 113 114 /** Check the condition if wchar_t is signed */115 #ifdef WCHAR_IS_UNSIGNED116 #define WCHAR_SIGNED_CHECK(cond) (true)117 #else118 #define WCHAR_SIGNED_CHECK(cond) (cond)119 #endif120 113 121 114 /** Byte mask consisting of lowest @n bits (out of 8) */ … … 213 206 * 214 207 * @return EOK if the character was encoded successfully, EOVERFLOW if there 215 * 216 * 217 */ 218 int chr_encode( constwchar_t ch, char *str, size_t *offset, size_t size)208 * was not enough space in the output buffer or EINVAL if the character 209 * code was invalid. 210 */ 211 int chr_encode(wchar_t ch, char *str, size_t *offset, size_t size) 219 212 { 220 213 if (*offset >= size) … … 434 427 bool ascii_check(wchar_t ch) 435 428 { 436 if ( WCHAR_SIGNED_CHECK(ch >= 0) && (ch <= 127))429 if ((ch >= 0) && (ch <= 127)) 437 430 return true; 438 431 … … 447 440 bool chr_check(wchar_t ch) 448 441 { 449 if ( WCHAR_SIGNED_CHECK(ch >= 0) && (ch <= 1114111))442 if ((ch >= 0) && (ch <= 1114111)) 450 443 return true; 451 444 -
tools/autotool.py
r90924df rd9f53877 49 49 50 50 PACKAGE_BINUTILS = "usually part of binutils" 51 PACKAGE_GCC = "preferably version 4. 7.0or newer"51 PACKAGE_GCC = "preferably version 4.5.1 or newer" 52 52 PACKAGE_CROSS = "use tools/toolchain.sh to build the cross-compiler toolchain" 53 53 … … 66 66 67 67 #define DECLARE_BUILTIN_TYPE(tag, type) \\ 68 AUTOTOOL_DECLARE("builtin_size", "", tag, STRING(type), "", "", sizeof(type)); \\ 69 AUTOTOOL_DECLARE("builtin_sign", "unsigned long long int", tag, STRING(type), "unsigned", "", __builtin_types_compatible_p(type, unsigned long long int)); \\ 70 AUTOTOOL_DECLARE("builtin_sign", "unsigned long int", tag, STRING(type), "unsigned", "", __builtin_types_compatible_p(type, unsigned long int)); \\ 71 AUTOTOOL_DECLARE("builtin_sign", "unsigned int", tag, STRING(type), "unsigned", "", __builtin_types_compatible_p(type, unsigned int)); \\ 72 AUTOTOOL_DECLARE("builtin_sign", "unsigned short int", tag, STRING(type), "unsigned", "", __builtin_types_compatible_p(type, unsigned short int)); \\ 73 AUTOTOOL_DECLARE("builtin_sign", "unsigned char", tag, STRING(type), "unsigned", "", __builtin_types_compatible_p(type, unsigned char)); \\ 74 AUTOTOOL_DECLARE("builtin_sign", "signed long long int", tag, STRING(type), "signed", "", __builtin_types_compatible_p(type, signed long long int)); \\ 75 AUTOTOOL_DECLARE("builtin_sign", "signed long int", tag, STRING(type), "signed", "", __builtin_types_compatible_p(type, signed long int)); \\ 76 AUTOTOOL_DECLARE("builtin_sign", "signed int", tag, STRING(type), "signed", "", __builtin_types_compatible_p(type, signed int)); \\ 77 AUTOTOOL_DECLARE("builtin_sign", "signed short int", tag, STRING(type), "signed", "", __builtin_types_compatible_p(type, signed short int)); \\ 78 AUTOTOOL_DECLARE("builtin_sign", "signed char", tag, STRING(type), "signed", "", __builtin_types_compatible_p(type, signed char)); 68 AUTOTOOL_DECLARE("builtin", "", tag, STRING(type), "", "", sizeof(type)); 79 69 80 70 #define DECLARE_INTSIZE(tag, type, strc, conc) \\ 81 71 AUTOTOOL_DECLARE("intsize", "unsigned", tag, #type, strc, conc, sizeof(unsigned type)); \\ 82 72 AUTOTOOL_DECLARE("intsize", "signed", tag, #type, strc, conc, sizeof(signed type)); 83 84 #define DECLARE_FLOATSIZE(tag, type) \\85 AUTOTOOL_DECLARE("floatsize", "", tag, #type, "", "", sizeof(type));86 73 87 74 int main(int argc, char *argv[]) … … 275 262 return int(value, base) 276 263 277 def probe_compiler(common, intsizes, floatsizes):264 def probe_compiler(common, sizes): 278 265 "Generate, compile and parse probing source" 279 266 … … 283 270 outf.write(PROBE_HEAD) 284 271 285 for typedef in intsizes:272 for typedef in sizes: 286 273 outf.write("\tDECLARE_INTSIZE(\"%s\", %s, %s, %s);\n" % (typedef['tag'], typedef['type'], typedef['strc'], typedef['conc'])) 287 288 for typedef in floatsizes:289 outf.write("\nDECLARE_FLOATSIZE(\"%s\", %s);\n" % (typedef['tag'], typedef['type']))290 274 291 275 outf.write(PROBE_TAIL) … … 331 315 signed_concs = {} 332 316 333 float_tags = {} 334 335 builtin_sizes = {} 336 builtin_signs = {} 317 builtins = {} 337 318 338 319 for j in range(len(lines)): … … 371 352 print_error(["Unexpected keyword \"%s\" in \"%s\" on line %s." % (subcategory, PROBE_OUTPUT, j), COMPILER_FAIL]) 372 353 373 if (category == " floatsize"):354 if (category == "builtin"): 374 355 try: 375 356 value_int = decode_value(value) … … 377 358 print_error(["Integer value expected in \"%s\" on line %s." % (PROBE_OUTPUT, j), COMPILER_FAIL]) 378 359 379 float_tags[tag] = value_int 380 381 if (category == "builtin_size"): 382 try: 383 value_int = decode_value(value) 384 except: 385 print_error(["Integer value expected in \"%s\" on line %s." % (PROBE_OUTPUT, j), COMPILER_FAIL]) 386 387 builtin_sizes[tag] = {'name': name, 'value': value_int} 388 389 if (category == "builtin_sign"): 390 try: 391 value_int = decode_value(value) 392 except: 393 print_error(["Integer value expected in \"%s\" on line %s." % (PROBE_OUTPUT, j), COMPILER_FAIL]) 394 395 if (value_int == 1): 396 if (not tag in builtin_signs): 397 builtin_signs[tag] = strc; 398 elif (builtin_signs[tag] != strc): 399 print_error(["Inconsistent builtin type detection in \"%s\" on line %s." % (PROBE_OUTPUT, j), COMPILER_FAIL]) 400 401 return {'unsigned_sizes': unsigned_sizes, 'signed_sizes': signed_sizes, 'unsigned_tags': unsigned_tags, 'signed_tags': signed_tags, 'unsigned_strcs': unsigned_strcs, 'signed_strcs': signed_strcs, 'unsigned_concs': unsigned_concs, 'signed_concs': signed_concs, 'float_tags': float_tags, 'builtin_sizes': builtin_sizes, 'builtin_signs': builtin_signs} 402 403 def detect_sizes(probe, bytes, inttags, floattags): 404 "Detect correct types for fixed-size types" 360 builtins[tag] = {'name': name, 'value': value_int} 361 362 return {'unsigned_sizes': unsigned_sizes, 'signed_sizes': signed_sizes, 'unsigned_tags': unsigned_tags, 'signed_tags': signed_tags, 'unsigned_strcs': unsigned_strcs, 'signed_strcs': signed_strcs, 'unsigned_concs': unsigned_concs, 'signed_concs': signed_concs, 'builtins': builtins} 363 364 def detect_uints(probe, bytes, tags): 365 "Detect correct types for fixed-size integer types" 405 366 406 367 macros = [] … … 409 370 for b in bytes: 410 371 if (not b in probe['unsigned_sizes']): 411 print_error(['Unable to find appropriate unsigned integer type for %u bytes .' % b,372 print_error(['Unable to find appropriate unsigned integer type for %u bytes' % b, 412 373 COMPILER_FAIL]) 413 374 414 375 if (not b in probe['signed_sizes']): 415 print_error(['Unable to find appropriate signed integer type for %u bytes .' % b,376 print_error(['Unable to find appropriate signed integer type for %u bytes' % b, 416 377 COMPILER_FAIL]) 417 378 418 379 if (not b in probe['unsigned_strcs']): 419 print_error(['Unable to find appropriate unsigned printf formatter for %u bytes .' % b,380 print_error(['Unable to find appropriate unsigned printf formatter for %u bytes' % b, 420 381 COMPILER_FAIL]) 421 382 422 383 if (not b in probe['signed_strcs']): 423 print_error(['Unable to find appropriate signed printf formatter for %u bytes .' % b,384 print_error(['Unable to find appropriate signed printf formatter for %u bytes' % b, 424 385 COMPILER_FAIL]) 425 386 426 387 if (not b in probe['unsigned_concs']): 427 print_error(['Unable to find appropriate unsigned literal macro for %u bytes .' % b,388 print_error(['Unable to find appropriate unsigned literal macro for %u bytes' % b, 428 389 COMPILER_FAIL]) 429 390 430 391 if (not b in probe['signed_concs']): 431 print_error(['Unable to find appropriate signed literal macro for %u bytes .' % b,392 print_error(['Unable to find appropriate signed literal macro for %u bytes' % b, 432 393 COMPILER_FAIL]) 433 394 … … 456 417 macros.append({'oldmacro': "c ## %s" % name, 'newmacro': "INT%u_C(c)" % (b * 8)}) 457 418 458 for tag in inttags:419 for tag in tags: 459 420 newmacro = "U%s" % tag 460 421 if (not tag in probe['unsigned_tags']): 461 print_error(['Unable to find appropriate size macro for %s .' % newmacro,422 print_error(['Unable to find appropriate size macro for %s' % newmacro, 462 423 COMPILER_FAIL]) 463 424 … … 465 426 macros.append({'oldmacro': "%s_MIN" % oldmacro, 'newmacro': "%s_MIN" % newmacro}) 466 427 macros.append({'oldmacro': "%s_MAX" % oldmacro, 'newmacro': "%s_MAX" % newmacro}) 467 macros.append({'oldmacro': "1", 'newmacro': 'U%s_SIZE_%s' % (tag, probe['unsigned_tags'][tag] * 8)})468 428 469 429 newmacro = tag 470 if (not tag in probe[' signed_tags']):430 if (not tag in probe['unsigned_tags']): 471 431 print_error(['Unable to find appropriate size macro for %s' % newmacro, 472 432 COMPILER_FAIL]) … … 475 435 macros.append({'oldmacro': "%s_MIN" % oldmacro, 'newmacro': "%s_MIN" % newmacro}) 476 436 macros.append({'oldmacro': "%s_MAX" % oldmacro, 'newmacro': "%s_MAX" % newmacro}) 477 macros.append({'oldmacro': "1", 'newmacro': '%s_SIZE_%s' % (tag, probe['signed_tags'][tag] * 8)})478 479 for tag in floattags:480 if (not tag in probe['float_tags']):481 print_error(['Unable to find appropriate size macro for %s' % tag,482 COMPILER_FAIL])483 484 macros.append({'oldmacro': "1", 'newmacro': '%s_SIZE_%s' % (tag, probe['float_tags'][tag] * 8)})485 486 if (not 'size' in probe['builtin_signs']):487 print_error(['Unable to determine whether size_t is signed or unsigned.',488 COMPILER_FAIL])489 490 if (probe['builtin_signs']['size'] != 'unsigned'):491 print_error(['The type size_t is not unsigned.',492 COMPILER_FAIL])493 437 494 438 fnd = True 495 439 496 if (not 'wchar' in probe['builtin _sizes']):440 if (not 'wchar' in probe['builtins']): 497 441 print_warning(['The compiler does not provide the macro __WCHAR_TYPE__', 498 442 'for defining the compiler-native type wchar_t. We are', … … 501 445 fnd = False 502 446 503 if (probe['builtin _sizes']['wchar']['value'] != 4):447 if (probe['builtins']['wchar']['value'] != 4): 504 448 print_warning(['The compiler provided macro __WCHAR_TYPE__ for defining', 505 449 'the compiler-native type wchar_t is not compliant with', … … 514 458 macros.append({'oldmacro': "__WCHAR_TYPE__", 'newmacro': "wchar_t"}) 515 459 516 if (not 'wchar' in probe['builtin_signs']):517 print_error(['Unable to determine whether wchar_t is signed or unsigned.',518 COMPILER_FAIL])519 520 if (probe['builtin_signs']['wchar'] == 'unsigned'):521 macros.append({'oldmacro': "1", 'newmacro': 'WCHAR_IS_UNSIGNED'})522 if (probe['builtin_signs']['wchar'] == 'signed'):523 macros.append({'oldmacro': "1", 'newmacro': 'WCHAR_IS_SIGNED'})524 525 460 fnd = True 526 461 527 if (not 'wint' in probe['builtin _sizes']):462 if (not 'wint' in probe['builtins']): 528 463 print_warning(['The compiler does not provide the macro __WINT_TYPE__', 529 464 'for defining the compiler-native type wint_t. We are', … … 532 467 fnd = False 533 468 534 if (probe['builtin _sizes']['wint']['value'] != 4):469 if (probe['builtins']['wint']['value'] != 4): 535 470 print_warning(['The compiler provided macro __WINT_TYPE__ for defining', 536 471 'the compiler-native type wint_t is not compliant with', … … 544 479 else: 545 480 macros.append({'oldmacro': "__WINT_TYPE__", 'newmacro': "wint_t"}) 546 547 if (not 'wint' in probe['builtin_signs']):548 print_error(['Unable to determine whether wint_t is signed or unsigned.',549 COMPILER_FAIL])550 551 if (probe['builtin_signs']['wint'] == 'unsigned'):552 macros.append({'oldmacro': "1", 'newmacro': 'WINT_IS_UNSIGNED'})553 if (probe['builtin_signs']['wint'] == 'signed'):554 macros.append({'oldmacro': "1", 'newmacro': 'WINT_IS_SIGNED'})555 481 556 482 return {'macros': macros, 'typedefs': typedefs} … … 645 571 646 572 if (config['CROSS_TARGET'] == "arm32"): 647 gnu_target = "arm-linux-gnu eabi"573 gnu_target = "arm-linux-gnu" 648 574 649 575 if (config['CROSS_TARGET'] == "ia32"): … … 660 586 if (config['PLATFORM'] == "arm32"): 661 587 target = config['PLATFORM'] 662 gnu_target = "arm-linux-gnu eabi"588 gnu_target = "arm-linux-gnu" 663 589 664 590 if (config['PLATFORM'] == "ia32"): … … 743 669 {'type': 'short int', 'tag': 'SHORT', 'strc': '"h"', 'conc': '"@"'}, 744 670 {'type': 'char', 'tag': 'CHAR', 'strc': '"hh"', 'conc': '"@@"'} 745 ],746 [747 {'type': 'long double', 'tag': 'LONG_DOUBLE'},748 {'type': 'double', 'tag': 'DOUBLE'},749 {'type': 'float', 'tag': 'FLOAT'}750 671 ] 751 672 ) 752 673 753 maps = detect_ sizes(probe, [1, 2, 4, 8], ['CHAR', 'SHORT', 'INT', 'LONG', 'LLONG'], ['LONG_DOUBLE', 'DOUBLE', 'FLOAT'])674 maps = detect_uints(probe, [1, 2, 4, 8], ['CHAR', 'SHORT', 'INT', 'LONG', 'LLONG']) 754 675 755 676 finally: -
tools/toolchain.sh
r90924df rd9f53877 55 55 BINUTILS_VERSION="2.22" 56 56 BINUTILS_RELEASE="" 57 GCC_VERSION="4. 7.0"57 GCC_VERSION="4.6.3" 58 58 GDB_VERSION="7.4" 59 59 60 60 BASEDIR="`pwd`" 61 61 BINUTILS="binutils-${BINUTILS_VERSION}${BINUTILS_RELEASE}.tar.bz2" 62 GCC="gcc-${GCC_VERSION}.tar.bz2" 62 GCC_CORE="gcc-core-${GCC_VERSION}.tar.bz2" 63 GCC_OBJC="gcc-objc-${GCC_VERSION}.tar.bz2" 64 GCC_CPP="gcc-g++-${GCC_VERSION}.tar.bz2" 63 65 GDB="gdb-${GDB_VERSION}.tar.bz2" 64 66 … … 273 275 274 276 download_fetch "${BINUTILS_SOURCE}" "${BINUTILS}" "ee0f10756c84979622b992a4a61ea3f5" 275 download_fetch "${GCC_SOURCE}" "${GCC}" "2a0f1d99fda235c29d40b561f81d9a77" 277 download_fetch "${GCC_SOURCE}" "${GCC_CORE}" "766091220c6a14fcaa2c06dd573e3758" 278 download_fetch "${GCC_SOURCE}" "${GCC_OBJC}" "48ba23770c34b1cb468f72618b4452c5" 279 download_fetch "${GCC_SOURCE}" "${GCC_CPP}" "37515158a0fb3d0800ec41a08c05e69e" 276 280 download_fetch "${GDB_SOURCE}" "${GDB}" "95a9a8305fed4d30a30a6dc28ff9d060" 277 281 } … … 295 299 echo ">>> Downloading tarballs" 296 300 source_check "${BASEDIR}/${BINUTILS}" 297 source_check "${BASEDIR}/${GCC}" 301 source_check "${BASEDIR}/${GCC_CORE}" 302 source_check "${BASEDIR}/${GCC_OBJC}" 303 source_check "${BASEDIR}/${GCC_CPP}" 298 304 source_check "${BASEDIR}/${GDB}" 299 305 … … 310 316 311 317 unpack_tarball "${BASEDIR}/${BINUTILS}" "binutils" 312 unpack_tarball "${BASEDIR}/${GCC}" "GCC" 318 unpack_tarball "${BASEDIR}/${GCC_CORE}" "GCC Core" 319 unpack_tarball "${BASEDIR}/${GCC_OBJC}" "Objective C" 320 unpack_tarball "${BASEDIR}/${GCC_CPP}" "C++" 313 321 unpack_tarball "${BASEDIR}/${GDB}" "GDB" 314 322 … … 370 378 "arm32") 371 379 prepare 372 build_target "arm32" "arm-linux-gnu eabi"380 build_target "arm32" "arm-linux-gnu" 373 381 ;; 374 382 "ia32") … … 407 415 prepare 408 416 build_target "amd64" "amd64-linux-gnu" 409 build_target "arm32" "arm-linux-gnu eabi"417 build_target "arm32" "arm-linux-gnu" 410 418 build_target "ia32" "i686-pc-linux-gnu" 411 419 build_target "ia64" "ia64-pc-linux-gnu" … … 420 428 prepare 421 429 build_target "amd64" "amd64-linux-gnu" & 422 build_target "arm32" "arm-linux-gnu eabi" &430 build_target "arm32" "arm-linux-gnu" & 423 431 build_target "ia32" "i686-pc-linux-gnu" & 424 432 build_target "ia64" "ia64-pc-linux-gnu" & -
uspace/Makefile.common
r90924df rd9f53877 149 149 endif 150 150 151 ifeq ($(STATIC_BUILD), y)152 153 154 else 155 156 157 151 ifeq ($(STATIC_BUILD), y) 152 BASE_LIBS = $(LIBC_PREFIX)/libc.a $(LIBSOFTINT_PREFIX)/libsoftint.a 153 LINKER_SCRIPT ?= $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld 154 else 155 BASE_LIBS = $(LIBC_PREFIX)/libc.so0 $(LIBSOFTINT_PREFIX)/libsofti.so0 156 LFLAGS = -Bdynamic 157 LINKER_SCRIPT ?= $(LIBC_PREFIX)/arch/$(UARCH)/_link-dlexe.ld 158 158 endif 159 159 -
uspace/app/binutils/Makefile
r90924df rd9f53877 112 112 endif 113 113 ifeq ($(PLATFORM),arm32) 114 TARGET = arm-linux-gnu eabi114 TARGET = arm-linux-gnu 115 115 endif 116 116 ifeq ($(PLATFORM),ia32) -
uspace/app/sbi/src/run_texpr.c
r90924df rd9f53877 98 98 { 99 99 stree_symbol_t *sym; 100 tdata_item_t *targ_i = NULL;101 tdata_item_t *titem = NULL;;100 tdata_item_t *targ_i; 101 tdata_item_t *titem; 102 102 tdata_object_t *tobject; 103 103 tdata_deleg_t *tdeleg; … … 139 139 return; 140 140 } 141 142 /* Make compiler happy. */ 143 titem = NULL; 141 144 142 145 switch (sym->sc) { … … 219 222 stree_tindex_t *tindex, tdata_item_t **res) 220 223 { 221 tdata_item_t *base_ti = NULL;224 tdata_item_t *base_ti; 222 225 tdata_item_t *titem; 223 226 tdata_array_t *tarray; -
uspace/app/tester/fault/fault2.c
r90924df rd9f53877 35 35 const char *test_fault2(void) 36 36 { 37 volatile long long var = 0; 38 volatile int var1 = *((aliasing_int *) (((char *) (&var)) + 1)); 37 volatile long long var; 38 volatile int var1; 39 40 var1 = *((aliasing_int *) (((char *) (&var)) + 1)); 39 41 printf("Read %d\n", var1); 40 42 -
uspace/drv/bus/usb/ehci/Makefile
r90924df rd9f53877 43 43 SOURCES = \ 44 44 main.c \ 45 res.c45 pci.c 46 46 47 47 include $(USPACE_PREFIX)/Makefile.common -
uspace/drv/bus/usb/ehci/main.c
r90924df rd9f53877 44 44 #include <usb/host/hcd.h> 45 45 46 #include " res.h"46 #include "pci.h" 47 47 48 48 #define NAME "ehci" … … 81 81 int irq = 0; 82 82 83 int ret = get_my_registers(device, ®_base, ®_size, &irq);83 int ret = pci_get_my_registers(device, ®_base, ®_size, &irq); 84 84 CHECK_RET_RETURN(ret, 85 85 "Failed to get memory addresses for %" PRIun ": %s.\n", … … 88 88 reg_base, reg_size, irq); 89 89 90 ret = disable_legacy(device, reg_base, reg_size);90 ret = pci_disable_legacy(device, reg_base, reg_size, irq); 91 91 CHECK_RET_RETURN(ret, 92 92 "Failed to disable legacy USB: %s.\n", str_error(ret)); -
uspace/drv/bus/usb/ohci/Makefile
r90924df rd9f53877 50 50 ohci_batch.c \ 51 51 ohci_endpoint.c \ 52 res.c \52 pci.c \ 53 53 root_hub.c \ 54 54 hw_struct/endpoint_descriptor.c \ -
uspace/drv/bus/usb/ohci/hw_struct/hcca.h
r90924df rd9f53877 46 46 uint16_t pad1; 47 47 uint32_t done_head; 48 uint32_t reserved[ 30];49 } hcca_t;48 uint32_t reserved[29]; 49 } __attribute__((packed, aligned)) hcca_t; 50 50 51 51 static inline void * hcca_get(void) -
uspace/drv/bus/usb/ohci/ohci.c
r90924df rd9f53877 42 42 43 43 #include "ohci.h" 44 #include " res.h"44 #include "pci.h" 45 45 #include "hc.h" 46 46 … … 180 180 int irq = 0; 181 181 182 ret = get_my_registers(device, ®_base, ®_size, &irq);182 ret = pci_get_my_registers(device, ®_base, ®_size, &irq); 183 183 CHECK_RET_DEST_FREE_RETURN(ret, 184 184 "Failed to get register memory addresses for %" PRIun ": %s.\n", … … 211 211 /* Try to enable interrupts */ 212 212 bool interrupts = false; 213 ret = enable_interrupts(device);213 ret = pci_enable_interrupts(device); 214 214 if (ret != EOK) { 215 215 usb_log_warning("Failed to enable interrupts: %s." -
uspace/drv/bus/usb/uhci/Makefile
r90924df rd9f53877 44 44 hc.c \ 45 45 main.c \ 46 res.c \46 pci.c \ 47 47 root_hub.c \ 48 48 transfer_list.c \ -
uspace/drv/bus/usb/uhci/uhci.c
r90924df rd9f53877 41 41 42 42 #include "uhci.h" 43 44 #include "res.h" 43 #include "pci.h" 44 45 45 #include "hc.h" 46 46 #include "root_hub.h" … … 49 49 * and USB root hub */ 50 50 typedef struct uhci { 51 /** Pointer to DDF represen tation of UHCI host controller */51 /** Pointer to DDF represenation of UHCI host controller */ 52 52 ddf_fun_t *hc_fun; 53 /** Pointer to DDF represen tation of UHCI root hub */53 /** Pointer to DDF represenation of UHCI root hub */ 54 54 ddf_fun_t *rh_fun; 55 55 56 /** Internal driver's represen tation of UHCI host controller */56 /** Internal driver's represenation of UHCI host controller */ 57 57 hc_t hc; 58 /** Internal driver's represen tation of UHCI root hub */58 /** Internal driver's represenation of UHCI root hub */ 59 59 rh_t rh; 60 60 } uhci_t; … … 187 187 int irq = 0; 188 188 189 ret = get_my_registers(device, ®_base, ®_size, &irq);189 ret = pci_get_my_registers(device, ®_base, ®_size, &irq); 190 190 CHECK_RET_DEST_FREE_RETURN(ret, 191 191 "Failed to get I/O addresses for %" PRIun ": %s.\n", … … 194 194 (void *) reg_base, reg_size, irq); 195 195 196 ret = disable_legacy(device);196 ret = pci_disable_legacy(device); 197 197 CHECK_RET_DEST_FREE_RETURN(ret, 198 198 "Failed to disable legacy USB: %s.\n", str_error(ret)); … … 220 220 221 221 bool interrupts = false; 222 ret = enable_interrupts(device);222 ret = pci_enable_interrupts(device); 223 223 if (ret != EOK) { 224 224 usb_log_warning("Failed to enable interrupts: %s." -
uspace/lib/c/arch/arm32/src/eabi.S
r90924df rd9f53877 1 1 # 2 # Copyright (c) 20 12 Martin Decky2 # Copyright (c) 2007 Pavel Jancik 3 3 # All rights reserved. 4 4 # … … 31 31 .global __aeabi_read_tp 32 32 33 .global __aeabi_idiv34 .global __aeabi_uidiv35 36 .global __aeabi_idivmod37 .global __aeabi_uidivmod38 39 .global __aeabi_ldivmod40 .global __aeabi_uldivmod41 42 33 __aeabi_read_tp: 43 34 mov r0, r9 44 35 mov pc, lr 45 46 __aeabi_idiv:47 push {sp, lr}48 bl __divsi349 ldr lr, [sp, #4]50 add sp, sp, #851 bx lr52 53 __aeabi_uidiv:54 push {sp, lr}55 bl __udivsi356 ldr lr, [sp, #4]57 add sp, sp, #858 bx lr59 60 __aeabi_idivmod:61 sub sp, sp, #862 push {sp, lr}63 bl __divmodsi364 ldr lr, [sp, #4]65 add sp, sp, #866 pop {r1, r2}67 bx lr68 69 __aeabi_uidivmod:70 sub sp, sp, #871 push {sp, lr}72 bl __udivmodsi373 ldr lr, [sp, #4]74 add sp, sp, #875 pop {r1, r2}76 bx lr77 78 __aeabi_ldivmod:79 sub sp, sp, #880 push {sp, lr}81 bl __divmoddi382 ldr lr, [sp, #4]83 add sp, sp, #884 pop {r2, r3}85 bx lr86 87 __aeabi_uldivmod:88 sub sp, sp, #889 push {sp, lr}90 bl __udivmoddi391 ldr lr, [sp, #4]92 add sp, sp, #893 pop {r2, r3}94 bx lr -
uspace/lib/c/generic/str.c
r90924df rd9f53877 46 46 #include <mem.h> 47 47 #include <str.h> 48 49 /** Check the condition if wchar_t is signed */50 #ifdef WCHAR_IS_UNSIGNED51 #define WCHAR_SIGNED_CHECK(cond) (true)52 #else53 #define WCHAR_SIGNED_CHECK(cond) (cond)54 #endif55 48 56 49 /** Byte mask consisting of lowest @n bits (out of 8) */ … … 406 399 bool ascii_check(wchar_t ch) 407 400 { 408 if ( WCHAR_SIGNED_CHECK(ch >= 0) && (ch <= 127))401 if ((ch >= 0) && (ch <= 127)) 409 402 return true; 410 403 … … 419 412 bool chr_check(wchar_t ch) 420 413 { 421 if ( WCHAR_SIGNED_CHECK(ch >= 0) && (ch <= 1114111))414 if ((ch >= 0) && (ch <= 1114111)) 422 415 return true; 423 416 … … 520 513 * @param count Size of the destination buffer (must be > 0). 521 514 * @param src Source string. 522 *523 515 */ 524 516 void str_cpy(char *dest, size_t size, const char *src) … … 553 545 * @param src Source string. 554 546 * @param n Maximum number of bytes to read from @a src. 555 *556 547 */ 557 548 void str_ncpy(char *dest, size_t size, const char *src, size_t n) -
uspace/lib/softfloat/Makefile
r90924df rd9f53877 29 29 30 30 USPACE_PREFIX = ../.. 31 EXTRA_CFLAGS = -Iinclude 31 EXTRA_CFLAGS = -Iinclude -Iarch/$(UARCH)/include/ 32 32 LIBRARY = libsoftfloat 33 33 -
uspace/lib/softfloat/generic/add.c
r90924df rd9f53877 39 39 #include <common.h> 40 40 41 /** Add two single-precision floats with the same sign. 41 /** 42 * Add two single-precision floats with the same signs. 42 43 * 43 44 * @param a First input operand. … … 45 46 * @return Result of addition. 46 47 */ 47 float32 add _float32(float32 a, float32 b)48 float32 addFloat32(float32 a, float32 b) 48 49 { 49 50 int expdiff; … … 52 53 expdiff = a.parts.exp - b.parts.exp; 53 54 if (expdiff < 0) { 54 if (is _float32_nan(b)) {55 /* TODO: fix SigNaN */ 56 if (is _float32_signan(b)) {55 if (isFloat32NaN(b)) { 56 /* TODO: fix SigNaN */ 57 if (isFloat32SigNaN(b)) { 57 58 } 58 59 … … 70 71 expdiff *= -1; 71 72 } else { 72 if ((is _float32_nan(a)) || (is_float32_nan(b))) {73 /* TODO: fix SigNaN */ 74 if (is _float32_signan(a) || is_float32_signan(b)) {75 } 76 return (is _float32_nan(a) ? a : b);73 if ((isFloat32NaN(a)) || (isFloat32NaN(b))) { 74 /* TODO: fix SigNaN */ 75 if (isFloat32SigNaN(a) || isFloat32SigNaN(b)) { 76 } 77 return (isFloat32NaN(a) ? a : b); 77 78 } 78 79 … … 149 150 } 150 151 151 /** Add two double-precision floats with the same sign. 152 /** 153 * Add two double-precision floats with the same signs. 152 154 * 153 155 * @param a First input operand. … … 155 157 * @return Result of addition. 156 158 */ 157 float64 add _float64(float64 a, float64 b)159 float64 addFloat64(float64 a, float64 b) 158 160 { 159 161 int expdiff; … … 163 165 expdiff = ((int) a.parts.exp) - b.parts.exp; 164 166 if (expdiff < 0) { 165 if (is _float64_nan(b)) {166 /* TODO: fix SigNaN */ 167 if (is _float64_signan(b)) {168 } 169 170 return b; 171 } 172 173 /* b is infinity and a not */ 174 if (b.parts.exp == FLOAT64_MAX_EXPONENT) { 167 if (isFloat64NaN(b)) { 168 /* TODO: fix SigNaN */ 169 if (isFloat64SigNaN(b)) { 170 } 171 172 return b; 173 } 174 175 /* b is infinity and a not */ 176 if (b.parts.exp == FLOAT64_MAX_EXPONENT) { 175 177 return b; 176 178 } … … 182 184 expdiff *= -1; 183 185 } else { 184 if (is _float64_nan(a)) {185 /* TODO: fix SigNaN */ 186 if (is _float64_signan(a) || is_float64_signan(b)) {186 if (isFloat64NaN(a)) { 187 /* TODO: fix SigNaN */ 188 if (isFloat64SigNaN(a) || isFloat64SigNaN(b)) { 187 189 } 188 190 return a; … … 263 265 } 264 266 265 /** Add two quadruple-precision floats with the same sign. 267 /** 268 * Add two quadruple-precision floats with the same signs. 266 269 * 267 270 * @param a First input operand. … … 269 272 * @return Result of addition. 270 273 */ 271 float128 add _float128(float128 a, float128 b)274 float128 addFloat128(float128 a, float128 b) 272 275 { 273 276 int expdiff; … … 277 280 expdiff = ((int) a.parts.exp) - b.parts.exp; 278 281 if (expdiff < 0) { 279 if (is _float128_nan(b)) {280 /* TODO: fix SigNaN */ 281 if (is _float128_signan(b)) {282 if (isFloat128NaN(b)) { 283 /* TODO: fix SigNaN */ 284 if (isFloat128SigNaN(b)) { 282 285 } 283 286 … … 298 301 expdiff *= -1; 299 302 } else { 300 if (is _float128_nan(a)) {301 /* TODO: fix SigNaN */ 302 if (is _float128_signan(a) || is_float128_signan(b)) {303 if (isFloat128NaN(a)) { 304 /* TODO: fix SigNaN */ 305 if (isFloat128SigNaN(a) || isFloat128SigNaN(b)) { 303 306 } 304 307 return a; -
uspace/lib/softfloat/generic/common.c
r90924df rd9f53877 66 66 * @return Finished double-precision float. 67 67 */ 68 float64 finish _float64(int32_t cexp, uint64_t cfrac, char sign)68 float64 finishFloat64(int32_t cexp, uint64_t cfrac, char sign) 69 69 { 70 70 float64 result; … … 140 140 * @return Finished quadruple-precision float. 141 141 */ 142 float128 finish _float128(int32_t cexp, uint64_t cfrac_hi, uint64_t cfrac_lo,142 float128 finishFloat128(int32_t cexp, uint64_t cfrac_hi, uint64_t cfrac_lo, 143 143 char sign, uint64_t shift_out) 144 144 { … … 238 238 * @return Number of detected leading zeroes. 239 239 */ 240 int count _zeroes8(uint8_t i)240 int countZeroes8(uint8_t i) 241 241 { 242 242 return zeroTable[i]; … … 249 249 * @return Number of detected leading zeroes. 250 250 */ 251 int count _zeroes32(uint32_t i)251 int countZeroes32(uint32_t i) 252 252 { 253 253 int j; 254 254 for (j = 0; j < 32; j += 8) { 255 255 if (i & (0xFF << (24 - j))) { 256 return (j + count _zeroes8(i >> (24 - j)));256 return (j + countZeroes8(i >> (24 - j))); 257 257 } 258 258 } … … 267 267 * @return Number of detected leading zeroes. 268 268 */ 269 int count _zeroes64(uint64_t i)269 int countZeroes64(uint64_t i) 270 270 { 271 271 int j; 272 272 for (j = 0; j < 64; j += 8) { 273 273 if (i & (0xFFll << (56 - j))) { 274 return (j + count _zeroes8(i >> (56 - j)));274 return (j + countZeroes8(i >> (56 - j))); 275 275 } 276 276 } … … 286 286 * @param fraction Fraction with hidden bit shifted to 30th bit. 287 287 */ 288 void round _float32(int32_t *exp, uint32_t *fraction)288 void roundFloat32(int32_t *exp, uint32_t *fraction) 289 289 { 290 290 /* rounding - if first bit after fraction is set then round up */ … … 312 312 * @param fraction Fraction with hidden bit shifted to 62nd bit. 313 313 */ 314 void round _float64(int32_t *exp, uint64_t *fraction)314 void roundFloat64(int32_t *exp, uint64_t *fraction) 315 315 { 316 316 /* rounding - if first bit after fraction is set then round up */ … … 339 339 * @param frac_lo Low part of fraction part with hidden bit shifted to 126th bit. 340 340 */ 341 void round _float128(int32_t *exp, uint64_t *frac_hi, uint64_t *frac_lo)341 void roundFloat128(int32_t *exp, uint64_t *frac_hi, uint64_t *frac_lo) 342 342 { 343 343 uint64_t tmp_hi, tmp_lo; -
uspace/lib/softfloat/generic/comparison.c
r90924df rd9f53877 45 45 * @return 1 if float is NaN, 0 otherwise. 46 46 */ 47 int is _float32_nan(float32 f)47 int isFloat32NaN(float32 f) 48 48 { 49 49 /* NaN : exp = 0xff and nonzero fraction */ … … 58 58 * @return 1 if float is NaN, 0 otherwise. 59 59 */ 60 int is _float64_nan(float64 d)60 int isFloat64NaN(float64 d) 61 61 { 62 62 /* NaN : exp = 0x7ff and nonzero fraction */ … … 71 71 * @return 1 if float is NaN, 0 otherwise. 72 72 */ 73 int is _float128_nan(float128 ld)73 int isFloat128NaN(float128 ld) 74 74 { 75 75 /* NaN : exp = 0x7fff and nonzero fraction */ … … 84 84 * @return 1 if float is signalling NaN, 0 otherwise. 85 85 */ 86 int is _float32_signan(float32 f)86 int isFloat32SigNaN(float32 f) 87 87 { 88 88 /* SigNaN : exp = 0xff and fraction = 0xxxxx..x (binary), … … 98 98 * @return 1 if float is signalling NaN, 0 otherwise. 99 99 */ 100 int is _float64_signan(float64 d)100 int isFloat64SigNaN(float64 d) 101 101 { 102 102 /* SigNaN : exp = 0x7ff and fraction = 0xxxxx..x (binary), … … 112 112 * @return 1 if float is signalling NaN, 0 otherwise. 113 113 */ 114 int is _float128_signan(float128 ld)114 int isFloat128SigNaN(float128 ld) 115 115 { 116 116 /* SigNaN : exp = 0x7fff and fraction = 0xxxxx..x (binary), … … 128 128 * @return 1 if float is infinite, 0 otherwise. 129 129 */ 130 int is _float32_infinity(float32 f)130 int isFloat32Infinity(float32 f) 131 131 { 132 132 /* NaN : exp = 0x7ff and zero fraction */ … … 140 140 * @return 1 if float is infinite, 0 otherwise. 141 141 */ 142 int is _float64_infinity(float64 d)142 int isFloat64Infinity(float64 d) 143 143 { 144 144 /* NaN : exp = 0x7ff and zero fraction */ … … 152 152 * @return 1 if float is infinite, 0 otherwise. 153 153 */ 154 int is _float128_infinity(float128 ld)154 int isFloat128Infinity(float128 ld) 155 155 { 156 156 /* NaN : exp = 0x7fff and zero fraction */ … … 165 165 * @return 1 if float is zero, 0 otherwise. 166 166 */ 167 int is _float32_zero(float32 f)168 { 169 return (((f.bin ) & 0x7FFFFFFF) == 0);167 int isFloat32Zero(float32 f) 168 { 169 return (((f.binary) & 0x7FFFFFFF) == 0); 170 170 } 171 171 … … 176 176 * @return 1 if float is zero, 0 otherwise. 177 177 */ 178 int is _float64_zero(float64 d)179 { 180 return (((d.bin ) & 0x7FFFFFFFFFFFFFFFll) == 0);178 int isFloat64Zero(float64 d) 179 { 180 return (((d.binary) & 0x7FFFFFFFFFFFFFFFll) == 0); 181 181 } 182 182 … … 187 187 * @return 1 if float is zero, 0 otherwise. 188 188 */ 189 int is _float128_zero(float128 ld)189 int isFloat128Zero(float128 ld) 190 190 { 191 191 uint64_t tmp_hi; 192 192 uint64_t tmp_lo; 193 194 and128(ld.bin .hi, ld.bin.lo,193 194 and128(ld.binary.hi, ld.binary.lo, 195 195 0x7FFFFFFFFFFFFFFFll, 0xFFFFFFFFFFFFFFFFll, &tmp_hi, &tmp_lo); 196 196 197 197 return eq128(tmp_hi, tmp_lo, 0x0ll, 0x0ll); 198 198 } … … 205 205 * @return 1 if both floats are equal, 0 otherwise. 206 206 */ 207 int is _float32_eq(float32 a, float32 b)207 int isFloat32eq(float32 a, float32 b) 208 208 { 209 209 /* a equals to b or both are zeros (with any sign) */ 210 return ((a.bin == b.bin) ||211 (((a.bin | b.bin) & 0x7FFFFFFF) == 0));210 return ((a.binary == b.binary) || 211 (((a.binary | b.binary) & 0x7FFFFFFF) == 0)); 212 212 } 213 213 … … 219 219 * @return 1 if both floats are equal, 0 otherwise. 220 220 */ 221 int is _float64_eq(float64 a, float64 b)221 int isFloat64eq(float64 a, float64 b) 222 222 { 223 223 /* a equals to b or both are zeros (with any sign) */ 224 return ((a.bin == b.bin) ||225 (((a.bin | b.bin) & 0x7FFFFFFFFFFFFFFFll) == 0));224 return ((a.binary == b.binary) || 225 (((a.binary | b.binary) & 0x7FFFFFFFFFFFFFFFll) == 0)); 226 226 } 227 227 … … 233 233 * @return 1 if both floats are equal, 0 otherwise. 234 234 */ 235 int is _float128_eq(float128 a, float128 b)235 int isFloat128eq(float128 a, float128 b) 236 236 { 237 237 uint64_t tmp_hi; 238 238 uint64_t tmp_lo; 239 239 240 240 /* both are zeros (with any sign) */ 241 or128(a.bin .hi, a.bin.lo,242 b.bin .hi, b.bin.lo, &tmp_hi, &tmp_lo);241 or128(a.binary.hi, a.binary.lo, 242 b.binary.hi, b.binary.lo, &tmp_hi, &tmp_lo); 243 243 and128(tmp_hi, tmp_lo, 244 244 0x7FFFFFFFFFFFFFFFll, 0xFFFFFFFFFFFFFFFFll, &tmp_hi, &tmp_lo); … … 246 246 247 247 /* a equals to b */ 248 int are_equal = eq128(a.bin .hi, a.bin.lo, b.bin.hi, b.bin.lo);249 248 int are_equal = eq128(a.binary.hi, a.binary.lo, b.binary.hi, b.binary.lo); 249 250 250 return are_equal || both_zero; 251 251 } … … 258 258 * @return 1 if a is lower than b, 0 otherwise. 259 259 */ 260 int is_float32_lt(float32 a, float32 b) 261 { 262 if (((a.bin | b.bin) & 0x7FFFFFFF) == 0) { 263 /* +- zeroes */ 264 return 0; 260 int isFloat32lt(float32 a, float32 b) 261 { 262 if (((a.binary | b.binary) & 0x7FFFFFFF) == 0) { 263 return 0; /* +- zeroes */ 265 264 } 266 265 267 266 if ((a.parts.sign) && (b.parts.sign)) { 268 267 /* if both are negative, smaller is that with greater binary value */ 269 return (a.bin > b.bin);268 return (a.binary > b.binary); 270 269 } 271 270 272 /* 273 * lets negate signs - now will be positive numbers always 274 * bigger than negative (first bit will be set for unsigned 275 * integer comparison) 276 */ 277 a.parts.sign = !a.parts.sign; 278 b.parts.sign = !b.parts.sign; 279 return (a.bin < b.bin); 271 /* lets negate signs - now will be positive numbers allways bigger than 272 * negative (first bit will be set for unsigned integer comparison) */ 273 a.parts.sign = !a.parts.sign; 274 b.parts.sign = !b.parts.sign; 275 return (a.binary < b.binary); 280 276 } 281 277 … … 287 283 * @return 1 if a is lower than b, 0 otherwise. 288 284 */ 289 int is_float64_lt(float64 a, float64 b) 290 { 291 if (((a.bin | b.bin) & 0x7FFFFFFFFFFFFFFFll) == 0) { 292 /* +- zeroes */ 293 return 0; 294 } 295 285 int isFloat64lt(float64 a, float64 b) 286 { 287 if (((a.binary | b.binary) & 0x7FFFFFFFFFFFFFFFll) == 0) { 288 return 0; /* +- zeroes */ 289 } 290 296 291 if ((a.parts.sign) && (b.parts.sign)) { 297 292 /* if both are negative, smaller is that with greater binary value */ 298 return (a.bin > b.bin); 299 } 300 301 /* 302 * lets negate signs - now will be positive numbers always 303 * bigger than negative (first bit will be set for unsigned 304 * integer comparison) 305 */ 306 a.parts.sign = !a.parts.sign; 307 b.parts.sign = !b.parts.sign; 308 return (a.bin < b.bin); 293 return (a.binary > b.binary); 294 } 295 296 /* lets negate signs - now will be positive numbers allways bigger than 297 * negative (first bit will be set for unsigned integer comparison) */ 298 a.parts.sign = !a.parts.sign; 299 b.parts.sign = !b.parts.sign; 300 return (a.binary < b.binary); 309 301 } 310 302 … … 316 308 * @return 1 if a is lower than b, 0 otherwise. 317 309 */ 318 int is _float128_lt(float128 a, float128 b)310 int isFloat128lt(float128 a, float128 b) 319 311 { 320 312 uint64_t tmp_hi; 321 313 uint64_t tmp_lo; 322 323 or128(a.bin .hi, a.bin.lo,324 b.bin .hi, b.bin.lo, &tmp_hi, &tmp_lo);314 315 or128(a.binary.hi, a.binary.lo, 316 b.binary.hi, b.binary.lo, &tmp_hi, &tmp_lo); 325 317 and128(tmp_hi, tmp_lo, 326 318 0x7FFFFFFFFFFFFFFFll, 0xFFFFFFFFFFFFFFFFll, &tmp_hi, &tmp_lo); 327 319 if (eq128(tmp_hi, tmp_lo, 0x0ll, 0x0ll)) { 328 /* +- zeroes */ 329 return 0; 330 } 331 320 return 0; /* +- zeroes */ 321 } 322 332 323 if ((a.parts.sign) && (b.parts.sign)) { 333 324 /* if both are negative, smaller is that with greater binary value */ 334 return lt128(b.bin.hi, b.bin.lo, a.bin.hi, a.bin.lo); 335 } 336 337 /* 338 * lets negate signs - now will be positive numbers always 339 * bigger than negative (first bit will be set for unsigned 340 * integer comparison) 341 */ 342 a.parts.sign = !a.parts.sign; 343 b.parts.sign = !b.parts.sign; 344 return lt128(a.bin.hi, a.bin.lo, b.bin.hi, b.bin.lo); 325 return lt128(b.binary.hi, b.binary.lo, a.binary.hi, a.binary.lo); 326 } 327 328 /* lets negate signs - now will be positive numbers allways bigger than 329 * negative (first bit will be set for unsigned integer comparison) */ 330 a.parts.sign = !a.parts.sign; 331 b.parts.sign = !b.parts.sign; 332 return lt128(a.binary.hi, a.binary.lo, b.binary.hi, b.binary.lo); 345 333 } 346 334 … … 352 340 * @return 1 if a is greater than b, 0 otherwise. 353 341 */ 354 int is_float32_gt(float32 a, float32 b) 355 { 356 if (((a.bin | b.bin) & 0x7FFFFFFF) == 0) { 357 /* zeroes are equal with any sign */ 358 return 0; 342 int isFloat32gt(float32 a, float32 b) 343 { 344 if (((a.binary | b.binary) & 0x7FFFFFFF) == 0) { 345 return 0; /* zeroes are equal with any sign */ 359 346 } 360 347 361 348 if ((a.parts.sign) && (b.parts.sign)) { 362 349 /* if both are negative, greater is that with smaller binary value */ 363 return (a.bin < b.bin);350 return (a.binary < b.binary); 364 351 } 365 352 366 /* 367 * lets negate signs - now will be positive numbers always 368 * bigger than negative (first bit will be set for unsigned 369 * integer comparison) 370 */ 371 a.parts.sign = !a.parts.sign; 372 b.parts.sign = !b.parts.sign; 373 return (a.bin > b.bin); 353 /* lets negate signs - now will be positive numbers allways bigger than 354 * negative (first bit will be set for unsigned integer comparison) */ 355 a.parts.sign = !a.parts.sign; 356 b.parts.sign = !b.parts.sign; 357 return (a.binary > b.binary); 374 358 } 375 359 … … 381 365 * @return 1 if a is greater than b, 0 otherwise. 382 366 */ 383 int is_float64_gt(float64 a, float64 b) 384 { 385 if (((a.bin | b.bin) & 0x7FFFFFFFFFFFFFFFll) == 0) { 386 /* zeroes are equal with any sign */ 387 return 0; 388 } 389 367 int isFloat64gt(float64 a, float64 b) 368 { 369 if (((a.binary | b.binary) & 0x7FFFFFFFFFFFFFFFll) == 0) { 370 return 0; /* zeroes are equal with any sign */ 371 } 372 390 373 if ((a.parts.sign) && (b.parts.sign)) { 391 374 /* if both are negative, greater is that with smaller binary value */ 392 return (a.bin < b.bin); 393 } 394 395 /* 396 * lets negate signs - now will be positive numbers always 397 * bigger than negative (first bit will be set for unsigned 398 * integer comparison) 399 */ 400 a.parts.sign = !a.parts.sign; 401 b.parts.sign = !b.parts.sign; 402 return (a.bin > b.bin); 375 return (a.binary < b.binary); 376 } 377 378 /* lets negate signs - now will be positive numbers allways bigger than 379 * negative (first bit will be set for unsigned integer comparison) */ 380 a.parts.sign = !a.parts.sign; 381 b.parts.sign = !b.parts.sign; 382 return (a.binary > b.binary); 403 383 } 404 384 … … 410 390 * @return 1 if a is greater than b, 0 otherwise. 411 391 */ 412 int is _float128_gt(float128 a, float128 b)392 int isFloat128gt(float128 a, float128 b) 413 393 { 414 394 uint64_t tmp_hi; 415 395 uint64_t tmp_lo; 416 417 or128(a.bin .hi, a.bin.lo,418 b.bin .hi, b.bin.lo, &tmp_hi, &tmp_lo);396 397 or128(a.binary.hi, a.binary.lo, 398 b.binary.hi, b.binary.lo, &tmp_hi, &tmp_lo); 419 399 and128(tmp_hi, tmp_lo, 420 400 0x7FFFFFFFFFFFFFFFll, 0xFFFFFFFFFFFFFFFFll, &tmp_hi, &tmp_lo); 421 401 if (eq128(tmp_hi, tmp_lo, 0x0ll, 0x0ll)) { 422 /* zeroes are equal with any sign */ 423 return 0; 424 } 425 402 return 0; /* zeroes are equal with any sign */ 403 } 404 426 405 if ((a.parts.sign) && (b.parts.sign)) { 427 406 /* if both are negative, greater is that with smaller binary value */ 428 return lt128(a.bin.hi, a.bin.lo, b.bin.hi, b.bin.lo); 429 } 430 431 /* 432 * lets negate signs - now will be positive numbers always 433 * bigger than negative (first bit will be set for unsigned 434 * integer comparison) 435 */ 436 a.parts.sign = !a.parts.sign; 437 b.parts.sign = !b.parts.sign; 438 return lt128(b.bin.hi, b.bin.lo, a.bin.hi, a.bin.lo); 407 return lt128(a.binary.hi, a.binary.lo, b.binary.hi, b.binary.lo); 408 } 409 410 /* lets negate signs - now will be positive numbers allways bigger than 411 * negative (first bit will be set for unsigned integer comparison) */ 412 a.parts.sign = !a.parts.sign; 413 b.parts.sign = !b.parts.sign; 414 return lt128(b.binary.hi, b.binary.lo, a.binary.hi, a.binary.lo); 439 415 } 440 416 -
uspace/lib/softfloat/generic/conversion.c
r90924df rd9f53877 39 39 #include <common.h> 40 40 41 float64 float32_to_float64(float32 a)41 float64 convertFloat32ToFloat64(float32 a) 42 42 { 43 43 float64 result; … … 48 48 result.parts.fraction <<= (FLOAT64_FRACTION_SIZE - FLOAT32_FRACTION_SIZE); 49 49 50 if ((is _float32_infinity(a)) || (is_float32_nan(a))) {50 if ((isFloat32Infinity(a)) || (isFloat32NaN(a))) { 51 51 result.parts.exp = FLOAT64_MAX_EXPONENT; 52 / / TODO; check if its correct for SigNaNs52 /* TODO; check if its correct for SigNaNs*/ 53 53 return result; 54 54 } … … 57 57 if (a.parts.exp == 0) { 58 58 /* normalize denormalized numbers */ 59 59 60 60 if (result.parts.fraction == 0) { /* fix zero */ 61 61 result.parts.exp = 0; … … 77 77 } 78 78 79 float128 float32_to_float128(float32 a)79 float128 convertFloat32ToFloat128(float32 a) 80 80 { 81 81 float128 result; 82 82 uint64_t frac_hi, frac_lo; 83 83 uint64_t tmp_hi, tmp_lo; 84 84 85 85 result.parts.sign = a.parts.sign; 86 86 result.parts.frac_hi = 0; … … 91 91 result.parts.frac_hi = frac_hi; 92 92 result.parts.frac_lo = frac_lo; 93 94 if ((is _float32_infinity(a)) || (is_float32_nan(a))) {93 94 if ((isFloat32Infinity(a)) || (isFloat32NaN(a))) { 95 95 result.parts.exp = FLOAT128_MAX_EXPONENT; 96 / / TODO; check if its correct for SigNaNs97 return result; 98 } 99 96 /* TODO; check if its correct for SigNaNs*/ 97 return result; 98 } 99 100 100 result.parts.exp = a.parts.exp + ((int) FLOAT128_BIAS - FLOAT32_BIAS); 101 101 if (a.parts.exp == 0) { 102 102 /* normalize denormalized numbers */ 103 103 104 104 if (eq128(result.parts.frac_hi, 105 105 result.parts.frac_lo, 0x0ll, 0x0ll)) { /* fix zero */ … … 107 107 return result; 108 108 } 109 109 110 110 frac_hi = result.parts.frac_hi; 111 111 frac_lo = result.parts.frac_lo; 112 112 113 113 and128(frac_hi, frac_lo, 114 114 FLOAT128_HIDDEN_BIT_MASK_HI, FLOAT128_HIDDEN_BIT_MASK_LO, … … 118 118 --result.parts.exp; 119 119 } 120 120 121 121 ++result.parts.exp; 122 122 result.parts.frac_hi = frac_hi; 123 123 result.parts.frac_lo = frac_lo; 124 124 } 125 126 return result; 127 } 128 129 float128 float64_to_float128(float64 a)125 126 return result; 127 } 128 129 float128 convertFloat64ToFloat128(float64 a) 130 130 { 131 131 float128 result; 132 132 uint64_t frac_hi, frac_lo; 133 133 uint64_t tmp_hi, tmp_lo; 134 134 135 135 result.parts.sign = a.parts.sign; 136 136 result.parts.frac_hi = 0; … … 141 141 result.parts.frac_hi = frac_hi; 142 142 result.parts.frac_lo = frac_lo; 143 144 if ((is _float64_infinity(a)) || (is_float64_nan(a))) {143 144 if ((isFloat64Infinity(a)) || (isFloat64NaN(a))) { 145 145 result.parts.exp = FLOAT128_MAX_EXPONENT; 146 / / TODO; check if its correct for SigNaNs147 return result; 148 } 149 146 /* TODO; check if its correct for SigNaNs*/ 147 return result; 148 } 149 150 150 result.parts.exp = a.parts.exp + ((int) FLOAT128_BIAS - FLOAT64_BIAS); 151 151 if (a.parts.exp == 0) { 152 152 /* normalize denormalized numbers */ 153 153 154 154 if (eq128(result.parts.frac_hi, 155 155 result.parts.frac_lo, 0x0ll, 0x0ll)) { /* fix zero */ … … 157 157 return result; 158 158 } 159 159 160 160 frac_hi = result.parts.frac_hi; 161 161 frac_lo = result.parts.frac_lo; 162 162 163 163 and128(frac_hi, frac_lo, 164 164 FLOAT128_HIDDEN_BIT_MASK_HI, FLOAT128_HIDDEN_BIT_MASK_LO, … … 168 168 --result.parts.exp; 169 169 } 170 170 171 171 ++result.parts.exp; 172 172 result.parts.frac_hi = frac_hi; 173 173 result.parts.frac_lo = frac_lo; 174 174 } 175 176 return result; 177 } 178 179 float32 float64_to_float32(float64 a)175 176 return result; 177 } 178 179 float32 convertFloat64ToFloat32(float64 a) 180 180 { 181 181 float32 result; … … 185 185 result.parts.sign = a.parts.sign; 186 186 187 if (is _float64_nan(a)) {187 if (isFloat64NaN(a)) { 188 188 result.parts.exp = FLOAT32_MAX_EXPONENT; 189 189 190 if (is _float64_signan(a)) {190 if (isFloat64SigNaN(a)) { 191 191 /* set first bit of fraction nonzero */ 192 192 result.parts.fraction = FLOAT32_HIDDEN_BIT_MASK >> 1; 193 193 return result; 194 194 } 195 195 196 196 /* fraction nonzero but its first bit is zero */ 197 197 result.parts.fraction = 0x1; 198 198 return result; 199 199 } 200 201 if (is _float64_infinity(a)) {200 201 if (isFloat64Infinity(a)) { 202 202 result.parts.fraction = 0; 203 203 result.parts.exp = FLOAT32_MAX_EXPONENT; 204 204 return result; 205 205 } 206 206 207 207 exp = (int) a.parts.exp - FLOAT64_BIAS + FLOAT32_BIAS; 208 208 … … 239 239 return result; 240 240 } 241 241 242 242 result.parts.exp = exp; 243 243 result.parts.fraction = … … 246 246 } 247 247 248 float32 float128_to_float32(float128 a)248 float32 convertFloat128ToFloat32(float128 a) 249 249 { 250 250 float32 result; 251 251 int32_t exp; 252 252 uint64_t frac_hi, frac_lo; 253 253 254 254 result.parts.sign = a.parts.sign; 255 256 if (is _float128_nan(a)) {255 256 if (isFloat128NaN(a)) { 257 257 result.parts.exp = FLOAT32_MAX_EXPONENT; 258 259 if (is _float128_signan(a)) {258 259 if (isFloat128SigNaN(a)) { 260 260 /* set first bit of fraction nonzero */ 261 261 result.parts.fraction = FLOAT32_HIDDEN_BIT_MASK >> 1; 262 262 return result; 263 263 } 264 264 265 265 /* fraction nonzero but its first bit is zero */ 266 266 result.parts.fraction = 0x1; 267 267 return result; 268 268 } 269 270 if (is _float128_infinity(a)) {269 270 if (isFloat128Infinity(a)) { 271 271 result.parts.fraction = 0; 272 272 result.parts.exp = FLOAT32_MAX_EXPONENT; 273 273 return result; 274 274 } 275 275 276 276 exp = (int) a.parts.exp - FLOAT128_BIAS + FLOAT32_BIAS; 277 277 278 278 if (exp >= FLOAT32_MAX_EXPONENT) { 279 279 /* FIXME: overflow */ … … 283 283 } else if (exp <= 0) { 284 284 /* underflow or denormalized */ 285 285 286 286 result.parts.exp = 0; 287 287 288 288 exp *= -1; 289 289 if (exp > FLOAT32_FRACTION_SIZE) { … … 292 292 return result; 293 293 } 294 294 295 295 /* denormalized */ 296 296 297 297 frac_hi = a.parts.frac_hi; 298 298 frac_lo = a.parts.frac_lo; 299 299 300 300 /* denormalize and set hidden bit */ 301 301 frac_hi |= FLOAT128_HIDDEN_BIT_MASK_HI; 302 302 303 303 rshift128(frac_hi, frac_lo, 304 304 (FLOAT128_FRACTION_SIZE - FLOAT32_FRACTION_SIZE + 1), 305 305 &frac_hi, &frac_lo); 306 306 307 307 while (exp > 0) { 308 308 --exp; … … 310 310 } 311 311 result.parts.fraction = frac_lo; 312 313 return result; 314 } 315 312 313 return result; 314 } 315 316 316 result.parts.exp = exp; 317 317 frac_hi = a.parts.frac_hi; … … 324 324 } 325 325 326 float64 float128_to_float64(float128 a)326 float64 convertFloat128ToFloat64(float128 a) 327 327 { 328 328 float64 result; 329 329 int32_t exp; 330 330 uint64_t frac_hi, frac_lo; 331 331 332 332 result.parts.sign = a.parts.sign; 333 334 if (is _float128_nan(a)) {333 334 if (isFloat128NaN(a)) { 335 335 result.parts.exp = FLOAT64_MAX_EXPONENT; 336 337 if (is _float128_signan(a)) {336 337 if (isFloat128SigNaN(a)) { 338 338 /* set first bit of fraction nonzero */ 339 339 result.parts.fraction = FLOAT64_HIDDEN_BIT_MASK >> 1; 340 340 return result; 341 341 } 342 342 343 343 /* fraction nonzero but its first bit is zero */ 344 344 result.parts.fraction = 0x1; 345 345 return result; 346 346 } 347 348 if (is _float128_infinity(a)) {347 348 if (isFloat128Infinity(a)) { 349 349 result.parts.fraction = 0; 350 350 result.parts.exp = FLOAT64_MAX_EXPONENT; 351 351 return result; 352 352 } 353 353 354 354 exp = (int) a.parts.exp - FLOAT128_BIAS + FLOAT64_BIAS; 355 355 356 356 if (exp >= FLOAT64_MAX_EXPONENT) { 357 357 /* FIXME: overflow */ … … 361 361 } else if (exp <= 0) { 362 362 /* underflow or denormalized */ 363 363 364 364 result.parts.exp = 0; 365 365 366 366 exp *= -1; 367 367 if (exp > FLOAT64_FRACTION_SIZE) { … … 370 370 return result; 371 371 } 372 372 373 373 /* denormalized */ 374 374 375 375 frac_hi = a.parts.frac_hi; 376 376 frac_lo = a.parts.frac_lo; 377 377 378 378 /* denormalize and set hidden bit */ 379 379 frac_hi |= FLOAT128_HIDDEN_BIT_MASK_HI; 380 380 381 381 rshift128(frac_hi, frac_lo, 382 382 (FLOAT128_FRACTION_SIZE - FLOAT64_FRACTION_SIZE + 1), 383 383 &frac_hi, &frac_lo); 384 384 385 385 while (exp > 0) { 386 386 --exp; … … 388 388 } 389 389 result.parts.fraction = frac_lo; 390 391 return result; 392 } 393 390 391 return result; 392 } 393 394 394 result.parts.exp = exp; 395 395 frac_hi = a.parts.frac_hi; … … 402 402 } 403 403 404 /** Helper procedure for converting float32 to uint32. 404 405 /** 406 * Helping procedure for converting float32 to uint32. 405 407 * 406 408 * @param a Floating point number in normalized form … … 422 424 /* shift fraction to left so hidden bit will be the most significant bit */ 423 425 frac <<= 32 - FLOAT32_FRACTION_SIZE - 1; 424 426 425 427 frac >>= 32 - (a.parts.exp - FLOAT32_BIAS) - 1; 426 428 if ((a.parts.sign == 1) && (frac != 0)) { … … 432 434 } 433 435 434 /* 435 * FIXME: Im not sure what to return if overflow/underflow happens 436 * 437 */ 436 /* 437 * FIXME: Im not sure what to return if overflow/underflow happens 438 * - now its the biggest or the smallest int 439 */ 438 440 uint32_t float32_to_uint32(float32 a) 439 441 { 440 if (is _float32_nan(a))442 if (isFloat32NaN(a)) 441 443 return UINT32_MAX; 442 444 443 if (is _float32_infinity(a) || (a.parts.exp >= (32 + FLOAT32_BIAS))) {445 if (isFloat32Infinity(a) || (a.parts.exp >= (32 + FLOAT32_BIAS))) { 444 446 if (a.parts.sign) 445 447 return UINT32_MIN; … … 451 453 } 452 454 453 /* 454 * FIXME: Im not sure what to return if overflow/underflow happens 455 * 456 */ 455 /* 456 * FIXME: Im not sure what to return if overflow/underflow happens 457 * - now its the biggest or the smallest int 458 */ 457 459 int32_t float32_to_int32(float32 a) 458 460 { 459 if (is _float32_nan(a))461 if (isFloat32NaN(a)) 460 462 return INT32_MAX; 461 463 462 if (is _float32_infinity(a) || (a.parts.exp >= (32 + FLOAT32_BIAS))) {464 if (isFloat32Infinity(a) || (a.parts.exp >= (32 + FLOAT32_BIAS))) { 463 465 if (a.parts.sign) 464 466 return INT32_MIN; … … 470 472 } 471 473 472 /** Helper procedure for converting float32 to uint64. 474 475 /** 476 * Helping procedure for converting float32 to uint64. 473 477 * 474 478 * @param a Floating point number in normalized form … … 479 483 { 480 484 uint64_t frac; 481 485 482 486 if (a.parts.exp < FLOAT32_BIAS) { 483 / / TODO: rounding487 /*TODO: rounding*/ 484 488 return 0; 485 489 } 486 490 487 491 frac = a.parts.fraction; 488 492 489 493 frac |= FLOAT32_HIDDEN_BIT_MASK; 490 494 /* shift fraction to left so hidden bit will be the most significant bit */ 491 495 frac <<= 64 - FLOAT32_FRACTION_SIZE - 1; 492 496 493 497 frac >>= 64 - (a.parts.exp - FLOAT32_BIAS) - 1; 494 498 if ((a.parts.sign == 1) && (frac != 0)) { … … 496 500 ++frac; 497 501 } 498 502 499 503 return frac; 500 504 } 501 505 502 /* 506 /* 503 507 * FIXME: Im not sure what to return if overflow/underflow happens 504 * 508 * - now its the biggest or the smallest int 505 509 */ 506 510 uint64_t float32_to_uint64(float32 a) 507 511 { 508 if (is _float32_nan(a))512 if (isFloat32NaN(a)) 509 513 return UINT64_MAX; 510 511 if (is_float32_infinity(a) || (a.parts.exp >= (64 + FLOAT32_BIAS))) { 514 515 516 if (isFloat32Infinity(a) || (a.parts.exp >= (64 + FLOAT32_BIAS))) { 512 517 if (a.parts.sign) 513 518 return UINT64_MIN; 514 519 515 520 return UINT64_MAX; 516 521 } 517 522 518 523 return _float32_to_uint64_helper(a); 519 524 } 520 525 521 /* 526 /* 522 527 * FIXME: Im not sure what to return if overflow/underflow happens 523 * 528 * - now its the biggest or the smallest int 524 529 */ 525 530 int64_t float32_to_int64(float32 a) 526 531 { 527 if (is _float32_nan(a))532 if (isFloat32NaN(a)) 528 533 return INT64_MAX; 529 530 if (is _float32_infinity(a) || (a.parts.exp >= (64 + FLOAT32_BIAS))) {534 535 if (isFloat32Infinity(a) || (a.parts.exp >= (64 + FLOAT32_BIAS))) { 531 536 if (a.parts.sign) 532 537 return INT64_MIN; 533 538 534 539 return INT64_MAX; 535 540 } 536 541 537 542 return _float32_to_uint64_helper(a); 538 543 } 539 544 540 /** Helper procedure for converting float64 to uint64. 545 546 /** 547 * Helping procedure for converting float64 to uint64. 541 548 * 542 549 * @param a Floating point number in normalized form … … 547 554 { 548 555 uint64_t frac; 549 556 550 557 if (a.parts.exp < FLOAT64_BIAS) { 551 / / TODO: rounding558 /*TODO: rounding*/ 552 559 return 0; 553 560 } 554 561 555 562 frac = a.parts.fraction; 556 563 557 564 frac |= FLOAT64_HIDDEN_BIT_MASK; 558 565 /* shift fraction to left so hidden bit will be the most significant bit */ 559 566 frac <<= 64 - FLOAT64_FRACTION_SIZE - 1; 560 567 561 568 frac >>= 64 - (a.parts.exp - FLOAT64_BIAS) - 1; 562 569 if ((a.parts.sign == 1) && (frac != 0)) { … … 564 571 ++frac; 565 572 } 566 573 567 574 return frac; 568 575 } … … 570 577 /* 571 578 * FIXME: Im not sure what to return if overflow/underflow happens 572 * 579 * - now its the biggest or the smallest int 573 580 */ 574 581 uint32_t float64_to_uint32(float64 a) 575 582 { 576 if (is _float64_nan(a))583 if (isFloat64NaN(a)) 577 584 return UINT32_MAX; 578 579 if (is _float64_infinity(a) || (a.parts.exp >= (32 + FLOAT64_BIAS))) {585 586 if (isFloat64Infinity(a) || (a.parts.exp >= (32 + FLOAT64_BIAS))) { 580 587 if (a.parts.sign) 581 588 return UINT32_MIN; 582 589 583 590 return UINT32_MAX; 584 591 } 585 592 586 593 return (uint32_t) _float64_to_uint64_helper(a); 587 594 } … … 589 596 /* 590 597 * FIXME: Im not sure what to return if overflow/underflow happens 591 * 598 * - now its the biggest or the smallest int 592 599 */ 593 600 int32_t float64_to_int32(float64 a) 594 601 { 595 if (is _float64_nan(a))602 if (isFloat64NaN(a)) 596 603 return INT32_MAX; 597 598 if (is _float64_infinity(a) || (a.parts.exp >= (32 + FLOAT64_BIAS))) {604 605 if (isFloat64Infinity(a) || (a.parts.exp >= (32 + FLOAT64_BIAS))) { 599 606 if (a.parts.sign) 600 607 return INT32_MIN; 601 608 602 609 return INT32_MAX; 603 610 } 604 611 605 612 return (int32_t) _float64_to_uint64_helper(a); 606 613 } 607 614 608 /* 615 616 /* 609 617 * FIXME: Im not sure what to return if overflow/underflow happens 610 * 611 */ 618 * - now its the biggest or the smallest int 619 */ 612 620 uint64_t float64_to_uint64(float64 a) 613 621 { 614 if (is _float64_nan(a))622 if (isFloat64NaN(a)) 615 623 return UINT64_MAX; 616 624 617 if (is _float64_infinity(a) || (a.parts.exp >= (64 + FLOAT64_BIAS))) {625 if (isFloat64Infinity(a) || (a.parts.exp >= (64 + FLOAT64_BIAS))) { 618 626 if (a.parts.sign) 619 627 return UINT64_MIN; … … 625 633 } 626 634 627 /* 635 /* 628 636 * FIXME: Im not sure what to return if overflow/underflow happens 629 * 630 */ 637 * - now its the biggest or the smallest int 638 */ 631 639 int64_t float64_to_int64(float64 a) 632 640 { 633 if (is _float64_nan(a))641 if (isFloat64NaN(a)) 634 642 return INT64_MAX; 635 643 636 if (is _float64_infinity(a) || (a.parts.exp >= (64 + FLOAT64_BIAS))) {644 if (isFloat64Infinity(a) || (a.parts.exp >= (64 + FLOAT64_BIAS))) { 637 645 if (a.parts.sign) 638 646 return INT64_MIN; … … 644 652 } 645 653 646 /** Helper procedure for converting float128 to uint64. 654 655 /** 656 * Helping procedure for converting float128 to uint64. 647 657 * 648 658 * @param a Floating point number in normalized form … … 653 663 { 654 664 uint64_t frac_hi, frac_lo; 655 665 656 666 if (a.parts.exp < FLOAT128_BIAS) { 657 / / TODO: rounding667 /*TODO: rounding*/ 658 668 return 0; 659 669 } 660 670 661 671 frac_hi = a.parts.frac_hi; 662 672 frac_lo = a.parts.frac_lo; 663 673 664 674 frac_hi |= FLOAT128_HIDDEN_BIT_MASK_HI; 665 675 /* shift fraction to left so hidden bit will be the most significant bit */ 666 676 lshift128(frac_hi, frac_lo, 667 677 (128 - FLOAT128_FRACTION_SIZE - 1), &frac_hi, &frac_lo); 668 678 669 679 rshift128(frac_hi, frac_lo, 670 680 (128 - (a.parts.exp - FLOAT128_BIAS) - 1), &frac_hi, &frac_lo); … … 673 683 add128(frac_hi, frac_lo, 0x0ll, 0x1ll, &frac_hi, &frac_lo); 674 684 } 675 685 676 686 return frac_lo; 677 687 } … … 679 689 /* 680 690 * FIXME: Im not sure what to return if overflow/underflow happens 681 * 691 * - now its the biggest or the smallest int 682 692 */ 683 693 uint32_t float128_to_uint32(float128 a) 684 694 { 685 if (is _float128_nan(a))695 if (isFloat128NaN(a)) 686 696 return UINT32_MAX; 687 688 if (is _float128_infinity(a) || (a.parts.exp >= (32 + FLOAT128_BIAS))) {697 698 if (isFloat128Infinity(a) || (a.parts.exp >= (32 + FLOAT128_BIAS))) { 689 699 if (a.parts.sign) 690 700 return UINT32_MIN; 691 701 692 702 return UINT32_MAX; 693 703 } 694 704 695 705 return (uint32_t) _float128_to_uint64_helper(a); 696 706 } … … 698 708 /* 699 709 * FIXME: Im not sure what to return if overflow/underflow happens 700 * 710 * - now its the biggest or the smallest int 701 711 */ 702 712 int32_t float128_to_int32(float128 a) 703 713 { 704 if (is _float128_nan(a))714 if (isFloat128NaN(a)) 705 715 return INT32_MAX; 706 707 if (is _float128_infinity(a) || (a.parts.exp >= (32 + FLOAT128_BIAS))) {716 717 if (isFloat128Infinity(a) || (a.parts.exp >= (32 + FLOAT128_BIAS))) { 708 718 if (a.parts.sign) 709 719 return INT32_MIN; 710 720 711 721 return INT32_MAX; 712 722 } 713 723 714 724 return (int32_t) _float128_to_uint64_helper(a); 715 725 } 726 716 727 717 728 /* 718 729 * FIXME: Im not sure what to return if overflow/underflow happens 719 * 730 * - now its the biggest or the smallest int 720 731 */ 721 732 uint64_t float128_to_uint64(float128 a) 722 733 { 723 if (is _float128_nan(a))734 if (isFloat128NaN(a)) 724 735 return UINT64_MAX; 725 726 if (is _float128_infinity(a) || (a.parts.exp >= (64 + FLOAT128_BIAS))) {736 737 if (isFloat128Infinity(a) || (a.parts.exp >= (64 + FLOAT128_BIAS))) { 727 738 if (a.parts.sign) 728 739 return UINT64_MIN; 729 740 730 741 return UINT64_MAX; 731 742 } 732 743 733 744 return _float128_to_uint64_helper(a); 734 745 } … … 736 747 /* 737 748 * FIXME: Im not sure what to return if overflow/underflow happens 738 * 749 * - now its the biggest or the smallest int 739 750 */ 740 751 int64_t float128_to_int64(float128 a) 741 752 { 742 if (is _float128_nan(a))753 if (isFloat128NaN(a)) 743 754 return INT64_MAX; 744 745 if (is _float128_infinity(a) || (a.parts.exp >= (64 + FLOAT128_BIAS))) {755 756 if (isFloat128Infinity(a) || (a.parts.exp >= (64 + FLOAT128_BIAS))) { 746 757 if (a.parts.sign) 747 758 return INT64_MIN; 748 759 749 760 return INT64_MAX; 750 761 } 751 762 752 763 return _float128_to_uint64_helper(a); 753 764 } 765 754 766 755 767 float32 uint32_to_float32(uint32_t i) … … 761 773 result.parts.sign = 0; 762 774 result.parts.fraction = 0; 763 764 counter = count _zeroes32(i);765 775 776 counter = countZeroes32(i); 777 766 778 exp = FLOAT32_BIAS + 32 - counter - 1; 767 779 768 780 if (counter == 32) { 769 result.bin = 0;781 result.binary = 0; 770 782 return result; 771 783 } … … 776 788 i >>= 1; 777 789 } 778 779 round _float32(&exp, &i);780 790 791 roundFloat32(&exp, &i); 792 781 793 result.parts.fraction = i >> (32 - FLOAT32_FRACTION_SIZE - 2); 782 794 result.parts.exp = exp; 783 784 return result; 785 } 786 787 float32 int32_to_float32(int32_t i) 795 796 return result; 797 } 798 799 float32 int32_to_float32(int32_t i) 788 800 { 789 801 float32 result; 790 791 if (i < 0) 802 803 if (i < 0) { 792 804 result = uint32_to_float32((uint32_t) (-i)); 793 else805 } else { 794 806 result = uint32_to_float32((uint32_t) i); 807 } 795 808 796 809 result.parts.sign = i < 0; 797 798 return result; 799 } 800 801 float32 uint64_to_float32(uint64_t i) 810 811 return result; 812 } 813 814 815 float32 uint64_to_float32(uint64_t i) 802 816 { 803 817 int counter; … … 808 822 result.parts.sign = 0; 809 823 result.parts.fraction = 0; 810 811 counter = count _zeroes64(i);812 824 825 counter = countZeroes64(i); 826 813 827 exp = FLOAT32_BIAS + 64 - counter - 1; 814 828 815 829 if (counter == 64) { 816 result.bin = 0;830 result.binary = 0; 817 831 return result; 818 832 } … … 826 840 827 841 j = (uint32_t) i; 828 round _float32(&exp, &j);829 842 roundFloat32(&exp, &j); 843 830 844 result.parts.fraction = j >> (32 - FLOAT32_FRACTION_SIZE - 2); 831 845 result.parts.exp = exp; … … 833 847 } 834 848 835 float32 int64_to_float32(int64_t i) 849 float32 int64_to_float32(int64_t i) 836 850 { 837 851 float32 result; 838 839 if (i < 0) 852 853 if (i < 0) { 840 854 result = uint64_to_float32((uint64_t) (-i)); 841 else855 } else { 842 856 result = uint64_to_float32((uint64_t) i); 857 } 843 858 844 859 result.parts.sign = i < 0; 845 846 return result;860 861 return result; 847 862 } 848 863 … … 856 871 result.parts.sign = 0; 857 872 result.parts.fraction = 0; 858 859 counter = count _zeroes32(i);860 873 874 counter = countZeroes32(i); 875 861 876 exp = FLOAT64_BIAS + 32 - counter - 1; 862 877 863 878 if (counter == 32) { 864 result.bin = 0;879 result.binary = 0; 865 880 return result; 866 881 } 867 882 868 883 frac = i; 869 frac <<= counter + 32 - 1; 870 871 round _float64(&exp, &frac);872 884 frac <<= counter + 32 - 1; 885 886 roundFloat64(&exp, &frac); 887 873 888 result.parts.fraction = frac >> (64 - FLOAT64_FRACTION_SIZE - 2); 874 889 result.parts.exp = exp; 875 876 return result; 877 } 878 879 float64 int32_to_float64(int32_t i) 890 891 return result; 892 } 893 894 float64 int32_to_float64(int32_t i) 880 895 { 881 896 float64 result; 882 883 if (i < 0) 897 898 if (i < 0) { 884 899 result = uint32_to_float64((uint32_t) (-i)); 885 else900 } else { 886 901 result = uint32_to_float64((uint32_t) i); 902 } 887 903 888 904 result.parts.sign = i < 0; 889 890 return result;891 } 892 893 894 float64 uint64_to_float64(uint64_t i) 905 906 return result; 907 } 908 909 910 float64 uint64_to_float64(uint64_t i) 895 911 { 896 912 int counter; … … 900 916 result.parts.sign = 0; 901 917 result.parts.fraction = 0; 902 903 counter = count _zeroes64(i);904 918 919 counter = countZeroes64(i); 920 905 921 exp = FLOAT64_BIAS + 64 - counter - 1; 906 922 907 923 if (counter == 64) { 908 result.bin = 0;924 result.binary = 0; 909 925 return result; 910 926 } … … 915 931 i >>= 1; 916 932 } 917 918 round _float64(&exp, &i);919 933 934 roundFloat64(&exp, &i); 935 920 936 result.parts.fraction = i >> (64 - FLOAT64_FRACTION_SIZE - 2); 921 937 result.parts.exp = exp; … … 923 939 } 924 940 925 float64 int64_to_float64(int64_t i) 941 float64 int64_to_float64(int64_t i) 926 942 { 927 943 float64 result; 928 929 if (i < 0) 944 945 if (i < 0) { 930 946 result = uint64_to_float64((uint64_t) (-i)); 931 else947 } else { 932 948 result = uint64_to_float64((uint64_t) i); 949 } 933 950 934 951 result.parts.sign = i < 0; 935 936 return result; 937 } 952 953 return result; 954 } 955 938 956 939 957 float128 uint32_to_float128(uint32_t i) … … 943 961 float128 result; 944 962 uint64_t frac_hi, frac_lo; 945 963 946 964 result.parts.sign = 0; 947 965 result.parts.frac_hi = 0; 948 966 result.parts.frac_lo = 0; 949 950 counter = count _zeroes32(i);951 967 968 counter = countZeroes32(i); 969 952 970 exp = FLOAT128_BIAS + 32 - counter - 1; 953 971 954 972 if (counter == 32) { 955 result.bin .hi = 0;956 result.bin .lo = 0;957 return result; 958 } 959 973 result.binary.hi = 0; 974 result.binary.lo = 0; 975 return result; 976 } 977 960 978 frac_hi = 0; 961 979 frac_lo = i; 962 980 lshift128(frac_hi, frac_lo, (counter + 96 - 1), &frac_hi, &frac_lo); 963 964 round _float128(&exp, &frac_hi, &frac_lo);965 981 982 roundFloat128(&exp, &frac_hi, &frac_lo); 983 966 984 rshift128(frac_hi, frac_lo, 967 985 (128 - FLOAT128_FRACTION_SIZE - 2), &frac_hi, &frac_lo); … … 969 987 result.parts.frac_lo = frac_lo; 970 988 result.parts.exp = exp; 971 989 972 990 return result; 973 991 } … … 976 994 { 977 995 float128 result; 978 979 if (i < 0) 996 997 if (i < 0) { 980 998 result = uint32_to_float128((uint32_t) (-i)); 981 else999 } else { 982 1000 result = uint32_to_float128((uint32_t) i); 983 1001 } 1002 984 1003 result.parts.sign = i < 0; 985 986 return result;1004 1005 return result; 987 1006 } 988 1007 … … 994 1013 float128 result; 995 1014 uint64_t frac_hi, frac_lo; 996 1015 997 1016 result.parts.sign = 0; 998 1017 result.parts.frac_hi = 0; 999 1018 result.parts.frac_lo = 0; 1000 1001 counter = count _zeroes64(i);1002 1019 1020 counter = countZeroes64(i); 1021 1003 1022 exp = FLOAT128_BIAS + 64 - counter - 1; 1004 1023 1005 1024 if (counter == 64) { 1006 result.bin .hi = 0;1007 result.bin .lo = 0;1008 return result; 1009 } 1010 1025 result.binary.hi = 0; 1026 result.binary.lo = 0; 1027 return result; 1028 } 1029 1011 1030 frac_hi = 0; 1012 1031 frac_lo = i; 1013 1032 lshift128(frac_hi, frac_lo, (counter + 64 - 1), &frac_hi, &frac_lo); 1014 1015 round _float128(&exp, &frac_hi, &frac_lo);1016 1033 1034 roundFloat128(&exp, &frac_hi, &frac_lo); 1035 1017 1036 rshift128(frac_hi, frac_lo, 1018 1037 (128 - FLOAT128_FRACTION_SIZE - 2), &frac_hi, &frac_lo); … … 1020 1039 result.parts.frac_lo = frac_lo; 1021 1040 result.parts.exp = exp; 1022 1041 1023 1042 return result; 1024 1043 } … … 1027 1046 { 1028 1047 float128 result; 1029 1030 if (i < 0) 1048 1049 if (i < 0) { 1031 1050 result = uint64_to_float128((uint64_t) (-i)); 1032 else1051 } else { 1033 1052 result = uint64_to_float128((uint64_t) i); 1034 1053 } 1054 1035 1055 result.parts.sign = i < 0; 1036 1037 return result;1056 1057 return result; 1038 1058 } 1039 1059 -
uspace/lib/softfloat/generic/div.c
r90924df rd9f53877 41 41 #include <common.h> 42 42 43 /** Divide two single-precision floats. 44 * 43 /** 44 * Divide two single-precision floats. 45 * 45 46 * @param a Nominator. 46 47 * @param b Denominator. 47 *48 48 * @return Result of division. 49 * 50 */ 51 float32 div_float32(float32 a, float32 b) 49 */ 50 float32 divFloat32(float32 a, float32 b) 52 51 { 53 52 float32 result; … … 57 56 result.parts.sign = a.parts.sign ^ b.parts.sign; 58 57 59 if (is _float32_nan(a)) {60 if (is _float32_signan(a)) {61 / / FIXME: SigNaN62 } 63 /* NaN*/58 if (isFloat32NaN(a)) { 59 if (isFloat32SigNaN(a)) { 60 /*FIXME: SigNaN*/ 61 } 62 /*NaN*/ 64 63 return a; 65 64 } 66 65 67 if (is _float32_nan(b)) {68 if (is _float32_signan(b)) {69 / / FIXME: SigNaN70 } 71 /* NaN*/66 if (isFloat32NaN(b)) { 67 if (isFloat32SigNaN(b)) { 68 /*FIXME: SigNaN*/ 69 } 70 /*NaN*/ 72 71 return b; 73 72 } 74 73 75 if (is _float32_infinity(a)) {76 if (is _float32_infinity(b)) {74 if (isFloat32Infinity(a)) { 75 if (isFloat32Infinity(b)) { 77 76 /*FIXME: inf / inf */ 78 result.bin = FLOAT32_NAN;77 result.binary = FLOAT32_NAN; 79 78 return result; 80 79 } … … 84 83 return result; 85 84 } 86 87 if (is _float32_infinity(b)) {88 if (is _float32_zero(a)) {85 86 if (isFloat32Infinity(b)) { 87 if (isFloat32Zero(a)) { 89 88 /* FIXME 0 / inf */ 90 89 result.parts.exp = 0; … … 98 97 } 99 98 100 if (is _float32_zero(b)) {101 if (is _float32_zero(a)) {99 if (isFloat32Zero(b)) { 100 if (isFloat32Zero(a)) { 102 101 /*FIXME: 0 / 0*/ 103 result.bin = FLOAT32_NAN;102 result.binary = FLOAT32_NAN; 104 103 return result; 105 104 } … … 122 121 return result; 123 122 } 124 123 125 124 /* normalize it*/ 126 125 afrac <<= 1; 127 /* afrac is nonzero => it must stop */ 126 /* afrac is nonzero => it must stop */ 128 127 while (!(afrac & FLOAT32_HIDDEN_BIT_MASK)) { 129 128 afrac <<= 1; … … 131 130 } 132 131 } 133 132 134 133 if (bexp == 0) { 135 134 bfrac <<= 1; 136 /* bfrac is nonzero => it must stop */ 135 /* bfrac is nonzero => it must stop */ 137 136 while (!(bfrac & FLOAT32_HIDDEN_BIT_MASK)) { 138 137 bfrac <<= 1; … … 140 139 } 141 140 } 142 143 afrac = 144 bfrac = 145 141 142 afrac = (afrac | FLOAT32_HIDDEN_BIT_MASK) << (32 - FLOAT32_FRACTION_SIZE - 1); 143 bfrac = (bfrac | FLOAT32_HIDDEN_BIT_MASK) << (32 - FLOAT32_FRACTION_SIZE); 144 146 145 if (bfrac <= (afrac << 1)) { 147 146 afrac >>= 1; … … 170 169 ++cexp; 171 170 cfrac >>= 1; 172 } 173 171 } 172 174 173 /* check overflow */ 175 174 if (cexp >= FLOAT32_MAX_EXPONENT) { … … 179 178 return result; 180 179 } 181 180 182 181 if (cexp < 0) { 183 182 /* FIXME: underflow */ … … 191 190 cexp++; 192 191 cfrac >>= 1; 193 } 192 } 194 193 } else { 195 194 result.parts.exp = (uint32_t) cexp; … … 198 197 result.parts.fraction = ((cfrac >> 6) & (~FLOAT32_HIDDEN_BIT_MASK)); 199 198 200 return result; 199 return result; 201 200 } 202 201 203 /** Divide two double-precision floats. 202 /** 203 * Divide two double-precision floats. 204 204 * 205 205 * @param a Nominator. 206 206 * @param b Denominator. 207 *208 207 * @return Result of division. 209 * 210 */ 211 float64 div_float64(float64 a, float64 b) 208 */ 209 float64 divFloat64(float64 a, float64 b) 212 210 { 213 211 float64 result; … … 219 217 result.parts.sign = a.parts.sign ^ b.parts.sign; 220 218 221 if (is _float64_nan(a)) {222 if (is _float64_signan(b)) {223 / / FIXME: SigNaN219 if (isFloat64NaN(a)) { 220 if (isFloat64SigNaN(b)) { 221 /*FIXME: SigNaN*/ 224 222 return b; 225 223 } 226 224 227 if (is _float64_signan(a)) {228 / / FIXME: SigNaN229 } 230 /* NaN*/225 if (isFloat64SigNaN(a)) { 226 /*FIXME: SigNaN*/ 227 } 228 /*NaN*/ 231 229 return a; 232 230 } 233 231 234 if (is _float64_nan(b)) {235 if (is _float64_signan(b)) {236 / / FIXME: SigNaN237 } 238 /* NaN*/232 if (isFloat64NaN(b)) { 233 if (isFloat64SigNaN(b)) { 234 /*FIXME: SigNaN*/ 235 } 236 /*NaN*/ 239 237 return b; 240 238 } 241 239 242 if (is _float64_infinity(a)) {243 if (is _float64_infinity(b) || is_float64_zero(b)) {244 / / FIXME: inf / inf245 result.bin = FLOAT64_NAN;240 if (isFloat64Infinity(a)) { 241 if (isFloat64Infinity(b) || isFloat64Zero(b)) { 242 /*FIXME: inf / inf */ 243 result.binary = FLOAT64_NAN; 246 244 return result; 247 245 } … … 251 249 return result; 252 250 } 253 254 if (is _float64_infinity(b)) {255 if (is _float64_zero(a)) {251 252 if (isFloat64Infinity(b)) { 253 if (isFloat64Zero(a)) { 256 254 /* FIXME 0 / inf */ 257 255 result.parts.exp = 0; … … 265 263 } 266 264 267 if (is _float64_zero(b)) {268 if (is _float64_zero(a)) {265 if (isFloat64Zero(b)) { 266 if (isFloat64Zero(a)) { 269 267 /*FIXME: 0 / 0*/ 270 result.bin = FLOAT64_NAN;268 result.binary = FLOAT64_NAN; 271 269 return result; 272 270 } … … 276 274 return result; 277 275 } 278 276 279 277 afrac = a.parts.fraction; 280 278 aexp = a.parts.exp; … … 289 287 return result; 290 288 } 291 289 292 290 /* normalize it*/ 293 291 aexp++; … … 298 296 } 299 297 } 300 298 301 299 if (bexp == 0) { 302 300 bexp++; … … 307 305 } 308 306 } 309 310 afrac = 311 bfrac = 312 307 308 afrac = (afrac | FLOAT64_HIDDEN_BIT_MASK) << (64 - FLOAT64_FRACTION_SIZE - 2); 309 bfrac = (bfrac | FLOAT64_HIDDEN_BIT_MASK) << (64 - FLOAT64_FRACTION_SIZE - 1); 310 313 311 if (bfrac <= (afrac << 1)) { 314 312 afrac >>= 1; … … 332 330 333 331 /* round and shift */ 334 result = finish _float64(cexp, cfrac, result.parts.sign);332 result = finishFloat64(cexp, cfrac, result.parts.sign); 335 333 return result; 336 334 } 337 335 338 /** Divide two quadruple-precision floats. 336 /** 337 * Divide two quadruple-precision floats. 339 338 * 340 339 * @param a Nominator. 341 340 * @param b Denominator. 342 *343 341 * @return Result of division. 344 * 345 */ 346 float128 div_float128(float128 a, float128 b) 342 */ 343 float128 divFloat128(float128 a, float128 b) 347 344 { 348 345 float128 result; … … 352 349 uint64_t rem_hihi, rem_hilo, rem_lohi, rem_lolo; 353 350 uint64_t tmp_hihi, tmp_hilo, tmp_lohi, tmp_lolo; 354 351 355 352 result.parts.sign = a.parts.sign ^ b.parts.sign; 356 357 if (is _float128_nan(a)) {358 if (is _float128_signan(b)) {359 / / FIXME: SigNaN353 354 if (isFloat128NaN(a)) { 355 if (isFloat128SigNaN(b)) { 356 /*FIXME: SigNaN*/ 360 357 return b; 361 358 } 362 363 if (is _float128_signan(a)) {364 / / FIXME: SigNaN365 } 366 /* NaN*/359 360 if (isFloat128SigNaN(a)) { 361 /*FIXME: SigNaN*/ 362 } 363 /*NaN*/ 367 364 return a; 368 365 } 369 370 if (is _float128_nan(b)) {371 if (is _float128_signan(b)) {372 / / FIXME: SigNaN373 } 374 /* NaN*/366 367 if (isFloat128NaN(b)) { 368 if (isFloat128SigNaN(b)) { 369 /*FIXME: SigNaN*/ 370 } 371 /*NaN*/ 375 372 return b; 376 373 } 377 378 if (is _float128_infinity(a)) {379 if (is _float128_infinity(b) || is_float128_zero(b)) {380 / / FIXME: inf / inf381 result.bin .hi = FLOAT128_NAN_HI;382 result.bin .lo = FLOAT128_NAN_LO;374 375 if (isFloat128Infinity(a)) { 376 if (isFloat128Infinity(b) || isFloat128Zero(b)) { 377 /*FIXME: inf / inf */ 378 result.binary.hi = FLOAT128_NAN_HI; 379 result.binary.lo = FLOAT128_NAN_LO; 383 380 return result; 384 381 } … … 389 386 return result; 390 387 } 391 392 if (is _float128_infinity(b)) {393 if (is _float128_zero(a)) {394 / / FIXME 0 / inf388 389 if (isFloat128Infinity(b)) { 390 if (isFloat128Zero(a)) { 391 /* FIXME 0 / inf */ 395 392 result.parts.exp = 0; 396 393 result.parts.frac_hi = 0; … … 398 395 return result; 399 396 } 400 / / FIXME: num / inf397 /* FIXME: num / inf*/ 401 398 result.parts.exp = 0; 402 399 result.parts.frac_hi = 0; … … 404 401 return result; 405 402 } 406 407 if (is _float128_zero(b)) {408 if (is _float128_zero(a)) {409 / / FIXME: 0 / 0410 result.bin .hi = FLOAT128_NAN_HI;411 result.bin .lo = FLOAT128_NAN_LO;412 return result; 413 } 414 / / FIXME: division by zero403 404 if (isFloat128Zero(b)) { 405 if (isFloat128Zero(a)) { 406 /*FIXME: 0 / 0*/ 407 result.binary.hi = FLOAT128_NAN_HI; 408 result.binary.lo = FLOAT128_NAN_LO; 409 return result; 410 } 411 /* FIXME: division by zero */ 415 412 result.parts.exp = 0; 416 413 result.parts.frac_hi = 0; … … 418 415 return result; 419 416 } 420 417 421 418 afrac_hi = a.parts.frac_hi; 422 419 afrac_lo = a.parts.frac_lo; … … 425 422 bfrac_lo = b.parts.frac_lo; 426 423 bexp = b.parts.exp; 427 424 428 425 /* denormalized numbers */ 429 426 if (aexp == 0) { … … 434 431 return result; 435 432 } 436 433 437 434 /* normalize it*/ 438 435 aexp++; … … 446 443 } 447 444 } 448 445 449 446 if (bexp == 0) { 450 447 bexp++; … … 458 455 } 459 456 } 460 457 461 458 or128(afrac_hi, afrac_lo, 462 459 FLOAT128_HIDDEN_BIT_MASK_HI, FLOAT128_HIDDEN_BIT_MASK_LO, … … 469 466 lshift128(bfrac_hi, bfrac_lo, 470 467 (128 - FLOAT128_FRACTION_SIZE - 1), &bfrac_hi, &bfrac_lo); 471 468 472 469 if (le128(bfrac_hi, bfrac_lo, afrac_hi, afrac_lo)) { 473 470 rshift128(afrac_hi, afrac_lo, 1, &afrac_hi, &afrac_lo); 474 471 aexp++; 475 472 } 476 473 477 474 cexp = aexp - bexp + FLOAT128_BIAS - 2; 478 475 479 476 cfrac_hi = div128est(afrac_hi, afrac_lo, bfrac_hi); 480 477 481 478 mul128(bfrac_hi, bfrac_lo, 0x0ll, cfrac_hi, 482 479 &tmp_lolo /* dummy */, &tmp_hihi, &tmp_hilo, &tmp_lohi); 483 484 /* sub192(afrac_hi, afrac_lo, 0, 480 481 /* sub192(afrac_hi, afrac_lo, 0, 485 482 * tmp_hihi, tmp_hilo, tmp_lohi 486 483 * &rem_hihi, &rem_hilo, &rem_lohi); */ … … 490 487 } 491 488 rem_lohi = -tmp_lohi; 492 489 493 490 while ((int64_t) rem_hihi < 0) { 494 491 --cfrac_hi; 495 /* add192(rem_hihi, rem_hilo, rem_lohi, 492 /* add192(rem_hihi, rem_hilo, rem_lohi, 496 493 * 0, bfrac_hi, bfrac_lo, 497 494 * &rem_hihi, &rem_hilo, &rem_lohi); */ … … 501 498 } 502 499 } 503 500 504 501 cfrac_lo = div128est(rem_hilo, rem_lohi, bfrac_lo); 505 502 506 503 if ((cfrac_lo & 0x3FFF) <= 4) { 507 504 mul128(bfrac_hi, bfrac_lo, 0x0ll, cfrac_lo, 508 509 505 &tmp_hihi /* dummy */, &tmp_hilo, &tmp_lohi, &tmp_lolo); 506 510 507 /* sub192(rem_hilo, rem_lohi, 0, 511 508 * tmp_hilo, tmp_lohi, tmp_lolo, … … 516 513 } 517 514 rem_lolo = -tmp_lolo; 518 515 519 516 while ((int64_t) rem_hilo < 0) { 520 517 --cfrac_lo; … … 527 524 } 528 525 } 529 526 530 527 cfrac_lo |= ((rem_hilo | rem_lohi | rem_lolo) != 0 ); 531 528 } 532 529 533 530 shift_out = cfrac_lo << (64 - (128 - FLOAT128_FRACTION_SIZE - 1)); 534 531 rshift128(cfrac_hi, cfrac_lo, (128 - FLOAT128_FRACTION_SIZE - 1), 535 532 &cfrac_hi, &cfrac_lo); 536 537 result = finish _float128(cexp, cfrac_hi, cfrac_lo, result.parts.sign, shift_out);533 534 result = finishFloat128(cexp, cfrac_hi, cfrac_lo, result.parts.sign, shift_out); 538 535 return result; 539 536 } -
uspace/lib/softfloat/generic/mul.c
r90924df rd9f53877 39 39 #include <common.h> 40 40 41 /** Multiply two single-precision floats. 41 /** 42 * Multiply two single-precision floats. 42 43 * 43 44 * @param a First input operand. 44 45 * @param b Second input operand. 45 *46 46 * @return Result of multiplication. 47 * 48 */ 49 float32 mul_float32(float32 a, float32 b) 47 */ 48 float32 mulFloat32(float32 a, float32 b) 50 49 { 51 50 float32 result; 52 51 uint64_t frac1, frac2; 53 52 int32_t exp; 54 53 55 54 result.parts.sign = a.parts.sign ^ b.parts.sign; 56 55 57 if (is _float32_nan(a) || is_float32_nan(b)) {56 if (isFloat32NaN(a) || isFloat32NaN(b)) { 58 57 /* TODO: fix SigNaNs */ 59 if (is _float32_signan(a)) {58 if (isFloat32SigNaN(a)) { 60 59 result.parts.fraction = a.parts.fraction; 61 60 result.parts.exp = a.parts.exp; 62 61 return result; 63 62 } 64 if (is _float32_signan(b)) { /* TODO: fix SigNaN */63 if (isFloat32SigNaN(b)) { /* TODO: fix SigNaN */ 65 64 result.parts.fraction = b.parts.fraction; 66 65 result.parts.exp = b.parts.exp; … … 68 67 } 69 68 /* set NaN as result */ 70 result.bin = FLOAT32_NAN;71 return result; 72 } 73 74 if (is _float32_infinity(a)) {75 if (is _float32_zero(b)) {76 /* FIXME: zero * infinity */ 77 result.bin = FLOAT32_NAN;69 result.binary = FLOAT32_NAN; 70 return result; 71 } 72 73 if (isFloat32Infinity(a)) { 74 if (isFloat32Zero(b)) { 75 /* FIXME: zero * infinity */ 76 result.binary = FLOAT32_NAN; 78 77 return result; 79 78 } … … 82 81 return result; 83 82 } 84 85 if (is _float32_infinity(b)) {86 if (is _float32_zero(a)) {87 /* FIXME: zero * infinity */ 88 result.bin = FLOAT32_NAN;83 84 if (isFloat32Infinity(b)) { 85 if (isFloat32Zero(a)) { 86 /* FIXME: zero * infinity */ 87 result.binary = FLOAT32_NAN; 89 88 return result; 90 89 } … … 93 92 return result; 94 93 } 95 94 96 95 /* exp is signed so we can easy detect underflow */ 97 96 exp = a.parts.exp + b.parts.exp; … … 101 100 /* FIXME: overflow */ 102 101 /* set infinity as result */ 103 result.bin = FLOAT32_INF;102 result.binary = FLOAT32_INF; 104 103 result.parts.sign = a.parts.sign ^ b.parts.sign; 105 104 return result; … … 122 121 123 122 frac2 = b.parts.fraction; 124 123 125 124 if (b.parts.exp > 0) { 126 125 frac2 |= FLOAT32_HIDDEN_BIT_MASK; … … 128 127 ++exp; 129 128 } 130 129 131 130 frac1 <<= 1; /* one bit space for rounding */ 132 131 133 132 frac1 = frac1 * frac2; 134 133 135 134 /* round and return */ 136 while ((exp < FLOAT32_MAX_EXPONENT) && 137 (frac1 >= (1 << (FLOAT32_FRACTION_SIZE + 2)))) { 135 while ((exp < FLOAT32_MAX_EXPONENT) && (frac1 >= (1 << (FLOAT32_FRACTION_SIZE + 2)))) { 138 136 /* 23 bits of fraction + one more for hidden bit (all shifted 1 bit left) */ 139 137 ++exp; 140 138 frac1 >>= 1; 141 139 } 142 140 143 141 /* rounding */ 144 142 /* ++frac1; FIXME: not works - without it is ok */ 145 143 frac1 >>= 1; /* shift off rounding space */ 146 144 147 if ((exp < FLOAT32_MAX_EXPONENT) && 148 (frac1 >= (1 << (FLOAT32_FRACTION_SIZE + 1)))) { 145 if ((exp < FLOAT32_MAX_EXPONENT) && (frac1 >= (1 << (FLOAT32_FRACTION_SIZE + 1)))) { 149 146 ++exp; 150 147 frac1 >>= 1; 151 148 } 152 153 if (exp >= FLOAT32_MAX_EXPONENT) { 149 150 if (exp >= FLOAT32_MAX_EXPONENT) { 154 151 /* TODO: fix overflow */ 155 152 /* return infinity*/ … … 160 157 161 158 exp -= FLOAT32_FRACTION_SIZE; 162 163 if (exp <= FLOAT32_FRACTION_SIZE) { 159 160 if (exp <= FLOAT32_FRACTION_SIZE) { 164 161 /* denormalized number */ 165 162 frac1 >>= 1; /* denormalize */ … … 178 175 result.parts.fraction = frac1 & ((1 << FLOAT32_FRACTION_SIZE) - 1); 179 176 180 return result; 177 return result; 181 178 } 182 179 183 /** Multiply two double-precision floats. 180 /** 181 * Multiply two double-precision floats. 184 182 * 185 183 * @param a First input operand. 186 184 * @param b Second input operand. 187 *188 185 * @return Result of multiplication. 189 * 190 */ 191 float64 mul_float64(float64 a, float64 b) 186 */ 187 float64 mulFloat64(float64 a, float64 b) 192 188 { 193 189 float64 result; 194 190 uint64_t frac1, frac2; 195 191 int32_t exp; 196 192 197 193 result.parts.sign = a.parts.sign ^ b.parts.sign; 198 194 199 if (is _float64_nan(a) || is_float64_nan(b)) {195 if (isFloat64NaN(a) || isFloat64NaN(b)) { 200 196 /* TODO: fix SigNaNs */ 201 if (is _float64_signan(a)) {197 if (isFloat64SigNaN(a)) { 202 198 result.parts.fraction = a.parts.fraction; 203 199 result.parts.exp = a.parts.exp; 204 200 return result; 205 201 } 206 if (is _float64_signan(b)) { /* TODO: fix SigNaN */202 if (isFloat64SigNaN(b)) { /* TODO: fix SigNaN */ 207 203 result.parts.fraction = b.parts.fraction; 208 204 result.parts.exp = b.parts.exp; … … 210 206 } 211 207 /* set NaN as result */ 212 result.bin = FLOAT64_NAN;213 return result; 214 } 215 216 if (is _float64_infinity(a)) {217 if (is _float64_zero(b)) {218 /* FIXME: zero * infinity */ 219 result.bin = FLOAT64_NAN;208 result.binary = FLOAT64_NAN; 209 return result; 210 } 211 212 if (isFloat64Infinity(a)) { 213 if (isFloat64Zero(b)) { 214 /* FIXME: zero * infinity */ 215 result.binary = FLOAT64_NAN; 220 216 return result; 221 217 } … … 224 220 return result; 225 221 } 226 227 if (is _float64_infinity(b)) {228 if (is _float64_zero(a)) {229 /* FIXME: zero * infinity */ 230 result.bin = FLOAT64_NAN;222 223 if (isFloat64Infinity(b)) { 224 if (isFloat64Zero(a)) { 225 /* FIXME: zero * infinity */ 226 result.binary = FLOAT64_NAN; 231 227 return result; 232 228 } … … 235 231 return result; 236 232 } 237 233 238 234 /* exp is signed so we can easy detect underflow */ 239 235 exp = a.parts.exp + b.parts.exp - FLOAT64_BIAS; 240 236 241 237 frac1 = a.parts.fraction; 242 238 243 239 if (a.parts.exp > 0) { 244 240 frac1 |= FLOAT64_HIDDEN_BIT_MASK; … … 248 244 249 245 frac2 = b.parts.fraction; 250 246 251 247 if (b.parts.exp > 0) { 252 248 frac2 |= FLOAT64_HIDDEN_BIT_MASK; … … 254 250 ++exp; 255 251 } 256 252 257 253 frac1 <<= (64 - FLOAT64_FRACTION_SIZE - 1); 258 254 frac2 <<= (64 - FLOAT64_FRACTION_SIZE - 2); 259 255 260 256 mul64(frac1, frac2, &frac1, &frac2); 261 257 262 258 frac1 |= (frac2 != 0); 263 259 if (frac1 & (0x1ll << 62)) { … … 265 261 exp--; 266 262 } 267 268 result = finish _float64(exp, frac1, result.parts.sign);263 264 result = finishFloat64(exp, frac1, result.parts.sign); 269 265 return result; 270 266 } 271 267 272 /** Multiply two quadruple-precision floats. 268 /** 269 * Multiply two quadruple-precision floats. 273 270 * 274 271 * @param a First input operand. 275 272 * @param b Second input operand. 276 *277 273 * @return Result of multiplication. 278 * 279 */ 280 float128 mul_float128(float128 a, float128 b) 274 */ 275 float128 mulFloat128(float128 a, float128 b) 281 276 { 282 277 float128 result; 283 278 uint64_t frac1_hi, frac1_lo, frac2_hi, frac2_lo, tmp_hi, tmp_lo; 284 279 int32_t exp; 285 280 286 281 result.parts.sign = a.parts.sign ^ b.parts.sign; 287 288 if (is _float128_nan(a) || is_float128_nan(b)) {282 283 if (isFloat128NaN(a) || isFloat128NaN(b)) { 289 284 /* TODO: fix SigNaNs */ 290 if (is _float128_signan(a)) {285 if (isFloat128SigNaN(a)) { 291 286 result.parts.frac_hi = a.parts.frac_hi; 292 287 result.parts.frac_lo = a.parts.frac_lo; … … 294 289 return result; 295 290 } 296 if (is _float128_signan(b)) { /* TODO: fix SigNaN */291 if (isFloat128SigNaN(b)) { /* TODO: fix SigNaN */ 297 292 result.parts.frac_hi = b.parts.frac_hi; 298 293 result.parts.frac_lo = b.parts.frac_lo; … … 301 296 } 302 297 /* set NaN as result */ 303 result.bin .hi = FLOAT128_NAN_HI;304 result.bin .lo = FLOAT128_NAN_LO;305 return result; 306 } 307 308 if (is _float128_infinity(a)) {309 if (is _float128_zero(b)) {310 /* FIXME: zero * infinity */ 311 result.bin .hi = FLOAT128_NAN_HI;312 result.bin .lo = FLOAT128_NAN_LO;298 result.binary.hi = FLOAT128_NAN_HI; 299 result.binary.lo = FLOAT128_NAN_LO; 300 return result; 301 } 302 303 if (isFloat128Infinity(a)) { 304 if (isFloat128Zero(b)) { 305 /* FIXME: zero * infinity */ 306 result.binary.hi = FLOAT128_NAN_HI; 307 result.binary.lo = FLOAT128_NAN_LO; 313 308 return result; 314 309 } … … 318 313 return result; 319 314 } 320 321 if (is _float128_infinity(b)) {322 if (is _float128_zero(a)) {323 /* FIXME: zero * infinity */ 324 result.bin .hi = FLOAT128_NAN_HI;325 result.bin .lo = FLOAT128_NAN_LO;315 316 if (isFloat128Infinity(b)) { 317 if (isFloat128Zero(a)) { 318 /* FIXME: zero * infinity */ 319 result.binary.hi = FLOAT128_NAN_HI; 320 result.binary.lo = FLOAT128_NAN_LO; 326 321 return result; 327 322 } … … 331 326 return result; 332 327 } 333 328 334 329 /* exp is signed so we can easy detect underflow */ 335 330 exp = a.parts.exp + b.parts.exp - FLOAT128_BIAS - 1; 336 331 337 332 frac1_hi = a.parts.frac_hi; 338 333 frac1_lo = a.parts.frac_lo; 339 334 340 335 if (a.parts.exp > 0) { 341 336 or128(frac1_hi, frac1_lo, 342 343 344 } else { 345 ++exp; 346 } 347 337 FLOAT128_HIDDEN_BIT_MASK_HI, FLOAT128_HIDDEN_BIT_MASK_LO, 338 &frac1_hi, &frac1_lo); 339 } else { 340 ++exp; 341 } 342 348 343 frac2_hi = b.parts.frac_hi; 349 344 frac2_lo = b.parts.frac_lo; 350 345 351 346 if (b.parts.exp > 0) { 352 347 or128(frac2_hi, frac2_lo, … … 356 351 ++exp; 357 352 } 358 353 359 354 lshift128(frac2_hi, frac2_lo, 360 355 128 - FLOAT128_FRACTION_SIZE, &frac2_hi, &frac2_lo); 361 356 362 357 tmp_hi = frac1_hi; 363 358 tmp_lo = frac1_lo; … … 366 361 add128(frac1_hi, frac1_lo, tmp_hi, tmp_lo, &frac1_hi, &frac1_lo); 367 362 frac2_hi |= (frac2_lo != 0x0ll); 368 363 369 364 if ((FLOAT128_HIDDEN_BIT_MASK_HI << 1) <= frac1_hi) { 370 365 frac2_hi >>= 1; … … 375 370 ++exp; 376 371 } 377 378 result = finish _float128(exp, frac1_hi, frac1_lo, result.parts.sign, frac2_hi);372 373 result = finishFloat128(exp, frac1_hi, frac1_lo, result.parts.sign, frac2_hi); 379 374 return result; 380 375 } -
uspace/lib/softfloat/generic/softfloat.c
r90924df rd9f53877 48 48 #include <other.h> 49 49 50 #include <functions.h> 51 50 52 /* Arithmetic functions */ 51 53 52 54 float __addsf3(float a, float b) 53 55 { 54 float_t fa; 55 float_t fb; 56 float_t res; 57 58 fa.val = a; 59 fb.val = b; 60 61 if (fa.data.parts.sign != fb.data.parts.sign) { 62 if (fa.data.parts.sign) { 63 fa.data.parts.sign = 0; 64 res.data = sub_float(fb.data, fa.data); 65 66 return res.val; 67 } 68 69 fb.data.parts.sign = 0; 70 res.data = sub_float(fa.data, fb.data); 71 72 return res.val; 73 } 74 75 res.data = add_float(fa.data, fb.data); 76 return res.val; 56 float32 fa, fb; 57 fa.f = a; 58 fb.f = b; 59 if (fa.parts.sign != fb.parts.sign) { 60 if (fa.parts.sign) { 61 fa.parts.sign = 0; 62 return subFloat32(fb, fa).f; 63 }; 64 fb.parts.sign = 0; 65 return subFloat32(fa, fb).f; 66 } 67 return addFloat32(fa, fb).f; 77 68 } 78 69 79 70 double __adddf3(double a, double b) 80 71 { 81 double_t da; 82 double_t db; 83 double_t res; 84 85 da.val = a; 86 db.val = b; 87 88 if (da.data.parts.sign != db.data.parts.sign) { 89 if (da.data.parts.sign) { 90 da.data.parts.sign = 0; 91 res.data = sub_double(db.data, da.data); 92 93 return res.val; 94 } 95 96 db.data.parts.sign = 0; 97 res.data = sub_double(da.data, db.data); 98 99 return res.val; 100 } 101 102 res.data = add_double(da.data, db.data); 103 return res.val; 72 float64 da, db; 73 da.d = a; 74 db.d = b; 75 if (da.parts.sign != db.parts.sign) { 76 if (da.parts.sign) { 77 da.parts.sign = 0; 78 return subFloat64(db, da).d; 79 }; 80 db.parts.sign = 0; 81 return subFloat64(da, db).d; 82 } 83 return addFloat64(da, db).d; 104 84 } 105 85 106 86 long double __addtf3(long double a, long double b) 107 87 { 108 long_double_t ta; 109 long_double_t tb; 110 long_double_t res; 111 112 ta.val = a; 113 tb.val = b; 114 115 if (ta.data.parts.sign != tb.data.parts.sign) { 116 if (ta.data.parts.sign) { 117 ta.data.parts.sign = 0; 118 res.data = sub_long_double(tb.data, ta.data); 119 120 return res.val; 121 } 122 123 tb.data.parts.sign = 0; 124 res.data = sub_long_double(ta.data, tb.data); 125 126 return res.val; 127 } 128 129 res.data = add_long_double(ta.data, tb.data); 130 return res.val; 88 float128 ta, tb; 89 ta.ld = a; 90 tb.ld = b; 91 if (ta.parts.sign != tb.parts.sign) { 92 if (ta.parts.sign) { 93 ta.parts.sign = 0; 94 return subFloat128(tb, ta).ld; 95 }; 96 tb.parts.sign = 0; 97 return subFloat128(ta, tb).ld; 98 } 99 return addFloat128(ta, tb).ld; 131 100 } 132 101 133 102 float __subsf3(float a, float b) 134 103 { 135 float_t fa; 136 float_t fb; 137 float_t res; 138 139 fa.val = a; 140 fb.val = b; 141 142 if (fa.data.parts.sign != fb.data.parts.sign) { 143 fb.data.parts.sign = !fb.data.parts.sign; 144 res.data = add_float(fa.data, fb.data); 145 146 return res.val; 147 } 148 149 res.data = sub_float(fa.data, fb.data); 150 return res.val; 104 float32 fa, fb; 105 fa.f = a; 106 fb.f = b; 107 if (fa.parts.sign != fb.parts.sign) { 108 fb.parts.sign = !fb.parts.sign; 109 return addFloat32(fa, fb).f; 110 } 111 return subFloat32(fa, fb).f; 151 112 } 152 113 153 114 double __subdf3(double a, double b) 154 115 { 155 double_t da; 156 double_t db; 157 double_t res; 158 159 da.val = a; 160 db.val = b; 161 162 if (da.data.parts.sign != db.data.parts.sign) { 163 db.data.parts.sign = !db.data.parts.sign; 164 res.data = add_double(da.data, db.data); 165 166 return res.val; 167 } 168 169 res.data = sub_double(da.data, db.data); 170 return res.val; 116 float64 da, db; 117 da.d = a; 118 db.d = b; 119 if (da.parts.sign != db.parts.sign) { 120 db.parts.sign = !db.parts.sign; 121 return addFloat64(da, db).d; 122 } 123 return subFloat64(da, db).d; 171 124 } 172 125 173 126 long double __subtf3(long double a, long double b) 174 127 { 175 long_double_t ta; 176 long_double_t tb; 177 long_double_t res; 178 179 ta.val = a; 180 tb.val = b; 181 182 if (ta.data.parts.sign != tb.data.parts.sign) { 183 tb.data.parts.sign = !tb.data.parts.sign; 184 res.data = add_long_double(ta.data, tb.data); 185 186 return res.val; 187 } 188 189 res.data = sub_long_double(ta.data, tb.data); 190 return res.val; 191 } 192 193 float __mulsf3(float a, float b) 194 { 195 float_t fa; 196 float_t fb; 197 float_t res; 198 199 fa.val = a; 200 fb.val = b; 201 202 res.data = mul_float(fa.data, fb.data); 203 return res.val; 204 } 205 206 double __muldf3(double a, double b) 207 { 208 double_t da; 209 double_t db; 210 double_t res; 211 212 da.val = a; 213 db.val = b; 214 215 res.data = mul_double(da.data, db.data); 216 return res.val; 128 float128 ta, tb; 129 ta.ld = a; 130 tb.ld = b; 131 if (ta.parts.sign != tb.parts.sign) { 132 tb.parts.sign = !tb.parts.sign; 133 return addFloat128(ta, tb).ld; 134 } 135 return subFloat128(ta, tb).ld; 136 } 137 138 float __mulsf3(float a, float b) 139 { 140 float32 fa, fb; 141 fa.f = a; 142 fb.f = b; 143 return mulFloat32(fa, fb).f; 144 } 145 146 double __muldf3(double a, double b) 147 { 148 float64 da, db; 149 da.d = a; 150 db.d = b; 151 return mulFloat64(da, db).d; 217 152 } 218 153 219 154 long double __multf3(long double a, long double b) 220 155 { 221 long_double_t ta; 222 long_double_t tb; 223 long_double_t res; 224 225 ta.val = a; 226 tb.val = b; 227 228 res.data = mul_long_double(ta.data, tb.data); 229 return res.val; 230 } 231 232 float __divsf3(float a, float b) 233 { 234 float_t fa; 235 float_t fb; 236 float_t res; 237 238 fa.val = a; 239 fb.val = b; 240 241 res.data = div_float(fa.data, fb.data); 242 return res.val; 243 } 244 245 double __divdf3(double a, double b) 246 { 247 double_t da; 248 double_t db; 249 double_t res; 250 251 da.val = a; 252 db.val = b; 253 254 res.data = div_double(da.data, db.data); 255 return res.val; 156 float128 ta, tb; 157 ta.ld = a; 158 tb.ld = b; 159 return mulFloat128(ta, tb).ld; 160 } 161 162 float __divsf3(float a, float b) 163 { 164 float32 fa, fb; 165 fa.f = a; 166 fb.f = b; 167 return divFloat32(fa, fb).f; 168 } 169 170 double __divdf3(double a, double b) 171 { 172 float64 da, db; 173 da.d = a; 174 db.d = b; 175 return divFloat64(da, db).d; 256 176 } 257 177 258 178 long double __divtf3(long double a, long double b) 259 179 { 260 long_double_t ta; 261 long_double_t tb; 262 long_double_t res; 263 264 ta.val = a; 265 tb.val = b; 266 267 res.data = div_long_double(ta.data, tb.data); 268 return res.val; 180 float128 ta, tb; 181 ta.ld = a; 182 tb.ld = b; 183 return divFloat128(ta, tb).ld; 269 184 } 270 185 271 186 float __negsf2(float a) 272 187 { 273 float_t fa; 274 275 fa.val = a; 276 fa.data.parts.sign = !fa.data.parts.sign; 277 278 return fa.val; 188 float32 fa; 189 fa.f = a; 190 fa.parts.sign = !fa.parts.sign; 191 return fa.f; 279 192 } 280 193 281 194 double __negdf2(double a) 282 195 { 283 double_t da; 284 285 da.val = a; 286 da.data.parts.sign = !da.data.parts.sign; 287 288 return da.val; 196 float64 da; 197 da.d = a; 198 da.parts.sign = !da.parts.sign; 199 return da.d; 289 200 } 290 201 291 202 long double __negtf2(long double a) 292 203 { 293 long_double_t ta; 294 295 ta.val = a; 296 ta.data.parts.sign = !ta.data.parts.sign; 297 298 return ta.val; 204 float128 ta; 205 ta.ld = a; 206 ta.parts.sign = !ta.parts.sign; 207 return ta.ld; 299 208 } 300 209 301 210 /* Conversion functions */ 302 211 303 double __extendsfdf2(float a) 304 { 305 float_t fa; 306 double_t res; 307 308 fa.val = a; 309 res.data = float_to_double(fa.data); 310 311 return res.val; 212 double __extendsfdf2(float a) 213 { 214 float32 fa; 215 fa.f = a; 216 return convertFloat32ToFloat64(fa).d; 312 217 } 313 218 314 219 long double __extendsftf2(float a) 315 220 { 316 float_t fa; 317 long_double_t res; 318 319 fa.val = a; 320 res.data = float_to_long_double(fa.data); 321 322 return res.val; 221 float32 fa; 222 fa.f = a; 223 return convertFloat32ToFloat128(fa).ld; 323 224 } 324 225 325 226 long double __extenddftf2(double a) 326 227 { 327 double_t da; 328 long_double_t res; 329 330 da.val = a; 331 res.data = double_to_long_double(da.data); 332 333 return res.val; 334 } 335 336 float __truncdfsf2(double a) 337 { 338 double_t da; 339 float_t res; 340 341 da.val = a; 342 res.data = double_to_float(da.data); 343 344 return res.val; 228 float64 da; 229 da.d = a; 230 return convertFloat64ToFloat128(da).ld; 231 } 232 233 float __truncdfsf2(double a) 234 { 235 float64 da; 236 da.d = a; 237 return convertFloat64ToFloat32(da).f; 345 238 } 346 239 347 240 float __trunctfsf2(long double a) 348 241 { 349 long_double_t ta; 350 float_t res; 351 352 ta.val = a; 353 res.data = long_double_to_float(ta.data); 354 355 return res.val; 242 float128 ta; 243 ta.ld = a; 244 return convertFloat128ToFloat32(ta).f; 356 245 } 357 246 358 247 double __trunctfdf2(long double a) 359 248 { 360 long_double_t ta; 361 double_t res; 362 363 ta.val = a; 364 res.data = long_double_to_double(ta.data); 365 366 return res.val; 249 float128 ta; 250 ta.ld = a; 251 return convertFloat128ToFloat64(ta).d; 367 252 } 368 253 369 254 int __fixsfsi(float a) 370 255 { 371 float _tfa;372 373 fa.val = a;374 return float _to_int(fa.data);256 float32 fa; 257 fa.f = a; 258 259 return float32_to_int(fa); 375 260 } 376 261 377 262 int __fixdfsi(double a) 378 263 { 379 double_tda;380 381 da.val = a;382 return double_to_int(da.data);264 float64 da; 265 da.d = a; 266 267 return float64_to_int(da); 383 268 } 384 269 385 270 int __fixtfsi(long double a) 386 271 { 387 long_double_tta;388 389 ta.val = a; 390 return long_double_to_int(ta.data);272 float128 ta; 273 ta.ld = a; 274 275 return float128_to_int(ta); 391 276 } 392 277 393 278 long __fixsfdi(float a) 394 279 { 395 float _tfa;396 397 fa.val = a;398 return float _to_long(fa.data);280 float32 fa; 281 fa.f = a; 282 283 return float32_to_long(fa); 399 284 } 400 285 401 286 long __fixdfdi(double a) 402 287 { 403 double_tda;404 405 da.val = a;406 return double_to_long(da.data);288 float64 da; 289 da.d = a; 290 291 return float64_to_long(da); 407 292 } 408 293 409 294 long __fixtfdi(long double a) 410 295 { 411 long_double_tta;412 413 ta.val = a; 414 return long_double_to_long(ta.data);296 float128 ta; 297 ta.ld = a; 298 299 return float128_to_long(ta); 415 300 } 416 301 417 302 long long __fixsfti(float a) 418 303 { 419 float _tfa;420 421 fa.val = a;422 return float _to_llong(fa.data);304 float32 fa; 305 fa.f = a; 306 307 return float32_to_longlong(fa); 423 308 } 424 309 425 310 long long __fixdfti(double a) 426 311 { 427 double_tda;428 429 da.val = a;430 return double_to_llong(da.data);312 float64 da; 313 da.d = a; 314 315 return float64_to_longlong(da); 431 316 } 432 317 433 318 long long __fixtfti(long double a) 434 319 { 435 long_double_tta;436 437 ta.val = a; 438 return long_double_to_llong(ta.data);320 float128 ta; 321 ta.ld = a; 322 323 return float128_to_longlong(ta); 439 324 } 440 325 441 326 unsigned int __fixunssfsi(float a) 442 327 { 443 float _tfa;444 445 fa.val = a;446 return float _to_uint(fa.data);328 float32 fa; 329 fa.f = a; 330 331 return float32_to_uint(fa); 447 332 } 448 333 449 334 unsigned int __fixunsdfsi(double a) 450 335 { 451 double_tda;452 453 da.val = a;454 return double_to_uint(da.data);336 float64 da; 337 da.d = a; 338 339 return float64_to_uint(da); 455 340 } 456 341 457 342 unsigned int __fixunstfsi(long double a) 458 343 { 459 long_double_tta;460 461 ta.val = a; 462 return long_double_to_uint(ta.data);344 float128 ta; 345 ta.ld = a; 346 347 return float128_to_uint(ta); 463 348 } 464 349 465 350 unsigned long __fixunssfdi(float a) 466 351 { 467 float _tfa;468 469 fa.val = a;470 return float _to_ulong(fa.data);352 float32 fa; 353 fa.f = a; 354 355 return float32_to_ulong(fa); 471 356 } 472 357 473 358 unsigned long __fixunsdfdi(double a) 474 359 { 475 double_tda;476 477 da.val = a;478 return double_to_ulong(da.data);360 float64 da; 361 da.d = a; 362 363 return float64_to_ulong(da); 479 364 } 480 365 481 366 unsigned long __fixunstfdi(long double a) 482 367 { 483 long_double_tta;484 485 ta.val = a; 486 return long_double_to_ulong(ta.data);368 float128 ta; 369 ta.ld = a; 370 371 return float128_to_ulong(ta); 487 372 } 488 373 489 374 unsigned long long __fixunssfti(float a) 490 375 { 491 float _tfa;492 493 fa.val = a;494 return float _to_ullong(fa.data);376 float32 fa; 377 fa.f = a; 378 379 return float32_to_ulonglong(fa); 495 380 } 496 381 497 382 unsigned long long __fixunsdfti(double a) 498 383 { 499 double_tda;500 501 da.val = a;502 return double_to_ullong(da.data);384 float64 da; 385 da.d = a; 386 387 return float64_to_ulonglong(da); 503 388 } 504 389 505 390 unsigned long long __fixunstfti(long double a) 506 391 { 507 long_double_tta;508 509 ta.val = a; 510 return long_double_to_ullong(ta.data);392 float128 ta; 393 ta.ld = a; 394 395 return float128_to_ulonglong(ta); 511 396 } 512 397 513 398 float __floatsisf(int i) 514 399 { 515 float _t res;516 517 res.data = int_to_float(i);518 return res.val;400 float32 fa; 401 402 fa = int_to_float32(i); 403 return fa.f; 519 404 } 520 405 521 406 double __floatsidf(int i) 522 407 { 523 double_t res;524 525 res.data = int_to_double(i);526 return res.val;408 float64 da; 409 410 da = int_to_float64(i); 411 return da.d; 527 412 } 528 413 529 414 long double __floatsitf(int i) 530 415 { 531 long_double_t res;532 533 res.data = int_to_long_double(i);534 return res.val;416 float128 ta; 417 418 ta = int_to_float128(i); 419 return ta.ld; 535 420 } 536 421 537 422 float __floatdisf(long i) 538 423 { 539 float _t res;540 541 res.data = long_to_float(i);542 return res.val;424 float32 fa; 425 426 fa = long_to_float32(i); 427 return fa.f; 543 428 } 544 429 545 430 double __floatdidf(long i) 546 431 { 547 double_t res;548 549 res.data = long_to_double(i);550 return res.val;432 float64 da; 433 434 da = long_to_float64(i); 435 return da.d; 551 436 } 552 437 553 438 long double __floatditf(long i) 554 439 { 555 long_double_t res;556 557 res.data = long_to_long_double(i);558 return res.val;559 } 560 440 float128 ta; 441 442 ta = long_to_float128(i); 443 return ta.ld; 444 } 445 561 446 float __floattisf(long long i) 562 447 { 563 float _t res;564 565 res.data = llong_to_float(i);566 return res.val;448 float32 fa; 449 450 fa = longlong_to_float32(i); 451 return fa.f; 567 452 } 568 453 569 454 double __floattidf(long long i) 570 455 { 571 double_t res;572 573 res.data = llong_to_double(i);574 return res.val;456 float64 da; 457 458 da = longlong_to_float64(i); 459 return da.d; 575 460 } 576 461 577 462 long double __floattitf(long long i) 578 463 { 579 long_double_t res;580 581 res.data = llong_to_long_double(i);582 return res.val;464 float128 ta; 465 466 ta = longlong_to_float128(i); 467 return ta.ld; 583 468 } 584 469 585 470 float __floatunsisf(unsigned int i) 586 471 { 587 float _t res;588 589 res.data = uint_to_float(i);590 return res.val;472 float32 fa; 473 474 fa = uint_to_float32(i); 475 return fa.f; 591 476 } 592 477 593 478 double __floatunsidf(unsigned int i) 594 479 { 595 double_t res;596 597 res.data = uint_to_double(i);598 return res.val;480 float64 da; 481 482 da = uint_to_float64(i); 483 return da.d; 599 484 } 600 485 601 486 long double __floatunsitf(unsigned int i) 602 487 { 603 long_double_t res;604 605 res.data = uint_to_long_double(i);606 return res.val;488 float128 ta; 489 490 ta = uint_to_float128(i); 491 return ta.ld; 607 492 } 608 493 609 494 float __floatundisf(unsigned long i) 610 495 { 611 float _t res;612 613 res.data = ulong_to_float(i);614 return res.val;496 float32 fa; 497 498 fa = ulong_to_float32(i); 499 return fa.f; 615 500 } 616 501 617 502 double __floatundidf(unsigned long i) 618 503 { 619 double_t res;620 621 res.data = ulong_to_double(i);622 return res.val;504 float64 da; 505 506 da = ulong_to_float64(i); 507 return da.d; 623 508 } 624 509 625 510 long double __floatunditf(unsigned long i) 626 511 { 627 long_double_t res;628 629 res.data = ulong_to_long_double(i);630 return res.val;512 float128 ta; 513 514 ta = ulong_to_float128(i); 515 return ta.ld; 631 516 } 632 517 633 518 float __floatuntisf(unsigned long long i) 634 519 { 635 float _t res;636 637 res.data = ullong_to_float(i);638 return res.val;520 float32 fa; 521 522 fa = ulonglong_to_float32(i); 523 return fa.f; 639 524 } 640 525 641 526 double __floatuntidf(unsigned long long i) 642 527 { 643 double_t res;644 645 res.data = ullong_to_double(i);646 return res.val;528 float64 da; 529 530 da = ulonglong_to_float64(i); 531 return da.d; 647 532 } 648 533 649 534 long double __floatuntitf(unsigned long long i) 650 535 { 651 long_double_t res;652 653 res.data = ullong_to_long_double(i);654 return res.val;536 float128 ta; 537 538 ta = ulonglong_to_float128(i); 539 return ta.ld; 655 540 } 656 541 … … 659 544 int __cmpsf2(float a, float b) 660 545 { 661 float_t fa; 662 float_t fb; 663 664 fa.val = a; 665 fb.val = b; 666 667 if ((is_float_nan(fa.data)) || (is_float_nan(fb.data))) { 668 /* no special constant for unordered - maybe signaled? */ 669 return 1; 670 } 671 672 if (is_float_eq(fa.data, fb.data)) 673 return 0; 674 675 if (is_float_lt(fa.data, fb.data)) 676 return -1; 677 546 float32 fa, fb; 547 fa.f = a; 548 fb.f = b; 549 550 if ((isFloat32NaN(fa)) || (isFloat32NaN(fb))) { 551 return 1; /* no special constant for unordered - maybe signaled? */ 552 } 553 554 if (isFloat32eq(fa, fb)) { 555 return 0; 556 } 557 558 if (isFloat32lt(fa, fb)) { 559 return -1; 560 } 561 678 562 return 1; 679 563 } … … 681 565 int __cmpdf2(double a, double b) 682 566 { 683 double_t da; 684 double_t db; 685 686 da.val = a; 687 db.val = b; 688 689 if ((is_double_nan(da.data)) || (is_double_nan(db.data))) { 690 /* no special constant for unordered - maybe signaled? */ 691 return 1; 692 } 693 694 if (is_double_eq(da.data, db.data)) 695 return 0; 696 697 if (is_double_lt(da.data, db.data)) 698 return -1; 699 567 float64 da, db; 568 da.d = a; 569 db.d = b; 570 571 if ((isFloat64NaN(da)) || (isFloat64NaN(db))) { 572 return 1; /* no special constant for unordered - maybe signaled? */ 573 } 574 575 if (isFloat64eq(da, db)) { 576 return 0; 577 } 578 579 if (isFloat64lt(da, db)) { 580 return -1; 581 } 582 700 583 return 1; 701 584 } … … 703 586 int __cmptf2(long double a, long double b) 704 587 { 705 long_double_t ta; 706 long_double_t tb; 707 708 ta.val = a; 709 tb.val = b; 710 711 if ((is_long_double_nan(ta.data)) || (is_long_double_nan(tb.data))) { 712 /* no special constant for unordered - maybe signaled? */ 713 return 1; 714 } 715 716 if (is_long_double_eq(ta.data, tb.data)) 717 return 0; 718 719 if (is_long_double_lt(ta.data, tb.data)) 720 return -1; 721 588 float128 ta, tb; 589 ta.ld = a; 590 tb.ld = b; 591 592 if ((isFloat128NaN(ta)) || (isFloat128NaN(tb))) { 593 return 1; /* no special constant for unordered - maybe signaled? */ 594 } 595 596 if (isFloat128eq(ta, tb)) { 597 return 0; 598 } 599 600 if (isFloat128lt(ta, tb)) { 601 return -1; 602 } 603 722 604 return 1; 723 605 } 724 606 725 int __unordsf2(float a, float b) 726 { 727 float_t fa; 728 float_t fb; 729 730 fa.val = a; 731 fb.val = b; 732 733 return ((is_float_nan(fa.data)) || (is_float_nan(fb.data))); 607 int __unordsf2(float a, float b) 608 { 609 float32 fa, fb; 610 fa.f = a; 611 fb.f = b; 612 return ((isFloat32NaN(fa)) || (isFloat32NaN(fb))); 734 613 } 735 614 736 615 int __unorddf2(double a, double b) 737 616 { 738 double_t da; 739 double_t db; 740 741 da.val = a; 742 db.val = b; 743 744 return ((is_double_nan(da.data)) || (is_double_nan(db.data))); 617 float64 da, db; 618 da.d = a; 619 db.d = b; 620 return ((isFloat64NaN(da)) || (isFloat64NaN(db))); 745 621 } 746 622 747 623 int __unordtf2(long double a, long double b) 748 624 { 749 long_double_t ta; 750 long_double_t tb; 751 752 ta.val = a; 753 tb.val = b; 754 755 return ((is_long_double_nan(ta.data)) || (is_long_double_nan(tb.data))); 756 } 757 758 int __eqsf2(float a, float b) 759 { 760 float_t fa; 761 float_t fb; 762 763 fa.val = a; 764 fb.val = b; 765 766 if ((is_float_nan(fa.data)) || (is_float_nan(fb.data))) { 767 // TODO: sigNaNs 768 return 1; 769 } 770 771 return is_float_eq(fa.data, fb.data) - 1; 625 float128 ta, tb; 626 ta.ld = a; 627 tb.ld = b; 628 return ((isFloat128NaN(ta)) || (isFloat128NaN(tb))); 629 } 630 631 int __eqsf2(float a, float b) 632 { 633 float32 fa, fb; 634 fa.f = a; 635 fb.f = b; 636 if ((isFloat32NaN(fa)) || (isFloat32NaN(fb))) { 637 /* TODO: sigNaNs */ 638 return 1; 639 } 640 return isFloat32eq(fa, fb) - 1; 772 641 } 773 642 774 643 int __eqdf2(double a, double b) 775 644 { 776 double_t da; 777 double_t db; 778 779 da.val = a; 780 db.val = b; 781 782 if ((is_double_nan(da.data)) || (is_double_nan(db.data))) { 783 // TODO: sigNaNs 784 return 1; 785 } 786 787 return is_double_eq(da.data, db.data) - 1; 645 float64 da, db; 646 da.d = a; 647 db.d = b; 648 if ((isFloat64NaN(da)) || (isFloat64NaN(db))) { 649 /* TODO: sigNaNs */ 650 return 1; 651 } 652 return isFloat64eq(da, db) - 1; 788 653 } 789 654 790 655 int __eqtf2(long double a, long double b) 791 656 { 792 long_double_t ta; 793 long_double_t tb; 794 795 ta.val = a; 796 tb.val = b; 797 798 if ((is_long_double_nan(ta.data)) || (is_long_double_nan(tb.data))) { 799 // TODO: sigNaNs 800 return 1; 801 } 802 803 return is_long_double_eq(ta.data, tb.data) - 1; 804 } 805 806 int __nesf2(float a, float b) 657 float128 ta, tb; 658 ta.ld = a; 659 tb.ld = b; 660 if ((isFloat128NaN(ta)) || (isFloat128NaN(tb))) { 661 /* TODO: sigNaNs */ 662 return 1; 663 } 664 return isFloat128eq(ta, tb) - 1; 665 } 666 667 int __nesf2(float a, float b) 807 668 { 808 669 /* strange behavior, but it was in gcc documentation */ … … 824 685 int __gesf2(float a, float b) 825 686 { 826 float _t fa;827 f loat_t fb;828 829 fa.val = a; 830 fb.val = b;831 832 if ((is_float_nan(fa.data)) || (is_float_nan(fb.data))) {833 // TODO: sigNaNs834 return -1;835 }836 837 if (is_float_eq(fa.data, fb.data))838 return 0;839 840 if (is_float_gt(fa.data, fb.data))841 return 1;687 float32 fa, fb; 688 fa.f = a; 689 fb.f = b; 690 691 if ((isFloat32NaN(fa)) || (isFloat32NaN(fb))) { 692 /* TODO: sigNaNs */ 693 return -1; 694 } 695 696 if (isFloat32eq(fa, fb)) { 697 return 0; 698 } 699 700 if (isFloat32gt(fa, fb)) { 701 return 1; 702 } 842 703 843 704 return -1; … … 846 707 int __gedf2(double a, double b) 847 708 { 848 double_t da;849 d ouble_t db;850 851 da.val = a; 852 db.val = b;853 854 if ((is_double_nan(da.data)) || (is_double_nan(db.data))) {855 // TODO: sigNaNs856 return -1; 857 }858 859 if (is_double_eq(da.data, db.data))860 return 0; 861 862 if (is_double_gt(da.data, db.data))863 return 1;864 709 float64 da, db; 710 da.d = a; 711 db.d = b; 712 713 if ((isFloat64NaN(da)) || (isFloat64NaN(db))) { 714 /* TODO: sigNaNs */ 715 return -1; 716 } 717 718 if (isFloat64eq(da, db)) { 719 return 0; 720 } 721 722 if (isFloat64gt(da, db)) { 723 return 1; 724 } 725 865 726 return -1; 866 727 } … … 868 729 int __getf2(long double a, long double b) 869 730 { 870 long_double_t ta;871 long_double_t tb;872 873 ta.val = a; 874 tb.val = b;875 876 if ((is_long_double_nan(ta.data)) || (is_long_double_nan(tb.data))) {877 // TODO: sigNaNs878 return -1; 879 }880 881 if (is_long_double_eq(ta.data, tb.data))882 return 0; 883 884 if (is_long_double_gt(ta.data, tb.data))885 return 1;886 731 float128 ta, tb; 732 ta.ld = a; 733 tb.ld = b; 734 735 if ((isFloat128NaN(ta)) || (isFloat128NaN(tb))) { 736 /* TODO: sigNaNs */ 737 return -1; 738 } 739 740 if (isFloat128eq(ta, tb)) { 741 return 0; 742 } 743 744 if (isFloat128gt(ta, tb)) { 745 return 1; 746 } 747 887 748 return -1; 888 749 } … … 890 751 int __ltsf2(float a, float b) 891 752 { 892 float_t fa; 893 float_t fb; 894 895 fa.val = a; 896 fb.val = b; 897 898 if ((is_float_nan(fa.data)) || (is_float_nan(fb.data))) { 899 // TODO: sigNaNs 900 return 1; 901 } 902 903 if (is_float_lt(fa.data, fb.data)) 904 return -1; 905 753 float32 fa, fb; 754 fa.f = a; 755 fb.f = b; 756 757 if ((isFloat32NaN(fa)) || (isFloat32NaN(fb))) { 758 /* TODO: sigNaNs */ 759 return 1; 760 } 761 762 if (isFloat32lt(fa, fb)) { 763 return -1; 764 } 765 906 766 return 0; 907 767 } … … 909 769 int __ltdf2(double a, double b) 910 770 { 911 double_t da; 912 double_t db; 913 914 da.val = a; 915 db.val = b; 916 917 if ((is_double_nan(da.data)) || (is_double_nan(db.data))) { 918 // TODO: sigNaNs 919 return 1; 920 } 921 922 if (is_double_lt(da.data, db.data)) 923 return -1; 924 771 float64 da, db; 772 da.d = a; 773 db.d = b; 774 775 if ((isFloat64NaN(da)) || (isFloat64NaN(db))) { 776 /* TODO: sigNaNs */ 777 return 1; 778 } 779 780 if (isFloat64lt(da, db)) { 781 return -1; 782 } 783 925 784 return 0; 926 785 } … … 928 787 int __lttf2(long double a, long double b) 929 788 { 930 long_double_t ta; 931 long_double_t tb; 932 933 ta.val = a; 934 tb.val = b; 935 936 if ((is_long_double_nan(ta.data)) || (is_long_double_nan(tb.data))) { 937 // TODO: sigNaNs 938 return 1; 939 } 940 941 if (is_long_double_lt(ta.data, tb.data)) 942 return -1; 943 789 float128 ta, tb; 790 ta.ld = a; 791 tb.ld = b; 792 793 if ((isFloat128NaN(ta)) || (isFloat128NaN(tb))) { 794 /* TODO: sigNaNs */ 795 return 1; 796 } 797 798 if (isFloat128lt(ta, tb)) { 799 return -1; 800 } 801 944 802 return 0; 945 803 } … … 947 805 int __lesf2(float a, float b) 948 806 { 949 float _t fa;950 f loat_t fb;951 952 fa.val = a; 953 fb.val = b;954 955 if ((is_float_nan(fa.data)) || (is_float_nan(fb.data))) {956 // TODO: sigNaNs957 return 1;958 }959 960 if (is_float_eq(fa.data, fb.data))961 return 0;962 963 if (is_float_lt(fa.data, fb.data))964 return -1;807 float32 fa, fb; 808 fa.f = a; 809 fb.f = b; 810 811 if ((isFloat32NaN(fa)) || (isFloat32NaN(fb))) { 812 /* TODO: sigNaNs */ 813 return 1; 814 } 815 816 if (isFloat32eq(fa, fb)) { 817 return 0; 818 } 819 820 if (isFloat32lt(fa, fb)) { 821 return -1; 822 } 965 823 966 824 return 1; … … 969 827 int __ledf2(double a, double b) 970 828 { 971 double_t da;972 d ouble_t db;973 974 da.val = a; 975 db.val = b;976 977 if ((is_double_nan(da.data)) || (is_double_nan(db.data))) {978 // TODO: sigNaNs979 return 1; 980 }981 982 if (is_double_eq(da.data, db.data))983 return 0; 984 985 if (is_double_lt(da.data, db.data))986 return -1;987 829 float64 da, db; 830 da.d = a; 831 db.d = b; 832 833 if ((isFloat64NaN(da)) || (isFloat64NaN(db))) { 834 /* TODO: sigNaNs */ 835 return 1; 836 } 837 838 if (isFloat64eq(da, db)) { 839 return 0; 840 } 841 842 if (isFloat64lt(da, db)) { 843 return -1; 844 } 845 988 846 return 1; 989 847 } … … 991 849 int __letf2(long double a, long double b) 992 850 { 993 long_double_t ta;994 long_double_t tb;995 996 ta.val = a; 997 tb.val = b;998 999 if ((is_long_double_nan(ta.data)) || (is_long_double_nan(tb.data))) {1000 // TODO: sigNaNs1001 return 1; 1002 }1003 1004 if (is_long_double_eq(ta.data, tb.data))1005 return 0; 1006 1007 if (is_long_double_lt(ta.data, tb.data))1008 return -1;1009 851 float128 ta, tb; 852 ta.ld = a; 853 tb.ld = b; 854 855 if ((isFloat128NaN(ta)) || (isFloat128NaN(tb))) { 856 /* TODO: sigNaNs */ 857 return 1; 858 } 859 860 if (isFloat128eq(ta, tb)) { 861 return 0; 862 } 863 864 if (isFloat128lt(ta, tb)) { 865 return -1; 866 } 867 1010 868 return 1; 1011 869 } … … 1013 871 int __gtsf2(float a, float b) 1014 872 { 1015 float_t fa; 1016 float_t fb; 1017 1018 fa.val = a; 1019 fb.val = b; 1020 1021 if ((is_float_nan(fa.data)) || (is_float_nan(fb.data))) { 1022 // TODO: sigNaNs 1023 return -1; 1024 } 1025 1026 if (is_float_gt(fa.data, fb.data)) 1027 return 1; 1028 873 float32 fa, fb; 874 fa.f = a; 875 fb.f = b; 876 877 if ((isFloat32NaN(fa)) || (isFloat32NaN(fb))) { 878 /* TODO: sigNaNs */ 879 return -1; 880 } 881 882 if (isFloat32gt(fa, fb)) { 883 return 1; 884 } 885 1029 886 return 0; 1030 887 } … … 1032 889 int __gtdf2(double a, double b) 1033 890 { 1034 double_t da; 1035 double_t db; 1036 1037 da.val = a; 1038 db.val = b; 1039 1040 if ((is_double_nan(da.data)) || (is_double_nan(db.data))) { 1041 // TODO: sigNaNs 1042 return -1; 1043 } 1044 1045 if (is_double_gt(da.data, db.data)) 1046 return 1; 1047 891 float64 da, db; 892 da.d = a; 893 db.d = b; 894 895 if ((isFloat64NaN(da)) || (isFloat64NaN(db))) { 896 /* TODO: sigNaNs */ 897 return -1; 898 } 899 900 if (isFloat64gt(da, db)) { 901 return 1; 902 } 903 1048 904 return 0; 1049 905 } … … 1051 907 int __gttf2(long double a, long double b) 1052 908 { 1053 long_double_t ta; 1054 long_double_t tb; 1055 1056 ta.val = a; 1057 tb.val = b; 1058 1059 if ((is_long_double_nan(ta.data)) || (is_long_double_nan(tb.data))) { 1060 // TODO: sigNaNs 1061 return -1; 1062 } 1063 1064 if (is_long_double_gt(ta.data, tb.data)) 1065 return 1; 1066 909 float128 ta, tb; 910 ta.ld = a; 911 tb.ld = b; 912 913 if ((isFloat128NaN(ta)) || (isFloat128NaN(tb))) { 914 /* TODO: sigNaNs */ 915 return -1; 916 } 917 918 if (isFloat128gt(ta, tb)) { 919 return 1; 920 } 921 1067 922 return 0; 1068 923 } 1069 924 925 926 927 #ifdef SPARC_SOFTFLOAT 928 1070 929 /* SPARC quadruple-precision wrappers */ 1071 930 … … 1157 1016 int _Qp_cmp(long double *a, long double *b) 1158 1017 { 1159 long_double_t ta; 1160 long_double_t tb; 1161 1162 ta.val = *a; 1163 tb.val = *b; 1164 1165 if ((is_long_double_nan(ta.data)) || (is_long_double_nan(tb.data))) 1018 float128 ta, tb; 1019 ta.ld = *a; 1020 tb.ld = *b; 1021 1022 if ((isFloat128NaN(ta)) || (isFloat128NaN(tb))) { 1166 1023 return 3; 1167 1168 if (is_long_double_eq(ta.data, tb.data)) 1169 return 0; 1170 1171 if (is_long_double_lt(ta.data, tb.data)) 1172 return 1; 1173 1024 } 1025 1026 if (isFloat128eq(ta, tb)) { 1027 return 0; 1028 } 1029 1030 if (isFloat128lt(ta, tb)) { 1031 return 1; 1032 } 1033 1174 1034 return 2; 1175 1035 } … … 1183 1043 int _Qp_feq(long double *a, long double *b) 1184 1044 { 1185 long_double_t ta; 1186 long_double_t tb; 1187 1188 ta.val = *a; 1189 tb.val = *b; 1190 1191 if ((is_long_double_nan(ta.data)) || (is_long_double_nan(tb.data))) 1192 return 0; 1193 1194 return is_long_double_eq(ta.data, tb.data); 1045 float128 ta, tb; 1046 ta.ld = *a; 1047 tb.ld = *b; 1048 1049 if ((isFloat128NaN(ta)) || (isFloat128NaN(tb))) { 1050 return 0; 1051 } 1052 1053 return isFloat128eq(ta, tb); 1195 1054 } 1196 1055 1197 1056 int _Qp_fge(long double *a, long double *b) 1198 1057 { 1199 long_double_t ta; 1200 long_double_t tb; 1201 1202 ta.val = *a; 1203 tb.val = *b; 1204 1205 if ((is_long_double_nan(ta.data)) || (is_long_double_nan(tb.data))) 1206 return 0; 1207 1208 return is_long_double_eq(ta.data, tb.data) || 1209 is_long_double_gt(ta.data, tb.data); 1058 float128 ta, tb; 1059 ta.ld = *a; 1060 tb.ld = *b; 1061 1062 if ((isFloat128NaN(ta)) || (isFloat128NaN(tb))) { 1063 return 0; 1064 } 1065 1066 return isFloat128eq(ta, tb) || isFloat128gt(ta, tb); 1210 1067 } 1211 1068 1212 1069 int _Qp_fgt(long double *a, long double *b) 1213 1070 { 1214 long_double_t ta; 1215 long_double_t tb; 1216 1217 ta.val = *a; 1218 tb.val = *b; 1219 1220 if ((is_long_double_nan(ta.data)) || (is_long_double_nan(tb.data))) 1221 return 0; 1222 1223 return is_long_double_gt(ta.data, tb.data); 1071 float128 ta, tb; 1072 ta.ld = *a; 1073 tb.ld = *b; 1074 1075 if ((isFloat128NaN(ta)) || (isFloat128NaN(tb))) { 1076 return 0; 1077 } 1078 1079 return isFloat128gt(ta, tb); 1224 1080 } 1225 1081 1226 1082 int _Qp_fle(long double*a, long double *b) 1227 1083 { 1228 long_double_t ta; 1229 long_double_t tb; 1230 1231 ta.val = *a; 1232 tb.val = *b; 1233 1234 if ((is_long_double_nan(ta.data)) || (is_long_double_nan(tb.data))) 1235 return 0; 1236 1237 return is_long_double_eq(ta.data, tb.data) || 1238 is_long_double_lt(ta.data, tb.data); 1084 float128 ta, tb; 1085 ta.ld = *a; 1086 tb.ld = *b; 1087 1088 if ((isFloat128NaN(ta)) || (isFloat128NaN(tb))) { 1089 return 0; 1090 } 1091 1092 return isFloat128eq(ta, tb) || isFloat128lt(ta, tb); 1239 1093 } 1240 1094 1241 1095 int _Qp_flt(long double *a, long double *b) 1242 1096 { 1243 long_double_t ta; 1244 long_double_t tb; 1245 1246 ta.val = *a; 1247 tb.val = *b; 1248 1249 if ((is_long_double_nan(ta.data)) || (is_long_double_nan(tb.data))) 1250 return 0; 1251 1252 return is_long_double_lt(ta.data, tb.data); 1097 float128 ta, tb; 1098 ta.ld = *a; 1099 tb.ld = *b; 1100 1101 if ((isFloat128NaN(ta)) || (isFloat128NaN(tb))) { 1102 return 0; 1103 } 1104 1105 return isFloat128lt(ta, tb); 1253 1106 } 1254 1107 1255 1108 int _Qp_fne(long double *a, long double *b) 1256 1109 { 1257 long_double_t ta; 1258 long_double_t tb; 1259 1260 ta.val = *a; 1261 tb.val = *b; 1262 1263 if ((is_long_double_nan(ta.data)) || (is_long_double_nan(tb.data))) 1264 return 0; 1265 1266 return !is_long_double_eq(ta.data, tb.data); 1267 } 1110 float128 ta, tb; 1111 ta.ld = *a; 1112 tb.ld = *b; 1113 1114 if ((isFloat128NaN(ta)) || (isFloat128NaN(tb))) { 1115 return 1; 1116 } 1117 1118 return !isFloat128eq(ta, tb); 1119 } 1120 1121 #endif 1268 1122 1269 1123 /** @} -
uspace/lib/softfloat/generic/sub.c
r90924df rd9f53877 39 39 #include <common.h> 40 40 41 /** Subtract two single-precision floats with the same sign. 41 /** 42 * Subtract two single-precision floats with the same signs. 42 43 * 43 44 * @param a First input operand. 44 45 * @param b Second input operand. 45 *46 46 * @return Result of substraction. 47 * 48 */ 49 float32 sub_float32(float32 a, float32 b) 47 */ 48 float32 subFloat32(float32 a, float32 b) 50 49 { 51 50 int expdiff; 52 51 uint32_t exp1, exp2, frac1, frac2; 53 52 float32 result; 54 55 result. bin= 0;53 54 result.f = 0; 56 55 57 56 expdiff = a.parts.exp - b.parts.exp; 58 if ((expdiff < 0 ) || ((expdiff == 0) && 59 (a.parts.fraction < b.parts.fraction))) { 60 if (is_float32_nan(b)) { 61 if (is_float32_signan(b)) { 62 // TODO: fix SigNaN 63 } 64 65 return b; 66 } 67 68 if (b.parts.exp == FLOAT32_MAX_EXPONENT) { 69 /* num -(+-inf) = -+inf */ 70 b.parts.sign = !b.parts.sign; 71 return b; 72 } 73 74 result.parts.sign = !a.parts.sign; 57 if ((expdiff < 0 ) || ((expdiff == 0) && (a.parts.fraction < b.parts.fraction))) { 58 if (isFloat32NaN(b)) { 59 /* TODO: fix SigNaN */ 60 if (isFloat32SigNaN(b)) { 61 } 62 return b; 63 } 64 65 if (b.parts.exp == FLOAT32_MAX_EXPONENT) { 66 b.parts.sign = !b.parts.sign; /* num -(+-inf) = -+inf */ 67 return b; 68 } 69 70 result.parts.sign = !a.parts.sign; 75 71 76 72 frac1 = b.parts.fraction; … … 80 76 expdiff *= -1; 81 77 } else { 82 if (is_float32_nan(a)) { 83 if ((is_float32_signan(a)) || (is_float32_signan(b))) { 84 // TODO: fix SigNaN 85 } 86 87 return a; 88 } 89 90 if (a.parts.exp == FLOAT32_MAX_EXPONENT) { 78 if (isFloat32NaN(a)) { 79 /* TODO: fix SigNaN */ 80 if (isFloat32SigNaN(a) || isFloat32SigNaN(b)) { 81 } 82 return a; 83 } 84 85 if (a.parts.exp == FLOAT32_MAX_EXPONENT) { 91 86 if (b.parts.exp == FLOAT32_MAX_EXPONENT) { 92 87 /* inf - inf => nan */ 93 / / TODO: fix exception94 result.bin = FLOAT32_NAN;88 /* TODO: fix exception */ 89 result.binary = FLOAT32_NAN; 95 90 return result; 96 91 } 97 98 92 return a; 99 93 } … … 104 98 exp1 = a.parts.exp; 105 99 frac2 = b.parts.fraction; 106 exp2 = b.parts.exp; 100 exp2 = b.parts.exp; 107 101 } 108 102 … … 111 105 result.parts.fraction = frac1 - frac2; 112 106 if (result.parts.fraction > frac1) { 113 / / TODO: underflow exception107 /* TODO: underflow exception */ 114 108 return result; 115 109 } 116 117 110 result.parts.exp = 0; 118 111 return result; 119 112 } 120 113 121 114 /* add hidden bit */ 122 frac1 |= FLOAT32_HIDDEN_BIT_MASK; 115 frac1 |= FLOAT32_HIDDEN_BIT_MASK; 123 116 124 117 if (exp2 == 0) { 125 118 /* denormalized */ 126 --expdiff; 119 --expdiff; 127 120 } else { 128 121 /* normalized */ … … 134 127 frac2 <<= 6; 135 128 136 if (expdiff > FLOAT32_FRACTION_SIZE + 1) 129 if (expdiff > FLOAT32_FRACTION_SIZE + 1) { 137 130 goto done; 131 } 138 132 139 133 frac1 = frac1 - (frac2 >> expdiff); 140 134 141 135 done: 142 136 /* TODO: find first nonzero digit and shift result and detect possibly underflow */ … … 149 143 /* rounding - if first bit after fraction is set then round up */ 150 144 frac1 += 0x20; 151 145 152 146 if (frac1 & (FLOAT32_HIDDEN_BIT_MASK << 7)) { 153 147 ++exp1; … … 156 150 157 151 /* Clear hidden bit and shift */ 158 result.parts.fraction = ((frac1 >> 6) & (~FLOAT32_HIDDEN_BIT_MASK)); 152 result.parts.fraction = ((frac1 >> 6) & (~FLOAT32_HIDDEN_BIT_MASK)); 159 153 result.parts.exp = exp1; 160 154 … … 162 156 } 163 157 164 /** Subtract two double-precision floats with the same sign. 158 /** 159 * Subtract two double-precision floats with the same signs. 165 160 * 166 161 * @param a First input operand. 167 162 * @param b Second input operand. 168 *169 163 * @return Result of substraction. 170 * 171 */ 172 float64 sub_float64(float64 a, float64 b) 164 */ 165 float64 subFloat64(float64 a, float64 b) 173 166 { 174 167 int expdiff; … … 176 169 uint64_t frac1, frac2; 177 170 float64 result; 178 179 result. bin= 0;171 172 result.d = 0; 180 173 181 174 expdiff = a.parts.exp - b.parts.exp; 182 if ((expdiff < 0 ) || 183 ((expdiff == 0) && (a.parts.fraction < b.parts.fraction))) { 184 if (is_float64_nan(b)) { 185 if (is_float64_signan(b)) { 186 // TODO: fix SigNaN 187 } 188 189 return b; 190 } 191 192 if (b.parts.exp == FLOAT64_MAX_EXPONENT) { 193 /* num -(+-inf) = -+inf */ 194 b.parts.sign = !b.parts.sign; 195 return b; 196 } 197 198 result.parts.sign = !a.parts.sign; 175 if ((expdiff < 0 ) || ((expdiff == 0) && (a.parts.fraction < b.parts.fraction))) { 176 if (isFloat64NaN(b)) { 177 /* TODO: fix SigNaN */ 178 if (isFloat64SigNaN(b)) { 179 } 180 return b; 181 } 182 183 if (b.parts.exp == FLOAT64_MAX_EXPONENT) { 184 b.parts.sign = !b.parts.sign; /* num -(+-inf) = -+inf */ 185 return b; 186 } 187 188 result.parts.sign = !a.parts.sign; 199 189 200 190 frac1 = b.parts.fraction; … … 204 194 expdiff *= -1; 205 195 } else { 206 if (is_float64_nan(a)) { 207 if (is_float64_signan(a) || is_float64_signan(b)) { 208 // TODO: fix SigNaN 209 } 210 211 return a; 212 } 213 214 if (a.parts.exp == FLOAT64_MAX_EXPONENT) { 196 if (isFloat64NaN(a)) { 197 /* TODO: fix SigNaN */ 198 if (isFloat64SigNaN(a) || isFloat64SigNaN(b)) { 199 } 200 return a; 201 } 202 203 if (a.parts.exp == FLOAT64_MAX_EXPONENT) { 215 204 if (b.parts.exp == FLOAT64_MAX_EXPONENT) { 216 205 /* inf - inf => nan */ 217 / / TODO: fix exception218 result.bin = FLOAT64_NAN;206 /* TODO: fix exception */ 207 result.binary = FLOAT64_NAN; 219 208 return result; 220 209 } 221 222 210 return a; 223 211 } … … 228 216 exp1 = a.parts.exp; 229 217 frac2 = b.parts.fraction; 230 exp2 = b.parts.exp; 218 exp2 = b.parts.exp; 231 219 } 232 220 … … 235 223 result.parts.fraction = frac1 - frac2; 236 224 if (result.parts.fraction > frac1) { 237 / / TODO: underflow exception225 /* TODO: underflow exception */ 238 226 return result; 239 227 } 240 241 228 result.parts.exp = 0; 242 229 return result; 243 230 } 244 231 245 232 /* add hidden bit */ 246 frac1 |= FLOAT64_HIDDEN_BIT_MASK; 233 frac1 |= FLOAT64_HIDDEN_BIT_MASK; 247 234 248 235 if (exp2 == 0) { 249 236 /* denormalized */ 250 --expdiff; 237 --expdiff; 251 238 } else { 252 239 /* normalized */ … … 258 245 frac2 <<= 6; 259 246 260 if (expdiff > FLOAT64_FRACTION_SIZE + 1) 247 if (expdiff > FLOAT64_FRACTION_SIZE + 1) { 261 248 goto done; 249 } 262 250 263 251 frac1 = frac1 - (frac2 >> expdiff); 264 252 265 253 done: 266 254 /* TODO: find first nonzero digit and shift result and detect possibly underflow */ … … 273 261 /* rounding - if first bit after fraction is set then round up */ 274 262 frac1 += 0x20; 275 263 276 264 if (frac1 & (FLOAT64_HIDDEN_BIT_MASK << 7)) { 277 265 ++exp1; … … 280 268 281 269 /* Clear hidden bit and shift */ 282 result.parts.fraction = ((frac1 >> 6) & (~FLOAT64_HIDDEN_BIT_MASK)); 270 result.parts.fraction = ((frac1 >> 6) & (~FLOAT64_HIDDEN_BIT_MASK)); 283 271 result.parts.exp = exp1; 284 272 … … 286 274 } 287 275 288 /** Subtract two quadruple-precision floats with the same sign. 276 /** 277 * Subtract two quadruple-precision floats with the same signs. 289 278 * 290 279 * @param a First input operand. 291 280 * @param b Second input operand. 292 *293 281 * @return Result of substraction. 294 * 295 */ 296 float128 sub_float128(float128 a, float128 b) 282 */ 283 float128 subFloat128(float128 a, float128 b) 297 284 { 298 285 int expdiff; … … 300 287 uint64_t frac1_hi, frac1_lo, frac2_hi, frac2_lo, tmp_hi, tmp_lo; 301 288 float128 result; 302 303 result.bin .hi = 0;304 result.bin .lo = 0;305 289 290 result.binary.hi = 0; 291 result.binary.lo = 0; 292 306 293 expdiff = a.parts.exp - b.parts.exp; 307 294 if ((expdiff < 0 ) || ((expdiff == 0) && 308 295 lt128(a.parts.frac_hi, a.parts.frac_lo, b.parts.frac_hi, b.parts.frac_lo))) { 309 if (is_float128_nan(b)) { 310 if (is_float128_signan(b)) { 311 // TODO: fix SigNaN 312 } 313 314 return b; 315 } 316 296 if (isFloat128NaN(b)) { 297 /* TODO: fix SigNaN */ 298 if (isFloat128SigNaN(b)) { 299 } 300 return b; 301 } 302 317 303 if (b.parts.exp == FLOAT128_MAX_EXPONENT) { 318 /* num -(+-inf) = -+inf */ 319 b.parts.sign = !b.parts.sign; 320 return b; 321 } 322 304 b.parts.sign = !b.parts.sign; /* num -(+-inf) = -+inf */ 305 return b; 306 } 307 323 308 result.parts.sign = !a.parts.sign; 324 309 325 310 frac1_hi = b.parts.frac_hi; 326 311 frac1_lo = b.parts.frac_lo; … … 331 316 expdiff *= -1; 332 317 } else { 333 if (is_float128_nan(a)) { 334 if (is_float128_signan(a) || is_float128_signan(b)) { 335 // TODO: fix SigNaN 336 } 337 338 return a; 339 } 340 318 if (isFloat128NaN(a)) { 319 /* TODO: fix SigNaN */ 320 if (isFloat128SigNaN(a) || isFloat128SigNaN(b)) { 321 } 322 return a; 323 } 324 341 325 if (a.parts.exp == FLOAT128_MAX_EXPONENT) { 342 326 if (b.parts.exp == FLOAT128_MAX_EXPONENT) { 343 327 /* inf - inf => nan */ 344 / / TODO: fix exception345 result.bin .hi = FLOAT128_NAN_HI;346 result.bin .lo = FLOAT128_NAN_LO;328 /* TODO: fix exception */ 329 result.binary.hi = FLOAT128_NAN_HI; 330 result.binary.lo = FLOAT128_NAN_LO; 347 331 return result; 348 332 } 349 333 return a; 350 334 } 351 335 352 336 result.parts.sign = a.parts.sign; 353 337 354 338 frac1_hi = a.parts.frac_hi; 355 339 frac1_lo = a.parts.frac_lo; … … 359 343 exp2 = b.parts.exp; 360 344 } 361 345 362 346 if (exp1 == 0) { 363 347 /* both are denormalized */ … … 366 350 result.parts.frac_lo = tmp_lo; 367 351 if (lt128(frac1_hi, frac1_lo, result.parts.frac_hi, result.parts.frac_lo)) { 368 / / TODO: underflow exception352 /* TODO: underflow exception */ 369 353 return result; 370 354 } 371 372 355 result.parts.exp = 0; 373 356 return result; 374 357 } 375 358 376 359 /* add hidden bit */ 377 360 or128(frac1_hi, frac1_lo, 378 361 FLOAT128_HIDDEN_BIT_MASK_HI, FLOAT128_HIDDEN_BIT_MASK_LO, 379 362 &frac1_hi, &frac1_lo); 380 363 381 364 if (exp2 == 0) { 382 365 /* denormalized */ … … 388 371 &frac2_hi, &frac2_lo); 389 372 } 390 373 391 374 /* create some space for rounding */ 392 375 lshift128(frac1_hi, frac1_lo, 6, &frac1_hi, &frac1_lo); 393 376 lshift128(frac2_hi, frac2_lo, 6, &frac2_hi, &frac2_lo); 394 395 if (expdiff > FLOAT128_FRACTION_SIZE + 1) 377 378 if (expdiff > FLOAT128_FRACTION_SIZE + 1) { 396 379 goto done; 397 380 } 381 398 382 rshift128(frac2_hi, frac2_lo, expdiff, &tmp_hi, &tmp_lo); 399 383 sub128(frac1_hi, frac1_lo, tmp_hi, tmp_lo, &frac1_hi, &frac1_lo); 400 384 401 385 done: 402 386 /* TODO: find first nonzero digit and shift result and detect possibly underflow */ … … 408 392 lshift128(frac1_hi, frac1_lo, 1, &frac1_hi, &frac1_lo); 409 393 /* TODO: fix underflow - frac1 == 0 does not necessary means underflow... */ 410 394 411 395 lshift128(FLOAT128_HIDDEN_BIT_MASK_HI, FLOAT128_HIDDEN_BIT_MASK_LO, 6, 412 396 &tmp_hi, &tmp_lo); 413 397 and128(frac1_hi, frac1_lo, tmp_hi, tmp_lo, &tmp_hi, &tmp_lo); 414 398 } 415 399 416 400 /* rounding - if first bit after fraction is set then round up */ 417 401 add128(frac1_hi, frac1_lo, 0x0ll, 0x20ll, &frac1_hi, &frac1_lo); 418 402 419 403 lshift128(FLOAT128_HIDDEN_BIT_MASK_HI, FLOAT128_HIDDEN_BIT_MASK_LO, 7, 420 404 &tmp_hi, &tmp_lo); … … 424 408 rshift128(frac1_hi, frac1_lo, 1, &frac1_hi, &frac1_lo); 425 409 } 426 410 427 411 /* Clear hidden bit and shift */ 428 412 rshift128(frac1_hi, frac1_lo, 6, &frac1_hi, &frac1_lo); … … 432 416 result.parts.frac_hi = tmp_hi; 433 417 result.parts.frac_lo = tmp_lo; 434 418 435 419 result.parts.exp = exp1; 436 420 437 421 return result; 438 422 } -
uspace/lib/softfloat/include/add.h
r90924df rd9f53877 37 37 #define __ADD_H__ 38 38 39 extern float32 add_float32(float32, float32); 40 extern float64 add_float64(float64, float64); 41 extern float96 add_float96(float96, float96); 42 extern float128 add_float128(float128, float128); 39 extern float32 addFloat32(float32, float32); 40 extern float64 addFloat64(float64, float64); 41 extern float128 addFloat128(float128, float128); 43 42 44 43 #endif -
uspace/lib/softfloat/include/common.h
r90924df rd9f53877 39 39 #include <sftypes.h> 40 40 41 extern float64 finish _float64(int32_t, uint64_t, char);42 extern float128 finish _float128(int32_t, uint64_t, uint64_t, char, uint64_t);41 extern float64 finishFloat64(int32_t, uint64_t, char); 42 extern float128 finishFloat128(int32_t, uint64_t, uint64_t, char, uint64_t); 43 43 44 extern int count _zeroes8(uint8_t);45 extern int count _zeroes32(uint32_t);46 extern int count _zeroes64(uint64_t);44 extern int countZeroes8(uint8_t); 45 extern int countZeroes32(uint32_t); 46 extern int countZeroes64(uint64_t); 47 47 48 extern void round _float32(int32_t *, uint32_t *);49 extern void round _float64(int32_t *, uint64_t *);50 extern void round _float128(int32_t *, uint64_t *, uint64_t *);48 extern void roundFloat32(int32_t *, uint32_t *); 49 extern void roundFloat64(int32_t *, uint64_t *); 50 extern void roundFloat128(int32_t *, uint64_t *, uint64_t *); 51 51 52 52 extern void lshift128(uint64_t, uint64_t, int, uint64_t *, uint64_t *); -
uspace/lib/softfloat/include/comparison.h
r90924df rd9f53877 37 37 #define __COMPARISON_H__ 38 38 39 extern int is _float32_nan(float32);40 extern int is _float32_signan(float32);39 extern int isFloat32NaN(float32); 40 extern int isFloat32SigNaN(float32); 41 41 42 extern int is _float32_infinity(float32);43 extern int is _float32_zero(float32);42 extern int isFloat32Infinity(float32); 43 extern int isFloat32Zero(float32); 44 44 45 extern int is _float32_eq(float32, float32);46 extern int is _float32_lt(float32, float32);47 extern int is _float32_gt(float32, float32);45 extern int isFloat32eq(float32, float32); 46 extern int isFloat32lt(float32, float32); 47 extern int isFloat32gt(float32, float32); 48 48 49 extern int is _float64_nan(float64);50 extern int is _float64_signan(float64);49 extern int isFloat64NaN(float64); 50 extern int isFloat64SigNaN(float64); 51 51 52 extern int is _float64_infinity(float64);53 extern int is _float64_zero(float64);52 extern int isFloat64Infinity(float64); 53 extern int isFloat64Zero(float64); 54 54 55 extern int is _float64_eq(float64, float64);56 extern int is _float64_lt(float64, float64);57 extern int is _float64_gt(float64, float64);55 extern int isFloat64eq(float64, float64); 56 extern int isFloat64lt(float64, float64); 57 extern int isFloat64gt(float64, float64); 58 58 59 extern int is _float96_nan(float96);60 extern int is _float96_signan(float96);59 extern int isFloat128NaN(float128); 60 extern int isFloat128SigNaN(float128); 61 61 62 extern int is _float96_infinity(float96);63 extern int is _float96_zero(float96);62 extern int isFloat128Infinity(float128); 63 extern int isFloat128Zero(float128); 64 64 65 extern int is_float96_eq(float96, float96); 66 extern int is_float96_lt(float96, float96); 67 extern int is_float96_gt(float96, float96); 68 69 extern int is_float128_nan(float128); 70 extern int is_float128_signan(float128); 71 72 extern int is_float128_infinity(float128); 73 extern int is_float128_zero(float128); 74 75 extern int is_float128_eq(float128, float128); 76 extern int is_float128_lt(float128, float128); 77 extern int is_float128_gt(float128, float128); 65 extern int isFloat128eq(float128, float128); 66 extern int isFloat128lt(float128, float128); 67 extern int isFloat128gt(float128, float128); 78 68 79 69 #endif -
uspace/lib/softfloat/include/conversion.h
r90924df rd9f53877 37 37 #define __CONVERSION_H__ 38 38 39 extern float64 float32_to_float64(float32); 40 extern float96 float32_to_float96(float32); 41 extern float128 float32_to_float128(float32); 42 extern float96 float64_to_float96(float64); 43 extern float128 float64_to_float128(float64); 44 extern float128 float96_to_float128(float96); 39 extern float64 convertFloat32ToFloat64(float32); 40 extern float128 convertFloat32ToFloat128(float32); 41 extern float128 convertFloat64ToFloat128(float64); 45 42 46 extern float32 float64_to_float32(float64); 47 extern float32 float96_to_float32(float96); 48 extern float64 float96_to_float64(float96); 49 extern float32 float128_to_float32(float128); 50 extern float64 float128_to_float64(float128); 51 extern float96 float128_to_float96(float128); 43 44 extern float32 convertFloat64ToFloat32(float64); 45 extern float32 convertFloat128ToFloat32(float128); 46 extern float64 convertFloat128ToFloat64(float128); 47 52 48 53 49 extern uint32_t float32_to_uint32(float32); … … 63 59 extern int64_t float64_to_int64(float64); 64 60 65 extern uint32_t float96_to_uint32(float96);66 extern int32_t float96_to_int32(float96);67 68 extern uint64_t float96_to_uint64(float96);69 extern int64_t float96_to_int64(float96);70 71 61 extern uint32_t float128_to_uint32(float128); 72 62 extern int32_t float128_to_int32(float128); … … 74 64 extern uint64_t float128_to_uint64(float128); 75 65 extern int64_t float128_to_int64(float128); 66 76 67 77 68 extern float32 uint32_to_float32(uint32_t); … … 87 78 extern float64 int64_to_float64(int64_t); 88 79 89 extern float96 uint32_to_float96(uint32_t);90 extern float96 int32_to_float96(int32_t);91 92 extern float96 uint64_to_float96(uint64_t);93 extern float96 int64_to_float96(int64_t);94 95 80 extern float128 uint32_to_float128(uint32_t); 96 81 extern float128 int32_to_float128(int32_t); -
uspace/lib/softfloat/include/div.h
r90924df rd9f53877 37 37 #define __DIV_H__ 38 38 39 extern float32 div_float32(float32, float32); 40 extern float64 div_float64(float64, float64); 41 extern float96 div_float96(float96, float96); 42 extern float128 div_float128(float128, float128); 39 extern float32 divFloat32(float32, float32); 40 extern float64 divFloat64(float64, float64); 41 extern float128 divFloat128(float128, float128); 43 42 44 43 #endif -
uspace/lib/softfloat/include/mul.h
r90924df rd9f53877 37 37 #define __MUL_H__ 38 38 39 extern float32 mul_float32(float32, float32); 40 extern float64 mul_float64(float64, float64); 41 extern float96 mul_float96(float96, float96); 42 extern float128 mul_float128(float128, float128); 39 extern float32 mulFloat32(float32, float32); 40 extern float64 mulFloat64(float64, float64); 41 extern float128 mulFloat128(float128, float128); 43 42 44 43 #endif -
uspace/lib/softfloat/include/sftypes.h
r90924df rd9f53877 40 40 #include <stdint.h> 41 41 42 /*43 * For recognizing NaNs or infinity use specialized comparison44 * functions, comparing with these constants is not sufficient.45 */46 47 #define FLOAT32_NAN UINT32_C(0x7FC00001)48 #define FLOAT32_SIGNAN UINT32_C(0x7F800001)49 #define FLOAT32_INF UINT32_C(0x7F800000)50 51 #define FLOAT64_NAN UINT64_C(0x7FF8000000000001)52 #define FLOAT64_SIGNAN UINT64_C(0x7FF0000000000001)53 #define FLOAT64_INF UINT64_C(0x7FF0000000000000)54 55 #define FLOAT96_NAN_HI UINT64_C(0x7FFF80000000)56 #define FLOAT96_NAN_LO UINT32_C(0x00010000)57 #define FLOAT96_SIGNAN_HI UINT64_C(0x7FFF00000000)58 #define FLOAT96_SIGNAN_LO UINT32_C(0x00010000)59 60 #define FLOAT128_NAN_HI UINT64_C(0x7FFF800000000000)61 #define FLOAT128_NAN_LO UINT64_C(0x0000000000000001)62 #define FLOAT128_SIGNAN_HI UINT64_C(0x7FFF000000000000)63 #define FLOAT128_SIGNAN_LO UINT64_C(0x0000000000000001)64 #define FLOAT128_INF_HI UINT64_C(0x7FFF000000000000)65 #define FLOAT128_INF_LO UINT64_C(0x0000000000000000)66 67 #define FLOAT32_FRACTION_SIZE 2368 #define FLOAT64_FRACTION_SIZE 5269 #define FLOAT96_FRACTION_SIZE 6470 #define FLOAT128_FRACTION_SIZE 11271 #define FLOAT128_FRAC_HI_SIZE 4872 #define FLOAT128_FRAC_LO_SIZE 6473 74 #define FLOAT32_HIDDEN_BIT_MASK UINT32_C(0x800000)75 #define FLOAT64_HIDDEN_BIT_MASK UINT64_C(0x10000000000000)76 #define FLOAT128_HIDDEN_BIT_MASK_HI UINT64_C(0x1000000000000)77 #define FLOAT128_HIDDEN_BIT_MASK_LO UINT64_C(0x0000000000000000)78 79 #define FLOAT32_MAX_EXPONENT 0xFF80 #define FLOAT64_MAX_EXPONENT 0x7FF81 #define FLOAT96_MAX_EXPONENT 0x7FFF82 #define FLOAT128_MAX_EXPONENT 0x7FFF83 84 #define FLOAT32_BIAS 0x7F85 #define FLOAT64_BIAS 0x3FF86 #define FLOAT96_BIAS 0x3FFF87 #define FLOAT128_BIAS 0x3FFF88 89 #if defined(__BE__)90 91 42 typedef union { 92 uint32_t bin; 43 float f; 44 uint32_t binary; 93 45 94 46 struct { 47 #if defined(__BE__) 95 48 uint32_t sign : 1; 96 49 uint32_t exp : 8; 97 50 uint32_t fraction : 23; 98 } parts __attribute__((packed)); 51 #elif defined(__LE__) 52 uint32_t fraction : 23; 53 uint32_t exp : 8; 54 uint32_t sign : 1; 55 #else 56 #error Unknown endianess 57 #endif 58 } parts __attribute__ ((packed)); 99 59 } float32; 100 60 101 61 typedef union { 102 uint64_t bin; 62 double d; 63 uint64_t binary; 103 64 104 65 struct { 66 #if defined(__BE__) 105 67 uint64_t sign : 1; 106 68 uint64_t exp : 11; 107 69 uint64_t fraction : 52; 108 } parts __attribute__((packed)); 70 #elif defined(__LE__) 71 uint64_t fraction : 52; 72 uint64_t exp : 11; 73 uint64_t sign : 1; 74 #else 75 #error Unknown endianess 76 #endif 77 } parts __attribute__ ((packed)); 109 78 } float64; 110 79 111 80 typedef union { 81 long double ld; 112 82 struct { 113 uint64_t hi; 114 uint32_t lo; 115 } bin __attribute__((packed)); 116 117 struct { 118 uint64_t padding : 16; 119 uint64_t sign : 1; 120 uint64_t exp : 15; 121 uint64_t fraction : 64; 122 } parts __attribute__((packed)); 123 } float96; 124 125 typedef union { 126 struct { 83 #if defined(__BE__) 127 84 uint64_t hi; 128 85 uint64_t lo; 129 } bin __attribute__((packed)); 130 86 #elif defined(__LE__) 87 uint64_t lo; 88 uint64_t hi; 89 #else 90 #error Unknown endianess 91 #endif 92 } binary; 93 131 94 struct { 95 #if defined(__BE__) 132 96 uint64_t sign : 1; 133 97 uint64_t exp : 15; 134 98 uint64_t frac_hi : 48; 135 99 uint64_t frac_lo : 64; 136 } parts __attribute__((packed));137 } float128;138 139 100 #elif defined(__LE__) 140 141 typedef union {142 uint32_t bin;143 144 struct {145 uint32_t fraction : 23;146 uint32_t exp : 8;147 uint32_t sign : 1;148 } parts __attribute__((packed));149 } float32;150 151 typedef union {152 uint64_t bin;153 154 struct {155 uint64_t fraction : 52;156 uint64_t exp : 11;157 uint64_t sign : 1;158 } parts __attribute__((packed));159 } float64;160 161 typedef union {162 struct {163 uint32_t lo;164 uint64_t hi;165 } bin __attribute__((packed));166 167 struct {168 uint64_t fraction : 64;169 uint64_t exp : 15;170 uint64_t sign : 1;171 uint64_t padding : 16;172 } parts __attribute__((packed));173 } float96;174 175 typedef union {176 struct {177 uint64_t lo;178 uint64_t hi;179 } bin __attribute__((packed));180 181 struct {182 101 uint64_t frac_lo : 64; 183 102 uint64_t frac_hi : 48; 184 103 uint64_t exp : 15; 185 104 uint64_t sign : 1; 186 } parts __attribute__((packed));187 } float128;188 189 105 #else 190 106 #error Unknown endianess 191 107 #endif 108 } parts __attribute__ ((packed)); 109 } float128; 192 110 193 typedef union { 194 float val; 195 196 #if defined(FLOAT_SIZE_32) 197 float32 data; 198 #elif defined(FLOAT_SIZE_64) 199 float64 data; 200 #elif defined(FLOAT_SIZE_96) 201 float96 data; 202 #elif defined(FLOAT_SIZE_128) 203 float128 data; 204 #else 205 #error Unsupported float size 206 #endif 207 } float_t; 111 /* 112 * For recognizing NaNs or infinity use specialized comparison functions, 113 * comparing with these constants is not sufficient. 114 */ 208 115 209 typedef union { 210 double val; 211 212 #if defined(DOUBLE_SIZE_32) 213 float32 data; 214 #elif defined(DOUBLE_SIZE_64) 215 float64 data; 216 #elif defined(DOUBLE_SIZE_96) 217 float96 data; 218 #elif defined(DOUBLE_SIZE_128) 219 float128 data; 220 #else 221 #error Unsupported double size 222 #endif 223 } double_t; 116 #define FLOAT32_NAN 0x7FC00001 117 #define FLOAT32_SIGNAN 0x7F800001 118 #define FLOAT32_INF 0x7F800000 224 119 225 typedef union { 226 long double val; 227 228 #if defined(LONG_DOUBLE_SIZE_32) 229 float32 data; 230 #elif defined(LONG_DOUBLE_SIZE_64) 231 float64 data; 232 #elif defined(LONG_DOUBLE_SIZE_96) 233 float96 data; 234 #elif defined(LONG_DOUBLE_SIZE_128) 235 float128 data; 236 #else 237 #error Unsupported long double size 238 #endif 239 } long_double_t; 120 #define FLOAT64_NAN 0x7FF8000000000001ll 121 #define FLOAT64_SIGNAN 0x7FF0000000000001ll 122 #define FLOAT64_INF 0x7FF0000000000000ll 240 123 124 #define FLOAT128_NAN_HI 0x7FFF800000000000ll 125 #define FLOAT128_NAN_LO 0x0000000000000001ll 126 #define FLOAT128_SIGNAN_HI 0x7FFF000000000000ll 127 #define FLOAT128_SIGNAN_LO 0x0000000000000001ll 128 #define FLOAT128_INF_HI 0x7FFF000000000000ll 129 #define FLOAT128_INF_LO 0x0000000000000000ll 241 130 242 #if defined(INT_SIZE_8) 131 #define FLOAT32_FRACTION_SIZE 23 132 #define FLOAT64_FRACTION_SIZE 52 133 #define FLOAT128_FRACTION_SIZE 112 134 #define FLOAT128_FRAC_HI_SIZE 48 135 #define FLOAT128_FRAC_LO_SIZE 64 243 136 244 #define _to_int _to_int8 245 #define from_int int8 137 #define FLOAT32_HIDDEN_BIT_MASK 0x800000 138 #define FLOAT64_HIDDEN_BIT_MASK 0x10000000000000ll 139 #define FLOAT128_HIDDEN_BIT_MASK_HI 0x1000000000000ll 140 #define FLOAT128_HIDDEN_BIT_MASK_LO 0x0000000000000000ll 246 141 247 #elif defined(INT_SIZE_16) 142 #define FLOAT32_MAX_EXPONENT 0xFF 143 #define FLOAT64_MAX_EXPONENT 0x7FF 144 #define FLOAT128_MAX_EXPONENT 0x7FFF 248 145 249 #define _to_int _to_int16 250 #define from_int int16 251 252 #elif defined(INT_SIZE_32) 253 254 #define _to_int _to_int32 255 #define from_int int32 256 257 #elif defined(INT_SIZE_64) 258 259 #define _to_int _to_int64 260 #define from_int int64 261 262 #endif 263 264 265 #if defined(UINT_SIZE_8) 266 267 #define _to_uint _to_uint8 268 #define from_uint uint8 269 270 #elif defined(UINT_SIZE_16) 271 272 #define _to_uint _to_uint16 273 #define from_uint uint16 274 275 #elif defined(UINT_SIZE_32) 276 277 #define _to_uint _to_uint32 278 #define from_uint uint32 279 280 #elif defined(UINT_SIZE_64) 281 282 #define _to_uint _to_uint64 283 #define from_uint uint64 284 285 #endif 286 287 288 #if defined(LONG_SIZE_8) 289 290 #define _to_long _to_int8 291 #define from_long int8 292 293 #elif defined(LONG_SIZE_16) 294 295 #define _to_long _to_int16 296 #define from_long int16 297 298 #elif defined(LONG_SIZE_32) 299 300 #define _to_long _to_int32 301 #define from_long int32 302 303 #elif defined(LONG_SIZE_64) 304 305 #define _to_long _to_int64 306 #define from_long int64 307 308 #endif 309 310 311 #if defined(ULONG_SIZE_8) 312 313 #define _to_ulong _to_uint8 314 #define from_ulong uint8 315 316 #elif defined(ULONG_SIZE_16) 317 318 #define _to_ulong _to_uint16 319 #define from_ulong uint16 320 321 #elif defined(ULONG_SIZE_32) 322 323 #define _to_ulong _to_uint32 324 #define from_ulong uint32 325 326 #elif defined(ULONG_SIZE_64) 327 328 #define _to_ulong _to_uint64 329 #define from_ulong uint64 330 331 #endif 332 333 334 #if defined(LLONG_SIZE_8) 335 336 #define _to_llong _to_int8 337 #define from_llong int8 338 339 #elif defined(LLONG_SIZE_16) 340 341 #define _to_llong _to_int16 342 #define from_llong int16 343 344 #elif defined(LLONG_SIZE_32) 345 346 #define _to_llong _to_int32 347 #define from_llong int32 348 349 #elif defined(LLONG_SIZE_64) 350 351 #define _to_llong _to_int64 352 #define from_llong int64 353 354 #endif 355 356 357 #if defined(ULLONG_SIZE_8) 358 359 #define _to_ullong _to_uint8 360 #define from_ullong uint8 361 362 #elif defined(ULLONG_SIZE_16) 363 364 #define _to_ullong _to_uint16 365 #define from_ullong uint16 366 367 #elif defined(ULLONG_SIZE_32) 368 369 #define _to_ullong _to_uint32 370 #define from_ullong uint32 371 372 #elif defined(ULLONG_SIZE_64) 373 374 #define _to_ullong _to_uint64 375 #define from_ullong uint64 376 377 #endif 378 379 380 #if defined(FLOAT_SIZE_32) 381 382 #define add_float add_float32 383 #define sub_float sub_float32 384 #define mul_float mul_float32 385 #define div_float div_float32 386 #define _to_float _to_float32 387 #define from_float float32 388 #define is_float_nan is_float32_nan 389 #define is_float_eq is_float32_eq 390 #define is_float_lt is_float32_lt 391 #define is_float_gt is_float32_gt 392 393 #elif defined(FLOAT_SIZE_64) 394 395 #define add_float add_float64 396 #define sub_float sub_float64 397 #define mul_float mul_float64 398 #define div_float div_float64 399 #define _to_float _to_float64 400 #define from_float float64 401 #define is_float_nan is_float64_nan 402 #define is_float_eq is_float64_eq 403 #define is_float_lt is_float64_lt 404 #define is_float_gt is_float64_gt 405 406 #elif defined(FLOAT_SIZE_96) 407 408 #define add_float add_float96 409 #define sub_float sub_float96 410 #define mul_float mul_float96 411 #define div_float div_float96 412 #define _to_float _to_float96 413 #define from_float float96 414 #define is_float_nan is_float96_nan 415 #define is_float_eq is_float96_eq 416 #define is_float_lt is_float96_lt 417 #define is_float_gt is_float96_gt 418 419 #elif defined(FLOAT_SIZE_128) 420 421 #define add_float add_float128 422 #define sub_float sub_float128 423 #define mul_float mul_float128 424 #define div_float div_float128 425 #define _to_float _to_float128 426 #define from_float float128 427 #define is_float_nan is_float128_nan 428 #define is_float_eq is_float128_eq 429 #define is_float_lt is_float128_lt 430 #define is_float_gt is_float128_gt 431 432 #endif 433 434 435 #if defined(DOUBLE_SIZE_32) 436 437 #define add_double add_float32 438 #define sub_double sub_float32 439 #define mul_double mul_float32 440 #define div_double div_float32 441 #define _to_double _to_float32 442 #define from_double float32 443 #define is_double_nan is_float32_nan 444 #define is_double_eq is_float32_eq 445 #define is_double_lt is_float32_lt 446 #define is_double_gt is_float32_gt 447 448 #elif defined(DOUBLE_SIZE_64) 449 450 #define add_double add_float64 451 #define sub_double sub_float64 452 #define mul_double mul_float64 453 #define div_double div_float64 454 #define _to_double _to_float64 455 #define from_double float64 456 #define is_double_nan is_float64_nan 457 #define is_double_eq is_float64_eq 458 #define is_double_lt is_float64_lt 459 #define is_double_gt is_float64_gt 460 461 #elif defined(DOUBLE_SIZE_96) 462 463 #define add_double add_float96 464 #define sub_double sub_float96 465 #define mul_double mul_float96 466 #define div_double div_float96 467 #define _to_double _to_float96 468 #define from_double float96 469 #define is_double_nan is_float96_nan 470 #define is_double_eq is_float96_eq 471 #define is_double_lt is_float96_lt 472 #define is_double_gt is_float96_gt 473 474 #elif defined(DOUBLE_SIZE_128) 475 476 #define add_double add_float128 477 #define sub_double sub_float128 478 #define mul_double mul_float128 479 #define div_double div_float128 480 #define _to_double _to_float128 481 #define from_double float128 482 #define is_double_nan is_float128_nan 483 #define is_double_eq is_float128_eq 484 #define is_double_lt is_float128_lt 485 #define is_double_gt is_float128_gt 486 487 #endif 488 489 490 #if defined(LONG_DOUBLE_SIZE_32) 491 492 #define add_long_double add_float32 493 #define sub_long_double sub_float32 494 #define mul_long_double mul_float32 495 #define div_long_double div_float32 496 #define _to_long_double _to_float32 497 #define from_long_double float32 498 #define is_long_double_nan is_float32_nan 499 #define is_long_double_eq is_float32_eq 500 #define is_long_double_lt is_float32_lt 501 #define is_long_double_gt is_float32_gt 502 503 #elif defined(LONG_DOUBLE_SIZE_64) 504 505 #define add_long_double add_float64 506 #define sub_long_double sub_float64 507 #define mul_long_double mul_float64 508 #define div_long_double div_float64 509 #define _to_long_double _to_float64 510 #define from_long_double float64 511 #define is_long_double_nan is_float64_nan 512 #define is_long_double_eq is_float64_eq 513 #define is_long_double_lt is_float64_lt 514 #define is_long_double_gt is_float64_gt 515 516 #elif defined(LONG_DOUBLE_SIZE_96) 517 518 #define add_long_double add_float96 519 #define sub_long_double sub_float96 520 #define mul_long_double mul_float96 521 #define div_long_double div_float96 522 #define _to_long_double _to_float96 523 #define from_long_double float96 524 #define is_long_double_nan is_float96_nan 525 #define is_long_double_eq is_float96_eq 526 #define is_long_double_lt is_float96_lt 527 #define is_long_double_gt is_float96_gt 528 529 #elif defined(LONG_DOUBLE_SIZE_128) 530 531 #define add_long_double add_float128 532 #define sub_long_double sub_float128 533 #define mul_long_double mul_float128 534 #define div_long_double div_float128 535 #define _to_long_double _to_float128 536 #define from_long_double float128 537 #define is_long_double_nan is_float128_nan 538 #define is_long_double_eq is_float128_eq 539 #define is_long_double_lt is_float128_lt 540 #define is_long_double_gt is_float128_gt 541 542 #endif 543 544 545 #define CONCAT(a, b) CONCAT_ARGS(a, b) 546 #define CONCAT_ARGS(a, b) a ## b 547 548 #define float32_to_float32(arg) (arg) 549 #define float64_to_float64(arg) (arg) 550 #define float96_to_float96(arg) (arg) 551 #define float128_to_float128(arg) (arg) 552 553 #define float_to_double CONCAT(from_float, _to_double) 554 #define float_to_long_double CONCAT(from_float, _to_long_double) 555 #define float_to_int CONCAT(from_float, _to_int) 556 #define float_to_uint CONCAT(from_float, _to_uint) 557 #define float_to_long CONCAT(from_float, _to_long) 558 #define float_to_ulong CONCAT(from_float, _to_ulong) 559 #define float_to_llong CONCAT(from_float, _to_llong) 560 #define float_to_ullong CONCAT(from_float, _to_ullong) 561 562 #define double_to_float CONCAT(from_double, _to_float) 563 #define double_to_long_double CONCAT(from_double, _to_long_double) 564 #define double_to_int CONCAT(from_double, _to_int) 565 #define double_to_uint CONCAT(from_double, _to_uint) 566 #define double_to_long CONCAT(from_double, _to_long) 567 #define double_to_ulong CONCAT(from_double, _to_ulong) 568 #define double_to_llong CONCAT(from_double, _to_llong) 569 #define double_to_ullong CONCAT(from_double, _to_ullong) 570 571 #define long_double_to_float CONCAT(from_long_double, _to_float) 572 #define long_double_to_double CONCAT(from_long_double, _to_double) 573 #define long_double_to_int CONCAT(from_long_double, _to_int) 574 #define long_double_to_uint CONCAT(from_long_double, _to_uint) 575 #define long_double_to_long CONCAT(from_long_double, _to_long) 576 #define long_double_to_ulong CONCAT(from_long_double, _to_ulong) 577 #define long_double_to_llong CONCAT(from_long_double, _to_llong) 578 #define long_double_to_ullong CONCAT(from_long_double, _to_ullong) 579 580 #define int_to_float CONCAT(from_int, _to_float) 581 #define int_to_double CONCAT(from_int, _to_double) 582 #define int_to_long_double CONCAT(from_int, _to_long_double) 583 584 #define uint_to_float CONCAT(from_uint, _to_float) 585 #define uint_to_double CONCAT(from_uint, _to_double) 586 #define uint_to_long_double CONCAT(from_uint, _to_long_double) 587 588 #define long_to_float CONCAT(from_long, _to_float) 589 #define long_to_double CONCAT(from_long, _to_double) 590 #define long_to_long_double CONCAT(from_long, _to_long_double) 591 592 #define ulong_to_float CONCAT(from_ulong, _to_float) 593 #define ulong_to_double CONCAT(from_ulong, _to_double) 594 #define ulong_to_long_double CONCAT(from_ulong, _to_long_double) 595 596 #define llong_to_float CONCAT(from_llong, _to_float) 597 #define llong_to_double CONCAT(from_llong, _to_double) 598 #define llong_to_long_double CONCAT(from_llong, _to_long_double) 599 600 #define ullong_to_float CONCAT(from_ullong, _to_float) 601 #define ullong_to_double CONCAT(from_ullong, _to_double) 602 #define ullong_to_long_double CONCAT(from_ullong, _to_long_double) 603 146 #define FLOAT32_BIAS 0x7F 147 #define FLOAT64_BIAS 0x3FF 148 #define FLOAT80_BIAS 0x3FFF 149 #define FLOAT128_BIAS 0x3FFF 604 150 605 151 #endif -
uspace/lib/softfloat/include/softfloat.h
r90924df rd9f53877 169 169 extern float __powisf2(float, int); 170 170 extern double __powidf2 (double, int); 171 extern long double __powitf2(long double, int); 172 extern long double __powixf2(long double, int); 171 extern long double __powitf2 (long double, int); 172 extern long double __powixf2 (long double, int); 173 174 173 175 174 176 /* SPARC quadruple-precision wrappers */ -
uspace/lib/softfloat/include/sub.h
r90924df rd9f53877 37 37 #define __SUB_H__ 38 38 39 extern float32 sub_float32(float32, float32); 40 extern float64 sub_float64(float64, float64); 41 extern float96 sub_float96(float96, float96); 42 extern float128 sub_float128(float128, float128); 39 extern float32 subFloat32(float32, float32); 40 extern float64 subFloat64(float64, float64); 41 extern float128 subFloat128(float128, float128); 43 42 44 43 #endif -
uspace/lib/softint/generic/division.c
r90924df rd9f53877 37 37 #include <division.h> 38 38 39 #define ABSVAL(x) ((x) > 0 ? (x) : -(x)) 40 #define SGN(x) ((x) >= 0 ? 1 : 0) 41 42 static unsigned int divandmod32(unsigned int a, unsigned int b, 43 unsigned int *remainder) 39 #define ABSVAL(x) ( (x) > 0 ? (x) : -(x)) 40 #define SGN(x) ( (x) >= 0 ? 1 : 0 ) 41 42 static unsigned int divandmod32(unsigned int a, unsigned int b, unsigned int *remainder) 44 43 { 45 44 unsigned int result; … … 54 53 } 55 54 56 if ( a < b) {55 if ( a < b) { 57 56 *remainder = a; 58 57 return 0; 59 58 } 60 61 for ( ; steps > 0; steps--) {59 60 for ( ; steps > 0; steps--) { 62 61 /* shift one bit to remainder */ 63 *remainder = ( (*remainder) << 1) | (( a >> 31) & 0x1);62 *remainder = ( (*remainder) << 1) | (( a >> 31) & 0x1); 64 63 result <<= 1; 65 64 66 65 if (*remainder >= b) { 67 *remainder -= b;68 result |= 0x1;66 *remainder -= b; 67 result |= 0x1; 69 68 } 70 69 a <<= 1; 71 70 } 72 71 73 72 return result; 74 73 } 75 74 76 static unsigned long long divandmod64(unsigned long long a, 77 75 76 static unsigned long long divandmod64(unsigned long long a, unsigned long long b, unsigned long long *remainder) 78 77 { 79 78 unsigned long long result; 80 int steps = sizeof(unsigned long long) * 8; 79 int steps = sizeof(unsigned long long) * 8; 81 80 82 81 *remainder = 0; … … 88 87 } 89 88 90 if ( a < b) {89 if ( a < b) { 91 90 *remainder = a; 92 91 return 0; 93 92 } 94 95 for ( ; steps > 0; steps--) {93 94 for ( ; steps > 0; steps--) { 96 95 /* shift one bit to remainder */ 97 *remainder = ( (*remainder) << 1) | ((a >> 63) & 0x1);96 *remainder = ( (*remainder) << 1) | ((a >> 63) & 0x1); 98 97 result <<= 1; 99 98 100 99 if (*remainder >= b) { 101 *remainder -= b;102 result |= 0x1;100 *remainder -= b; 101 result |= 0x1; 103 102 } 104 103 a <<= 1; 105 104 } 106 105 107 106 return result; 108 107 } 109 108 110 109 /* 32bit integer division */ 111 int __divsi3(int a, int b) 110 int __divsi3(int a, int b) 112 111 { 113 112 unsigned int rem; 114 int result = (int) divandmod32(ABSVAL(a), ABSVAL(b), &rem);113 int result; 115 114 116 if (SGN(a) == SGN(b))117 return result; 118 115 result = (int)divandmod32(ABSVAL(a), ABSVAL(b), &rem); 116 117 if ( SGN(a) == SGN(b)) return result; 119 118 return -result; 120 119 } 121 120 122 121 /* 64bit integer division */ 123 long long __divdi3(long long a, long long b) 122 long long __divdi3(long long a, long long b) 124 123 { 125 124 unsigned long long rem; 126 long long result = (long long) divandmod64(ABSVAL(a), ABSVAL(b), &rem);125 long long result; 127 126 128 if (SGN(a) == SGN(b))129 return result; 130 127 result = (long long)divandmod64(ABSVAL(a), ABSVAL(b), &rem); 128 129 if ( SGN(a) == SGN(b)) return result; 131 130 return -result; 132 131 } … … 142 141 unsigned long long __udivdi3(unsigned long long a, unsigned long long b) 143 142 { 144 unsigned long long rem;143 unsigned long long rem; 145 144 return divandmod64(a, b, &rem); 146 145 } … … 153 152 154 153 /* if divident is negative, remainder must be too */ 155 if (!(SGN(a))) 156 return -((int) rem); 154 if (!(SGN(a))) { 155 return -((int)rem); 156 } 157 157 158 return (int) 158 return (int)rem; 159 159 } 160 160 161 161 /* 64bit remainder of the signed division */ 162 long long __moddi3(long long a, longlong b)162 long long __moddi3(long long a,long long b) 163 163 { 164 164 unsigned long long rem; … … 166 166 167 167 /* if divident is negative, remainder must be too */ 168 if (!(SGN(a))) 169 return -((long long) rem); 168 if (!(SGN(a))) { 169 return -((long long)rem); 170 } 170 171 171 return (long long) 172 return (long long)rem; 172 173 } 173 174 … … 188 189 } 189 190 190 int __divmodsi3(int a, int b, int *c) 191 { 192 unsigned int rem; 193 int result = (int) divandmod32(ABSVAL(a), ABSVAL(b), &rem); 194 195 if (SGN(a) == SGN(b)) { 196 *c = rem; 197 return result; 198 } 199 200 *c = -rem; 201 return -result; 202 } 203 204 unsigned int __udivmodsi3(unsigned int a, unsigned int b, 205 unsigned int *c) 206 { 207 return divandmod32(a, b, c); 208 } 209 210 long long __divmoddi3(long long a, long long b, long long *c) 211 { 212 unsigned long long rem; 213 long long result = (int) divandmod64(ABSVAL(a), ABSVAL(b), &rem); 214 215 if (SGN(a) == SGN(b)) { 216 *c = rem; 217 return result; 218 } 219 220 *c = -rem; 221 return -result; 222 } 223 224 unsigned long long __udivmoddi3(unsigned long long a, unsigned long long b, 225 unsigned long long *c) 191 unsigned long long __udivmoddi3(unsigned long long a, unsigned long long b, unsigned long long *c) 226 192 { 227 193 return divandmod64(a, b, c); -
uspace/lib/softint/include/comparison.h
r90924df rd9f53877 38 38 39 39 /* Signed comparison (a < b => 0, a == b => 1, a > b => 2). */ 40 extern int __cmpdi2(long long, long long);40 int __cmpdi2 (long long a, long long b); 41 41 42 42 /* Unsigned comparison (a < b => 0, a == b => 1, a > b => 2). */ 43 extern int __ucmpdi2(unsigned long long, unsigned long long);43 int __ucmpdi2 (unsigned long long a, unsigned long long b); 44 44 45 45 #endif -
uspace/lib/softint/include/division.h
r90924df rd9f53877 29 29 /** @addtogroup softint 30 30 * @{ 31 */ 31 */ 32 32 /** 33 33 * @file … … 37 37 #define __SOFTINT_DIVISION_H__ 38 38 39 extern int __divsi3(int, int);40 extern long long __divdi3(long long, long long);41 39 42 extern unsigned int __udivsi3(unsigned int, unsigned int); 43 extern unsigned long long __udivdi3(unsigned long long, unsigned long long);40 /* 32bit integer division */ 41 int __divsi3(int a, int b); 44 42 45 extern int __modsi3(int, int); 46 extern long long __moddi3(long long, long long);43 /* 64bit integer division */ 44 long long __divdi3(long long a, long long b); 47 45 48 extern unsigned int __umodsi3(unsigned int, unsigned int); 49 extern unsigned long long __umoddi3(unsigned long long, unsigned long long);46 /* 32bit unsigned integer division */ 47 unsigned int __udivsi3(unsigned int a, unsigned int b); 50 48 51 extern int __divmodsi3(int, int, int *); 52 extern unsigned int __udivmodsi3(unsigned int, unsigned int, unsigned int *);49 /* 64bit unsigned integer division */ 50 unsigned long long __udivdi3(unsigned long long a, unsigned long long b); 53 51 54 extern long long __divmoddi3(long long, long long, long long *); 55 extern unsigned long long __udivmoddi3(unsigned long long, unsigned long long, 56 unsigned long long *); 52 /* 32bit remainder of the signed division */ 53 int __modsi3(int a, int b); 54 55 /* 64bit remainder of the signed division */ 56 long long __moddi3(long long a, long long b); 57 58 /* 32bit remainder of the unsigned division */ 59 unsigned int __umodsi3(unsigned int a, unsigned int b); 60 61 /* 64bit remainder of the unsigned division */ 62 unsigned long long __umoddi3(unsigned long long a, unsigned long long b); 63 64 unsigned long long __udivmoddi3(unsigned long long a, unsigned long long b, unsigned long long *c); 57 65 58 66 #endif … … 60 68 /** @} 61 69 */ 70 -
uspace/lib/softint/include/lltype.h
r90924df rd9f53877 39 39 #include <stdint.h> 40 40 41 #define HALF_BIT_CNT 42 #define WHOLE_BIT_CNT 41 #define HALF_BIT_CNT (sizeof(int32_t) * sizeof(char)) 42 #define WHOLE_BIT_CNT (sizeof(int64_t) * sizeof(char)) 43 43 44 44 #ifdef __BE__ -
uspace/lib/softint/include/multiplication.h
r90924df rd9f53877 29 29 /** @addtogroup softint 30 30 * @{ 31 */ 31 */ 32 32 /** 33 33 * @file … … 38 38 39 39 /* 64 bit multiplication */ 40 extern long long __muldi3(long long, long long);40 long long __muldi3(long long a, long long b); 41 41 42 42 #endif -
uspace/lib/softint/include/shift.h
r90924df rd9f53877 38 38 39 39 /* Arithmetic/logical shift left. */ 40 extern long long __ashldi3(long long, int);40 long long __ashldi3 (long long val, int shift); 41 41 42 42 /* Arithmetic shift right. */ 43 extern long long __ashrdi3(long long, int);43 long long __ashrdi3 (long long val, int shift); 44 44 45 45 /* Logical shift right. */ 46 extern long long __lshrdi3(long long, int);46 long long __lshrdi3 (long long val, int shift); 47 47 48 48 #endif -
uspace/srv/fs/exfat/exfat_fat.c
r90924df rd9f53877 127 127 { 128 128 exfat_cluster_t firstc = nodep->firstc; 129 exfat_cluster_t currc = 0;129 exfat_cluster_t currc; 130 130 aoff64_t relbn = bn; 131 131 int rc; -
uspace/srv/hid/fb/port/ega.c
r90924df rd9f53877 117 117 uint8_t glyph; 118 118 119 if ( ascii_check(field->ch))119 if ((field->ch >= 0) && (field->ch < 128)) 120 120 glyph = field->ch; 121 121 else -
uspace/srv/hid/fb/port/kchar.c
r90924df rd9f53877 48 48 static void kchar_putchar(wchar_t ch) 49 49 { 50 if ( ascii_check(ch))50 if ((ch >= 0) && (ch < 128)) 51 51 *kchar.addr = ch; 52 52 else -
uspace/srv/hid/fb/port/kfb.c
r90924df rd9f53877 409 409 charfield_t *field = screenbuffer_field_at(vp->backbuf, col, row); 410 410 411 pixel_t bgcolor = 0;412 pixel_t fgcolor = 0;411 pixel_t bgcolor; 412 pixel_t fgcolor; 413 413 attrs_rgb(field->attrs, &bgcolor, &fgcolor); 414 414 … … 525 525 } 526 526 527 pixel_t bgcolor = 0;528 pixel_t fgcolor = 0;527 pixel_t bgcolor; 528 pixel_t fgcolor; 529 529 attrs_rgb(vp->attrs, &bgcolor, &fgcolor); 530 530 -
uspace/srv/hid/fb/port/niagara.c
r90924df rd9f53877 68 68 static void niagara_putchar(wchar_t ch) 69 69 { 70 if ( ascii_check(ch))70 if ((ch >= 0) && (ch < 128)) 71 71 niagara_putc(ch); 72 72 else
Note:
See TracChangeset
for help on using the changeset viewer.