Browse Source

Fixes for RtList

tags/1.9.4
falkTX 11 years ago
parent
commit
ee40792c21
8 changed files with 137 additions and 23 deletions
  1. +1
    -1
      source/backend/CarlaBackend.hpp
  2. +1
    -1
      source/bridges/qtcreator/carla-bridge-plugin.pro
  3. +1
    -0
      source/carla_shared.py
  4. +2
    -2
      source/includes/CarlaDefines.hpp
  5. +45
    -1
      source/libs/rtmempool/list.h
  6. +1
    -1
      source/tests/ANSI.cpp
  7. +8
    -1
      source/tests/RtList.cpp
  8. +78
    -16
      source/utils/RtList.hpp

+ 1
- 1
source/backend/CarlaBackend.hpp View File

@@ -620,7 +620,7 @@ enum ProcessMode {
*/
enum TransportMode {
TRANSPORT_MODE_INTERNAL = 0, //!< Internal transport mode.
TRANSPORT_MODE_JACK = 1, //!< JACK transport, only available if driver name is "JACK"
TRANSPORT_MODE_JACK = 1 //!< JACK transport, only available if driver name is "JACK"
};

/*!


+ 1
- 1
source/bridges/qtcreator/carla-bridge-plugin.pro View File

@@ -107,7 +107,7 @@ INCLUDEPATH = .. \

# -----------------------------------------------------------

DEFINES = QTCREATOR_TEST
DEFINES = QTCREATOR_TEST HAVE_CPP11_SUPPORT
DEFINES += DEBUG
#DEFINES += VESTIGE_HEADER
DEFINES += BUILD_BRIDGE BUILD_BRIDGE_PLUGIN BRIDGE_PLUGIN


+ 1
- 0
source/carla_shared.py View File

@@ -316,6 +316,7 @@ PROCESS_MODE_SINGLE_CLIENT = 0
PROCESS_MODE_MULTIPLE_CLIENTS = 1
PROCESS_MODE_CONTINUOUS_RACK = 2
PROCESS_MODE_PATCHBAY = 3
PROCESS_MODE_BRIDGE = 4

# Transport Mode
TRANSPORT_MODE_INTERNAL = 0


+ 2
- 2
source/includes/CarlaDefines.hpp View File

@@ -23,7 +23,7 @@
# define CARLA_OS_MAC
#elif defined(__HAIKU__)
# define CARLA_OS_HAIKU
#elif defined(__linux__) || defined(__linux) || defined(QTCREATOR_TEST)
#elif defined(__linux__) || defined(__linux)
# define CARLA_OS_LINUX
#elif defined(WIN64) || defined(_WIN64) || defined(__WIN64__)
# define CARLA_OS_WIN64
@@ -40,7 +40,7 @@
#endif

// Check for C++11 support
#if defined(HAVE_CPP11_SUPPORT) || defined(QTCREATOR_TEST)
#if defined(HAVE_CPP11_SUPPORT)
# define CARLA_PROPER_CPP11_SUPPORT
#elif defined(__GNUC__) && defined(__GXX_EXPERIMENTAL_CXX0X__)
# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 405


+ 45
- 1
source/libs/rtmempool/list.h View File

@@ -25,7 +25,9 @@
#define __LINUX_LIST_H__

/* This file is from Linux Kernel (include/linux/list.h)
* and modified by simply removing hardware prefetching of list items.
* and modified by removing hardware prefetching of list items
* and added list_split_tail* functions.
*
* Here by copyright, credits attributed to wherever they belong.
* Filipe Coelho (aka falkTX <falktx@falktx.com>)
*/
@@ -224,6 +226,19 @@ static inline void __list_splice(struct list_head *list, struct list_head *head)
at->prev = last;
}

static inline void __list_splice_tail(struct list_head *list, struct list_head *head)
{
struct list_head *first = list->next;
struct list_head *last = list->prev;
struct list_head *at = head->prev;

first->prev = at;
at->next = first;

last->next = head;
head->prev = last;
}

/**
* list_splice - join two lists
* @list: the new list to add.
@@ -235,6 +250,19 @@ static inline void list_splice(struct list_head *list, struct list_head *head)
__list_splice(list, head);
}

/**
* list_splice_tail - join two lists
* @list: the new list to add.
* @head: the place to add it in the first list.
*
* @list goes to the end (at head->prev)
*/
static inline void list_splice_tail(struct list_head *list, struct list_head *head)
{
if (!list_empty(list))
__list_splice_tail(list, head);
}

/**
* list_splice_init - join two lists and reinitialise the emptied list.
* @list: the new list to add.
@@ -250,6 +278,22 @@ static inline void list_splice_init(struct list_head *list, struct list_head *he
}
}

/**
* list_splice_init - join two lists and reinitialise the emptied list.
* @list: the new list to add.
* @head: the place to add it in the first list.
*
* The list at @list is reinitialised
* @list goes to the end (at head->prev)
*/
static inline void list_splice_tail_init(struct list_head *list, struct list_head *head)
{
if (!list_empty(list)) {
__list_splice_tail(list, head);
INIT_LIST_HEAD(list);
}
}

/**
* list_entry - get the struct for this entry
* @ptr: the &struct list_head pointer.


+ 1
- 1
source/tests/ANSI.cpp View File

@@ -17,7 +17,7 @@

// still need qt classes check
//#include "CarlaPlugin.hpp"
#include "plugin/DssiPlugin.cpp"
//#include "plugin/DssiPlugin.cpp"

#if 0
#include "CarlaDefines.hpp"


+ 8
- 1
source/tests/RtList.cpp View File

@@ -71,7 +71,7 @@ struct PostRtEvents {
{
if (mutex.tryLock())
{
dataPendingRT.splice(data, true);
dataPendingRT.spliceAppend(data, true);
mutex.unlock();
}
}
@@ -145,6 +145,13 @@ int main()
assert(postRtEvents.data.count() == 4);
assert(postRtEvents.dataPendingRT.count() == 0);

for (auto it = postRtEvents.data.begin(); it.valid(); it.next())
{
MyData& my = *it;

printf("FOR DATA!!!: %i %s\n", my.idStr, (const char*)my.str);
}

run4Tests();

// reset


+ 78
- 16
source/utils/RtList.hpp View File

@@ -26,9 +26,9 @@ extern "C" {
}

// Declare non copyable and prevent heap allocation
#define LIST_DECLARATIONS(className) \
className(const className&); \
className& operator= (const className&); \
#define LIST_DECLARATIONS(className) \
className(const className&); \
className& operator= (const className&); \
static void* operator new (size_t) { return nullptr; } \
static void operator delete (void*) {}

@@ -42,6 +42,46 @@ template<typename T>
class List
{
protected:
struct Data {
T value;
k_list_head siblings;
};

class Itenerator {
public:
Itenerator(k_list_head* queue)
: kQueue(queue),
fEntry(queue->next),
fData(nullptr)
{
CARLA_ASSERT(kQueue != nullptr);
CARLA_ASSERT(fEntry != nullptr);
}

bool valid()
{
prefetch(fEntry->next);
return (fEntry != kQueue);
}

void next()
{
fEntry = fEntry->next;
}

T& operator*()
{
fData = list_entry(fEntry, Data, siblings);
CARLA_ASSERT(fData != nullptr);
return fData->value;
}

private:
k_list_head* const kQueue;
k_list_head* fEntry;
Data* fData;
};

List()
: kDataSize(sizeof(Data)),
fCount(0)
@@ -55,6 +95,11 @@ public:
CARLA_ASSERT(fCount == 0);
}

Itenerator begin()
{
return Itenerator(&fQueue);
}

void clear()
{
if (fCount != 0)
@@ -110,7 +155,7 @@ public:
T& getAt(const size_t index, const bool remove = false)
{
if (fCount == 0 || index >= fCount)
return _retEmpty();
return _getEmpty();

size_t i = 0;
Data* data = nullptr;
@@ -137,7 +182,7 @@ public:

CARLA_ASSERT(data != nullptr);

return (data != nullptr) ? data->value : _retEmpty();
return (data != nullptr) ? data->value : _getEmpty();
}

T& getFirst(const bool remove = false)
@@ -194,7 +239,22 @@ public:
}
}

virtual void splice(List& list, const bool init = false)
virtual void spliceAppend(List& list, const bool init = false)
{
if (init)
{
list_splice_tail_init(&fQueue, &list.fQueue);
list.fCount += fCount;
fCount = 0;
}
else
{
list_splice_tail(&fQueue, &list.fQueue);
list.fCount += fCount;
}
}

virtual void spliceInsert(List& list, const bool init = false)
{
if (init)
{
@@ -214,11 +274,6 @@ protected:
size_t fCount;
k_list_head fQueue;

struct Data {
T value;
k_list_head siblings;
};

virtual Data* _allocate() = 0;
virtual void _deallocate(Data* const dataPtr) = 0;

@@ -232,7 +287,7 @@ private:
T& _getFirstOrLast(const bool first, const bool remove)
{
if (fCount == 0)
return _retEmpty();
return _getEmpty();

k_list_head* const entry = first ? fQueue.next : fQueue.prev;
Data* const data = list_entry(entry, Data, siblings);
@@ -240,7 +295,7 @@ private:
CARLA_ASSERT(data != nullptr);

if (data == nullptr)
return _retEmpty();
return _getEmpty();

T& ret = data->value;

@@ -254,7 +309,7 @@ private:
return ret;
}

T& _retEmpty()
T& _getEmpty()
{
// FIXME ?
static T value;
@@ -371,11 +426,18 @@ public:
kMemPool->resize(minPreallocated, maxPreallocated);
}

void splice(RtList& list, const bool init = false)
void spliceAppend(RtList& list, const bool init = false)
{
CARLA_ASSERT(kMemPool == list.kMemPool);

List<T>::spliceAppend(list, init);
}

void spliceInsert(RtList& list, const bool init = false)
{
CARLA_ASSERT(kMemPool == list.kMemPool);

List<T>::splice(list, init);
List<T>::spliceInsert(list, init);
}

private:


Loading…
Cancel
Save