aboutsummaryrefslogtreecommitdiffstats
path: root/LUFA/Common
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2011-04-12 03:03:56 +0000
committerDean Camera <dean@fourwalledcubicle.com>2011-04-12 03:03:56 +0000
commit995195a2b06142fb0882cf116a12bdab8e19603f (patch)
treeb560fb306c067c44266a494f2d40f16132e0a9f4 /LUFA/Common
parent852b5e612d549d1f086ceca4df0b589ac24cb37f (diff)
downloadlufa-995195a2b06142fb0882cf116a12bdab8e19603f.tar.gz
lufa-995195a2b06142fb0882cf116a12bdab8e19603f.tar.bz2
lufa-995195a2b06142fb0882cf116a12bdab8e19603f.zip
Add missing function attributes to the pipe/endpoint functions for all architectures.
Perform endianness correction in the HID report parser for big-endian platforms.
Diffstat (limited to 'LUFA/Common')
-rw-r--r--LUFA/Common/Common.h12
-rw-r--r--LUFA/Common/Endianness.h24
2 files changed, 23 insertions, 13 deletions
diff --git a/LUFA/Common/Common.h b/LUFA/Common/Common.h
index 9d64403bc..6a9356bbb 100644
--- a/LUFA/Common/Common.h
+++ b/LUFA/Common/Common.h
@@ -232,6 +232,15 @@
* assembly output in an unexpected manner on sections of code that are ordering-specific.
*/
#define GCC_MEMORY_BARRIER() __asm__ __volatile__("" ::: "memory");
+
+ /** Evaluates to boolean true if the specified value can be determined at compile time to be a constant value
+ * when compiling under GCC.
+ *
+ * \param[in] x Value to check compile time constantness of.
+ *
+ * \return Boolean true if the given value is known to be a compile time constant.
+ */
+ #define GCC_IS_COMPILE_CONST(x) __builtin_constant_p(x)
#if !defined(ISR) || defined(__DOXYGEN__)
/** Macro for the definition of interrupt service routines, so that the compiler can insert the required
@@ -273,10 +282,11 @@
*
* \param[in] Milliseconds Number of milliseconds to delay
*/
+ static inline void Delay_MS(uint8_t Milliseconds) ATTR_ALWAYS_INLINE;
static inline void Delay_MS(uint8_t Milliseconds)
{
#if (ARCH == ARCH_AVR8)
- if (__builtin_constant_p(Milliseconds))
+ if (GCC_IS_COMPILE_CONST(Milliseconds))
{
_delay_ms(Milliseconds);
}
diff --git a/LUFA/Common/Endianness.h b/LUFA/Common/Endianness.h
index f7bc33677..ef8c1a788 100644
--- a/LUFA/Common/Endianness.h
+++ b/LUFA/Common/Endianness.h
@@ -74,7 +74,7 @@
*
* \ingroup Group_ByteSwapping
*
- * \param[in] x 16-bit value whose byte ordering is to be swapped.
+ * \param[in] x 16-bit value whose byte ordering is to be swapped.
*
* \return Input value with the byte ordering reversed.
*/
@@ -87,7 +87,7 @@
*
* \ingroup Group_ByteSwapping
*
- * \param[in] x 32-bit value whose byte ordering is to be swapped.
+ * \param[in] x 32-bit value whose byte ordering is to be swapped.
*
* \return Input value with the byte ordering reversed.
*/
@@ -440,24 +440,24 @@
*
* \ingroup Group_ByteSwapping
*
- * \param[in,out] Data Pointer to a number containing an even number of bytes to be reversed.
- * \param[in] Bytes Length of the data in bytes.
+ * \param[in,out] Data Pointer to a number containing an even number of bytes to be reversed.
+ * \param[in] Length Length of the data in bytes.
*/
- static inline void SwapEndian_n(void* Data,
- uint8_t Bytes) ATTR_NON_NULL_PTR_ARG(1);
- static inline void SwapEndian_n(void* Data,
- uint8_t Bytes)
+ static inline void SwapEndian_n(void* const Data,
+ uint8_t Length) ATTR_NON_NULL_PTR_ARG(1);
+ static inline void SwapEndian_n(void* const Data,
+ uint8_t Length)
{
uint8_t* CurrDataPos = (uint8_t*)Data;
- while (Bytes > 1)
+ while (Length > 1)
{
uint8_t Temp = *CurrDataPos;
- *CurrDataPos = *(CurrDataPos + Bytes - 1);
- *(CurrDataPos + Bytes - 1) = Temp;
+ *CurrDataPos = *(CurrDataPos + Length - 1);
+ *(CurrDataPos + Length - 1) = Temp;
CurrDataPos++;
- Bytes -= 2;
+ Length -= 2;
}
}