2001-05-05 05:02:15 +08:00
|
|
|
/* string.h: Extra string defs
|
|
|
|
|
|
|
|
Copyright 2001 Red Hat, Inc.
|
|
|
|
|
|
|
|
This file is part of Cygwin.
|
|
|
|
|
|
|
|
This software is a copyrighted work licensed under the terms of the
|
|
|
|
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
|
|
|
details. */
|
|
|
|
|
|
|
|
#ifndef _CYGWIN_STRING_H
|
|
|
|
#define _CYGWIN_STRING_H
|
|
|
|
|
|
|
|
#include_next <string.h>
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#undef strchr
|
|
|
|
#define strchr cygwin_strchr
|
2001-05-07 00:00:23 +08:00
|
|
|
static inline __stdcall char *
|
2001-05-05 05:02:15 +08:00
|
|
|
strchr (const char *s, int c)
|
|
|
|
{
|
|
|
|
register char * res;
|
2001-05-05 05:06:13 +08:00
|
|
|
__asm__ __volatile__ ("\
|
2001-05-05 05:02:15 +08:00
|
|
|
movb %%al,%%ah\n\
|
|
|
|
1: movb (%1),%%al\n\
|
|
|
|
cmpb %%ah,%%al\n\
|
|
|
|
je 2f\n\
|
|
|
|
incl %1\n\
|
|
|
|
testb %%al,%%al\n\
|
|
|
|
jne 1b\n\
|
|
|
|
xorl %1,%1\n\
|
|
|
|
2: movl %1,%0\n\
|
2001-05-05 05:06:13 +08:00
|
|
|
":"=a" (res), "=r" (s)
|
2001-05-05 05:02:15 +08:00
|
|
|
:"0" (c), "1" (s));
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif /* _CYGWIN_STRING_H */
|