qpc/include/qequeue.h
2024-11-02 15:38:41 -04:00

151 lines
4.0 KiB
C

//$file${include::qequeue.h} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
//
// Model: qpc.qm
// File: ${include::qequeue.h}
//
// 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.
//
// 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
//
// 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.
//
// 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_
#ifndef QF_EQUEUE_CTR_SIZE
#define QF_EQUEUE_CTR_SIZE 1U
#endif
#if (QF_EQUEUE_CTR_SIZE == 1U)
typedef uint8_t QEQueueCtr;
#elif (QF_EQUEUE_CTR_SIZE == 2U)
typedef uint16_t QEQueueCtr;
#else
#error "QF_EQUEUE_CTR_SIZE defined incorrectly, expected 1U or 2U"
#endif
struct QEvt; // forward declartion
//$declare${QF::QEQueue} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
//${QF::QEQueue} .............................................................
//! @class QEQueue
typedef struct QEQueue {
// private:
//! @private @memberof QEQueue
struct QEvt const * volatile frontEvt;
//! @private @memberof QEQueue
struct QEvt const * * ring;
//! @private @memberof QEQueue
QEQueueCtr end;
//! @private @memberof QEQueue
QEQueueCtr volatile head;
//! @private @memberof QEQueue
QEQueueCtr volatile tail;
//! @private @memberof QEQueue
QEQueueCtr volatile nFree;
#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
QEQueueCtr nMin;
#endif // ndef Q_UNSAFE
// type:
} QEQueue;
// dummy static member to force generating 'struct QEQueue {...}'
extern QEQueue * QEQueue_dummy;
// public:
//! @public @memberof QEQueue
void QEQueue_init(QEQueue * const me,
struct QEvt const * * const qSto,
uint_fast16_t const qLen);
//! @public @memberof QEQueue
bool QEQueue_post(QEQueue * const me,
struct QEvt const * const e,
uint_fast16_t const margin,
uint_fast8_t const qsId);
//! @public @memberof QEQueue
void QEQueue_postLIFO(QEQueue * const me,
struct QEvt const * const e,
uint_fast8_t const qsId);
//! @public @memberof QEQueue
struct QEvt const * QEQueue_get(QEQueue * const me,
uint_fast8_t const qsId);
//! @public @memberof QEQueue
static inline QEQueueCtr QEQueue_getNFree(QEQueue const * const me) {
return me->nFree;
}
//! @public @memberof QEQueue
static inline QEQueueCtr QEQueue_getNMin(QEQueue const * const me) {
#ifndef Q_UNSAFE
return me->nMin;
#else
return 0U;
#endif
}
//! @public @memberof QEQueue
static inline bool QEQueue_isEmpty(QEQueue const * const me) {
return me->frontEvt == (struct QEvt *)0;
}
//$enddecl${QF::QEQueue} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#endif // QEQUEUE_H_