X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Futil%2Fblob.h;h=e1e156eb43fa1e40f9dc34d20a80f826f48c42f5;hb=9fd0f455af7bc741ea330fcd12478833580dbcfc;hp=0c2759119836a9c187b5b2577f48bd07e9c30387;hpb=ad56022b0d96ca6a823623dd93b3f0bf9de17ba8;p=mesa.git diff --git a/src/util/blob.h b/src/util/blob.h index 0c275911983..e1e156eb43f 100644 --- a/src/util/blob.h +++ b/src/util/blob.h @@ -175,6 +175,42 @@ blob_overwrite_bytes(struct blob *blob, const void *bytes, size_t to_write); +/** + * Add a uint8_t to a blob. + * + * \return True unless allocation failed. + */ +bool +blob_write_uint8(struct blob *blob, uint8_t value); + +/** + * Overwrite a uint8_t previously written to the blob. + * + * Writes a uint8_t value to an existing portion of the blob at an offset of + * \offset. This data range must have previously been written to the blob by + * one of the blob_write_* calls. + * + * \return True unless the requested position or position+to_write lie outside + * the current blob's size. + */ +bool +blob_overwrite_uint8(struct blob *blob, + size_t offset, + uint8_t value); + +/** + * Add a uint16_t to a blob. + * + * \note This function will only write to a uint16_t-aligned offset from the + * beginning of the blob's data, so some padding bytes may be added to the + * blob if this write follows some unaligned write (such as + * blob_write_string). + * + * \return True unless allocation failed. + */ +bool +blob_write_uint16(struct blob *blob, uint16_t value); + /** * Add a uint32_t to a blob. * @@ -303,6 +339,27 @@ blob_copy_bytes(struct blob_reader *blob, void *dest, size_t size); void blob_skip_bytes(struct blob_reader *blob, size_t size); +/** + * Read a uint8_t from the current location, (and update the current location + * to just past this uint8_t). + * + * \return The uint8_t read + */ +uint8_t +blob_read_uint8(struct blob_reader *blob); + +/** + * Read a uint16_t from the current location, (and update the current location + * to just past this uint16_t). + * + * \note This function will only read from a uint16_t-aligned offset from the + * beginning of the blob's data, so some padding bytes may be skipped. + * + * \return The uint16_t read + */ +uint16_t +blob_read_uint16(struct blob_reader *blob); + /** * Read a uint32_t from the current location, (and update the current location * to just past this uint32_t).