Skip to contentSkip to conversation

introduction: add note on bitfield portability

PATCH In review Michael S. Tsirkin 2 participants 2 messages Mar 6, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 introduction: add note on bitfield portability

---
 introduction.tex | 7 +++++++
 1 file changed, 7 insertions(+)
introduction.tex +7 -0
index d0b770e..18ad76e 100644
@@ -175,5 +175,12 @@ packed by C compilers on little-endian architectures but not the
 way bitfields are packed by C compilers on big-endian
 architectures.
 
+Assuming that CPU_TO_BE16 converts a 16-bit integer from a native
+CPU to the big-endian byte order, the following is the equivalent
+portable C code to generate a value in this format:
+\begin{lstlisting}
+CPU_TO_BE16(B << 15 | A)
+\end{lstlisting}
+
 \newpage
 
Signature · 6 lines
MST

---------------------------------------------------------------------
To unsubscribe from this mail list, you must leave the OASIS TC that 
generates this mail.  Follow this link to all your TCs in OASIS at:
https://www.oasis-open.org/apps/org/workgroup/portal/my_workgroups.php 
Reviewed-by on v1 1/1
#1 lore raw

On Tue, 6 Mar 2018 16:35:46 +0200
"Michael S. Tsirkin" <[email protected]> wrote:

[You picked my old email address :)]

Quoted 12 lines
---
 introduction.tex | 7 +++++++
 1 file changed, 7 insertions(+)
introduction.tex +0 -0
index d0b770e..18ad76e 100644
@@ -175,5 +175,12 @@ packed by C compilers on little-endian architectures but not the
 way bitfields are packed by C compilers on big-endian
 architectures.

introduction.tex packed by C compilers on little-endian architectures but not the · line 186

Quoted 10 lines
introduction.tex +7 -0
 
+Assuming that CPU_TO_BE16 converts a 16-bit integer from a native
+CPU to the big-endian byte order, the following is the equivalent
+portable C code to generate a value in this format:
+\begin{lstlisting}
+CPU_TO_BE16(B << 15 | A)
+\end{lstlisting}
+
 \newpage
 

---------------------------------------------------------------------
To unsubscribe from this mail list, you must leave the OASIS TC that generates this mail. Follow this link to all your TCs in OASIS at:
https://www.oasis-open.org/apps/org/workgroup/portal/my_workgroups.php