KallistiOS  ##version##
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
string.h
Go to the documentation of this file.
1 /* KallistiOS ##version##
2 
3  kos/string.h
4  Copyright (C)2004 Dan Potter
5 
6 */
7 
8 /** \file kos/string.h
9  \brief Variants on standard block memory copy/set functions.
10 
11  This file contains variants on the standard block memory copy/set functions.
12  These variants copy/set memory in the specified block sizes, which may be
13  helpful for interacting with memory-mapped hardware.
14 
15  \author Dan Potter
16 */
17 
18 #ifndef __KOS_STRING_H
19 #define __KOS_STRING_H
20 
21 #include <sys/cdefs.h>
22 __BEGIN_DECLS
23 
24 #include <string.h>
25 
26 /** \brief Copy a block of memory, 4 bytes at a time.
27 
28  This function is identical to memcpy(), except it copies 4 bytes at a time.
29 
30  \param dest The destination of the copy.
31  \param src The source to copy.
32  \param count The number of bytes to copy. This should be
33  divisible by 4 (and will be rounded down if not).
34  \return The original value of dest.
35 */
36 void * memcpy4(void * dest, const void *src, size_t count);
37 
38 /** \brief Set a block of memory, 4 bytes at a time.
39 
40  This function is identical to memset(), except it sets 4 bytes at a time.
41  This implies that all 32-bits of c are used, not just the first 8 as in
42  memset().
43 
44  \param s The destination of the set.
45  \param c The value to set to.
46  \param count The number of bytes to set. This should be
47  divisible by 4 (and will be rounded down if not).
48  \return The original value of dest.
49 */
50 void * memset4(void * s, unsigned long c, size_t count);
51 
52 /** \brief Copy a block of memory, 2 bytes at a time.
53 
54  This function is identical to memcpy(), except it copies 2 bytes at a time.
55 
56  \param dest The destination of the copy.
57  \param src The source to copy.
58  \param count The number of bytes to copy. This should be
59  divisible by 2 (and will be rounded down if not).
60  \return The original value of dest.
61 */
62 void * memcpy2(void * dest, const void *src, size_t count);
63 
64 /** \brief Set a block of memory, 2 bytes at a time.
65 
66  This function is identical to memset(), except it sets 2 bytes at a time.
67  This implies that all 16-bits of c are used, not just the first 8 as in
68  memset().
69 
70  \param s The destination of the set.
71  \param c The value to set to.
72  \param count The number of bytes to set. This should be
73  divisible by 2 (and will be rounded down if not).
74  \return The original value of dest.
75 */
76 void * memset2(void * s, unsigned short c, size_t count);
77 
78 __END_DECLS
79 
80 #endif /* __KOS_STRING_H */
81 
82 
void * memcpy4(void *dest, const void *src, size_t count)
Copy a block of memory, 4 bytes at a time.
void * memset2(void *s, unsigned short c, size_t count)
Set a block of memory, 2 bytes at a time.
Variants on standard block memory copy/set functions.
void * memset4(void *s, unsigned long c, size_t count)
Set a block of memory, 4 bytes at a time.
void * memcpy2(void *dest, const void *src, size_t count)
Copy a block of memory, 2 bytes at a time.