Skip to content
Merged

Dev #91

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"includePath": [
"${workspaceFolder}/include",
"${workspaceFolder}/dist/*/build/*-extern-prefix/src/**",
"${workspaceFolder}/dist/*/build/_deps/*-src/*/include",
"${workspaceFolder}/examples/**",
"${workspaceFolder}/tests/**"
],
Expand Down Expand Up @@ -53,4 +54,4 @@
}
],
"version": 4
}
}
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"streetsidesoftware.code-spell-checker",
"discretegames.f5anything",
"ms-vscode.cmake-tools",
"spadin.memento-inputs"
"spadin.memento-inputs",
"ms-python.black-formatter"
]
}
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,7 @@
"python.defaultInterpreterPath": "${workspaceFolder}/dist/venv/bin/python3",
"vim.textwidth": 100,
"vim.tabstop": 8,
}
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
}
}
7 changes: 6 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ The format is based on `Keep a Changelog`_, and this project adheres to
Added
`````

...
- ``libstored.protocol.ArqLayer`` for general-purpose ARQ.

Fixed
`````

- ``ZmqClient`` assertion during cleanup

.. _Unreleased: https://github.com/DEMCON/libstored/compare/v2.1.0...HEAD

Expand Down
4 changes: 3 additions & 1 deletion include/libstored/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ typedef SSIZE_T ssize_t;
// Platform
//

#ifdef __ZEPHYR__
#if defined(STORED_OS_BAREMETAL) || defined(STORED_OS_GENERIC)
// Accept pre-defined setup.
#elif defined(__ZEPHYR__)
# define STORED_OS_BAREMETAL 1
# include <zephyr/toolchain.h>
// By default, turn off; picolibc does not provide it by default.
Expand Down
64 changes: 50 additions & 14 deletions include/libstored/protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,15 +269,23 @@ class ProtocolLayer {
return m_down;
}

# ifdef STORED_COMPILER_GCC
# pragma GCC push_options
# pragma GCC optimize("-foptimize-sibling-calls")
# endif // GCC

/*!
* \brief Decode a frame and forward the decoded frame to the upper layer.
*
* The given buffer may be decoded in-place.
*/
virtual void decode(void* buffer, size_t len)
{
if(up())
up()->decode(buffer, len);
ProtocolLayer* const p = up();
if(!p)
return;

p->decode(buffer, len);
}

/*!
Expand All @@ -296,8 +304,11 @@ class ProtocolLayer {
*/
virtual void encode(void const* buffer, size_t len, bool last = true)
{
if(down())
down()->encode(buffer, len, last);
ProtocolLayer* const p = down();
if(!p)
return;

p->encode(buffer, len, last);
}

/*!
Expand All @@ -316,8 +327,11 @@ class ProtocolLayer {
*/
virtual void setPurgeableResponse(bool purgeable = true)
{
if(down())
down()->setPurgeableResponse(purgeable);
ProtocolLayer* const p = down();
if(!p)
return;

p->setPurgeableResponse(purgeable);
}

/*!
Expand All @@ -331,7 +345,11 @@ class ProtocolLayer {
*/
virtual size_t mtu() const
{
return down() ? down()->mtu() : 0;
ProtocolLayer const* const p = down();
if(!p)
return 0;

return p->mtu();
}

/*!
Expand All @@ -346,36 +364,53 @@ class ProtocolLayer {
*/
virtual bool flush()
{
return down() ? down()->flush() : true;
ProtocolLayer* const p = down();
if(!p)
return true;

return p->flush();
}

/*!
* \brief Reset the stack (top-down), and drop all messages.
*/
virtual void reset()
{
if(down())
down()->reset();
ProtocolLayer* const p = down();
if(!p)
return;

p->reset();
}

/*!
* \brief (Re)connected notification (bottom-up).
*/
virtual void connected()
{
if(up())
up()->connected();
ProtocolLayer* const p = up();
if(!p)
return;

p->connected();
}

/*!
* \brief Disconnected notification (bottom-up).
*/
virtual void disconnected()
{
if(up())
up()->disconnected();
ProtocolLayer* const p = up();
if(!p)
return;

p->disconnected();
}

# ifdef STORED_COMPILER_GCC
# pragma GCC pop_options
# endif // GCC

private:
/*! \brief The layer above this one. */
ProtocolLayer* m_up;
Expand Down Expand Up @@ -1470,6 +1505,7 @@ class MuxLayer : public ProtocolLayer {
ChannelId m_encodingChannel;
ProtocolLayer* m_decodingChannel;
bool m_decodingEsc;
bool m_encoding;
};

namespace impl {
Expand Down
Loading
Loading