xref: /dflybsd-src/sys/dev/drm/include/linux/string.h (revision 3f2dd94a569761201b5b0a18b2f697f97fe1b9dc)
1d6aa1cc5SFrançois Tigeot /*
25a31741fSFrançois Tigeot  * Copyright (c) 2010 Isilon Systems, Inc.
35a31741fSFrançois Tigeot  * Copyright (c) 2010 iX Systems, Inc.
45a31741fSFrançois Tigeot  * Copyright (c) 2010 Panasas, Inc.
55a31741fSFrançois Tigeot  * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd.
6d6aa1cc5SFrançois Tigeot  * Copyright (c) 2018 François Tigeot <ftigeot@wolfpond.org>
75a31741fSFrançois Tigeot  * All rights reserved.
85a31741fSFrançois Tigeot  *
95a31741fSFrançois Tigeot  * Redistribution and use in source and binary forms, with or without
105a31741fSFrançois Tigeot  * modification, are permitted provided that the following conditions
115a31741fSFrançois Tigeot  * are met:
125a31741fSFrançois Tigeot  * 1. Redistributions of source code must retain the above copyright
135a31741fSFrançois Tigeot  *    notice unmodified, this list of conditions, and the following
145a31741fSFrançois Tigeot  *    disclaimer.
155a31741fSFrançois Tigeot  * 2. Redistributions in binary form must reproduce the above copyright
165a31741fSFrançois Tigeot  *    notice, this list of conditions and the following disclaimer in the
175a31741fSFrançois Tigeot  *    documentation and/or other materials provided with the distribution.
185a31741fSFrançois Tigeot  *
195a31741fSFrançois Tigeot  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
205a31741fSFrançois Tigeot  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
215a31741fSFrançois Tigeot  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
225a31741fSFrançois Tigeot  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
235a31741fSFrançois Tigeot  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
245a31741fSFrançois Tigeot  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
255a31741fSFrançois Tigeot  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
265a31741fSFrançois Tigeot  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
275a31741fSFrançois Tigeot  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
285a31741fSFrançois Tigeot  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
295a31741fSFrançois Tigeot  */
305a31741fSFrançois Tigeot 
315a31741fSFrançois Tigeot #ifndef	_LINUX_STRING_H_
325a31741fSFrançois Tigeot #define	_LINUX_STRING_H_
335a31741fSFrançois Tigeot 
34d6aa1cc5SFrançois Tigeot #include <linux/compiler.h>
355a31741fSFrançois Tigeot #include <linux/types.h>
36d6aa1cc5SFrançois Tigeot #include <linux/stddef.h>
379286b91eSSascha Wildner #include <sys/stdarg.h>
385a31741fSFrançois Tigeot 
394bc7ef12SFrançois Tigeot #define __UNCONST(a)	((void *)(unsigned long)(const void *)(a))
404bc7ef12SFrançois Tigeot 
414bc7ef12SFrançois Tigeot static inline void *
memchr_inv(const void * buffer,int c,size_t len)424bc7ef12SFrançois Tigeot memchr_inv(const void *buffer, int c, size_t len)
434bc7ef12SFrançois Tigeot {
444bc7ef12SFrançois Tigeot 	const uint8_t byte = c;	/* XXX lose */
454bc7ef12SFrançois Tigeot 	const char *p;
464bc7ef12SFrançois Tigeot 
474bc7ef12SFrançois Tigeot 	for (p = buffer; len-- > 0; p++)
484bc7ef12SFrançois Tigeot 		if (*p != byte)
494bc7ef12SFrançois Tigeot 			return __UNCONST(p);
504bc7ef12SFrançois Tigeot 
514bc7ef12SFrançois Tigeot 	return NULL;
524bc7ef12SFrançois Tigeot }
535a31741fSFrançois Tigeot 
54d6aa1cc5SFrançois Tigeot void *kmemdup(const void *src, size_t len, gfp_t gfp);
555a31741fSFrançois Tigeot 
56*3f2dd94aSFrançois Tigeot #include <asm/string_64.h>	/* for memset64() */
57*3f2dd94aSFrançois Tigeot 
585a31741fSFrançois Tigeot #endif	/* _LINUX_STRING_H_ */
59