diff options
author | Jon Medhurst <tixy@linaro.org> | 2013-04-03 11:59:40 +0100 |
---|---|---|
committer | Jon Medhurst <tixy@linaro.org> | 2013-04-03 12:54:15 +0100 |
commit | 7ef1b3596e3625d6335fd03904dfdcc75f365919 (patch) | |
tree | 4b309e83ab767e561a2235668b3ad6cd830bb40c /daemon/Buffer.h | |
parent | 06ebd1eab0a782377611efee820bb57f09692cbf (diff) |
gator: Version 5.14DS-5.14
Signed-off-by: Jon Medhurst <tixy@linaro.org>
Diffstat (limited to 'daemon/Buffer.h')
-rw-r--r-- | daemon/Buffer.h | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/daemon/Buffer.h b/daemon/Buffer.h new file mode 100644 index 0000000..c460fb7 --- /dev/null +++ b/daemon/Buffer.h @@ -0,0 +1,66 @@ +/** + * Copyright (C) ARM Limited 2013. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef BUFFER_H +#define BUFFER_H + +#include <stddef.h> +#include <stdint.h> +#include <semaphore.h> + +#define GATOR_LIVE + +class Sender; + +class Buffer { +public: + static const size_t MAXSIZE_PACK32 = 5; + static const size_t MAXSIZE_PACK64 = 10; + + Buffer (int32_t core, int32_t buftype, const int size, sem_t *const readerSem); + ~Buffer (); + + void write (Sender * sender); + + int bytesAvailable () const; + void commit (const uint64_t time); + void check (const uint64_t time); + + void frame (); + + bool eventHeader (uint64_t curr_time); + void event (int32_t key, int32_t value); + void event64 (int64_t key, int64_t value); + + void setDone (); + bool isDone () const; + +private: + bool commitReady () const; + bool checkSpace (int bytes); + + void packInt (int32_t x); + void packInt64 (int64_t x); + + const int32_t core; + const int32_t buftype; + const int size; + int readPos; + int writePos; + int commitPos; + bool available; + bool done; + char *const buf; +#ifdef GATOR_LIVE + uint64_t commitTime; +#endif + + sem_t *const readerSem; +}; + +#endif // BUFFER_H |