61 |
\note If the strings you are working on resident in program space (flash), |
\note If the strings you are working on resident in program space (flash), |
62 |
you will need to use the string functions described in \ref avr_pgmspace. */ |
you will need to use the string functions described in \ref avr_pgmspace. */ |
63 |
|
|
64 |
|
/** \ingroup avr_string |
65 |
|
|
66 |
|
This macro finds the first (least significant) bit set in the |
67 |
|
input value. |
68 |
|
|
69 |
|
This macro is very similar to the function ffs() except that |
70 |
|
it evaluates its argument at compile-time, so it should only |
71 |
|
be applied to compile-time constant expressions where it will |
72 |
|
reduce to a constant itself. |
73 |
|
Application of this macro to expressions that are not constant |
74 |
|
at compile-time is not recommended, and might result in a huge |
75 |
|
amount of code generated. |
76 |
|
|
77 |
|
\returns The _FFS() macro returns the position of the first |
78 |
|
(least significant) bit set in the word val, or 0 if no bits are set. |
79 |
|
The least significant bit is position 1. |
80 |
|
*/ |
81 |
|
#if defined(DOXYGEN) |
82 |
|
#define _FFS(x) |
83 |
|
#else /* !DOXYGEN */ |
84 |
|
#define _FFS(x) \ |
85 |
|
( (x) & 1 ? 1 \ |
86 |
|
: (x) & 2 ? 2 \ |
87 |
|
: (x) & 4 ? 3 \ |
88 |
|
: (x) & 010 ? 4 \ |
89 |
|
: (x) & 020 ? 5 \ |
90 |
|
: (x) & 040 ? 6 \ |
91 |
|
: (x) & 0100 ? 7 \ |
92 |
|
: (x) & 0200 ? 8 \ |
93 |
|
: (x) & 0400 ? 9 \ |
94 |
|
: (x) & 01000 ? 10 \ |
95 |
|
: (x) & 02000 ? 11 \ |
96 |
|
: (x) & 04000 ? 12 \ |
97 |
|
: (x) & 010000 ? 13 \ |
98 |
|
: (x) & 020000 ? 14 \ |
99 |
|
: (x) & 040000 ? 15 \ |
100 |
|
: (x) & 0100000 ? 16 \ |
101 |
|
: 0 ) |
102 |
|
#endif /* DOXYGEN */ |
103 |
|
|
104 |
|
extern int ffs (int) __attribute__((const)); |
105 |
|
extern int ffsl (long) __attribute__((const)); |
106 |
|
extern int ffsll (long long) __attribute__((const)); |
107 |
extern void *memccpy(void *, const void *, int, size_t); |
extern void *memccpy(void *, const void *, int, size_t); |
108 |
extern void *memchr(const void *, int, size_t) __ATTR_PURE__; |
extern void *memchr(const void *, int, size_t) __ATTR_PURE__; |
109 |
extern int memcmp(const void *, const void *, size_t) __ATTR_PURE__; |
extern int memcmp(const void *, const void *, size_t) __ATTR_PURE__; |