]> granicus.if.org Git - esp-idf/commitdiff
Structure size alligned by compiler.
authorDmitry <Dmitry@espressif.com>
Mon, 12 Mar 2018 12:34:16 +0000 (15:34 +0300)
committerDmitry <Dmitry@espressif.com>
Mon, 12 Mar 2018 12:34:16 +0000 (15:34 +0300)
components/wear_levelling/private_include/WL_Config.h

index 62f10eec3cdaaa6e987fec2ce0768c18b0c971bb..a1daa32d928b71a86909fda5cd5bab20930e2a40 100644 (file)
 * @brief This class is used as a structure to configure wear levelling module\r
 *\r
 */\r
-#ifndef wl_config_t_size\r
-#define wl_config_t_size (int)((48 - (2*sizeof(size_t) + 7*sizeof(uint32_t)) + sizeof(uint32_t) - 1)/sizeof(uint32_t))\r
-#endif // wl_config_t_size\r
-typedef struct WL_Config_s {\r
-    size_t   start_addr;      /*!< start address in the flash*/\r
+\r
+#if defined(_MSC_VER)\r
+#define ALIGNED_(x) __declspec(align(x))\r
+#else\r
+#if defined(__GNUC__)\r
+#define ALIGNED_(x) __attribute__ ((aligned(x)))\r
+#endif\r
+#endif\r
+\r
+typedef struct ALIGNED_(16) WL_Config_s { /*!< Size of wl_config_t structure should be divided by 16 for encryption*/\r
+    size_t   start_addr;    /*!< start address in the flash*/\r
     uint32_t full_mem_size; /*!< Amount of memory used to store data in bytes*/\r
     uint32_t page_size;     /*!< One page size in bytes. Page could be more then memory block. This parameter must be page_size >= N*block_size.*/\r
     uint32_t sector_size;   /*!< size of flash memory sector that will be erased and stored at once (erase)*/\r
@@ -32,13 +38,7 @@ typedef struct WL_Config_s {
     uint32_t wr_size;       /*!< Minimum amount of bytes per one block at write operation: 1...*/\r
     uint32_t version;       /*!< A version of current implementatioon. To erase and reallocate complete memory this ID must be different from id before.*/\r
     size_t   temp_buff_size;  /*!< Size of temporary allocated buffer to copy from one flash area to another. The best way, if this value will be equal to sector size.*/\r
-    uint32_t reserved[wl_config_t_size];   /*!< dummy array to make wl_config_t size compatible with flash encryption (divided by 16)*/\r
     uint32_t crc;           /*!< CRC for this config*/\r
-public:\r
-    WL_Config_s()\r
-    {\r
-        for (int i=0 ; i< wl_config_t_size ; i++) this->reserved[i] = 0;\r
-    }\r
 } wl_config_t;\r
 \r
 #ifndef _MSC_VER // MSVS has different format for this define\r