X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=blobdiff_plain;f=src%2Fhelper%2Fbinarybuffer.h;h=f1da8c4aa3cb070aa1c7140e6061a035fe82921e;hp=c2d643b13e44e8a9b9d6a2a54bc3081a5b1e7201;hb=6949b5393d9fb6511ddef13ce0bef1a147e7f962;hpb=7641fb6ac6bc0736627a26dad9616fcb67cf59ab diff --git a/src/helper/binarybuffer.h b/src/helper/binarybuffer.h index c2d643b13e..f1da8c4aa3 100644 --- a/src/helper/binarybuffer.h +++ b/src/helper/binarybuffer.h @@ -16,13 +16,11 @@ * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * along with this program. If not, see . * ***************************************************************************/ -#ifndef BINARYBUFFER_H -#define BINARYBUFFER_H +#ifndef OPENOCD_HELPER_BINARYBUFFER_H +#define OPENOCD_HELPER_BINARYBUFFER_H #include "list.h" @@ -39,10 +37,10 @@ * @param num The number of bits from @c value to copy (1-32). * @param value Up to 32 bits that will be copied to _buffer. */ -static inline void buf_set_u32(void *_buffer, +static inline void buf_set_u32(uint8_t *_buffer, unsigned first, unsigned num, uint32_t value) { - uint8_t *buffer = (uint8_t *)_buffer; + uint8_t *buffer = _buffer; if ((num == 32) && (first == 0)) { buffer[3] = (value >> 24) & 0xff; @@ -68,10 +66,10 @@ static inline void buf_set_u32(void *_buffer, * @param num The number of bits from @c value to copy (1-64). * @param value Up to 64 bits that will be copied to _buffer. */ -static inline void buf_set_u64(void *_buffer, +static inline void buf_set_u64(uint8_t *_buffer, unsigned first, unsigned num, uint64_t value) { - uint8_t *buffer = (uint8_t *)_buffer; + uint8_t *buffer = _buffer; if ((num == 32) && (first == 0)) { buffer[3] = (value >> 24) & 0xff; @@ -106,10 +104,10 @@ static inline void buf_set_u64(void *_buffer, * @param num The number of bits from @c _buffer to read (1-32). * @returns Up to 32-bits that were read from @c _buffer. */ -static inline uint32_t buf_get_u32(const void *_buffer, +static inline uint32_t buf_get_u32(const uint8_t *_buffer, unsigned first, unsigned num) { - uint8_t *buffer = (uint8_t *)_buffer; + const uint8_t *buffer = _buffer; if ((num == 32) && (first == 0)) { return (((uint32_t)buffer[3]) << 24) | @@ -135,10 +133,10 @@ static inline uint32_t buf_get_u32(const void *_buffer, * @param num The number of bits from @c _buffer to read (1-64). * @returns Up to 64-bits that were read from @c _buffer. */ -static inline uint64_t buf_get_u64(const void *_buffer, +static inline uint64_t buf_get_u64(const uint8_t *_buffer, unsigned first, unsigned num) { - uint8_t *buffer = (uint8_t *)_buffer; + const uint8_t *buffer = _buffer; if ((num == 32) && (first == 0)) { return 0 + ((((uint32_t)buffer[3]) << 24) | /* Note - zero plus is to avoid a checkpatch bug */ @@ -236,7 +234,8 @@ void bit_copy_discard(struct bit_copy_queue *q); /* functions to convert to/from hex encoded buffer * used in ti-icdi driver and gdb server */ -int unhexify(char *bin, const char *hex, int count); -int hexify(char *hex, const char *bin, int count, int out_maxlen); +size_t unhexify(uint8_t *bin, const char *hex, size_t count); +size_t hexify(char *hex, const uint8_t *bin, size_t count, size_t out_maxlen); +void buffer_shr(void *_buf, unsigned buf_len, unsigned count); -#endif /* BINARYBUFFER_H */ +#endif /* OPENOCD_HELPER_BINARYBUFFER_H */