Code-style consistency improvement:

Apply clang-format-all.sh using the _clang-format file through all the cpp/.h files.
make sure not to apply it to certain serialization structures, since some parser expects the * as part of the name, instead of type.
This commit contains no other changes aside from adding and applying clang-format-all.sh
This commit is contained in:
erwincoumans
2018-09-23 14:17:31 -07:00
parent b73b05e9fb
commit ab8f16961e
1773 changed files with 1081087 additions and 474249 deletions

View File

@@ -16,24 +16,19 @@ subject to the following restrictions:
#ifndef B3_POSIX_THREAD_SUPPORT_H
#define B3_POSIX_THREAD_SUPPORT_H
#include "Bullet3Common/b3Scalar.h"
#ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE 600 //for definition of pthread_barrier_t, see http://pages.cs.wisc.edu/~travitch/pthreads_primer.html
#endif //_XOPEN_SOURCE
#define _XOPEN_SOURCE 600 //for definition of pthread_barrier_t, see http://pages.cs.wisc.edu/~travitch/pthreads_primer.html
#endif //_XOPEN_SOURCE
#include <pthread.h>
#include <semaphore.h>
#include "Bullet3Common/b3AlignedObjectArray.h"
#include "b3ThreadSupportInterface.h"
typedef void (*b3PosixThreadFunc)(void* userPtr,void* lsMemory);
typedef void (*b3PosixThreadFunc)(void* userPtr, void* lsMemory);
typedef void* (*b3PosixlsMemorySetupFunc)();
typedef void (*b3PosixlsMemoryReleaseFunc)(void* ptr);
@@ -41,90 +36,84 @@ typedef void (*b3PosixlsMemoryReleaseFunc)(void* ptr);
class b3PosixThreadSupport : public b3ThreadSupportInterface
{
public:
typedef enum sStatus {
STATUS_BUSY,
STATUS_READY,
STATUS_FINISHED
} Status;
typedef enum sStatus
{
STATUS_BUSY,
STATUS_READY,
STATUS_FINISHED
} Status;
// placeholder, until libspe2 support is there
struct b3ThreadStatus
struct b3ThreadStatus
{
int m_taskId;
int m_commandId;
int m_status;
int m_taskId;
int m_commandId;
int m_status;
b3PosixThreadFunc m_userThreadFunc;
void* m_userPtr; //for taskDesc etc
b3PosixThreadFunc m_userThreadFunc;
void* m_userPtr; //for taskDesc etc
b3PosixlsMemoryReleaseFunc m_lsMemoryReleaseFunc;
void* m_lsMemory; //initialized using PosixLocalStoreMemorySetupFunc
void* m_lsMemory; //initialized using PosixLocalStoreMemorySetupFunc
pthread_t thread;
//each tread will wait until this signal to start its work
sem_t* startSemaphore;
pthread_t thread;
//each tread will wait until this signal to start its work
sem_t* startSemaphore;
// this is a copy of m_mainSemaphore,
//each tread will signal once it is finished with its work
sem_t* m_mainSemaphore;
unsigned long threadUsed;
// this is a copy of m_mainSemaphore,
//each tread will signal once it is finished with its work
sem_t* m_mainSemaphore;
unsigned long threadUsed;
};
private:
b3AlignedObjectArray<b3ThreadStatus> m_activeThreadStatus;
private:
b3AlignedObjectArray<b3ThreadStatus> m_activeThreadStatus;
// m_mainSemaphoresemaphore will signal, if and how many threads are finished with their work
sem_t* m_mainSemaphore;
public:
///Setup and initialize SPU/CELL/Libspe2
struct ThreadConstructionInfo
struct ThreadConstructionInfo
{
ThreadConstructionInfo(const char* uniqueName,
b3PosixThreadFunc userThreadFunc,
b3PosixlsMemorySetupFunc lsMemoryFunc,
b3PosixlsMemoryReleaseFunc lsMemoryReleaseFunc,
int numThreads=1,
int threadStackSize=65535
)
:m_uniqueName(uniqueName),
m_userThreadFunc(userThreadFunc),
m_lsMemoryFunc(lsMemoryFunc),
m_lsMemoryReleaseFunc(lsMemoryReleaseFunc),
m_numThreads(numThreads),
m_threadStackSize(threadStackSize)
b3PosixThreadFunc userThreadFunc,
b3PosixlsMemorySetupFunc lsMemoryFunc,
b3PosixlsMemoryReleaseFunc lsMemoryReleaseFunc,
int numThreads = 1,
int threadStackSize = 65535)
: m_uniqueName(uniqueName),
m_userThreadFunc(userThreadFunc),
m_lsMemoryFunc(lsMemoryFunc),
m_lsMemoryReleaseFunc(lsMemoryReleaseFunc),
m_numThreads(numThreads),
m_threadStackSize(threadStackSize)
{
}
const char* m_uniqueName;
b3PosixThreadFunc m_userThreadFunc;
b3PosixlsMemorySetupFunc m_lsMemoryFunc;
b3PosixlsMemoryReleaseFunc m_lsMemoryReleaseFunc;
int m_numThreads;
int m_threadStackSize;
const char* m_uniqueName;
b3PosixThreadFunc m_userThreadFunc;
b3PosixlsMemorySetupFunc m_lsMemoryFunc;
b3PosixlsMemoryReleaseFunc m_lsMemoryReleaseFunc;
int m_numThreads;
int m_threadStackSize;
};
b3PosixThreadSupport(ThreadConstructionInfo& threadConstructionInfo);
///cleanup/shutdown Libspe2
virtual ~b3PosixThreadSupport();
///cleanup/shutdown Libspe2
virtual ~b3PosixThreadSupport();
void startThreads(ThreadConstructionInfo& threadInfo);
void startThreads(ThreadConstructionInfo& threadInfo);
virtual void runTask(int uiCommand, void* uiArgument0, int uiArgument1);
virtual void runTask(int uiCommand, void* uiArgument0, int uiArgument1);
virtual void waitForResponse(int* puiArgument0, int* puiArgument1);
virtual void waitForResponse(int *puiArgument0, int *puiArgument1);
///tell the task scheduler we are done with the SPU tasks
virtual void stopThreads();
///tell the task scheduler we are done with the SPU tasks
virtual void stopThreads();
virtual void setNumTasks(int numTasks) {}
@@ -134,8 +123,7 @@ public:
}
///non-blocking test if a task is completed. First implement all versions, and then enable this API
virtual bool isTaskCompleted(int *puiArgument0, int *puiArgument1, int timeOutInMilliseconds);
virtual bool isTaskCompleted(int* puiArgument0, int* puiArgument1, int timeOutInMilliseconds);
virtual b3Barrier* createBarrier();
@@ -145,15 +133,10 @@ public:
virtual void deleteCriticalSection(b3CriticalSection* criticalSection);
virtual void* getThreadLocalMemory(int taskId)
virtual void* getThreadLocalMemory(int taskId)
{
return m_activeThreadStatus[taskId].m_lsMemory;
}
};
#endif // B3_POSIX_THREAD_SUPPORT_H
#endif // B3_POSIX_THREAD_SUPPORT_H