This is an automated email from the ASF dual-hosted git repository.

andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
     new ad165a5f1 kernel/os_mbuf: Add OS_MBUF_USRHDR_TO_MBUF
ad165a5f1 is described below

commit ad165a5f174338c5dee339b5f31ab01718696006
Author: Mariusz Skamra <[email protected]>
AuthorDate: Wed May 7 09:17:11 2025 +0200

    kernel/os_mbuf: Add OS_MBUF_USRHDR_TO_MBUF
    
    This adds OS_MBUF_USRHDR_TO_MBUF helper macro that calculates
    mbuf pointer from given user packet pointer.
---
 kernel/os/include/os/os_mbuf.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/kernel/os/include/os/os_mbuf.h b/kernel/os/include/os/os_mbuf.h
index 73fe477bd..43ff65b63 100644
--- a/kernel/os/include/os/os_mbuf.h
+++ b/kernel/os/include/os/os_mbuf.h
@@ -150,6 +150,11 @@ struct os_mqueue {
 #define OS_MBUF_PKTHDR_TO_MBUF(__hdr)   \
      (struct os_mbuf *)((uint8_t *)(__hdr) - sizeof(struct os_mbuf))
 
+/** Given a user packet header pointer, return a pointer to the mbuf */
+#define OS_MBUF_USRHDR_TO_MBUF(__hdr)                                         \
+    ((struct os_mbuf *)((uint8_t *)OS_MBUF_PKTHDR_TO_MBUF(__hdr) -            \
+                        sizeof(struct os_mbuf_pkthdr)))
+
 /**
  * Gets the length of an entire mbuf chain.  The specified mbuf must have a
  * packet header.

Reply via email to