$extrastylesheet
avr-libc
2.0.0
Standard C library for AVR-GCC
|
AVR Libc Home Page |
![]() |
AVR Libc Development Pages |
|||
Main Page |
User Manual |
Library Reference |
FAQ |
Example Projects |
00001 /* Copyright (c) 2002,2007 Marek Michalkiewicz 00002 All rights reserved. 00003 00004 Redistribution and use in source and binary forms, with or without 00005 modification, are permitted provided that the following conditions are met: 00006 00007 * Redistributions of source code must retain the above copyright 00008 notice, this list of conditions and the following disclaimer. 00009 00010 * Redistributions in binary form must reproduce the above copyright 00011 notice, this list of conditions and the following disclaimer in 00012 the documentation and/or other materials provided with the 00013 distribution. 00014 00015 * Neither the name of the copyright holders nor the names of 00016 contributors may be used to endorse or promote products derived 00017 from this software without specific prior written permission. 00018 00019 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00020 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00021 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00022 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00023 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00024 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00025 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00026 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00027 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00028 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00029 POSSIBILITY OF SUCH DAMAGE. */ 00030 00031 /* $Id: string.h 2503 2016-02-07 22:59:47Z joerg_wunsch $ */ 00032 00033 /* 00034 string.h 00035 00036 Contributors: 00037 Created by Marek Michalkiewicz <marekm@linux.org.pl> 00038 */ 00039 00040 #ifndef _STRING_H_ 00041 #define _STRING_H_ 1 00042 00043 #ifndef __DOXYGEN__ 00044 #define __need_NULL 00045 #define __need_size_t 00046 #include <stddef.h> 00047 00048 #ifndef __ATTR_PURE__ 00049 #define __ATTR_PURE__ __attribute__((__pure__)) 00050 #endif 00051 00052 #ifndef __ATTR_CONST__ 00053 # define __ATTR_CONST__ __attribute__((__const__)) 00054 #endif 00055 #endif /* !__DOXYGEN__ */ 00056 00057 #ifdef __cplusplus 00058 extern "C" { 00059 #endif 00060 00061 /** \file */ 00062 /** \defgroup avr_string <string.h>: Strings 00063 \code #include <string.h> \endcode 00064 00065 The string functions perform string operations on NULL terminated 00066 strings. 00067 00068 \note If the strings you are working on resident in program space (flash), 00069 you will need to use the string functions described in \ref avr_pgmspace. */ 00070 00071 00072 /** \ingroup avr_string 00073 00074 This macro finds the first (least significant) bit set in the 00075 input value. 00076 00077 This macro is very similar to the function ffs() except that 00078 it evaluates its argument at compile-time, so it should only 00079 be applied to compile-time constant expressions where it will 00080 reduce to a constant itself. 00081 Application of this macro to expressions that are not constant 00082 at compile-time is not recommended, and might result in a huge 00083 amount of code generated. 00084 00085 \returns The _FFS() macro returns the position of the first 00086 (least significant) bit set in the word val, or 0 if no bits are set. 00087 The least significant bit is position 1. Only 16 bits of argument 00088 are evaluted. 00089 */ 00090 #if defined(__DOXYGEN__) 00091 #define _FFS(x) 00092 #else /* !DOXYGEN */ 00093 #define _FFS(x) \ 00094 (1 \ 00095 + (((x) & 1) == 0) \ 00096 + (((x) & 3) == 0) \ 00097 + (((x) & 7) == 0) \ 00098 + (((x) & 017) == 0) \ 00099 + (((x) & 037) == 0) \ 00100 + (((x) & 077) == 0) \ 00101 + (((x) & 0177) == 0) \ 00102 + (((x) & 0377) == 0) \ 00103 + (((x) & 0777) == 0) \ 00104 + (((x) & 01777) == 0) \ 00105 + (((x) & 03777) == 0) \ 00106 + (((x) & 07777) == 0) \ 00107 + (((x) & 017777) == 0) \ 00108 + (((x) & 037777) == 0) \ 00109 + (((x) & 077777) == 0) \ 00110 - (((x) & 0177777) == 0) * 16) 00111 #endif /* DOXYGEN */ 00112 00113 extern int ffs (int __val) __ATTR_CONST__; 00114 extern int ffsl (long __val) __ATTR_CONST__; 00115 __extension__ extern int ffsll (long long __val) __ATTR_CONST__; 00116 extern void *memccpy(void *, const void *, int, size_t); 00117 extern void *memchr(const void *, int, size_t) __ATTR_PURE__; 00118 extern int memcmp(const void *, const void *, size_t) __ATTR_PURE__; 00119 extern void *memcpy(void *, const void *, size_t); 00120 extern void *memmem(const void *, size_t, const void *, size_t) __ATTR_PURE__; 00121 extern void *memmove(void *, const void *, size_t); 00122 extern void *memrchr(const void *, int, size_t) __ATTR_PURE__; 00123 extern void *memset(void *, int, size_t); 00124 extern char *strcat(char *, const char *); 00125 extern char *strchr(const char *, int) __ATTR_PURE__; 00126 extern char *strchrnul(const char *, int) __ATTR_PURE__; 00127 extern int strcmp(const char *, const char *) __ATTR_PURE__; 00128 extern char *strcpy(char *, const char *); 00129 extern int strcasecmp(const char *, const char *) __ATTR_PURE__; 00130 extern char *strcasestr(const char *, const char *) __ATTR_PURE__; 00131 extern size_t strcspn(const char *__s, const char *__reject) __ATTR_PURE__; 00132 extern char *strdup(const char *s1); 00133 extern size_t strlcat(char *, const char *, size_t); 00134 extern size_t strlcpy(char *, const char *, size_t); 00135 extern size_t strlen(const char *) __ATTR_PURE__; 00136 extern char *strlwr(char *); 00137 extern char *strncat(char *, const char *, size_t); 00138 extern int strncmp(const char *, const char *, size_t) __ATTR_PURE__; 00139 extern char *strncpy(char *, const char *, size_t); 00140 extern int strncasecmp(const char *, const char *, size_t) __ATTR_PURE__; 00141 extern size_t strnlen(const char *, size_t) __ATTR_PURE__; 00142 extern char *strpbrk(const char *__s, const char *__accept) __ATTR_PURE__; 00143 extern char *strrchr(const char *, int) __ATTR_PURE__; 00144 extern char *strrev(char *); 00145 extern char *strsep(char **, const char *); 00146 extern size_t strspn(const char *__s, const char *__accept) __ATTR_PURE__; 00147 extern char *strstr(const char *, const char *) __ATTR_PURE__; 00148 extern char *strtok(char *, const char *); 00149 extern char *strtok_r(char *, const char *, char **); 00150 extern char *strupr(char *); 00151 00152 #ifndef __DOXYGEN__ 00153 /* libstdc++ compatibility, dummy declarations */ 00154 extern int strcoll(const char *s1, const char *s2); 00155 extern char *strerror(int errnum); 00156 extern size_t strxfrm(char *dest, const char *src, size_t n); 00157 #endif /* !__DOXYGEN__ */ 00158 00159 #ifdef __cplusplus 00160 } 00161 #endif 00162 00163 #endif /* _STRING_H_ */ 00164