• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revisión0ee0093aa64683bd348ff39a4d301691154e47f7 (tree)
Tiempo2020-02-24 23:09:50
AutorYoshinori Sato <ysato@user...>
CommiterYoshinori Sato

Log Message

qemu/bitops.h: Add extract8 and extract16

Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20190607091116.49044-10-ysato@users.sourceforge.jp>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

Cambiar Resumen

Diferencia incremental

--- a/include/qemu/bitops.h
+++ b/include/qemu/bitops.h
@@ -302,6 +302,44 @@ static inline uint32_t extract32(uint32_t value, int start, int length)
302302 }
303303
304304 /**
305+ * extract8:
306+ * @value: the value to extract the bit field from
307+ * @start: the lowest bit in the bit field (numbered from 0)
308+ * @length: the length of the bit field
309+ *
310+ * Extract from the 8 bit input @value the bit field specified by the
311+ * @start and @length parameters, and return it. The bit field must
312+ * lie entirely within the 8 bit word. It is valid to request that
313+ * all 8 bits are returned (ie @length 8 and @start 0).
314+ *
315+ * Returns: the value of the bit field extracted from the input value.
316+ */
317+static inline uint8_t extract8(uint8_t value, int start, int length)
318+{
319+ assert(start >= 0 && length > 0 && length <= 8 - start);
320+ return extract32(value, start, length);
321+}
322+
323+/**
324+ * extract16:
325+ * @value: the value to extract the bit field from
326+ * @start: the lowest bit in the bit field (numbered from 0)
327+ * @length: the length of the bit field
328+ *
329+ * Extract from the 16 bit input @value the bit field specified by the
330+ * @start and @length parameters, and return it. The bit field must
331+ * lie entirely within the 16 bit word. It is valid to request that
332+ * all 16 bits are returned (ie @length 16 and @start 0).
333+ *
334+ * Returns: the value of the bit field extracted from the input value.
335+ */
336+static inline uint16_t extract16(uint16_t value, int start, int length)
337+{
338+ assert(start >= 0 && length > 0 && length <= 16 - start);
339+ return extract32(value, start, length);
340+}
341+
342+/**
305343 * extract64:
306344 * @value: the value to extract the bit field from
307345 * @start: the lowest bit in the bit field (numbered from 0)