summaryrefslogtreecommitdiffstats
path: root/qemu/roms/openhackware/src/libc/include/string.h
blob: a2c4e0ea5d6f0d243eaa1cb3210abd6ed281889d (plain)
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
/*
 * <string.h>
 *
 * Open Hack'Ware BIOS: subset of POSIX string definitions
 * 
 * Copyright (c) 2004-2005 Jocelyn Mayer
 * 
 *   This program is free software; you can redistribute it and/or
 *   modify it under the terms of the GNU General Public License V2
 *   as published by the Free Software Foundation
 *
 *   This program 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 this program; if not, write to the Free Software
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#if !defined (__OHW_STRING_H__)
#define __OHW_STRING_H__

/* size_t is declared here */
#include <stddef.h>

void *memcpy (void *dest, const void *src, size_t n);
void *memccpy (void *dest, const void *src, int c, size_t n);
void *mempcpy (void *dest, const void *src, size_t n);
void *memmove (void *dest, const void *src, size_t n);
void *memcmove (void *dest, const void *src, int c, size_t n);
void *mempmove (void *dest, const void *src, size_t n);
void *memset (void *s, int c, size_t n);
int memcmp (const void *s1, const void *s2, size_t n);
void *memchr (const void *s, int c, size_t n);
void *rawmemchr (const void *s, int c);
void *memrchr (const void *s, int c, size_t n);
void *memmem (const void *haystack, size_t haystacklen,
              const void *needle, size_t neddlelen);
void *strcpy (char *dest, const char *src);
void *strncpy (char *dest, const char *src, size_t n);
char *strdup (const char *s);
char *strndup (const char *s, size_t n);
void *stpcpy (char *dest, const char *src);
void *stpncpy (char *dest, const char *src, size_t n);
char *strcat (char *dest, const char *src);
char *strncat (char *dest, const char *src, size_t n);
int strcmp (const char *s1, const char *s2);
int strcasecmp (const char *s1, const char *s2);
int strncmp (const char *s1, const char *s2, size_t n);
int strncasecmp (const char *s1, const char *s2, size_t n);
char *strchr (const char *s, int c);
char *strchrnul (const char *s, int c);
char *strrchr (const char *s, int c);
char *strstr (const char *haystack, const char *needle);
char *strcasestr (const char *haystack, const char *needle);
#if 0 // TODO
size_t strspn (const char *s, const char *accept);
size_t strcspn (const char *s, const char *reject);
char *strpbrk (const char *s, const char *accept);
char *strtok (char *s, const char *delim);
char *strtok_r (char *s, const char *delim, char **ptrptr);
char *strsep (char **stringp, const char *delim);
#endif // TODO
char *basename (char *path);
char *dirname (char *path);
size_t strlen (const char *s);
size_t strnlen (const char *s, size_t maxlen);

#if 0
static inline int ffs (int value)
{
    int tmp;
    
    __asm__ __volatile__ ("cntlzw %0, %1" : "=r" (tmp) : "r" (value));
    
    return 32 - tmp;
}
#endif

static inline int ffs (int value)
{
    return __builtin_ffs(value);
}

int ffsl (long i);
int ffsll (long long i);

#endif /* !defined (__OHW_STRING_H__) */