/*
* Copyright (C) 2013, 2014 Eric Biggers
*
- * This file is part of wimlib, a library for working with WIM files.
+ * This file 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 3 of the License, or (at your option) any
+ * later version.
*
- * wimlib is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 3 of the License, or (at your option)
- * any later version.
- *
- * wimlib 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 General Public License for more
+ * This file 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 General Public License
- * along with wimlib; if not, see http://www.gnu.org/licenses/.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this file; if not, see http://www.gnu.org/licenses/.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
+#include "wimlib/bitops.h"
#include "wimlib/endianness.h"
#include "wimlib/lzms.h"
+#include "wimlib/unaligned.h"
#include "wimlib/util.h"
#include <pthread.h>
LZMS_ASSERT(slot == expected_num_slots);
slot_bases[slot] = final;
- extra_bits[slot - 1] = bsr32(slot_bases[slot] - slot_bases[slot - 1]);
+ extra_bits[slot - 1] = fls32(slot_bases[slot] - slot_bases[slot - 1]);
}
/* Initialize the global offset and length slot tables. */
if (i - *closest_target_usage_p <= max_trans_offset) {
LZMS_DEBUG("Undid x86 translation at position %d "
"(opcode 0x%02x)", i, data[i]);
- le32 *p32 = (le32*)&data[i + num_op_bytes];
- u32 n = le32_to_cpu(*p32);
- *p32 = cpu_to_le32(n - i);
+ void *p32 = &data[i + num_op_bytes];
+ u32 n = get_unaligned_u32_le(p32);
+ put_unaligned_u32_le(n - i, p32);
}
- pos = i + le16_to_cpu(*(const le16*)&data[i + num_op_bytes]);
+ pos = i + get_unaligned_u16_le(&data[i + num_op_bytes]);
} else {
- pos = i + le16_to_cpu(*(const le16*)&data[i + num_op_bytes]);
+ pos = i + get_unaligned_u16_le(&data[i + num_op_bytes]);
if (i - *closest_target_usage_p <= max_trans_offset) {
LZMS_DEBUG("Did x86 translation at position %d "
"(opcode 0x%02x)", i, data[i]);
- le32 *p32 = (le32*)&data[i + num_op_bytes];
- u32 n = le32_to_cpu(*p32);
- *p32 = cpu_to_le32(n + i);
+ void *p32 = &data[i + num_op_bytes];
+ u32 n = get_unaligned_u32_le(p32);
+ put_unaligned_u32_le(n + i, p32);
}
}