source: branches/libc-0.6/src/emx/include/string.h

Last change on this file was 3899, checked in by bird, 11 years ago

trunk+0.6: Modified the existing swab() function in string.h to be standard compliant (signed last argument, don't copy negative counts, truncate odd values instead of ignoring them). Fixes #281.

  • Property cvs2svn:cvs-rev set to 1.18
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 7.8 KB
Line 
1/* string.h,v 1.13 2004/09/14 22:27:36 bird Exp */
2/** @file
3 * FreeBSD 5.1
4 * @changed bird: EMXifications.
5 * @changed bird: GNU extension(s).
6 */
7
8/*-
9 * Copyright (c) 1990, 1993
10 * The Regents of the University of California. All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * 3. All advertising materials mentioning features or use of this software
21 * must display the following acknowledgement:
22 * This product includes software developed by the University of
23 * California, Berkeley and its contributors.
24 * 4. Neither the name of the University nor the names of its contributors
25 * may be used to endorse or promote products derived from this software
26 * without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
29 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
32 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 * SUCH DAMAGE.
39 *
40 * @(#)string.h 8.1 (Berkeley) 6/2/93
41 * $FreeBSD: src/include/string.h,v 1.18 2002/10/14 20:38:40 mike Exp $
42 */
43
44#ifndef _STRING_H_
45#define _STRING_H_
46
47#include <sys/cdefs.h>
48#include <sys/_types.h>
49
50/*
51 * Prototype functions which were historically defined in <string.h>, but
52 * are required by POSIX to be prototyped in <strings.h>.
53 */
54#if __BSD_VISIBLE
55#include <strings.h>
56#endif
57
58#if !defined(_SIZE_T_DECLARED) && !defined(_SIZE_T) /* bird: EMX */
59typedef __size_t size_t;
60#define _SIZE_T_DECLARED
61#define _SIZE_T /* bird: EMX */
62#endif
63
64#ifndef NULL
65#define NULL 0
66#endif
67
68__BEGIN_DECLS
69#if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE
70void *memccpy(void * __restrict, const void * __restrict, int, size_t);
71#endif
72void *memchr(const void *, int, size_t);
73int memcmp(const void *, const void *, size_t);
74void *memcpy(void * __restrict, const void * __restrict, size_t);
75void *memmove(void *, const void *, size_t);
76void *memset(void *, int, size_t);
77#if __BSD_VISIBLE
78char *stpcpy(char *, const char *);
79char *strcasestr(const char *, const char *);
80#endif
81char *strcat(char * __restrict, const char * __restrict);
82char *strchr(const char *, int);
83int strcmp(const char *, const char *);
84int strcoll(const char *, const char *);
85char *strcpy(char * __restrict, const char * __restrict);
86size_t strcspn(const char *, const char *);
87#if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE
88char *strdup(const char *);
89#endif
90char *strerror(int);
91#if __POSIX_VISIBLE >= 200112
92int strerror_r(int, char *, size_t);
93#endif
94#if __BSD_VISIBLE
95size_t strlcat(char *, const char *, size_t);
96size_t strlcpy(char *, const char *, size_t);
97#endif
98size_t strlen(const char *);
99#if __BSD_VISIBLE
100void strmode(int, char *);
101#endif
102char *strncat(char * __restrict, const char * __restrict, size_t);
103int strncmp(const char *, const char *, size_t);
104char *strncpy(char * __restrict, const char * __restrict, size_t);
105#if __BSD_VISIBLE
106char *strnstr(const char *, const char *, size_t);
107#endif
108char *strpbrk(const char *, const char *);
109char *strrchr(const char *, int);
110#if __BSD_VISIBLE
111char *strsep(char **, const char *);
112 char *strsignal(int);
113#endif
114size_t strspn(const char *, const char *);
115char *strstr(const char *, const char *);
116char *strtok(char * __restrict, const char * __restrict);
117#if __POSIX_VISIBLE >= 199506 || __XSI_VISIBLE >= 500
118char *strtok_r(char *, const char *, char **);
119#endif
120size_t strxfrm(char * __restrict, const char * __restrict, size_t);
121#if __BSD_VISIBLE
122# ifndef _SWAB_DECLARED /* bird: also in unistd.h */
123# define _SWAB_DECLARED /* bird: also in unistd.h */
124# if !defined(_SSIZE_T_DECLARED) && !defined(_SSIZE_T)
125typedef __ssize_t ssize_t;
126# define _SSIZE_T_DECLARED
127# define _SSIZE_T
128# endif
129void swab(const void * __restrict, void * __restrict, ssize_t);
130# endif /* !_SWAB_DECLARED */ /* bird: also in unistd.h */
131#endif
132
133
134/* bird: EMX stuff - start */
135
136#if !defined (__STRICT_ANSI__) && !defined (_POSIX_SOURCE) || defined(__USE_EMX)
137#if !defined (_MEMDIF_EQ)
138#define _MEMDIF_EQ 0xffffffff
139#endif
140int memicmp(const void *, const void *, size_t);
141int stricmp(const char *, const char *);
142char * strlwr(char *);
143int strnicmp(const char *, const char *, size_t);
144char * strnset(char *, int, size_t);
145char * strrev(char *);
146char * strset(char *, int);
147char * strupr(char *);
148#endif
149
150#if (!defined (__STRICT_ANSI__) && !defined (_POSIX_SOURCE)) || defined (_WITH_UNDERSCORE) || defined(__USE_EMX)
151size_t _memcount (const void *, int, size_t);
152size_t _memdif (const void *, const void *, size_t);
153void *_memrchr (const void *, int, size_t);
154void _memswap (void *, void *, size_t);
155char *_strncpy (char *, const char *, size_t);
156void *_memccpy (void *, const void *, int, size_t);
157int _memicmp (const void *, const void *, size_t);
158char *_strdup (const char *);
159int _stricmp (const char *, const char *);
160char *_strlwr (char *);
161int _strnicmp (const char *, const char *, size_t);
162char *_strnset (char *, int, size_t);
163char *_strrev (char *);
164char *_strset (char *, int);
165char *_strupr (char *);
166char *_strsep (char **, const char *);
167#endif
168
169/* bird: EMX stuff - end */
170
171/* bird: LIBC extensions - start */
172#ifdef __USE_EMX
173void *_memcpy_amd(void *, const void *, size_t);
174#endif
175
176/* bird: LIBC extensions - end */
177
178/* bird: GNU stuff - start */
179#ifdef __USE_GNU
180char *basename(const char *);
181size_t strnlen(const char *, size_t);
182void *mempcpy(void *, const void *, size_t);
183char *strndup(const char *, size_t);
184void *memrchr(const void *, int, size_t);
185#define memrchr(pach, ch, cch) _memrchr(pach, ch, cch)
186int strverscmp(const char *, const char *);
187char *strchrnul(const char *, int);
188void *rawmemchr(const void *, int);
189char *stpncpy(char *, const char *, int);
190
191size_t __strnlen(const char *, size_t);
192void *__mempcpy(void *, const void *, size_t);
193char *__strndup(const char *, size_t);
194void *_memrchr(const void *, int, size_t);
195void *__memrchr(const void *, int, size_t);
196#define __memrchr(pach, ch, cch) _memrchr(pach, ch, cch)
197int __strverscmp(const char *, const char *);
198char *__strchrnul(const char *, int);
199void *__rawmemchr(const void *, int);
200char *__stpncpy(char *, const char *, int);
201
202#define strdupa(psz) \
203 (__extension__({ \
204 const char *__pszInput = (psz); \
205 size_t __cchInput = strlen(__pszInput) + 1; \
206 char *__pszReturn = __builtin_alloca(__cchInput); \
207 (char *)memcpy(__pszReturn, __pszInput, __cchInput); \
208 }))
209
210#define strndupa(psz, cch) \
211 (__extension__({ \
212 const char *__pszInput = (psz); \
213 size_t __cchInput = strnlen(__pszInput, (cch)); \
214 char *__pszReturn = __builtin_alloca(__cchInput + 1); \
215 __pszReturn[__cchInput] = '\0'; \
216 (char *)memcpy(__pszReturn, __pszInput, __cchInput); \
217 }))
218
219#endif
220/* bird: GNU stuff - end */
221
222__END_DECLS
223
224#endif /* _STRING_H_ */
225
Note: See TracBrowser for help on using the repository browser.