summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLv Zheng <lv.zheng@intel.com>2016-05-23 23:06:55 +0800
committerLv Zheng <lv.zheng@intel.com>2016-06-06 12:58:30 +0800
commit17d2c00994f3e04d0b25dccb00220e69dc8bb443 (patch)
treed702a930d41e49a8ed1931ad7aa4eb1da018db59
parent33f019a5bf9901048822f7cc1701603d4087cf99 (diff)
downloadacpica-17d2c00994f3e04d0b25dccb00220e69dc8bb443.tar.gz
Clib: Add memmove() to improve portability
This patch implements memmove(). Lv Zheng. Signed-off-by: Lv Zheng <lv.zheng@intel.com>
-rw-r--r--source/components/utilities/utclib.c55
-rw-r--r--source/include/acclib.h6
2 files changed, 61 insertions, 0 deletions
diff --git a/source/components/utilities/utclib.c b/source/components/utilities/utclib.c
index 7e61b980a..0bc9215fd 100644
--- a/source/components/utilities/utclib.c
+++ b/source/components/utilities/utclib.c
@@ -201,6 +201,61 @@ memcmp (
/*******************************************************************************
*
+ * FUNCTION: memmove
+ *
+ * PARAMETERS: Dest - Target of the copy
+ * Src - Source buffer to copy
+ * Count - Number of bytes to copy
+ *
+ * RETURN: Dest
+ *
+ * DESCRIPTION: Copy arbitrary bytes of memory with respect to the overlapping
+ *
+ ******************************************************************************/
+
+void *
+memmove (
+ void *Dest,
+ const void *Src,
+ ACPI_SIZE Count)
+{
+ char *New = (char *) Dest;
+ char *Old = (char *) Src;
+
+
+ if (Old > New)
+ {
+ /* Copy from the beginning */
+
+ while (Count)
+ {
+ *New = *Old;
+ New++;
+ Old++;
+ Count--;
+ }
+ }
+ else if (Old < New)
+ {
+ /* Copy from the end */
+
+ New = New + Count - 1;
+ Old = Old + Count - 1;
+ while (Count)
+ {
+ *New = *Old;
+ New--;
+ Old--;
+ Count--;
+ }
+ }
+
+ return (Dest);
+}
+
+
+/*******************************************************************************
+ *
* FUNCTION: memcpy
*
* PARAMETERS: Dest - Target of the copy
diff --git a/source/include/acclib.h b/source/include/acclib.h
index 67c05bf36..9f5853596 100644
--- a/source/include/acclib.h
+++ b/source/include/acclib.h
@@ -237,6 +237,12 @@ memcpy (
ACPI_SIZE Count);
void *
+memmove (
+ void *Dest,
+ const void *Src,
+ ACPI_SIZE Count);
+
+void *
memset (
void *Dest,
int Value,