mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-06 03:31:43 +00:00
refactored HAL library
builds two libraries, Athena and Desktop. Simulation should use Desktop, Robots should use Athena Also: - copied Driverstation and Joystick from Devices into Sim - Descreased dependency of pthreads in JNI. - removed Simulation ifdef from non simulation - added missing decprecated attribute for msvc - removed usage reporting from sim - removed unused pom.xml and constexpr Change-Id: If8eb540f9434dce17c77a245fda6985713e80b2d
This commit is contained in:
@@ -164,8 +164,8 @@ enum HALAllianceStationID {
|
||||
/* The maximum number of axes that will be stored in a single HALJoystickAxes
|
||||
struct. This is used for allocating buffers, not bounds checking, since
|
||||
there are usually less axes in practice. */
|
||||
static constexpr size_t kMaxJoystickAxes = 12;
|
||||
static constexpr size_t kMaxJoystickPOVs = 12;
|
||||
static const size_t kMaxJoystickAxes = 12;
|
||||
static const size_t kMaxJoystickPOVs = 12;
|
||||
|
||||
struct HALJoystickAxes {
|
||||
uint16_t count;
|
||||
@@ -234,8 +234,8 @@ extern "C"
|
||||
int HALSetJoystickOutputs(uint8_t joystickNum, uint32_t outputs, uint16_t leftRumble, uint16_t rightRumble);
|
||||
int HALGetMatchTime(float *matchTime);
|
||||
|
||||
void HALSetNewDataSem(MULTIWAIT_ID sem);
|
||||
|
||||
void HALSetNewDataSem(NATIVE_MULTIWAIT_ID sem);
|
||||
|
||||
bool HALGetSystemActive(int32_t *status);
|
||||
bool HALGetBrownedOut(int32_t *status);
|
||||
|
||||
|
||||
@@ -1,42 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <pthread.h>
|
||||
#include <semaphore.h>
|
||||
#include <mutex>
|
||||
#include <condition_variable>
|
||||
|
||||
typedef pthread_mutex_t* MUTEX_ID;
|
||||
typedef sem_t* SEMAPHORE_ID;
|
||||
typedef pthread_cond_t* MULTIWAIT_ID;
|
||||
typedef std::mutex* MUTEX_ID;
|
||||
typedef std::condition_variable* MULTIWAIT_ID;
|
||||
typedef std::condition_variable::native_handle_type NATIVE_MULTIWAIT_ID;
|
||||
|
||||
extern "C"
|
||||
{
|
||||
extern const uint32_t SEMAPHORE_Q_FIFO;
|
||||
extern const uint32_t SEMAPHORE_Q_PRIORITY;
|
||||
extern const uint32_t SEMAPHORE_DELETE_SAFE;
|
||||
extern const uint32_t SEMAPHORE_INVERSION_SAFE;
|
||||
|
||||
extern const int32_t SEMAPHORE_NO_WAIT;
|
||||
extern const int32_t SEMAPHORE_WAIT_FOREVER;
|
||||
|
||||
extern const uint32_t SEMAPHORE_EMPTY;
|
||||
extern const uint32_t SEMAPHORE_FULL;
|
||||
|
||||
MUTEX_ID initializeMutexRecursive();
|
||||
MUTEX_ID initializeMutexNormal();
|
||||
void deleteMutex(MUTEX_ID sem);
|
||||
int8_t takeMutex(MUTEX_ID sem);
|
||||
int8_t tryTakeMutex(MUTEX_ID sem);
|
||||
int8_t giveMutex(MUTEX_ID sem);
|
||||
|
||||
SEMAPHORE_ID initializeSemaphore(uint32_t initial_value);
|
||||
void deleteSemaphore(SEMAPHORE_ID sem);
|
||||
int8_t takeSemaphore(SEMAPHORE_ID sem);
|
||||
int8_t tryTakeSemaphore(SEMAPHORE_ID sem);
|
||||
int8_t giveSemaphore(SEMAPHORE_ID sem);
|
||||
void takeMutex(MUTEX_ID sem);
|
||||
bool tryTakeMutex(MUTEX_ID sem);
|
||||
void giveMutex(MUTEX_ID sem);
|
||||
|
||||
MULTIWAIT_ID initializeMultiWait();
|
||||
void deleteMultiWait(MULTIWAIT_ID sem);
|
||||
int8_t takeMultiWait(MULTIWAIT_ID sem, MUTEX_ID m, int32_t timeout);
|
||||
int8_t giveMultiWait(MULTIWAIT_ID sem);
|
||||
void takeMultiWait(MULTIWAIT_ID sem, MUTEX_ID m);
|
||||
void giveMultiWait(MULTIWAIT_ID sem);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "priority_mutex.h"
|
||||
|
||||
class priority_condition_variable {
|
||||
typedef pthread_cond_t* native_handle_type;
|
||||
typedef std::condition_variable::native_handle_type native_handle_type;
|
||||
typedef std::chrono::system_clock clock_t;
|
||||
|
||||
public:
|
||||
@@ -99,7 +99,7 @@ class priority_condition_variable {
|
||||
struct Unlock {
|
||||
explicit Unlock(Lock& lk) : m_lock(lk) { lk.unlock(); }
|
||||
|
||||
~Unlock() noexcept(false) {
|
||||
~Unlock() /*noexcept(false)*/ {
|
||||
if (std::uncaught_exception()) {
|
||||
try { m_lock.lock(); } catch(...) {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user