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

Comparing libecb/ecb.h (file contents):
Revision 1.209 by root, Fri Mar 25 15:23:14 2022 UTC vs.
Revision 1.210 by root, Fri Mar 25 15:28:08 2022 UTC

355#define ECB_CONCAT(a, b) ECB_CONCAT_(a, b) 355#define ECB_CONCAT(a, b) ECB_CONCAT_(a, b)
356#define ECB_STRINGIFY_(a) # a 356#define ECB_STRINGIFY_(a) # a
357#define ECB_STRINGIFY(a) ECB_STRINGIFY_(a) 357#define ECB_STRINGIFY(a) ECB_STRINGIFY_(a)
358#define ECB_STRINGIFY_EXPR(expr) ((expr), ECB_STRINGIFY_ (expr)) 358#define ECB_STRINGIFY_EXPR(expr) ((expr), ECB_STRINGIFY_ (expr))
359 359
360/* This marks larger functions that do not neccessarily need to be inlined */
361/* TODO: popssibly static would be best for these at the moment? */
360#define ecb_function_ ecb_inline 362#define ecb_function_ ecb_inline
361 363
362#if ECB_GCC_VERSION(3,1) || ECB_CLANG_VERSION(2,8) 364#if ECB_GCC_VERSION(3,1) || ECB_CLANG_VERSION(2,8)
363 #define ecb_attribute(attrlist) __attribute__ (attrlist) 365 #define ecb_attribute(attrlist) __attribute__ (attrlist)
364#else 366#else
961#endif 963#endif
962 964
963/*****************************************************************************/ 965/*****************************************************************************/
964/* gray code */ 966/* gray code */
965 967
966ecb_function_ uint_fast8_t ecb_gray8_encode (uint_fast8_t b) { return b ^ (b >> 1); } 968ecb_inline uint_fast8_t ecb_gray_encode8 (uint_fast8_t b) { return b ^ (b >> 1); }
967ecb_function_ uint_fast16_t ecb_gray16_encode (uint_fast16_t b) { return b ^ (b >> 1); } 969ecb_inline uint_fast16_t ecb_gray_encode16 (uint_fast16_t b) { return b ^ (b >> 1); }
968ecb_function_ uint_fast32_t ecb_gray32_encode (uint_fast32_t b) { return b ^ (b >> 1); } 970ecb_inline uint_fast32_t ecb_gray_encode32 (uint_fast32_t b) { return b ^ (b >> 1); }
969ecb_function_ uint_fast64_t ecb_gray64_encode (uint_fast64_t b) { return b ^ (b >> 1); } 971ecb_inline uint_fast64_t ecb_gray_encode64 (uint_fast64_t b) { return b ^ (b >> 1); }
970 972
973ecb_function_ uint8_t ecb_gray_decode8 (uint8_t g);
971ecb_function_ uint8_t ecb_gray8_decode (uint8_t g) 974ecb_function_ uint8_t ecb_gray_decode8 (uint8_t g)
972{ 975{
973 g ^= g >> 1; 976 g ^= g >> 1;
974 g ^= g >> 2; 977 g ^= g >> 2;
975 g ^= g >> 4; 978 g ^= g >> 4;
976 979
977 return g; 980 return g;
978} 981}
979 982
983ecb_function_ uint16_t ecb_gray_decode16 (uint16_t g);
980ecb_function_ uint16_t ecb_gray16_decode (uint16_t g) 984ecb_function_ uint16_t ecb_gray_decode16 (uint16_t g)
981{ 985{
982 g ^= g >> 1; 986 g ^= g >> 1;
983 g ^= g >> 2; 987 g ^= g >> 2;
984 g ^= g >> 4; 988 g ^= g >> 4;
985 g ^= g >> 8; 989 g ^= g >> 8;
986 990
987 return g; 991 return g;
988} 992}
989 993
994ecb_function_ uint32_t ecb_gray_decode32 (uint32_t g);
990ecb_function_ uint32_t ecb_gray32_decode (uint32_t g) 995ecb_function_ uint32_t ecb_gray_decode32 (uint32_t g)
991{ 996{
992 g ^= g >> 1; 997 g ^= g >> 1;
993 g ^= g >> 2; 998 g ^= g >> 2;
994 g ^= g >> 4; 999 g ^= g >> 4;
995 g ^= g >> 8; 1000 g ^= g >> 8;
996 g ^= g >> 16; 1001 g ^= g >> 16;
997 1002
998 return g; 1003 return g;
999} 1004}
1000 1005
1006ecb_function_ uint64_t ecb_gray_decode64 (uint64_t g);
1001ecb_function_ uint64_t ecb_gray64_decode (uint64_t g) 1007ecb_function_ uint64_t ecb_gray_decode64 (uint64_t g)
1002{ 1008{
1003 g ^= g >> 1; 1009 g ^= g >> 1;
1004 g ^= g >> 2; 1010 g ^= g >> 2;
1005 g ^= g >> 4; 1011 g ^= g >> 4;
1006 g ^= g >> 8; 1012 g ^= g >> 8;
1010 return g; 1016 return g;
1011} 1017}
1012 1018
1013#if ECB_CPP 1019#if ECB_CPP
1014 1020
1015ecb_function_ uint8_t ecb_gray_encode (uint8_t b) { return ecb_gray8_encode (b); } 1021ecb_inline uint8_t ecb_gray_encode (uint8_t b) { return ecb_gray_encode8 (b); }
1016ecb_function_ uint16_t ecb_gray_encode (uint16_t b) { return ecb_gray16_encode (b); } 1022ecb_inline uint16_t ecb_gray_encode (uint16_t b) { return ecb_gray_encode16 (b); }
1017ecb_function_ uint32_t ecb_gray_encode (uint32_t b) { return ecb_gray32_encode (b); } 1023ecb_inline uint32_t ecb_gray_encode (uint32_t b) { return ecb_gray_encode32 (b); }
1018ecb_function_ uint64_t ecb_gray_encode (uint64_t b) { return ecb_gray64_encode (b); } 1024ecb_inline uint64_t ecb_gray_encode (uint64_t b) { return ecb_gray_encode64 (b); }
1019 1025
1020ecb_function_ uint8_t ecb_gray_decode (uint8_t g) { return ecb_gray8_decode (g); } 1026ecb_inline uint8_t ecb_gray_decode (uint8_t g) { return ecb_gray_decode8 (g); }
1021ecb_function_ uint16_t ecb_gray_decode (uint16_t g) { return ecb_gray16_decode (g); } 1027ecb_inline uint16_t ecb_gray_decode (uint16_t g) { return ecb_gray_decode16 (g); }
1022ecb_function_ uint32_t ecb_gray_decode (uint32_t g) { return ecb_gray32_decode (g); } 1028ecb_inline uint32_t ecb_gray_decode (uint32_t g) { return ecb_gray_decode32 (g); }
1023ecb_function_ uint64_t ecb_gray_decode (uint64_t g) { return ecb_gray64_decode (g); } 1029ecb_inline uint64_t ecb_gray_decode (uint64_t g) { return ecb_gray_decode64 (g); }
1024 1030
1025#endif 1031#endif
1026 1032
1027/*****************************************************************************/ 1033/*****************************************************************************/
1028/* 2d hilbert curves */ 1034/* 2d hilbert curves */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines