Import fix from preempt branch.
authorbatt <batt@38d2e660-2303-0410-9eaa-f027e97ec537>
Wed, 20 Jan 2010 16:38:52 +0000 (16:38 +0000)
committerbatt <batt@38d2e660-2303-0410-9eaa-f027e97ec537>
Wed, 20 Jan 2010 16:38:52 +0000 (16:38 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3160 38d2e660-2303-0410-9eaa-f027e97ec537

bertos/cpu/types.h
bertos/mware/formatwr.c

index daeec2ea7b332a198ab55168e6984bc565686feb..252d77a9796764ce929bbcb46dd6b09d67b3f1a1 100644 (file)
 #endif
 #endif
 
+#ifndef SIZEOF_SIZE_T
+#if CPU_REG_BITS < 32
+       #define SIZEOF_SIZE_T   2
+#elif CPU_REG_BITS == 32
+       #define SIZEOF_SIZE_T   4
+#else /* CPU_REG_BITS > 32 */
+       #define SIZEOF_SIZE_T   8
+#endif
+#endif
+
 #ifndef CPU_BITS_PER_CHAR
 #define CPU_BITS_PER_CHAR   (SIZEOF_CHAR * 8)
 #endif
@@ -215,6 +225,6 @@ STATIC_ASSERT(sizeof(uint64_t) * CPU_BITS_PER_CHAR == 64);
 #endif
 STATIC_ASSERT(sizeof(cpu_stack_t) == SIZEOF_CPUSTACK_T);
 STATIC_ASSERT(sizeof(cpu_aligned_stack_t) == SIZEOF_CPUALIGNED_T);
-
+STATIC_ASSERT(sizeof(size_t) == SIZEOF_SIZE_T);
 
 #endif /* CPU_TYPES_H */
index 996f8df04c5e7562d100f5760a86765cb8c15eb5..7293c4dc7a0b4f624314b83a2de072f0f02ee97b 100644 (file)
@@ -505,14 +505,21 @@ NEXT_FLAG:
                {
                        case 'l':
                        case 'L':
+               #if SIZEOF_SIZE_T == SIZEOF_LONG
                        case 'z':
                                flags.l_L_modifier = true;
+               #elif SIZEOF_SIZE_T == SIZEOF_INT
+                               flags.l_L_modifier = true;
+                       case 'z':
+               #endif
                                format++;
                                break;
+
                        case 'h':
                                flags.h_modifier = true;
                                format++;
                                break;
+
                }
 
                /*
@@ -853,10 +860,13 @@ FLOATING_CONVERSION:
                switch (PGM_READ_CHAR(format))
                {
                        case 'l':
+               #if SIZEOF_SIZE_T == SIZEOF_LONG
                        case 'z':
-                               /* for the 'z' modifier, we make this assumption */
-                               STATIC_ASSERT(sizeof(size_t) == sizeof(long));
                                l_modifier = true;
+               #elif SIZEOF_SIZE_T == SIZEOF_INT
+                               l_modifier = true;
+                       case 'z':
+               #endif
                                format++;
                                break;