xref: /titanic_52/usr/src/boot/sys/boot/arm/at91/libat91/p_string.c (revision 4a5d661a82b942b6538acd26209d959ce98b593a)
1 /******************************************************************************
2  *
3  * Filename: p_string.c
4  *
5  * Instantiation of basic string operations to prevent inclusion of full
6  * string library.  These are simple implementations not necessarily optimized
7  * for speed, but rather to show intent.
8  *
9  * Revision information:
10  *
11  * 20AUG2004	kb_admin	initial creation
12  * 12JAN2005	kb_admin	minor updates
13  *
14  * BEGIN_KBDD_BLOCK
15  * No warranty, expressed or implied, is included with this software.  It is
16  * provided "AS IS" and no warranty of any kind including statutory or aspects
17  * relating to merchantability or fitness for any purpose is provided.  All
18  * intellectual property rights of others is maintained with the respective
19  * owners.  This software is not copyrighted and is intended for reference
20  * only.
21  * END_BLOCK
22  *
23  * $FreeBSD$
24  *****************************************************************************/
25 
26 #include "lib.h"
27 
28 /*
29  * .KB_C_FN_DEFINITION_START
30  * void p_memset(char *buffer, char value, int size)
31  *  This global function sets memory at the pointer for the specified
32  * number of bytes to value.
33  * .KB_C_FN_DEFINITION_END
34  */
35 void
36 p_memset(char *buffer, char value, int size)
37 {
38 	while (size--)
39 		*buffer++ = value;
40 }
41 
42 /*
43  * .KB_C_FN_DEFINITION_START
44  * int p_memcmp(char *to, char *from, unsigned size)
45  *  This global function compares data at to against data at from for
46  * size bytes.  Returns 0 if the locations are equal.  size must be
47  * greater than 0.
48  * .KB_C_FN_DEFINITION_END
49  */
50 int
51 p_memcmp(const char *to, const char *from, unsigned size)
52 {
53 	while ((--size) && (*to++ == *from++))
54 		continue;
55 
56 	return (*to != *from);
57 }
58