ref: 0589b9280b623ef2dc2ec2c5c879b4d23cabddb9
parent: 53b4f91981f5898473830d53c24c27e17f83a8a1
author: gkostka <kostka.grzegorz@gmail.com>
date: Fri Apr 1 11:05:29 EDT 2016
ext4_config: add CONFIG_UNALIGNED_ACCESS configuration switch On some targets unaligned 32/16 bit access will raise exeption.
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -15,11 +15,11 @@
if (CMAKE_SYSTEM_PROCESSOR STREQUAL cortex-m0)
#...
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL cortex-m3)
- #...
+ add_definitions(-DCONFIG_UNALIGNED_ACCESS=1)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL arm-sim)
#...
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL cortex-m4)
- #...
+ add_definitions(-DCONFIG_UNALIGNED_ACCESS=1)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL bf518)
#...
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL avrxmega7)
--- a/include/ext4_config.h
+++ b/include/ext4_config.h
@@ -144,6 +144,11 @@
#define CONFIG_MAX_TRUNCATE_SIZE (16ul * 1024ul * 1024ul)
#endif
+
+/**@brief Unaligned access switch on/off*/
+#ifndef CONFIG_UNALIGNED_ACCESS
+#define CONFIG_UNALIGNED_ACCESS 1
+#endif
#ifdef __cplusplus
}
#endif
--- a/src/ext4_bitmap.c
+++ b/src/ext4_bitmap.c
@@ -59,6 +59,7 @@
sbit = i;
bmap += (sbit >> 3);
+#if CONFIG_UNALIGNED_ACCESS
while (bcnt >= 32) {
*(uint32_t *)bmap = 0;
bmap += 4;
@@ -72,6 +73,7 @@
bcnt -= 16;
sbit += 16;
}
+#endif
while (bcnt >= 8) {
*bmap = 0;
@@ -110,6 +112,7 @@
sbit = i;
bmap += (sbit >> 3);
+#if CONFIG_UNALIGNED_ACCESS
while (bcnt >= 32) {
if (*(uint32_t *)bmap != 0xFFFFFFFF)
goto finish_it;
@@ -127,8 +130,8 @@
bcnt -= 16;
sbit += 16;
}
-
finish_it:
+#endif
while (bcnt >= 8) {
if (*bmap != 0xFF) {
for (i = 0; i < 8; ++i) {