Replace blind interface descriptor search in the incomplete AndroidAccessoryHost...
[pub/USBasp.git] / LUFA / Drivers / Misc / RingBuffer.h
index 1a825ac..c953638 100644 (file)
@@ -66,7 +66,7 @@
  *      RingBuffer_t Buffer;\r
  *      uint8_t      BufferData[128];\r
  *\r
- *      // Initialise the buffer with the created storage array\r
+ *      // Initialize the buffer with the created storage array\r
  *      RingBuffer_InitBuffer(&Buffer, BufferData, sizeof(BufferData));\r
  *\r
  *      // Insert some data into the buffer\r
        /* Includes: */\r
                #include "../../Common/Common.h"\r
 \r
+       /* Enable C linkage for C++ Compilers: */\r
+               #if defined(__cplusplus)\r
+                       extern "C" {\r
+               #endif\r
+\r
        /* Type Defines: */\r
                /** \brief Ring Buffer Management Structure.\r
                 *\r
                {\r
                        GCC_FORCE_POINTER_ACCESS(Buffer);\r
 \r
-                       ATOMIC_BLOCK(ATOMIC_RESTORESTATE)\r
-                       {       \r
-                               Buffer->In     = DataPtr;\r
-                               Buffer->Out    = DataPtr;\r
-                               Buffer->Start  = &DataPtr[0];\r
-                               Buffer->End    = &DataPtr[Size];\r
-                               Buffer->Size   = Size;\r
-                               Buffer->Count  = 0;\r
-                       }\r
+                       uint_reg_t CurrentGlobalInt = GetGlobalInterruptMask();\r
+                       GlobalInterruptDisable();\r
+       \r
+                       Buffer->In     = DataPtr;\r
+                       Buffer->Out    = DataPtr;\r
+                       Buffer->Start  = &DataPtr[0];\r
+                       Buffer->End    = &DataPtr[Size];\r
+                       Buffer->Size   = Size;\r
+                       Buffer->Count  = 0;\r
+\r
+                       SetGlobalInterruptMask(CurrentGlobalInt);\r
                }\r
 \r
                /** Retrieves the minimum number of bytes stored in a particular buffer. This value is computed\r
                {\r
                        uint16_t Count;\r
 \r
-                       ATOMIC_BLOCK(ATOMIC_RESTORESTATE)\r
-                       {\r
-                               Count = Buffer->Count;\r
-                       }\r
+                       uint_reg_t CurrentGlobalInt = GetGlobalInterruptMask();\r
+                       GlobalInterruptDisable();\r
+                       \r
+                       Count = Buffer->Count;\r
 \r
+                       SetGlobalInterruptMask(CurrentGlobalInt);\r
                        return Count;\r
                }\r
 \r
                        if (++Buffer->In == Buffer->End)\r
                          Buffer->In = Buffer->Start;\r
 \r
-                       ATOMIC_BLOCK(ATOMIC_RESTORESTATE)\r
-                       {\r
-                               Buffer->Count++;\r
-                       }\r
+                       uint_reg_t CurrentGlobalInt = GetGlobalInterruptMask();\r
+                       GlobalInterruptDisable();\r
+                       \r
+                       Buffer->Count++;\r
+\r
+                       SetGlobalInterruptMask(CurrentGlobalInt);\r
                }\r
 \r
                /** Removes an element from the ring buffer.\r
                        if (++Buffer->Out == Buffer->End)\r
                          Buffer->Out = Buffer->Start;\r
 \r
-                       ATOMIC_BLOCK(ATOMIC_RESTORESTATE)\r
-                       {\r
-                               Buffer->Count--;\r
-                       }\r
+                       uint_reg_t CurrentGlobalInt = GetGlobalInterruptMask();\r
+                       GlobalInterruptDisable();\r
+                       \r
+                       Buffer->Count--;\r
+\r
+                       SetGlobalInterruptMask(CurrentGlobalInt);\r
 \r
                        return Data;\r
                }\r
                        return *Buffer->Out;\r
                }\r
 \r
+       /* Disable C linkage for C++ Compilers: */\r
+               #if defined(__cplusplus)\r
+                       }\r
+               #endif\r
+\r
 #endif\r
 \r
 /** @} */\r