ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/CBOR-XS/ecb.h
(Generate patch)

Comparing CBOR-XS/ecb.h (file contents):
Revision 1.10 by root, Sun Dec 14 05:48:40 2014 UTC vs.
Revision 1.11 by root, Mon Apr 27 20:21:53 2015 UTC

1/* 1/*
2 * libecb - http://software.schmorp.de/pkg/libecb 2 * libecb - http://software.schmorp.de/pkg/libecb
3 * 3 *
4 * Copyright (©) 2009-2014 Marc Alexander Lehmann <libecb@schmorp.de> 4 * Copyright (©) 2009-2015 Marc Alexander Lehmann <libecb@schmorp.de>
5 * Copyright (©) 2011 Emanuele Giaquinta 5 * Copyright (©) 2011 Emanuele Giaquinta
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without modifica- 8 * Redistribution and use in source and binary forms, with or without modifica-
9 * tion, are permitted provided that the following conditions are met: 9 * tion, are permitted provided that the following conditions are met:
302 302
303#define ECB_CONCAT_(a, b) a ## b 303#define ECB_CONCAT_(a, b) a ## b
304#define ECB_CONCAT(a, b) ECB_CONCAT_(a, b) 304#define ECB_CONCAT(a, b) ECB_CONCAT_(a, b)
305#define ECB_STRINGIFY_(a) # a 305#define ECB_STRINGIFY_(a) # a
306#define ECB_STRINGIFY(a) ECB_STRINGIFY_(a) 306#define ECB_STRINGIFY(a) ECB_STRINGIFY_(a)
307#define ECB_STRINGIFY_EXPR(expr) ((expr), ECB_STRINGIFY_ (expr))
307 308
308#define ecb_function_ ecb_inline 309#define ecb_function_ ecb_inline
309 310
310#if ECB_GCC_VERSION(3,1) || ECB_CLANG_VERSION(2,8) 311#if ECB_GCC_VERSION(3,1) || ECB_CLANG_VERSION(2,8)
311 #define ecb_attribute(attrlist) __attribute__ (attrlist) 312 #define ecb_attribute(attrlist) __attribute__ (attrlist)
348 #define ecb_deprecated __declspec (deprecated) 349 #define ecb_deprecated __declspec (deprecated)
349#else 350#else
350 #define ecb_deprecated ecb_attribute ((__deprecated__)) 351 #define ecb_deprecated ecb_attribute ((__deprecated__))
351#endif 352#endif
352 353
354#if __MSC_VER >= 1500
355 #define ecb_deprecated_message(msg) __declspec (deprecated (msg))
356#elif ECB_GCC_VERSION(4,5)
357 #define ecb_deprecated_message(msg) ecb_attribute ((__deprecated__ (msg))
358#else
359 #define ecb_deprecated_message(msg) ecb_deprecated
360#endif
361
362#if _MSC_VER >= 1400
363 #define ecb_noinline __declspec (noinline)
364#else
353#define ecb_noinline ecb_attribute ((__noinline__)) 365 #define ecb_noinline ecb_attribute ((__noinline__))
366#endif
367
354#define ecb_unused ecb_attribute ((__unused__)) 368#define ecb_unused ecb_attribute ((__unused__))
355#define ecb_const ecb_attribute ((__const__)) 369#define ecb_const ecb_attribute ((__const__))
356#define ecb_pure ecb_attribute ((__pure__)) 370#define ecb_pure ecb_attribute ((__pure__))
357 371
358/* TODO http://msdn.microsoft.com/en-us/library/k6ktzx3s.aspx __declspec(noreturn) */ 372/* TODO http://msdn.microsoft.com/en-us/library/k6ktzx3s.aspx __declspec(noreturn) */
359#if ECB_C11 || __IBMC_NORETURN 373#if ECB_C11 || __IBMC_NORETURN
360 /* http://pic.dhe.ibm.com/infocenter/compbg/v121v141/topic/com.ibm.xlcpp121.bg.doc/language_ref/noreturn.html */ 374 /* http://pic.dhe.ibm.com/infocenter/compbg/v121v141/topic/com.ibm.xlcpp121.bg.doc/language_ref/noreturn.html */
361 #define ecb_noreturn _Noreturn 375 #define ecb_noreturn _Noreturn
376#elif ECB_CPP11
377 #define ecb_noreturn [[noreturn]]
378#elif _MSC_VER >= 1200
379 #define ecb_noreturn __declspec (noreturn)
362#else 380#else
363 #define ecb_noreturn ecb_attribute ((__noreturn__)) 381 #define ecb_noreturn ecb_attribute ((__noreturn__))
364#endif 382#endif
365 383
366#if ECB_GCC_VERSION(4,3) 384#if ECB_GCC_VERSION(4,3)
393 #define ecb_ctz32(x) __builtin_ctz (x) 411 #define ecb_ctz32(x) __builtin_ctz (x)
394 #define ecb_ctz64(x) __builtin_ctzll (x) 412 #define ecb_ctz64(x) __builtin_ctzll (x)
395 #define ecb_popcount32(x) __builtin_popcount (x) 413 #define ecb_popcount32(x) __builtin_popcount (x)
396 /* no popcountll */ 414 /* no popcountll */
397#else 415#else
398 ecb_function_ int ecb_ctz32 (uint32_t x) ecb_const; 416 ecb_function_ ecb_const int ecb_ctz32 (uint32_t x);
399 ecb_function_ int 417 ecb_function_ ecb_const int
400 ecb_ctz32 (uint32_t x) 418 ecb_ctz32 (uint32_t x)
401 { 419 {
402 int r = 0; 420 int r = 0;
403 421
404 x &= ~x + 1; /* this isolates the lowest bit */ 422 x &= ~x + 1; /* this isolates the lowest bit */
418#endif 436#endif
419 437
420 return r; 438 return r;
421 } 439 }
422 440
423 ecb_function_ int ecb_ctz64 (uint64_t x) ecb_const; 441 ecb_function_ ecb_const int ecb_ctz64 (uint64_t x);
424 ecb_function_ int 442 ecb_function_ ecb_const int
425 ecb_ctz64 (uint64_t x) 443 ecb_ctz64 (uint64_t x)
426 { 444 {
427 int shift = x & 0xffffffffU ? 0 : 32; 445 int shift = x & 0xffffffffU ? 0 : 32;
428 return ecb_ctz32 (x >> shift) + shift; 446 return ecb_ctz32 (x >> shift) + shift;
429 } 447 }
430 448
431 ecb_function_ int ecb_popcount32 (uint32_t x) ecb_const; 449 ecb_function_ ecb_const int ecb_popcount32 (uint32_t x);
432 ecb_function_ int 450 ecb_function_ ecb_const int
433 ecb_popcount32 (uint32_t x) 451 ecb_popcount32 (uint32_t x)
434 { 452 {
435 x -= (x >> 1) & 0x55555555; 453 x -= (x >> 1) & 0x55555555;
436 x = ((x >> 2) & 0x33333333) + (x & 0x33333333); 454 x = ((x >> 2) & 0x33333333) + (x & 0x33333333);
437 x = ((x >> 4) + x) & 0x0f0f0f0f; 455 x = ((x >> 4) + x) & 0x0f0f0f0f;
438 x *= 0x01010101; 456 x *= 0x01010101;
439 457
440 return x >> 24; 458 return x >> 24;
441 } 459 }
442 460
443 ecb_function_ int ecb_ld32 (uint32_t x) ecb_const; 461 ecb_function_ ecb_const int ecb_ld32 (uint32_t x);
444 ecb_function_ int ecb_ld32 (uint32_t x) 462 ecb_function_ ecb_const int ecb_ld32 (uint32_t x)
445 { 463 {
446 int r = 0; 464 int r = 0;
447 465
448 if (x >> 16) { x >>= 16; r += 16; } 466 if (x >> 16) { x >>= 16; r += 16; }
449 if (x >> 8) { x >>= 8; r += 8; } 467 if (x >> 8) { x >>= 8; r += 8; }
452 if (x >> 1) { r += 1; } 470 if (x >> 1) { r += 1; }
453 471
454 return r; 472 return r;
455 } 473 }
456 474
457 ecb_function_ int ecb_ld64 (uint64_t x) ecb_const; 475 ecb_function_ ecb_const int ecb_ld64 (uint64_t x);
458 ecb_function_ int ecb_ld64 (uint64_t x) 476 ecb_function_ ecb_const int ecb_ld64 (uint64_t x)
459 { 477 {
460 int r = 0; 478 int r = 0;
461 479
462 if (x >> 32) { x >>= 32; r += 32; } 480 if (x >> 32) { x >>= 32; r += 32; }
463 481
464 return r + ecb_ld32 (x); 482 return r + ecb_ld32 (x);
465 } 483 }
466#endif 484#endif
467 485
468ecb_function_ ecb_bool ecb_is_pot32 (uint32_t x) ecb_const; 486ecb_function_ ecb_const ecb_bool ecb_is_pot32 (uint32_t x);
469ecb_function_ ecb_bool ecb_is_pot32 (uint32_t x) { return !(x & (x - 1)); } 487ecb_function_ ecb_const ecb_bool ecb_is_pot32 (uint32_t x) { return !(x & (x - 1)); }
470ecb_function_ ecb_bool ecb_is_pot64 (uint64_t x) ecb_const; 488ecb_function_ ecb_const ecb_bool ecb_is_pot64 (uint64_t x);
471ecb_function_ ecb_bool ecb_is_pot64 (uint64_t x) { return !(x & (x - 1)); } 489ecb_function_ ecb_const ecb_bool ecb_is_pot64 (uint64_t x) { return !(x & (x - 1)); }
472 490
473ecb_function_ uint8_t ecb_bitrev8 (uint8_t x) ecb_const; 491ecb_function_ ecb_const uint8_t ecb_bitrev8 (uint8_t x);
474ecb_function_ uint8_t ecb_bitrev8 (uint8_t x) 492ecb_function_ ecb_const uint8_t ecb_bitrev8 (uint8_t x)
475{ 493{
476 return ( (x * 0x0802U & 0x22110U) 494 return ( (x * 0x0802U & 0x22110U)
477 | (x * 0x8020U & 0x88440U)) * 0x10101U >> 16; 495 | (x * 0x8020U & 0x88440U)) * 0x10101U >> 16;
478} 496}
479 497
480ecb_function_ uint16_t ecb_bitrev16 (uint16_t x) ecb_const; 498ecb_function_ ecb_const uint16_t ecb_bitrev16 (uint16_t x);
481ecb_function_ uint16_t ecb_bitrev16 (uint16_t x) 499ecb_function_ ecb_const uint16_t ecb_bitrev16 (uint16_t x)
482{ 500{
483 x = ((x >> 1) & 0x5555) | ((x & 0x5555) << 1); 501 x = ((x >> 1) & 0x5555) | ((x & 0x5555) << 1);
484 x = ((x >> 2) & 0x3333) | ((x & 0x3333) << 2); 502 x = ((x >> 2) & 0x3333) | ((x & 0x3333) << 2);
485 x = ((x >> 4) & 0x0f0f) | ((x & 0x0f0f) << 4); 503 x = ((x >> 4) & 0x0f0f) | ((x & 0x0f0f) << 4);
486 x = ( x >> 8 ) | ( x << 8); 504 x = ( x >> 8 ) | ( x << 8);
487 505
488 return x; 506 return x;
489} 507}
490 508
491ecb_function_ uint32_t ecb_bitrev32 (uint32_t x) ecb_const; 509ecb_function_ ecb_const uint32_t ecb_bitrev32 (uint32_t x);
492ecb_function_ uint32_t ecb_bitrev32 (uint32_t x) 510ecb_function_ ecb_const uint32_t ecb_bitrev32 (uint32_t x)
493{ 511{
494 x = ((x >> 1) & 0x55555555) | ((x & 0x55555555) << 1); 512 x = ((x >> 1) & 0x55555555) | ((x & 0x55555555) << 1);
495 x = ((x >> 2) & 0x33333333) | ((x & 0x33333333) << 2); 513 x = ((x >> 2) & 0x33333333) | ((x & 0x33333333) << 2);
496 x = ((x >> 4) & 0x0f0f0f0f) | ((x & 0x0f0f0f0f) << 4); 514 x = ((x >> 4) & 0x0f0f0f0f) | ((x & 0x0f0f0f0f) << 4);
497 x = ((x >> 8) & 0x00ff00ff) | ((x & 0x00ff00ff) << 8); 515 x = ((x >> 8) & 0x00ff00ff) | ((x & 0x00ff00ff) << 8);
500 return x; 518 return x;
501} 519}
502 520
503/* popcount64 is only available on 64 bit cpus as gcc builtin */ 521/* popcount64 is only available on 64 bit cpus as gcc builtin */
504/* so for this version we are lazy */ 522/* so for this version we are lazy */
505ecb_function_ int ecb_popcount64 (uint64_t x) ecb_const; 523ecb_function_ ecb_const int ecb_popcount64 (uint64_t x);
506ecb_function_ int 524ecb_function_ ecb_const int
507ecb_popcount64 (uint64_t x) 525ecb_popcount64 (uint64_t x)
508{ 526{
509 return ecb_popcount32 (x) + ecb_popcount32 (x >> 32); 527 return ecb_popcount32 (x) + ecb_popcount32 (x >> 32);
510} 528}
511 529
512ecb_inline uint8_t ecb_rotl8 (uint8_t x, unsigned int count) ecb_const; 530ecb_inline ecb_const uint8_t ecb_rotl8 (uint8_t x, unsigned int count);
513ecb_inline uint8_t ecb_rotr8 (uint8_t x, unsigned int count) ecb_const; 531ecb_inline ecb_const uint8_t ecb_rotr8 (uint8_t x, unsigned int count);
514ecb_inline uint16_t ecb_rotl16 (uint16_t x, unsigned int count) ecb_const; 532ecb_inline ecb_const uint16_t ecb_rotl16 (uint16_t x, unsigned int count);
515ecb_inline uint16_t ecb_rotr16 (uint16_t x, unsigned int count) ecb_const; 533ecb_inline ecb_const uint16_t ecb_rotr16 (uint16_t x, unsigned int count);
516ecb_inline uint32_t ecb_rotl32 (uint32_t x, unsigned int count) ecb_const; 534ecb_inline ecb_const uint32_t ecb_rotl32 (uint32_t x, unsigned int count);
517ecb_inline uint32_t ecb_rotr32 (uint32_t x, unsigned int count) ecb_const; 535ecb_inline ecb_const uint32_t ecb_rotr32 (uint32_t x, unsigned int count);
518ecb_inline uint64_t ecb_rotl64 (uint64_t x, unsigned int count) ecb_const; 536ecb_inline ecb_const uint64_t ecb_rotl64 (uint64_t x, unsigned int count);
519ecb_inline uint64_t ecb_rotr64 (uint64_t x, unsigned int count) ecb_const; 537ecb_inline ecb_const uint64_t ecb_rotr64 (uint64_t x, unsigned int count);
520 538
521ecb_inline uint8_t ecb_rotl8 (uint8_t x, unsigned int count) { return (x >> ( 8 - count)) | (x << count); } 539ecb_inline ecb_const uint8_t ecb_rotl8 (uint8_t x, unsigned int count) { return (x >> ( 8 - count)) | (x << count); }
522ecb_inline uint8_t ecb_rotr8 (uint8_t x, unsigned int count) { return (x << ( 8 - count)) | (x >> count); } 540ecb_inline ecb_const uint8_t ecb_rotr8 (uint8_t x, unsigned int count) { return (x << ( 8 - count)) | (x >> count); }
523ecb_inline uint16_t ecb_rotl16 (uint16_t x, unsigned int count) { return (x >> (16 - count)) | (x << count); } 541ecb_inline ecb_const uint16_t ecb_rotl16 (uint16_t x, unsigned int count) { return (x >> (16 - count)) | (x << count); }
524ecb_inline uint16_t ecb_rotr16 (uint16_t x, unsigned int count) { return (x << (16 - count)) | (x >> count); } 542ecb_inline ecb_const uint16_t ecb_rotr16 (uint16_t x, unsigned int count) { return (x << (16 - count)) | (x >> count); }
525ecb_inline uint32_t ecb_rotl32 (uint32_t x, unsigned int count) { return (x >> (32 - count)) | (x << count); } 543ecb_inline ecb_const uint32_t ecb_rotl32 (uint32_t x, unsigned int count) { return (x >> (32 - count)) | (x << count); }
526ecb_inline uint32_t ecb_rotr32 (uint32_t x, unsigned int count) { return (x << (32 - count)) | (x >> count); } 544ecb_inline ecb_const uint32_t ecb_rotr32 (uint32_t x, unsigned int count) { return (x << (32 - count)) | (x >> count); }
527ecb_inline uint64_t ecb_rotl64 (uint64_t x, unsigned int count) { return (x >> (64 - count)) | (x << count); } 545ecb_inline ecb_const uint64_t ecb_rotl64 (uint64_t x, unsigned int count) { return (x >> (64 - count)) | (x << count); }
528ecb_inline uint64_t ecb_rotr64 (uint64_t x, unsigned int count) { return (x << (64 - count)) | (x >> count); } 546ecb_inline ecb_const uint64_t ecb_rotr64 (uint64_t x, unsigned int count) { return (x << (64 - count)) | (x >> count); }
529 547
530#if ECB_GCC_VERSION(4,3) || (ECB_CLANG_BUILTIN(__builtin_bswap32) && ECB_CLANG_BUILTIN(__builtin_bswap64)) 548#if ECB_GCC_VERSION(4,3) || (ECB_CLANG_BUILTIN(__builtin_bswap32) && ECB_CLANG_BUILTIN(__builtin_bswap64))
531 #define ecb_bswap16(x) (__builtin_bswap32 (x) >> 16) 549 #define ecb_bswap16(x) (__builtin_bswap32 (x) >> 16)
532 #define ecb_bswap32(x) __builtin_bswap32 (x) 550 #define ecb_bswap32(x) __builtin_bswap32 (x)
533 #define ecb_bswap64(x) __builtin_bswap64 (x) 551 #define ecb_bswap64(x) __builtin_bswap64 (x)
534#else 552#else
535 ecb_function_ uint16_t ecb_bswap16 (uint16_t x) ecb_const; 553 ecb_function_ ecb_const uint16_t ecb_bswap16 (uint16_t x);
536 ecb_function_ uint16_t 554 ecb_function_ ecb_const uint16_t
537 ecb_bswap16 (uint16_t x) 555 ecb_bswap16 (uint16_t x)
538 { 556 {
539 return ecb_rotl16 (x, 8); 557 return ecb_rotl16 (x, 8);
540 } 558 }
541 559
542 ecb_function_ uint32_t ecb_bswap32 (uint32_t x) ecb_const; 560 ecb_function_ ecb_const uint32_t ecb_bswap32 (uint32_t x);
543 ecb_function_ uint32_t 561 ecb_function_ ecb_const uint32_t
544 ecb_bswap32 (uint32_t x) 562 ecb_bswap32 (uint32_t x)
545 { 563 {
546 return (((uint32_t)ecb_bswap16 (x)) << 16) | ecb_bswap16 (x >> 16); 564 return (((uint32_t)ecb_bswap16 (x)) << 16) | ecb_bswap16 (x >> 16);
547 } 565 }
548 566
549 ecb_function_ uint64_t ecb_bswap64 (uint64_t x) ecb_const; 567 ecb_function_ ecb_const uint64_t ecb_bswap64 (uint64_t x);
550 ecb_function_ uint64_t 568 ecb_function_ ecb_const uint64_t
551 ecb_bswap64 (uint64_t x) 569 ecb_bswap64 (uint64_t x)
552 { 570 {
553 return (((uint64_t)ecb_bswap32 (x)) << 32) | ecb_bswap32 (x >> 32); 571 return (((uint64_t)ecb_bswap32 (x)) << 32) | ecb_bswap32 (x >> 32);
554 } 572 }
555#endif 573#endif
556 574
557#if ECB_GCC_VERSION(4,5) || ECB_CLANG_BUILTIN(__builtin_unreachable) 575#if ECB_GCC_VERSION(4,5) || ECB_CLANG_BUILTIN(__builtin_unreachable)
558 #define ecb_unreachable() __builtin_unreachable () 576 #define ecb_unreachable() __builtin_unreachable ()
559#else 577#else
560 /* this seems to work fine, but gcc always emits a warning for it :/ */ 578 /* this seems to work fine, but gcc always emits a warning for it :/ */
561 ecb_inline void ecb_unreachable (void) ecb_noreturn; 579 ecb_inline ecb_noreturn void ecb_unreachable (void);
562 ecb_inline void ecb_unreachable (void) { } 580 ecb_inline ecb_noreturn void ecb_unreachable (void) { }
563#endif 581#endif
564 582
565/* try to tell the compiler that some condition is definitely true */ 583/* try to tell the compiler that some condition is definitely true */
566#define ecb_assume(cond) if (!(cond)) ecb_unreachable (); else 0 584#define ecb_assume(cond) if (!(cond)) ecb_unreachable (); else 0
567 585
568ecb_inline unsigned char ecb_byteorder_helper (void) ecb_const; 586ecb_inline ecb_const unsigned char ecb_byteorder_helper (void);
569ecb_inline unsigned char 587ecb_inline ecb_const unsigned char
570ecb_byteorder_helper (void) 588ecb_byteorder_helper (void)
571{ 589{
572 /* the union code still generates code under pressure in gcc, */ 590 /* the union code still generates code under pressure in gcc, */
573 /* but less than using pointers, and always seems to */ 591 /* but less than using pointers, and always seems to */
574 /* successfully return a constant. */ 592 /* successfully return a constant. */
589 } u = { 0x11223344 }; 607 } u = { 0x11223344 };
590 return u.c; 608 return u.c;
591#endif 609#endif
592} 610}
593 611
594ecb_inline ecb_bool ecb_big_endian (void) ecb_const; 612ecb_inline ecb_const ecb_bool ecb_big_endian (void);
595ecb_inline ecb_bool ecb_big_endian (void) { return ecb_byteorder_helper () == 0x11; } 613ecb_inline ecb_const ecb_bool ecb_big_endian (void) { return ecb_byteorder_helper () == 0x11; }
596ecb_inline ecb_bool ecb_little_endian (void) ecb_const; 614ecb_inline ecb_const ecb_bool ecb_little_endian (void);
597ecb_inline ecb_bool ecb_little_endian (void) { return ecb_byteorder_helper () == 0x44; } 615ecb_inline ecb_const ecb_bool ecb_little_endian (void) { return ecb_byteorder_helper () == 0x44; }
598 616
599#if ECB_GCC_VERSION(3,0) || ECB_C99 617#if ECB_GCC_VERSION(3,0) || ECB_C99
600 #define ecb_mod(m,n) ((m) % (n) + ((m) % (n) < 0 ? (n) : 0)) 618 #define ecb_mod(m,n) ((m) % (n) + ((m) % (n) < 0 ? (n) : 0))
601#else 619#else
602 #define ecb_mod(m,n) ((m) < 0 ? ((n) - 1 - ((-1 - (m)) % (n))) : ((m) % (n))) 620 #define ecb_mod(m,n) ((m) < 0 ? ((n) - 1 - ((-1 - (m)) % (n))) : ((m) % (n)))
677 #else 695 #else
678 #define ecb_ldexpf(x,e) (float) ldexp ((x), (e)) 696 #define ecb_ldexpf(x,e) (float) ldexp ((x), (e))
679 #endif 697 #endif
680 698
681 /* converts an ieee half/binary16 to a float */ 699 /* converts an ieee half/binary16 to a float */
682 ecb_function_ float ecb_binary16_to_float (uint16_t x) ecb_const; 700 ecb_function_ ecb_const float ecb_binary16_to_float (uint16_t x);
683 ecb_function_ float 701 ecb_function_ ecb_const float
684 ecb_binary16_to_float (uint16_t x) 702 ecb_binary16_to_float (uint16_t x)
685 { 703 {
686 int e = (x >> 10) & 0x1f; 704 int e = (x >> 10) & 0x1f;
687 int m = x & 0x3ff; 705 int m = x & 0x3ff;
688 float r; 706 float r;
694 712
695 return x & 0x8000 ? -r : r; 713 return x & 0x8000 ? -r : r;
696 } 714 }
697 715
698 /* convert a float to ieee single/binary32 */ 716 /* convert a float to ieee single/binary32 */
699 ecb_function_ uint32_t ecb_float_to_binary32 (float x) ecb_const; 717 ecb_function_ ecb_const uint32_t ecb_float_to_binary32 (float x);
700 ecb_function_ uint32_t 718 ecb_function_ ecb_const uint32_t
701 ecb_float_to_binary32 (float x) 719 ecb_float_to_binary32 (float x)
702 { 720 {
703 uint32_t r; 721 uint32_t r;
704 722
705 #if ECB_STDFP 723 #if ECB_STDFP
734 752
735 return r; 753 return r;
736 } 754 }
737 755
738 /* converts an ieee single/binary32 to a float */ 756 /* converts an ieee single/binary32 to a float */
739 ecb_function_ float ecb_binary32_to_float (uint32_t x) ecb_const; 757 ecb_function_ ecb_const float ecb_binary32_to_float (uint32_t x);
740 ecb_function_ float 758 ecb_function_ ecb_const float
741 ecb_binary32_to_float (uint32_t x) 759 ecb_binary32_to_float (uint32_t x)
742 { 760 {
743 float r; 761 float r;
744 762
745 #if ECB_STDFP 763 #if ECB_STDFP
764 782
765 return r; 783 return r;
766 } 784 }
767 785
768 /* convert a double to ieee double/binary64 */ 786 /* convert a double to ieee double/binary64 */
769 ecb_function_ uint64_t ecb_double_to_binary64 (double x) ecb_const; 787 ecb_function_ ecb_const uint64_t ecb_double_to_binary64 (double x);
770 ecb_function_ uint64_t 788 ecb_function_ ecb_const uint64_t
771 ecb_double_to_binary64 (double x) 789 ecb_double_to_binary64 (double x)
772 { 790 {
773 uint64_t r; 791 uint64_t r;
774 792
775 #if ECB_STDFP 793 #if ECB_STDFP
804 822
805 return r; 823 return r;
806 } 824 }
807 825
808 /* converts an ieee double/binary64 to a double */ 826 /* converts an ieee double/binary64 to a double */
809 ecb_function_ double ecb_binary64_to_double (uint64_t x) ecb_const; 827 ecb_function_ ecb_const double ecb_binary64_to_double (uint64_t x);
810 ecb_function_ double 828 ecb_function_ ecb_const double
811 ecb_binary64_to_double (uint64_t x) 829 ecb_binary64_to_double (uint64_t x)
812 { 830 {
813 double r; 831 double r;
814 832
815 #if ECB_STDFP 833 #if ECB_STDFP

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines