haiku/headers/posix/strings.h
Adrien Destugues 2dc597d50d Optimize ffs() implementation
- Use gcc builtin
- Define as a static inline function in the .h so no function call overhead is needed
- Keep the function in libroot for backwards compatibility
- Remove a duplicate implementation in the freebsd compatibility layer

gcc2 does not document the builtin, but it is in fact already available
there as well.

Fixes #3281.

Change-Id: I94f8a2548637aa70e85febbfab06f07c1a427005
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2605
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2020-05-08 14:01:53 +00:00

35 lines
811 B
C

/*
* Copyright 2014 Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _STRINGS_H_
#define _STRINGS_H_
#include <sys/types.h>
#ifdef __cplusplus
extern "C" {
#endif
static inline int ffs(int i) { return __builtin_ffs(i); }
extern int strcasecmp(const char *string1, const char *string2);
extern int strncasecmp(const char *string1, const char *string2,
size_t length);
/* legacy compatibility -- might be removed one day */
#define bcmp(a, b, length) memcmp((a), (b), (length))
#define bcopy(source, dest, length) memmove((dest), (source), (length))
#define bzero(buffer, length) memset((buffer), 0, (length))
extern char *index(const char *s, int c);
extern char *rindex(char const *s, int c);
#ifdef __cplusplus
}
#endif
#endif /* _STRINGS_H_ */