change log for rtems (2011-12-12)

rtems-vc at rtems.org rtems-vc at rtems.org
Mon Dec 12 15:30:17 UTC 2011


 *sh*:
2011-12-12	Sebastian Huber <sebastian.huber at embedded-brains.de>

	* score/src/wkstringduplicate.c: New file.
	* score/Makefile.am: Reflect change above.
	* score/include/rtems/score/wkspace.h: Declare
	_Workspace_String_duplicate().

M 1.3086  cpukit/ChangeLog
M  1.113  cpukit/score/Makefile.am
M   1.34  cpukit/score/include/rtems/score/wkspace.h
A    1.1  cpukit/score/src/wkstringduplicate.c

diff -u rtems/cpukit/ChangeLog:1.3085 rtems/cpukit/ChangeLog:1.3086
--- rtems/cpukit/ChangeLog:1.3085	Fri Dec  9 23:34:14 2011
+++ rtems/cpukit/ChangeLog	Mon Dec 12 09:17:32 2011
@@ -1,3 +1,10 @@
+2011-12-12	Sebastian Huber <sebastian.huber at embedded-brains.de>
+
+	* score/src/wkstringduplicate.c: New file.
+	* score/Makefile.am: Reflect change above.
+	* score/include/rtems/score/wkspace.h: Declare
+	_Workspace_String_duplicate().
+
 2011-12-10	Ralf Corsépius <ralf.corsepius at rtems.org>
 
 	* posix/src/fork.c: Include <unistd.h> for "fork" prototype.

diff -u rtems/cpukit/score/Makefile.am:1.112 rtems/cpukit/score/Makefile.am:1.113
--- rtems/cpukit/score/Makefile.am:1.112	Tue Dec  6 08:23:26 2011
+++ rtems/cpukit/score/Makefile.am	Mon Dec 12 09:17:33 2011
@@ -329,7 +329,7 @@
 libscore_a_SOURCES += src/apiext.c src/chain.c src/chainappend.c \
     src/chainextract.c src/chainget.c src/chaininsert.c \
     src/chainappendempty.c src/chainprependempty.c src/chaingetempty.c \
-    src/interr.c src/isr.c src/wkspace.c
+    src/interr.c src/isr.c src/wkspace.c src/wkstringduplicate.c
 
 EXTRA_DIST = src/Unlimited.txt
 

diff -u rtems/cpukit/score/include/rtems/score/wkspace.h:1.33 rtems/cpukit/score/include/rtems/score/wkspace.h:1.34
--- rtems/cpukit/score/include/rtems/score/wkspace.h:1.33	Fri Jun 17 10:40:09 2011
+++ rtems/cpukit/score/include/rtems/score/wkspace.h	Mon Dec 12 09:17:33 2011
@@ -99,6 +99,23 @@
   size_t  size
 );
 
+/**
+ * @brief Duplicates the @a string with memory from the Workspace.
+ *
+ * If the @a string length exceeds @a maxlen, then the additional characters
+ * will be discarded.
+ *
+ * @param[in] string Pointer to zero terminated string.
+ * @param[in] maxlen Maximum length of the duplicated string.
+ *
+ * @return NULL Not enough memory.
+ * @return other Duplicated string.
+ */
+char *_Workspace_String_duplicate(
+  const char *string,
+  size_t maxlen
+);
+
 #ifndef __RTEMS_APPLICATION__
 #include <rtems/score/wkspace.inl>
 #endif

diff -u /dev/null rtems/cpukit/score/src/wkstringduplicate.c:1.1
--- /dev/null	Mon Dec 12 09:30:17 2011
+++ rtems/cpukit/score/src/wkstringduplicate.c	Mon Dec 12 09:17:33 2011
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2011 embedded brains GmbH.  All rights reserved.
+ *
+ *  embedded brains GmbH
+ *  Obere Lagerstr. 30
+ *  82178 Puchheim
+ *  Germany
+ *  <rtems at embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ * $Id$
+ */
+
+#if HAVE_CONFIG_H
+  #include "config.h"
+#endif
+
+#include <rtems/score/wkspace.h>
+
+#include <string.h>
+
+char *_Workspace_String_duplicate(
+  const char *string,
+  size_t maxlen
+)
+{
+  size_t n = strnlen(string, maxlen);
+  char *dup = _Workspace_Allocate(n + 1);
+
+  if (dup != NULL) {
+    dup [n] = '\0';
+    memcpy(dup, string, n);
+  }
+
+  return dup;
+}


 *sh*:
2011-12-12	Sebastian Huber <sebastian.huber at embedded-brains.de>

	* spwkspace/init.c: Test _Workspace_String_duplicate().

M  1.502  testsuites/sptests/ChangeLog
M    1.7  testsuites/sptests/spwkspace/init.c

diff -u rtems/testsuites/sptests/ChangeLog:1.501 rtems/testsuites/sptests/ChangeLog:1.502
--- rtems/testsuites/sptests/ChangeLog:1.501	Thu Dec  8 15:38:35 2011
+++ rtems/testsuites/sptests/ChangeLog	Mon Dec 12 09:18:18 2011
@@ -1,3 +1,7 @@
+2011-12-12	Sebastian Huber <sebastian.huber at embedded-brains.de>
+
+	* spwkspace/init.c: Test _Workspace_String_duplicate().
+
 2011-12-08	Joel Sherrill <joel.sherrill at oarcorp.com>
 
 	PR 1589/build

diff -u rtems/testsuites/sptests/spwkspace/init.c:1.6 rtems/testsuites/sptests/spwkspace/init.c:1.7
--- rtems/testsuites/sptests/spwkspace/init.c:1.6	Wed Mar  9 14:11:55 2011
+++ rtems/testsuites/sptests/spwkspace/init.c	Mon Dec 12 09:18:18 2011
@@ -17,6 +17,41 @@
 
 #include <tmacros.h>
 
+#include <string.h>
+
+#include <rtems/score/wkspace.h>
+
+static void test_workspace_string_duplicate(void)
+{
+  char a [] = "abcd";
+  char b [] = "abc";
+  char c [] = "ab";
+  char d [] = "a";
+  char e [] = "";
+  size_t maxlen = 3;
+  char *dup_a = _Workspace_String_duplicate( a, maxlen );
+  char *dup_b = _Workspace_String_duplicate( b, maxlen );
+  char *dup_c = _Workspace_String_duplicate( c, maxlen );
+  char *dup_d = _Workspace_String_duplicate( d, maxlen );
+  char *dup_e = _Workspace_String_duplicate( e, maxlen );
+
+  rtems_test_assert( dup_a != NULL );
+  rtems_test_assert( dup_b != NULL );
+  rtems_test_assert( dup_c != NULL );
+  rtems_test_assert( dup_d != NULL );
+  rtems_test_assert( dup_e != NULL );
+  rtems_test_assert( strcmp( dup_a, b ) == 0 );
+  rtems_test_assert( strcmp( dup_b, b ) == 0 );
+  rtems_test_assert( strcmp( dup_c, c ) == 0 );
+  rtems_test_assert( strcmp( dup_d, d ) == 0 );
+  rtems_test_assert( strcmp( dup_e, e ) == 0 );
+
+  _Workspace_Free( dup_a );
+  _Workspace_Free( dup_b );
+  _Workspace_Free( dup_c );
+  _Workspace_Free( dup_d );
+  _Workspace_Free( dup_e );
+}
 
 rtems_task Init(
   rtems_task_argument argument
@@ -61,6 +96,9 @@
   retbool = rtems_workspace_free( p1 );
   rtems_test_assert( retbool == true );
 
+  puts( "_Workspace_String_duplicate - samples" );
+  test_workspace_string_duplicate();
+
   puts( "*** END OF TEST WORKSPACE CLASSIC API ***" );
   rtems_test_exit( 0 );
 }



--

Generated by Deluxe Loginfo [http://www.codewiz.org/projects/index.html#loginfo] 2.122 by Bernardo Innocenti <bernie at develer.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/vc/attachments/20111212/76be01ca/attachment-0001.html>


More information about the vc mailing list