OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.18.0/] [newlib/] [libc/] [machine/] [m68k/] [strlen.c] - Blame information for rev 252

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 207 jeremybenn
/*
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
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.