Last change
on this file since 444 was
444,
checked in by satin@…, 6 years ago
|
add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc
|
File size:
650 bytes
|
Line | |
---|
1 | /* |
---|
2 | * C library strlen routine |
---|
3 | * |
---|
4 | * This routine has been optimized for the CPU32+. |
---|
5 | * It should run on all 68k machines. |
---|
6 | * |
---|
7 | * W. Eric Norum |
---|
8 | * Saskatchewan Accelerator Laboratory |
---|
9 | * University of Saskatchewan |
---|
10 | * Saskatoon, Saskatchewan, CANADA |
---|
11 | * eric@skatter.usask.ca |
---|
12 | */ |
---|
13 | |
---|
14 | #include <string.h> |
---|
15 | |
---|
16 | /* |
---|
17 | * Test bytes using CPU32+ loop mode if possible. |
---|
18 | */ |
---|
19 | size_t |
---|
20 | strlen (const char *str) |
---|
21 | { |
---|
22 | unsigned int n = ~0; |
---|
23 | const char *cp = str; |
---|
24 | |
---|
25 | asm volatile ("1:\n" |
---|
26 | "\ttst.b (%0)+\n" |
---|
27 | #if defined(__mcpu32__) |
---|
28 | "\tdbeq %1,1b\n" |
---|
29 | #endif |
---|
30 | "\tbne.b 1b\n" : |
---|
31 | "=a" (cp), "=d" (n) : |
---|
32 | "0" (cp), "1" (n) : |
---|
33 | "cc"); |
---|
34 | return (cp - str) - 1; |
---|
35 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.