sync_api.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #ifndef SYNC_API_H
  2. #define SYNC_API_H
  3. #include <stdbool.h>
  4. #include "subsecond_time.h"
  5. #include "fixed_types.h"
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9. typedef SInt32 carbon_mutex_t;
  10. typedef SInt32 carbon_cond_t;
  11. typedef SInt32 carbon_barrier_t;
  12. // These are the dummy functions that will get replaced
  13. // by the simulator
  14. // Related to Mutexes
  15. void CarbonMutexInit(carbon_mutex_t *mux);
  16. SubsecondTime CarbonMutexLock(carbon_mutex_t *mux, SubsecondTime delay = SubsecondTime::Zero());
  17. SubsecondTime CarbonMutexTrylock(carbon_mutex_t *mux);
  18. SubsecondTime CarbonMutexUnlock(carbon_mutex_t *mux, SubsecondTime delay = SubsecondTime::Zero());
  19. bool CarbonIsMutexValid(carbon_mutex_t *mux);
  20. // Related to condition variables
  21. void CarbonCondInit(carbon_cond_t *cond);
  22. SubsecondTime CarbonCondWait(carbon_cond_t *cond, carbon_mutex_t *mux);
  23. SubsecondTime CarbonCondSignal(carbon_cond_t *cond);
  24. SubsecondTime CarbonCondBroadcast(carbon_cond_t *cond);
  25. bool CarbonIsCondValid(carbon_cond_t *cond);
  26. // Related to barriers
  27. void CarbonBarrierInit(carbon_barrier_t *barrier, unsigned int count);
  28. SubsecondTime CarbonBarrierWait(carbon_barrier_t *barrier);
  29. bool CarbonIsBarrierValid(carbon_barrier_t *barrier);
  30. #ifdef __cplusplus
  31. }
  32. #endif
  33. #endif