1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
|
#ifndef CYGONCE_LIBC_STRING_STRINGSUPP_HXX
#define CYGONCE_LIBC_STRING_STRINGSUPP_HXX
//===========================================================================
//
// stringsupp.hxx
//
// Support for the ANSI standard string functions
//
//===========================================================================
// ####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later
// version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License
// along with eCos; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// As a special exception, if other files instantiate templates or use
// macros or inline functions from this file, or you compile this file
// and link it with other works to produce a work based on this file,
// this file does not by itself cause the resulting work to be covered by
// the GNU General Public License. However the source code for this file
// must still be made available in accordance with section (3) of the GNU
// General Public License v2.
//
// This exception does not invalidate any other reasons why a work based
// on this file might be covered by the GNU General Public License.
// -------------------------------------------
// ####ECOSGPLCOPYRIGHTEND####
//===========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s): jlarmour
// Contributors: jlarmour
// Date: 2000-04-14
// Purpose: Internal support for the libc string function implementations
// Description:
// Usage:
//
//####DESCRIPTIONEND####
//
//===========================================================================
// CONFIGURATION
#include <pkgconf/libc_string.h> // Configuration header
// INCLUDES
#include <cyg/infra/cyg_type.h> // Common type definitions
#include <stddef.h> // Compiler definitions such as
// size_t, NULL etc.
// CONSTANTS
#ifndef CYGIMP_LIBC_STRING_PREFER_SMALL_TO_FAST
// Masks for CYG_LIBC_STR_DETECTNULL below
__externC const cyg_uint64 Cyg_libc_str_null_mask_1;
__externC const cyg_uint64 Cyg_libc_str_null_mask_2;
#endif
// MACROS
// Nonzero if X is not aligned on a word boundary.
#define CYG_LIBC_STR_UNALIGNED(X) ((CYG_WORD)(X) & (sizeof (CYG_WORD) - 1))
// Nonzero if either X or Y is not aligned on a word boundary.
#define CYG_LIBC_STR_UNALIGNED2(X , Y) \
(((CYG_WORD)(X) & (sizeof (CYG_WORD) - 1)) | \
((CYG_WORD)(Y) & (sizeof (CYG_WORD) - 1)))
// Nonzero if any byte of X contains a NULL.
#define CYG_LIBC_STR_DETECTNULL(X) \
(((X) - (CYG_WORD)Cyg_libc_str_null_mask_1) & \
~(X) & (CYG_WORD)Cyg_libc_str_null_mask_2)
// How many bytes are copied each iteration of the 4X unrolled loop in the
// optimised string implementations
#define CYG_LIBC_STR_OPT_BIGBLOCKSIZE (sizeof(CYG_WORD) << 2)
// How many bytes are copied each iteration of the word copy loop in the
// optimised string implementations
#define CYG_LIBC_STR_OPT_LITTLEBLOCKSIZE (sizeof (CYG_WORD))
// Threshold for punting to the byte copier in the optimised string
// implementations
#define CYG_LIBC_STR_OPT_TOO_SMALL(LEN) \
((LEN) < CYG_LIBC_STR_OPT_LITTLEBLOCKSIZE)
// FUNCTION PROTOTYPES
// These are function prototypes for the aliased functions that actually
// implement the string functions
//===========================================================================
// 7.11.2 Copying functions
__externC void *
__memmove( void *, const void *, size_t );
__externC char *
__strcpy( char *, const char * );
__externC char *
__strncpy( char *, const char *, size_t );
//===========================================================================
// 7.11.3 Concatenation functions
__externC char *
__strcat( char *, const char * );
__externC char *
__strncat( char *, const char *, size_t );
//===========================================================================
// 7.11.4 Comparison functions
__externC int
__memcmp( const void *, const void *, size_t );
__externC int
__strcmp( const char *, const char * );
__externC int
__strcoll( const char *, const char * );
__externC int
__strncmp( const char *, const char *, size_t );
__externC size_t
__strxfrm( char *, const char *, size_t );
//===========================================================================
// 7.11.5 Search functions
__externC void *
__memchr( const void *, int , size_t );
__externC char *
__strchr( const char *, int );
__externC size_t
__strcspn( const char *, const char * );
__externC char *
__strpbrk( const char *, const char * );
__externC char *
__strrchr( const char *, int );
__externC size_t
__strspn( const char *, const char * );
__externC char *
__strstr( const char *, const char * );
__externC char *
__strtok( char *, const char * );
// For POSIX 1003.1 section 8.3.3 strtok_r()
__externC char *
__strtok_r( char *, const char *, char ** );
//===========================================================================
// 7.11.6 Miscellaneous functions
__externC size_t
__strlen( const char * );
// NB This is a BSD function
__externC char *
__strdup( const char * );
// NB This is a GNU extension
#ifndef __STRICT_ANSI__
# ifdef CYGFUN_LIBC_STRING_GNU_STRNLEN
__externC size_t
__strnlen( const char *, size_t );
# endif
#endif
#endif // CYGONCE_LIBC_STRING_STRINGSUPP_HXX multiple inclusion protection
// EOF stringsupp.hxx
|