| 112 | } |
| 113 | |
| 114 | int strcmp(const char* str1, const char* str2) |
| 115 | { |
| 116 | // bless metrowerks for this implementation |
| 117 | |
| 118 | register u8* left = (u8*)str1; |
| 119 | register u8* right = (u8*)str2; |
| 120 | u32 align, l1, r1, x; |
| 121 | |
| 122 | u32 K1, K2; |
| 123 | |
| 124 | l1 = *left; |
| 125 | r1 = *right; |
| 126 | if (l1 - r1) { |
| 127 | return (l1 - r1); |
| 128 | } |
| 129 | |
| 130 | if ((align = ((int)left & 3)) != ((int)right & 3)) { |
| 131 | goto bytecopy; |
| 132 | } |
| 133 | if (align) { |
| 134 | if (l1 == 0) { |
| 135 | return 0; |
| 136 | } |
| 137 | for (align = 3 - align; align; align--) { |
| 138 | l1 = *(++left); |
| 139 | r1 = *(++right); |
| 140 | if (l1 - r1) { |
| 141 | return (l1 - r1); |
| 142 | } |
| 143 | if (l1 == 0) { |
| 144 | return 0; |
| 145 | } |
| 146 | } |
| 147 | left++; |
| 148 | right++; |
| 149 | } |
| 150 | |
| 151 | l1 = *(int*)left; |
| 152 | r1 = *(int*)right; |
| 153 | |
| 154 | K1 = 0x80808080; |
| 155 | K2 = 0xFEFEFEFF; |
| 156 | |
| 157 | x = l1 + K2; |
| 158 | if (x & K1) { |
| 159 | goto adjust; |
| 160 | } |
| 161 | while (l1 == r1) { |
| 162 | l1 = *(++((int*)(left))); |
| 163 | r1 = *(++((int*)(right))); |
| 164 | x = l1 + K2; |
| 165 | if (x & K1) { |
| 166 | goto adjust; |
| 167 | } |
| 168 | } |
| 169 | if (l1 > r1) |
| 170 | return 1; |
| 171 | return -1; |
no outgoing calls
no test coverage detected