Updated PCI IDs to latest snapshot.
[tangerine.git] / tools / fd2inline / include-src / inline / strsup.h
blob2e3b750a2d13efc4fda6770d6084a855a58e9e00
1 #if !defined(_STRSUP_H) && defined(__OPTIMIZE__)
3 #define _STRSUP_H
5 #include <sys/types.h>
7 extern __inline__ void *memcpy(void *s1,const void *s2,size_t n)
8 { register char *a6 __asm("a6") = *(char **)4;
9 register const void *a0 __asm("a0") = s2;
10 register const void *a1 __asm("a1") = s1;
11 register size_t d0 __asm("d0") = n;
12 __asm __volatile ("jsr a6@(-0x270)"
13 : /* no output */
14 : "r" (a6), "r" (a0), "r" (a1), "r" (d0)
15 : "a0","a1","d0","d1", "memory");
17 return s1;
20 extern __inline__ void *memmove(void *s1,const void *s2,size_t n)
22 bcopy(s2,s1,n); return s1;
25 extern __inline__ void *memset(void *s,int c,size_t n)
27 if (n != 0) {
28 unsigned char *p=s;
29 do {
30 *p++=c;
31 } while(--n != 0);
33 return s;
36 extern __inline__ int memcmp(const void *s1,const void *s2,size_t n)
37 { const unsigned char *p1=s1,*p2=s2;
38 unsigned long r,c;
40 if((r=n)) {
41 c=0;
42 do {
43 r=*p1++;
44 ((unsigned char)c)=*p2++;
45 } while(!(r-=c) && --n);
47 return r;
50 extern __inline__ void *memchr(const void *s,int c,size_t n)
52 if (n != 0) {
53 unsigned char *p=(unsigned char *)s;
54 do {
55 if (*p++==(unsigned char)c)
56 return --p;
57 } while(--n != 0);
59 return (void *)n;
62 extern __inline__ size_t strlen_plus_one(const char *string)
63 { const char *s=string;
65 do{}while(*s++); return (s-string);
68 extern __inline__ size_t strlen(const char *string)
69 { const char *s=string;
71 do{}while(*s++); return ~(string-s);
74 extern __inline__ char *strcpy(char *s1,const char *s2)
75 { char *s=s1;
77 do {
78 *s++=*s2;
79 } while(*s2++!='\0');
80 return s1;
83 extern __inline__ char *strncpy(char *s1,const char *s2,size_t n)
85 if (n != 0) {
86 char *s=s1;
88 do{}while((*s++=*s2++) && (--n != 0));
89 if (n)
90 while(--n != 0) *s++=0;
92 return s1;
95 extern __inline__ char *strcat(char *s1,const char *s2)
96 { char *s=s1;
98 do{}while(*s++); --s; do{}while((*s++=*s2++)); return s1;
101 extern __inline__ char *strncat(char *s1,const char *s2,size_t n)
103 if (n != 0) {
104 char *s=s1;
106 do{}while(*s++); --s;
107 for(;;) {
108 if(!(*s++=*s2++))
109 return s1;
110 if(!--n) {
111 *s=0; return s1;
115 return s1;
118 extern __inline__ int strcmp(const char *s1,const char *s2)
119 { const unsigned char *p1=s1,*p2=s2;
120 unsigned long r,c;
122 c=0;
123 do {
124 r=*p1++;
125 ((unsigned char)c)=*p2++;
126 } while(!(r-=c) && (unsigned char)c);
127 return r;
130 extern __inline__ int strncmp(const char *s1,const char *s2,size_t n)
131 { const unsigned char *p1=s1,*p2=s2;
132 unsigned long r,c;
134 if((r=n)) {
135 c=0;
136 do {
137 r=*p1++;
138 ((unsigned char)c)=*p2++;
139 } while(!(r-=c) && (unsigned char)c && --n);
141 return r;
143 #if 0
144 extern __inline__ char *strchr(const char *s,int c)
146 while (*s!=(char)c)
147 if (!(*s++))
148 return NULL;
149 return (char *)s;
151 #endif
152 extern __inline__ char *strupr(char *s)
153 { unsigned char *s1=(unsigned char *)s;
155 while(*s1) {
156 if ((*s1>('a'-1)) && (*s1<('z'+1)))
157 *s1-='a'-'A';
158 s1++;
160 return s;
163 extern __inline__ char *strlwr(char *s)
164 { unsigned char *s1=(unsigned char *)s;
166 while(*s1) {
167 if ((*s1>('A'-1)) && (*s1<('Z'+1)))
168 *s1+='a'-'A';
169 s1++;
171 return s;
174 extern __inline__ char *stpcpy(char *dst,char *src)
176 do{}while((*dst++=*src++)); return(dst-1);
179 #elif !defined(__OPTIMIZE__)
181 #define strlen_plus_one(s) strlen(s)+1L
183 #endif /* _STRSUP_H */