X-Git-Url: https://review.openocd.org/gitweb?a=blobdiff_plain;f=src%2Fhelper%2Fbinarybuffer.h;h=eef4057ab17cb419262209c69f9b5a899812b4d7;hb=557d1b6490fab73bd0df0b1127275db784281595;hp=81d3f63ac76942182c0139af00ea37f10757f111;hpb=0e2c2fe1d1eec5482078147d551215a58604cc3a;p=openocd.git diff --git a/src/helper/binarybuffer.h b/src/helper/binarybuffer.h index 81d3f63ac7..eef4057ab1 100644 --- a/src/helper/binarybuffer.h +++ b/src/helper/binarybuffer.h @@ -2,7 +2,7 @@ * Copyright (C) 2004, 2005 by Dominic Rath * * Dominic.Rath@gmx.de * * * - * Copyright (C) 2007,2008 Øyvind Harboe * + * Copyright (C) 2007,2008 Øyvind Harboe * * oyvind.harboe@zylin.com * * * * This program is free software; you can redistribute it and/or modify * @@ -32,7 +32,7 @@ /* inlining this will help show what fn that is taking time during profiling. */ static inline void buf_set_u32(uint8_t* buffer, unsigned int first, unsigned int num, uint32_t value) { - if ((num==32) && (first==0)) + if ((num == 32) && (first == 0)) { buffer[3]=(value >> 24)&0xff; buffer[2]=(value >> 16)&0xff; @@ -41,8 +41,8 @@ static inline void buf_set_u32(uint8_t* buffer, unsigned int first, unsigned int } else { unsigned int i; - - for (i=first; i> (i-first))&1) == 1) buffer[i/8] |= 1 << (i%8); @@ -53,20 +53,20 @@ static inline void buf_set_u32(uint8_t* buffer, unsigned int first, unsigned int } static inline uint32_t buf_get_u32(const uint8_t* buffer, unsigned int first, unsigned int num) { - if ((num==32) && (first==0)) + if ((num == 32) && (first == 0)) { - return (((uint32_t)buffer[3])<<24)|(((uint32_t)buffer[2])<<16)|(((uint32_t)buffer[1])<<8)|(((uint32_t)buffer[0])<<0); + return (((uint32_t)buffer[3]) << 24) | (((uint32_t)buffer[2]) << 16) | (((uint32_t)buffer[1]) << 8) | (((uint32_t)buffer[0]) << 0); } else { uint32_t result = 0; unsigned int i; - - for (i=first; i>(i%8))&1) == 1) result |= 1 << (i-first); } - + return result; } } @@ -86,7 +86,7 @@ extern char* buf_to_str(const uint8_t *buf, int size, int radix); struct scan_field_s; extern int buf_to_u32_handler(uint8_t *in_buf, void *priv, struct scan_field_s *field); -#define CEIL(m, n) ((m + n - 1) / n) +#define CEIL(m, n) (((m) + (n) - 1) / (n)) /* read a uint32_t from a buffer in target memory endianness */ static inline uint32_t fast_target_buffer_get_u32(const uint8_t *buffer, int little)