qpc/include/qequeue.h

151 lines
4.0 KiB
C
Raw Normal View History

//$file${include::qequeue.h} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
//
// Model: qpc.qm
// File: ${include::qequeue.h}
//
2024-10-15 13:15:11 -04:00
// This code has been generated by QM 7.0.0 <www.state-machine.com/qm>.
// DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
//
2024-10-15 13:15:11 -04:00
// Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved.
//
// Q u a n t u m L e a P s
// ------------------------
// Modern Embedded Software
//
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial
//
2024-10-15 13:15:11 -04:00
// The QP/C software is dual-licensed under the terms of the open-source GNU
// General Public License (GPL) or under the terms of one of the closed-
// source Quantum Leaps commercial licenses.
//
// Redistributions in source code must retain this top-level comment block.
// Plagiarizing this software to sidestep the license obligations is illegal.
//
2024-10-15 13:15:11 -04:00
// NOTE:
// The GPL does NOT permit the incorporation of this code into proprietary
// programs. Please contact Quantum Leaps for commercial licensing options,
// which expressly supersede the GPL and are designed explicitly for
// closed-source distribution.
//
// Quantum Leaps contact information:
// <www.state-machine.com/licensing>
// <info@state-machine.com>
//
//$endhead${include::qequeue.h} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#ifndef QEQUEUE_H_
#define QEQUEUE_H_
2012-08-14 18:07:04 -04:00
#ifndef QF_EQUEUE_CTR_SIZE
2020-03-17 21:33:20 -04:00
#define QF_EQUEUE_CTR_SIZE 1U
2012-08-14 18:07:04 -04:00
#endif
#if (QF_EQUEUE_CTR_SIZE == 1U)
2017-12-11 12:13:22 -05:00
typedef uint8_t QEQueueCtr;
2020-03-17 21:33:20 -04:00
#elif (QF_EQUEUE_CTR_SIZE == 2U)
2017-12-11 12:13:22 -05:00
typedef uint16_t QEQueueCtr;
2012-08-14 18:07:04 -04:00
#else
2024-10-15 13:15:11 -04:00
#error "QF_EQUEUE_CTR_SIZE defined incorrectly, expected 1U or 2U"
2012-08-14 18:07:04 -04:00
#endif
2024-10-15 13:15:11 -04:00
struct QEvt; // forward declartion
//$declare${QF::QEQueue} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
//${QF::QEQueue} .............................................................
//! @class QEQueue
typedef struct QEQueue {
// private:
2012-08-14 18:07:04 -04:00
//! @private @memberof QEQueue
struct QEvt const * volatile frontEvt;
2012-08-14 18:07:04 -04:00
//! @private @memberof QEQueue
2024-10-15 13:15:11 -04:00
struct QEvt const * * ring;
//! @private @memberof QEQueue
2012-08-14 18:07:04 -04:00
QEQueueCtr end;
//! @private @memberof QEQueue
2013-09-23 14:34:35 -04:00
QEQueueCtr volatile head;
2012-08-14 18:07:04 -04:00
//! @private @memberof QEQueue
2013-09-23 14:34:35 -04:00
QEQueueCtr volatile tail;
2012-08-14 18:07:04 -04:00
//! @private @memberof QEQueue
2013-09-23 14:34:35 -04:00
QEQueueCtr volatile nFree;
2012-08-14 18:07:04 -04:00
2024-10-15 13:15:11 -04:00
#ifndef Q_UNSAFE
//! @private @memberof QEQueue
uintptr_t frontEvt_dis;
#endif // ndef Q_UNSAFE
#ifndef Q_UNSAFE
//! @private @memberof QEQueue
QEQueueCtr head_dis;
#endif // ndef Q_UNSAFE
#ifndef Q_UNSAFE
//! @private @memberof QEQueue
QEQueueCtr tail_dis;
#endif // ndef Q_UNSAFE
#ifndef Q_UNSAFE
//! @private @memberof QEQueue
QEQueueCtr nFree_dis;
#endif // ndef Q_UNSAFE
#ifndef Q_UNSAFE
//! @private @memberof QEQueue
2012-08-14 18:07:04 -04:00
QEQueueCtr nMin;
2024-10-15 13:15:11 -04:00
#endif // ndef Q_UNSAFE
2024-10-15 13:15:11 -04:00
// type:
2012-08-14 18:07:04 -04:00
} QEQueue;
2024-10-15 13:15:11 -04:00
// dummy static member to force generating 'struct QEQueue {...}'
extern QEQueue * QEQueue_dummy;
2012-08-14 18:07:04 -04:00
// public:
2012-08-14 18:07:04 -04:00
//! @public @memberof QEQueue
2012-08-14 18:07:04 -04:00
void QEQueue_init(QEQueue * const me,
2024-10-15 13:15:11 -04:00
struct QEvt const * * const qSto,
uint_fast16_t const qLen);
2013-09-23 14:34:35 -04:00
//! @public @memberof QEQueue
bool QEQueue_post(QEQueue * const me,
struct QEvt const * const e,
uint_fast16_t const margin,
2024-01-30 20:48:12 -05:00
uint_fast8_t const qsId);
2012-08-14 18:07:04 -04:00
//! @public @memberof QEQueue
void QEQueue_postLIFO(QEQueue * const me,
struct QEvt const * const e,
2024-01-30 20:48:12 -05:00
uint_fast8_t const qsId);
2012-08-14 18:07:04 -04:00
//! @public @memberof QEQueue
struct QEvt const * QEQueue_get(QEQueue * const me,
2024-01-30 20:48:12 -05:00
uint_fast8_t const qsId);
2012-08-14 18:07:04 -04:00
//! @public @memberof QEQueue
static inline QEQueueCtr QEQueue_getNFree(QEQueue const * const me) {
return me->nFree;
}
2012-08-14 18:07:04 -04:00
//! @public @memberof QEQueue
static inline QEQueueCtr QEQueue_getNMin(QEQueue const * const me) {
2024-10-15 13:15:11 -04:00
#ifndef Q_UNSAFE
return me->nMin;
2024-10-15 13:15:11 -04:00
#else
return 0U;
#endif
}
2015-04-28 13:45:35 -04:00
//! @public @memberof QEQueue
static inline bool QEQueue_isEmpty(QEQueue const * const me) {
return me->frontEvt == (struct QEvt *)0;
}
//$enddecl${QF::QEQueue} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2012-12-10 16:00:27 -05:00
#endif // QEQUEUE_H_