[beast/win32] Provide portable memset4 and memcpy4 (guaranteed 4-byte wmemset / wmemcpy)
- From: Stefan Westerfeld <stw src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [beast/win32] Provide portable memset4 and memcpy4 (guaranteed 4-byte wmemset / wmemcpy)
- Date: Sat, 29 Aug 2009 13:49:12 +0000 (UTC)
commit fb747f06c54037a8d3fe0e7f6720fcfbebc229b4
Author: Stefan Westerfeld <stefan space twc de>
Date: Sat Aug 29 13:47:47 2009 +0200
Provide portable memset4 and memcpy4 (guaranteed 4-byte wmemset / wmemcpy)
birnet/birnetos.hh | 3 ++-
birnet/birnetosunix.cc | 13 +++++++++++--
birnet/birnetoswin32.cc | 10 ++++++++--
sfi/sfiwrapper.cc | 13 +++++++++++++
sfi/sfiwrapper.h | 9 ++++++---
5 files changed, 40 insertions(+), 8 deletions(-)
---
diff --git a/birnet/birnetos.hh b/birnet/birnetos.hh
index 2538189..8646483 100644
--- a/birnet/birnetos.hh
+++ b/birnet/birnetos.hh
@@ -32,7 +32,8 @@ bool check_sse_sys();
void syslog (int priority, const char *format, ...);
void raise_sigtrap();
int getpid();
-void memset4 (uint32 *mem, uint32 filler, uint length);
+void memset4 (uint32 *mem, uint32 filler, uint count);
+void memcpy4 (uint32 *dest, const uint32 *src, size_t count);
int mkdir (const char *path, mode_t mode);
// stat
diff --git a/birnet/birnetosunix.cc b/birnet/birnetosunix.cc
index 9429c16..a3616d6 100644
--- a/birnet/birnetosunix.cc
+++ b/birnet/birnetosunix.cc
@@ -78,12 +78,21 @@ raise_sigtrap ()
void
memset4 (guint32 *mem,
guint32 filler,
- guint length)
+ guint count)
{
BIRNET_STATIC_ASSERT (sizeof (*mem) == 4);
BIRNET_STATIC_ASSERT (sizeof (filler) == 4);
BIRNET_STATIC_ASSERT (sizeof (wchar_t) == 4);
- wmemset ((wchar_t*) mem, filler, length);
+ wmemset ((wchar_t*) mem, filler, count);
+}
+
+void
+memcpy4 (uint32 *dest,
+ const uint32 *src,
+ size_t count)
+{
+ BIRNET_STATIC_ASSERT (sizeof (wchar_t) == 4);
+ wmemcpy ((wchar_t*) dest, (const wchar_t*) src, count);
}
// (at least) 48-bit random number generator
diff --git a/birnet/birnetoswin32.cc b/birnet/birnetoswin32.cc
index d6a796d..4d9c39d 100644
--- a/birnet/birnetoswin32.cc
+++ b/birnet/birnetoswin32.cc
@@ -131,12 +131,18 @@ strerror_r (int errnum, char *buf, size_t buflen)
}
void
-memset4 (uint32 *mem, uint32 filler, uint length)
+memset4 (uint32 *mem, uint32 filler, size_t count)
{
- while (length--)
+ while (count--)
*mem++ = filler;
}
+void
+memcpy4 (uint32 *dest, const uint32 *src, size_t count)
+{
+ memcpy (dest, src, count * 4);
+}
+
int
mkdir (const char *path,
mode_t mode)
diff --git a/sfi/sfiwrapper.cc b/sfi/sfiwrapper.cc
index ad6c5bc..b424b15 100644
--- a/sfi/sfiwrapper.cc
+++ b/sfi/sfiwrapper.cc
@@ -347,4 +347,17 @@ sfi_os_mkdir (const char *path, mode_t mode)
{
return Birnet::OS::mkdir (path, mode);
}
+
+void
+sfi_os_memset4 (uint32 *dest, uint32 ch, size_t count)
+{
+ Birnet::OS::memset4 (dest, ch, count);
+}
+
+void
+sfi_os_memcpy4 (uint32 *dest, const uint32 *src, size_t count)
+{
+ Birnet::OS::memcpy4 (dest, src, count);
+}
+
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/sfiwrapper.h b/sfi/sfiwrapper.h
index 6ee97de..c3d43e8 100644
--- a/sfi/sfiwrapper.h
+++ b/sfi/sfiwrapper.h
@@ -286,9 +286,12 @@ void sfi_runtime_problem (char ewran_tag,
/* --- birnet OS layer --- */
-bool sfi_os_stat_is_socket (mode_t mode); /* S_ISSOCK */
-bool sfi_os_stat_is_link (mode_t mode); /* S_ISLNK */
-int sfi_os_mkdir (const char *path, mode_t mode);
+bool sfi_os_stat_is_socket (mode_t mode); /* S_ISSOCK */
+bool sfi_os_stat_is_link (mode_t mode); /* S_ISLNK */
+int sfi_os_mkdir (const char *path, mode_t mode);
+void sfi_os_memset4 (uint32 *dest, uint32 ch, size_t count);
+void sfi_os_memcpy4 (uint32 *dest, const uint32 *src, size_t count);
+
BIRNET_EXTERN_C_END();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]