X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=src%2Fio.h;h=1a617e261d28bee11c6607e22ce278ceb641625b;hb=277957c10e96a23f822b2e6ae22c8d126a93141a;hp=81144f7b333b597d4d02e3ed4bf1cf45cac5ae3e;hpb=885632f08c75c1d7bb5d25436231c78f6ad7e0c0;p=wimlib diff --git a/src/io.h b/src/io.h index 81144f7b..1a617e26 100644 --- a/src/io.h +++ b/src/io.h @@ -3,23 +3,6 @@ * * A few endianness-aware macros for reading and writing data from in-memory * buffers. - * - * Copyright (C) 2012 Eric Biggers - * - * wimlib - Library for working with WIM files - * - * This library is free software; you can redistribute it and/or modify it under - * the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 2.1 of the License, or (at your option) any - * later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A - * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License along - * with this library; if not, write to the Free Software Foundation, Inc., 59 - * Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _WIMLIB_IO_H @@ -46,7 +29,7 @@ static inline const u8 *get_u8(const u8 *p, u8 *res) static inline const u8 *get_u16(const u8 *p, u16 *res) { - *res = to_le16(*(u16*)p); + *res = le16_to_cpu(*(u16*)p); return p + 2; } @@ -54,21 +37,21 @@ static inline const u8 *get_u16(const u8 *p, u16 *res) static inline const u8 *get_u32(const u8 *p, u32 *res) { - *res = to_le32(*(u32*)p); + *res = le32_to_cpu(*(u32*)p); return p + 4; } static inline const u8 *get_u56(const u8 *p, u64 *res) { - *res = to_le64(*(u64*)p) & 0x00ffffffffffffff; + *res = le64_to_cpu(*(u64*)p) & 0x00ffffffffffffff; return p + 7; } static inline const u8 *get_u64(const u8 *p, u64 *res) { - *res = to_le64(*(u64*)p); + *res = le64_to_cpu(*(u64*)p); return p + 8; } @@ -86,13 +69,13 @@ static inline u8 *put_u8(u8 *res, u8 val) static inline u8 *put_u16(u8 *res, u16 val) { - *(uint16_t*)res = to_le16(val); + *(uint16_t*)res = cpu_to_le16(val); return res + 2; } static inline u8 *put_u32(u8 *res, u32 val) { - *(uint32_t*)res = to_le32(val); + *(uint32_t*)res = cpu_to_le32(val); return res + 4; } @@ -115,7 +98,7 @@ static inline u8 *put_u56(u8 *res, u64 val) static inline u8 *put_u64(u8 *res, u64 val) { - *(u64*)res = to_le64(val); + *(u64*)res = cpu_to_le64(val); return res + 8; } @@ -125,9 +108,13 @@ static inline const u8 *get_bytes(const u8 *p, size_t num_bytes, void *res) return p + num_bytes; } +static inline u8 *put_zeroes(u8 *p, size_t num_bytes) +{ + return (u8*)memset(p, 0, num_bytes) + num_bytes; +} + static inline u8 *put_bytes(u8 *p, size_t num_bytes, const u8 *input) { - memcpy(p, input, num_bytes); - return p + num_bytes; + return (u8*)memcpy(p, input, num_bytes) + num_bytes; } #endif /* _WIMLIB_IO_H */