用于嵌入式Linux系统的标准C的库函数

源代码在线查看: strchr.c

软件大小: 6528 K
上传用户: whyzhao
关键词: Linux 嵌入式 标准
下载地址: 免注册下载 普通下载 VIP

相关代码

				#if defined __thumb__								#include "../../string/strchr.c"								#else								#include 				#include "xscale.h"								char *				strchr (const char *s, int c)				{				  unsigned int c2;				  asm (PRELOADSTR ("%0") : : "r" (s));								  c &= 0xff;								#ifndef __OPTIMIZE_SIZE__				  /* Skip unaligned part.  */				  if ((long)s & 3)				    {				      s--;				      do					{					  int c2 = *++s;					  if (c2 == c)					    return (char *)s;					  if (c2 == '\0')					    return 0;					}				      while (((long)s & 3) != 0);				    }								  c2 = c + (c 				  c2 += c2 								  /* Load two constants:				     R6 = 0xfefefeff [ == ~(0x80808080 				     R5 = 0x80808080  */								  asm (PRELOADSTR ("%0") "\n\					mov	r5, #0x80\n\					add	r5, r5, #0x8000\n\					add	r5, r5, r5, lsl #16\n\					mvn	r6, r5, lsl #1\n\				\n\					sub	%0, %0, #4\n\				0:\n\					ldr	r1, [%0, #4]!\n\				"	PRELOADSTR ("%0") "\n\					add	r3, r1, r6\n\					bic	r3, r3, r1\n\					ands	r2, r3, r5\n\					bne	1f\n\					eor	r2, r1, %1\n\					add	r3, r2, r6\n\					bic	r3, r3, r2\n\					ands	r1, r3, r5\n\					beq	0b\n\				1:"				       : "=&r" (s)				       : "r" (c2), "0" (s)				       : "r1", "r2", "r3", "r5", "r6", "cc");				#endif								  while (*s && *s != c)				    s++;				  if (*s == c)				    return (char *)s;				  return NULL;				}								#endif							

相关资源