OSDN Git Service

* select.cc (select_stuff::wait): Temporarily disallow APCS.
[pf3gnuchains/pf3gnuchains4x.git] / winsup / cygwin / string.h
1 /* string.h: Extra string defs
2
3    Copyright 2001, 2007, 2008, 2011 Red Hat, Inc.
4
5 This file is part of Cygwin.
6
7 This software is a copyrighted work licensed under the terms of the
8 Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
9 details. */
10
11 #ifndef _CYGWIN_STRING_H
12 #define _CYGWIN_STRING_H
13
14 #include_next <string.h>
15
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19
20 #undef strechr
21 #define strechr cygwin_strechr
22 static inline __stdcall char *
23 strechr (const char *s, int c)
24 {
25   register char * res;
26   __asm__ __volatile__ ("\
27         movb    %%al,%%ah\n\
28 1:      movb    (%1),%%al\n\
29         cmpb    %%ah,%%al\n\
30         je      2f\n\
31         incl    %1\n\
32         testb   %%al,%%al\n\
33         jne     1b\n\
34         decl    %1\n\
35 2:      movl    %1,%0\n\
36         ":"=a" (res), "=r" (s)
37         :"0" (c), "1" (s));
38   return res;
39 }
40
41 #ifdef __INSIDE_CYGWIN__
42
43 extern const char isalpha_array[];
44
45 static inline int
46 ascii_strcasematch (const char *cs, const char *ct)
47 {
48   register int __res;
49   int d0, d1;
50   __asm__ ("\
51         .global _isalpha_array                  \n\
52         cld                                     \n\
53         andl    $0xff,%%eax                     \n\
54 1:      lodsb                                   \n\
55         scasb                                   \n\
56         je      2f                              \n\
57         xorb    _isalpha_array(%%eax),%%al      \n\
58         cmpb    -1(%%edi),%%al                  \n\
59         jne     3f                              \n\
60 2:      testb   %%al,%%al                       \n\
61         jnz     1b                              \n\
62         movl    $1,%%eax                        \n\
63         jmp     4f                              \n\
64 3:      xor     %0,%0                           \n\
65 4:"
66         :"=a" (__res), "=&S" (d0), "=&D" (d1)
67                      : "1" (cs),   "2" (ct));
68
69   return __res;
70 }
71
72 static inline int
73 ascii_strncasematch (const char *cs, const char *ct, size_t n)
74 {
75   register int __res;
76   int d0, d1, d2;
77   __asm__ ("\
78         .global _isalpha_array;                 \n\
79         cld                                     \n\
80         andl    $0xff,%%eax                     \n\
81 1:      decl    %3                              \n\
82         js      3f                              \n\
83         lodsb                                   \n\
84         scasb                                   \n\
85         je      2f                              \n\
86         xorb    _isalpha_array(%%eax),%%al      \n\
87         cmpb    -1(%%edi),%%al                  \n\
88         jne     4f                              \n\
89 2:      testb   %%al,%%al                       \n\
90         jnz     1b                              \n\
91 3:      movl    $1,%%eax                        \n\
92         jmp     5f                              \n\
93 4:      xor     %0,%0                           \n\
94 5:"
95         :"=a" (__res), "=&S" (d0), "=&D" (d1), "=&c" (d2)
96                        :"1" (cs),  "2" (ct), "3" (n));
97
98   return __res;
99 }
100
101 #undef strcasecmp
102 #define strcasecmp cygwin_strcasecmp
103 int __stdcall cygwin_strcasecmp (const char *, const char *);
104
105 #undef strncasecmp
106 #define strncasecmp cygwin_strncasecmp
107 int __stdcall cygwin_strncasecmp (const char *, const char *, size_t);
108
109 #define strcasematch(s1,s2)     (!cygwin_strcasecmp ((s1),(s2)))
110 #define strncasematch(s1,s2,n)  (!cygwin_strncasecmp ((s1),(s2),(n)))
111
112 #undef strlwr
113 #define strlwr cygwin_strlwr
114 char * __stdcall cygwin_strlwr (char *);
115
116 #undef strupr
117 #define strupr cygwin_strupr
118 char * __stdcall cygwin_strupr (char *);
119
120 #endif /* __INSIDE_CYGWIN__ */
121
122 char *__stdcall strccpy (char *s1, const char **s2, char c);
123
124 #ifdef __cplusplus
125 }
126 #endif
127
128 #endif /* _CYGWIN_STRING_H */