From b22be2d54ad7d06a52f9a0df615bb2a45a0c5585 Mon Sep 17 00:00:00 2001 From: Uwe Hermann Date: Sat, 10 Mar 2007 22:07:51 +0000 Subject: [PATCH] Add Doxygen-comments to all functions in lib/mem.c. Signed-off-by: Uwe Hermann Acked-by: Stefan Reinauer git-svn-id: svn://coreboot.org/repository/LinuxBIOSv3@239 f3766cd6-281f-0410-b1cd-43a5c92072e9 --- lib/mem.c | 49 ++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 40 insertions(+), 9 deletions(-) diff --git a/lib/mem.c b/lib/mem.c index b330c0576b..b727d19783 100644 --- a/lib/mem.c +++ b/lib/mem.c @@ -3,6 +3,7 @@ * * Copyright (C) 2007 Ronald G. Minnich * Copyright (C) 2007 Peter Stuge + * Copyright (C) 2007 Uwe Hermann * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,7 +19,9 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA */ -/* Memory routines with some optimizations. */ +/* Memory routines with some optimizations. Please don't be silly and inline + * these. Inlines are not as wonderful as people think. + */ #include @@ -96,20 +99,41 @@ static void memcpy_helper(void *dest, const void *src, int len, int backwards) } } -/* Won't handle overlaps. */ -/* Please don't be silly and inline these. Inlines are not as wonderful as people think */ +/** + * Copy 'len' bytes from one memory area to another. + * + * The memory areas may _not_ overlap. + * + * @param dest Pointer to the destination memory area. + * @param src Pointer to the source memory area. + * @param len Number of bytes to copy. + */ void memcpy(void *dest, const void *src, int len) { memcpy_helper(dest, src, len, 0); } -/* Handles overlapping memory. */ -/* seperate function in case we decide to use the built-in -- not sure yet. */ +/** + * Copy 'len' bytes from one memory area to another. + * + * The memory areas may overlap. + * + * @param dest Pointer to the destination memory area. + * @param src Pointer to the source memory area. + * @param len Number of bytes to copy. + */ void memmove(void *dest, const void *src, int len) { memcpy_helper(dest, src, len, dest > src && dest < (src + len)); } +/** + * Fill a memory area with the specified byte. + * + * @param v Pointer to the beginning of the memory area. + * @param a The byte which is used for filling the memory area. + * @param len The number of bytes to write. + */ void memset(void *v, unsigned char a, int len) { unsigned char *cp = v; @@ -117,9 +141,17 @@ void memset(void *v, unsigned char a, int len) *cp++ = a; } -/* did you ever notice that the memcmp web page does not specify - * a signed or unsigned compare? It matters ... oh well, we assumed unsigned - */ +/** + * Compare the first 'len' bytes of two memory areas. + * + * We assume unsigned characters here. + * + * @param s1 Pointer to the first memory area. + * @param s2 Pointer to the second memory area. + * @param len Number of bytes to compare. + * @return Returns a negative number if s1 is shorter than s2. Returns zero if + * s1 matches s2. Returns a positive number if s1 is longer than s2. + */ int memcmp(const void *s1, const void *s2, int len) { const unsigned char *d = (const unsigned char *)s1; @@ -132,5 +164,4 @@ int memcmp(const void *s1, const void *s2, int len) d++, s++; } return 0; - }