X-Git-Url: https://review.openocd.org/gitweb?a=blobdiff_plain;f=src%2Fhelper%2Ftypes.h;h=3d27e83b6853f6b7bc1187a6a042a8c7b31b577e;hb=a6863e9a52c227086d874ef033de2499005ae318;hp=04b005945939fb8925633b5762b25bc2f1442ae0;hpb=f6a3fc818bc6a24b6c5bbcc6057f72d2b0b2e2ab;p=openocd.git diff --git a/src/helper/types.h b/src/helper/types.h index 04b0059459..3d27e83b68 100644 --- a/src/helper/types.h +++ b/src/helper/types.h @@ -18,7 +18,7 @@ * 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., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * ***************************************************************************/ #ifndef TYPES_H #define TYPES_H @@ -116,6 +116,11 @@ static inline uint32_t le_to_h_u32(const uint8_t* buf) return (uint32_t)(buf[0] | buf[1] << 8 | buf[2] << 16 | buf[3] << 24); } +static inline uint32_t le_to_h_u24(const uint8_t* buf) +{ + return (uint32_t)(buf[0] | buf[1] << 8 | buf[2] << 16); +} + static inline uint16_t le_to_h_u16(const uint8_t* buf) { return (uint16_t)(buf[0] | buf[1] << 8); @@ -126,6 +131,11 @@ static inline uint32_t be_to_h_u32(const uint8_t* buf) return (uint32_t)(buf[3] | buf[2] << 8 | buf[1] << 16 | buf[0] << 24); } +static inline uint32_t be_to_h_u24(const uint8_t* buf) +{ + return (uint32_t)(buf[2] | buf[1] << 8 | buf[0] << 16); +} + static inline uint16_t be_to_h_u16(const uint8_t* buf) { return (uint16_t)(buf[1] | buf[0] << 8); @@ -147,6 +157,20 @@ static inline void h_u32_to_be(uint8_t* buf, int val) buf[3] = (uint8_t) (val >> 0); } +static inline void h_u24_to_le(uint8_t* buf, int val) +{ + buf[2] = (uint8_t) (val >> 16); + buf[1] = (uint8_t) (val >> 8); + buf[0] = (uint8_t) (val >> 0); +} + +static inline void h_u24_to_be(uint8_t* buf, int val) +{ + buf[0] = (uint8_t) (val >> 16); + buf[1] = (uint8_t) (val >> 8); + buf[2] = (uint8_t) (val >> 0); +} + static inline void h_u16_to_le(uint8_t* buf, int val) { buf[1] = (uint8_t) (val >> 8); @@ -173,6 +197,8 @@ static inline void h_u16_to_be(uint8_t* buf, int val) #define PRIi32 "i" #define PRIu32 "u" #define PRId8 PRId32 +#define SCNx64 "llx" +#define PRIx64 "llx" typedef CYG_ADDRWORD intptr_t; typedef int64_t intmax_t; @@ -191,11 +217,11 @@ typedef uint64_t uintmax_t; #define UINT64_MAX (__CONCAT(INT64_MAX, U) * 2ULL + 1ULL) #endif - #ifndef LLONG_MAX + #ifndef LLONG_MAX #define ULLONG_MAX UINT64_C(0xFFFFFFFFFFFFFFFF) #define LLONG_MAX INT64_C(0x7FFFFFFFFFFFFFFF) #define LLONG_MIN ULLONG_MAX - #endif + #endif #define ULLONG_MAX 18446744073709551615