Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
attributes.c
00001 #include "mbed_toolchain.h" 00002 00003 #include <stdio.h> 00004 #include <stdint.h> 00005 00006 00007 MBED_PACKED(struct) TestAttrPackedStruct1 { 00008 char a; 00009 int x; 00010 }; 00011 00012 typedef MBED_PACKED(struct) 00013 { 00014 char a; 00015 int x; 00016 } 00017 TestAttrPackedStruct2; 00018 00019 int testPacked() 00020 { 00021 int failed = 0; 00022 00023 if (sizeof(struct TestAttrPackedStruct1) != sizeof(int) + sizeof(char)) { 00024 failed++; 00025 } 00026 00027 if (sizeof(TestAttrPackedStruct2) != sizeof(int) + sizeof(char)) { 00028 failed++; 00029 } 00030 00031 return failed; 00032 } 00033 00034 00035 MBED_ALIGN(8) char a; 00036 MBED_ALIGN(8) char b; 00037 MBED_ALIGN(16) char c; 00038 MBED_ALIGN(8) char d; 00039 MBED_ALIGN(16) char e; 00040 00041 int testAlign() 00042 { 00043 int failed = 0; 00044 00045 if (((uintptr_t)&a) & 0x7) { 00046 failed++; 00047 } 00048 if (((uintptr_t)&b) & 0x7) { 00049 failed++; 00050 } 00051 if (((uintptr_t)&c) & 0xf) { 00052 failed++; 00053 } 00054 if (((uintptr_t)&d) & 0x7) { 00055 failed++; 00056 } 00057 if (((uintptr_t)&e) & 0xf) { 00058 failed++; 00059 } 00060 00061 return failed; 00062 } 00063 00064 00065 int testUnused1(MBED_UNUSED int arg) 00066 { 00067 return 0; 00068 } 00069 00070 int testUnused() 00071 { 00072 return testUnused1(0); 00073 } 00074 00075 00076 int testWeak1(); 00077 int testWeak2(); 00078 00079 MBED_WEAK int testWeak1() 00080 { 00081 return 1; 00082 } 00083 00084 int testWeak2() 00085 { 00086 return 0; 00087 } 00088 00089 int testWeak() 00090 { 00091 return testWeak1() | testWeak2(); 00092 } 00093 00094 00095 MBED_PURE int testPure1() 00096 { 00097 return 0; 00098 } 00099 00100 int testPure() 00101 { 00102 return testPure1(); 00103 } 00104 00105 00106 MBED_FORCEINLINE int testForceInline1() 00107 { 00108 return 0; 00109 } 00110 00111 int testForceInline() 00112 { 00113 return testForceInline1(); 00114 } 00115 00116 00117 MBED_NORETURN int testNoReturn1() 00118 { 00119 while (1) {} 00120 } 00121 00122 int testNoReturn() 00123 { 00124 if (0) { 00125 testNoReturn1(); 00126 } 00127 return 0; 00128 } 00129 00130 00131 int testUnreachable1(int i) 00132 { 00133 switch (i) { 00134 case 0: 00135 return 0; 00136 } 00137 00138 MBED_UNREACHABLE; 00139 } 00140 00141 int testUnreachable() 00142 { 00143 return testUnreachable1(0); 00144 } 00145 00146 00147 MBED_DEPRECATED("this message should not be displayed") 00148 void testDeprecatedUnused(); 00149 void testDeprecatedUnused() { } 00150 00151 MBED_DEPRECATED("this message should be displayed") 00152 int testDeprecatedUsed(); 00153 int testDeprecatedUsed() 00154 { 00155 return 0; 00156 } 00157 00158 MBED_DEPRECATED_SINCE("mbed-os-3.14", "this message should not be displayed") 00159 void testDeprecatedSinceUnused(); 00160 void testDeprecatedSinceUnused() { } 00161 00162 MBED_DEPRECATED_SINCE("mbed-os-3.14", "this message should be displayed") 00163 int testDeprecatedSinceUsed(); 00164 int testDeprecatedSinceUsed() 00165 { 00166 return 0; 00167 } 00168 00169 int testDeprecated() 00170 { 00171 return testDeprecatedUsed() + testDeprecatedSinceUsed(); 00172 } 00173
Generated on Tue Aug 9 2022 00:37:03 by
1.7.2