[GSOC] Help regarding deleting unused functions

2013-07-14 Thread Vipul Nayyar
Hello,

While doing my current task of removing legacy code, after compilation, I 
receive warnings for a certain function, that is defined but not used. As 
suggested by Sebastian, I delete it, after checking whether it's really been 
not called anywhere in the current file, and outside it. Most of the functions 
that I'm talking about right now are static, or supposed to be static.

After re-compilation, warning for that deleted function is obviously gone, but 
there are new warnings of functions defined but not used. So, ultimately I have 
to delete these static functions who are inter-related(calling each other), in 
order to remove the warnings. Currently I was trying my hand on i386 pc386 BSP, 
where I encountered this thing. 

I really don't know whether deleting these multiple inter-related static 
functions is the right way to go or a horribly wrong one.

Hoping to hear soon.

Regards
Vipul Nayyar 
___
rtems-devel mailing list
rtems-devel@rtems.org
http://www.rtems.org/mailman/listinfo/rtems-devel


[PATCH 6/6] add stdatomic.h support check when configure

2013-07-14 Thread WeiY
---
 cpukit/aclocal/check-atomic.m4|9 +
 cpukit/configure.ac   |7 +++
 cpukit/rtems/Makefile.am  |2 ++
 cpukit/rtems/preinstall.am|2 ++
 cpukit/score/Makefile.am  |2 ++
 cpukit/score/preinstall.am|3 ++-
 testsuites/sptests/configure.ac   |4 
 testsuites/sptests/spatomic01/Makefile.am |4 
 testsuites/sptests/spatomic02/Makefile.am |4 
 testsuites/sptests/spatomic03/Makefile.am |4 
 testsuites/sptests/spatomic04/Makefile.am |4 
 testsuites/sptests/spatomic05/Makefile.am |4 
 testsuites/sptests/spatomic06/Makefile.am |4 
 testsuites/sptests/spatomic07/Makefile.am |4 
 14 files changed, 52 insertions(+), 5 deletions(-)

diff --git a/cpukit/aclocal/check-atomic.m4 b/cpukit/aclocal/check-atomic.m4
index 97943eb..b62ef45 100644
--- a/cpukit/aclocal/check-atomic.m4
+++ b/cpukit/aclocal/check-atomic.m4
@@ -5,9 +5,10 @@ AC_REQUIRE([RTEMS_CANONICAL_TARGET_CPU])dnl
 
 AC_CACHE_CHECK([whether CPU supports atomic operations],
   [rtems_cv_ATOMIC],[
-AS_IF(
-  [test -f ${srcdir}/score/cpu/$RTEMS_CPU/rtems/score/cpuatomic.h],
-  [rtems_cv_ATOMIC=yes],
-  [rtems_cv_ATOMIC=no])
+AC_LINK_IFELSE(
+  [AC_LANG_PROGRAM([[#include stdatomic.h]],
+[[atomic_uint_fast32_t t; atomic_init(t, 0); atomic_store( t, 1 
);]])],
+[rtems_cv_ATOMIC=yes],
+[rtems_cv_ATOMIC=no])
   ])
 ])
diff --git a/cpukit/configure.ac b/cpukit/configure.ac
index d82d30f..f897ece 100644
--- a/cpukit/configure.ac
+++ b/cpukit/configure.ac
@@ -149,6 +149,7 @@ RTEMS_CHECK_MULTIPROCESSING
 RTEMS_CHECK_POSIX_API
 RTEMS_CHECK_NETWORKING
 RTEMS_CHECK_SMP
+RTEMS_CHECK_ATOMIC
 
 rtems_major=`echo _RTEMS_VERSION | sed s/\..*//`
 rtems_minor=`echo _RTEMS_VERSION | sed s/[[0-9]][[0-9]]*\.//;s/\..*//`
@@ -186,6 +187,11 @@ RTEMS_CPUOPT([RTEMS_NETWORKING],
   [1],
   [if networking is enabled])
 
+RTEMS_CPUOPT([RTEMS_ATOMIC],
+  [test x$rtems_cv_ATOMIC = xyes],
+  [1],
+  [if cpu supports atomic operations])
+
 RTEMS_CPUOPT([RTEMS_VERSION],
   [true],
   []_RTEMS_VERSION[],
@@ -304,6 +310,7 @@ AM_CONDITIONAL(HAS_SMP,[test $RTEMS_HAS_SMP = yes])
 
 AM_CONDITIONAL(HAS_PTHREADS,test x$rtems_cv_HAS_POSIX_API = xyes)
 AM_CONDITIONAL(LIBNETWORKING,test x$rtems_cv_HAS_NETWORKING = xyes)
+AM_CONDITIONAL([ATOMIC],[test x$rtems_cv_ATOMIC = xyes])
 
 AM_CONDITIONAL([LIBSHELL],[test x$HAVE_ASSIGNABLE_STDIO = xyes])
 AM_CONDITIONAL([LIBSERDBG],[test x$rtems_cv_cc_attribute_weak = xyes])
diff --git a/cpukit/rtems/Makefile.am b/cpukit/rtems/Makefile.am
index a9b4ca8..31e2c3d 100644
--- a/cpukit/rtems/Makefile.am
+++ b/cpukit/rtems/Makefile.am
@@ -40,7 +40,9 @@ include_rtems_rtems_HEADERS += include/rtems/rtems/support.h
 include_rtems_rtems_HEADERS += include/rtems/rtems/tasks.h
 include_rtems_rtems_HEADERS += include/rtems/rtems/timer.h
 include_rtems_rtems_HEADERS += include/rtems/rtems/types.h
+if ATOMIC
 include_rtems_rtems_HEADERS += include/rtems/rtems/atomic.h
+endif
 include_rtems_rtems_HEADERS += mainpage.h
 
 if HAS_MP
diff --git a/cpukit/rtems/preinstall.am b/cpukit/rtems/preinstall.am
index 8a0f780..128d78f 100644
--- a/cpukit/rtems/preinstall.am
+++ b/cpukit/rtems/preinstall.am
@@ -131,9 +131,11 @@ $(PROJECT_INCLUDE)/rtems/rtems/types.h: 
include/rtems/rtems/types.h $(PROJECT_IN
$(INSTALL_DATA) $ $(PROJECT_INCLUDE)/rtems/rtems/types.h
 PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/types.h
 
+if ATOMIC
 $(PROJECT_INCLUDE)/rtems/rtems/atomic.h: include/rtems/rtems/atomic.h 
$(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp)
$(INSTALL_DATA) $ $(PROJECT_INCLUDE)/rtems/rtems/atomic.h
 PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/atomic.h
+endif
 
 $(PROJECT_INCLUDE)/rtems/rtems/mainpage.h: mainpage.h 
$(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp)
$(INSTALL_DATA) $ $(PROJECT_INCLUDE)/rtems/rtems/mainpage.h
diff --git a/cpukit/score/Makefile.am b/cpukit/score/Makefile.am
index 82bf26d..338c797 100644
--- a/cpukit/score/Makefile.am
+++ b/cpukit/score/Makefile.am
@@ -60,10 +60,12 @@ include_rtems_score_HEADERS += 
include/rtems/score/watchdog.h
 include_rtems_score_HEADERS += include/rtems/score/wkspace.h
 include_rtems_score_HEADERS += include/rtems/score/cpuopts.h
 include_rtems_score_HEADERS += include/rtems/score/basedefs.h
+if ATOMIC
 include_rtems_score_HEADERS += include/rtems/score/atomic.h
 include_rtems_score_HEADERS += include/rtems/score/genericcpuatomic.h
 include_rtems_score_HEADERS += include/rtems/score/genericatomicops.h
 include_rtems_score_HEADERS += include/rtems/score/cpustdatomic.h
+endif
 
 if HAS_PTHREADS
 include_rtems_score_HEADERS += include/rtems/score/corespinlock.h
diff --git a/cpukit/score/preinstall.am b/cpukit/score/preinstall.am
index 1b7955e..a48d21e 100644
--- a/cpukit/score/preinstall.am
+++ b/cpukit/score/preinstall.am
@@ -223,6 +223,7 @@ 

[PATCH 4/6] spatomic test case update

2013-07-14 Thread WeiY
---
 testsuites/sptests/spatomic01/tasks.c |   33 ++
 testsuites/sptests/spatomic02/tasks.c |   35 ++-
 testsuites/sptests/spatomic03/tasks.c |   44 ---
 testsuites/sptests/spatomic04/tasks.c |   46 
 testsuites/sptests/spatomic05/tasks.c |   44 ---
 testsuites/sptests/spatomic06/tasks.c |   44 ---
 testsuites/sptests/spatomic07/tasks.c |   77 +++--
 7 files changed, 135 insertions(+), 188 deletions(-)

diff --git a/testsuites/sptests/spatomic01/tasks.c 
b/testsuites/sptests/spatomic01/tasks.c
index c75a94d..9392a5b 100644
--- a/testsuites/sptests/spatomic01/tasks.c
+++ b/testsuites/sptests/spatomic01/tasks.c
@@ -18,20 +18,21 @@
 #include stdlib.h
 #include rtems/rtems/atomic.h
 
-#define TEST_REPEAT 20
+#define TEST_REPEAT 1000
 
-#define ATOMIC_LOAD_NO_BARRIER(NAME, TYPE, task_id, mem_bar) \
+#define ATOMIC_LOAD_NO_BARRIER(NAME, TYPE, R_TYPE, task_id, mem_bar) \
 {\
-  Atomic_##TYPE t = (Atomic_##TYPE)-1, a = 0;\
+  Atomic_##TYPE t;   \
+  R_TYPE a;  \
+  R_TYPE b;  \
   unsigned int i;\
-  a = _Atomic_Load_##NAME(t, mem_bar);  \
-  rtems_test_assert(a == t); \
   for (i = 0; i  TEST_REPEAT; i++){ \
-t = (Atomic_##TYPE)rand();   \
+b = (R_TYPE)rand();  \
+atomic_init(t, b);  \
 a = _Atomic_Load_##NAME(t, mem_bar);\
-rtems_test_assert(a == t);   \
+rtems_test_assert(a == b);   \
   }  \
-  printf(\ntask%d: _Atomic_Load_ #NAME : SUCCESS\n, (unsigned 
int)task_id); \
+  printf(\ntask%d: Atomic_Load_ #NAME : SUCCESS\n, (unsigned int)task_id); 
\
 }
 
 rtems_task Test_task(
@@ -48,22 +49,14 @@ rtems_task Test_task(
 
   /* Print that the task is up and running. */
   /* test relaxed barrier */
-  ATOMIC_LOAD_NO_BARRIER(int, Int, argument, ATOMIC_RELAXED_BARRIER);
+  ATOMIC_LOAD_NO_BARRIER(uint, Uint, uint_fast32_t, argument, 
ATOMIC_ORDER_RELAXED);
 
-  ATOMIC_LOAD_NO_BARRIER(long, Long, argument, ATOMIC_RELAXED_BARRIER);
-
-  ATOMIC_LOAD_NO_BARRIER(ptr, Pointer, argument, ATOMIC_RELAXED_BARRIER);
-
-  ATOMIC_LOAD_NO_BARRIER(32, Int32, argument, ATOMIC_RELAXED_BARRIER);
+  ATOMIC_LOAD_NO_BARRIER(ptr, Pointer, uintptr_t, argument, 
ATOMIC_ORDER_RELAXED);
 
   /* test acquire barrier */
-  ATOMIC_LOAD_NO_BARRIER(int, Int, argument, ATOMIC_ACQUIRE_BARRIER);
-
-  ATOMIC_LOAD_NO_BARRIER(long, Long, argument, ATOMIC_ACQUIRE_BARRIER);
-
-  ATOMIC_LOAD_NO_BARRIER(ptr, Pointer, argument, ATOMIC_ACQUIRE_BARRIER);
+  ATOMIC_LOAD_NO_BARRIER(uint, Uint, uint_fast32_t, argument, 
ATOMIC_ORDER_ACQUIRE);
 
-  ATOMIC_LOAD_NO_BARRIER(32, Int32, argument, ATOMIC_ACQUIRE_BARRIER);
+  ATOMIC_LOAD_NO_BARRIER(ptr, Pointer, uintptr_t, argument, 
ATOMIC_ORDER_ACQUIRE);
 
   /* Set the flag that the task is up and running */
   TaskRan[argument] = true;
diff --git a/testsuites/sptests/spatomic02/tasks.c 
b/testsuites/sptests/spatomic02/tasks.c
index 67c2460..abaee88 100644
--- a/testsuites/sptests/spatomic02/tasks.c
+++ b/testsuites/sptests/spatomic02/tasks.c
@@ -18,20 +18,21 @@
 #include stdlib.h
 #include rtems/rtems/atomic.h
 
-#define TEST_REPEAT 20
+#define TEST_REPEAT 1000
 
-#define ATOMIC_STORE_NO_BARRIER(NAME, TYPE, task_id, mem_bar)\
+#define ATOMIC_STORE_NO_BARRIER(NAME, TYPE, R_TYPE, task_id, mem_bar)\
 {\
-  Atomic_##TYPE t = (Atomic_##TYPE)-1, a = 0;\
+  Atomic_##TYPE t;   \
+  R_TYPE a;  \
+  R_TYPE b;  \
   unsigned int i;\
-  _Atomic_Store_##NAME(a, t, mem_bar);  \
-  rtems_test_assert(a == t); \
   for (i = 0; i  TEST_REPEAT; i++){ \
-t = (Atomic_##TYPE)rand();   \
-_Atomic_Store_##NAME(a, t, mem_bar);\
-rtems_test_assert(a == t);   \
+b = (R_TYPE)rand();  \
+_Atomic_Store_##NAME(t, b, mem_bar);\
+a = _Atomic_Load_##NAME(t, mem_bar);\
+rtems_test_assert(a == b);   \
   }  \
-  printf(\ntask%d: _Atomic_Store_ #NAME : SUCCESS\n, (unsigned 
int)task_id); \
+  printf(\ntask%d: Atomic_Store_ #NAME : SUCCESS\n, (unsigned 
int)task_id); \
 }
 
 

[PATCH 5/6] smpatomic test case update

2013-07-14 Thread WeiY
---
 testsuites/smptests/smpatomic01/tasks.c |   33 ++
 testsuites/smptests/smpatomic02/tasks.c |   35 ++-
 testsuites/smptests/smpatomic03/tasks.c |   44 --
 testsuites/smptests/smpatomic04/tasks.c |   44 --
 testsuites/smptests/smpatomic05/tasks.c |   44 --
 testsuites/smptests/smpatomic06/tasks.c |   44 --
 testsuites/smptests/smpatomic07/tasks.c |   75 ++-
 7 files changed, 133 insertions(+), 186 deletions(-)

diff --git a/testsuites/smptests/smpatomic01/tasks.c 
b/testsuites/smptests/smpatomic01/tasks.c
index 36bb431..28afad9 100644
--- a/testsuites/smptests/smpatomic01/tasks.c
+++ b/testsuites/smptests/smpatomic01/tasks.c
@@ -18,20 +18,21 @@
 #include stdlib.h
 #include rtems/rtems/atomic.h
 
-#define TEST_REPEAT 20
+#define TEST_REPEAT 1000
 
-#define ATOMIC_LOAD_NO_BARRIER(NAME, TYPE, cpuid, mem_bar) \
+#define ATOMIC_LOAD_NO_BARRIER(NAME, TYPE, R_TYPE, cpuid, mem_bar) \
 {\
-  Atomic_##TYPE t = (Atomic_##TYPE)-1, a = 0;\
+  Atomic_##TYPE t;   \
+  R_TYPE a;  \
+  R_TYPE b;  \
   unsigned int i;\
-  a = _Atomic_Load_##NAME(t, mem_bar);  \
-  rtems_test_assert(a == t); \
   for (i = 0; i  TEST_REPEAT; i++){ \
-t = (Atomic_##TYPE)rand();   \
+b = (R_TYPE)rand();  \
+atomic_init(t, b);  \
 a = _Atomic_Load_##NAME(t, mem_bar);\
-rtems_test_assert(a == t);   \
+rtems_test_assert(a == b);   \
   }  \
-  locked_printf(\nCPU%d _Atomic_Load_ #NAME : SUCCESS\n, cpuid); \
+  locked_printf(\nCPU%d Atomic_Load_ #NAME : SUCCESS\n, cpuid); \
 }
 
 rtems_task Test_task(
@@ -51,22 +52,14 @@ rtems_task Test_task(
 
   /* Print that the task is up and running. */
   /* test relaxed barrier */
-  ATOMIC_LOAD_NO_BARRIER(int, Int, cpu_num, ATOMIC_RELAXED_BARRIER);
+  ATOMIC_LOAD_NO_BARRIER(uint, Uint, uint_fast32_t, cpu_num, 
ATOMIC_ORDER_RELAXED);
 
-  ATOMIC_LOAD_NO_BARRIER(long, Long, cpu_num, ATOMIC_RELAXED_BARRIER);
-
-  ATOMIC_LOAD_NO_BARRIER(ptr, Pointer, cpu_num, ATOMIC_RELAXED_BARRIER);
-
-  ATOMIC_LOAD_NO_BARRIER(32, Int32, cpu_num, ATOMIC_RELAXED_BARRIER);
+  ATOMIC_LOAD_NO_BARRIER(ptr, Pointer, uintptr_t, cpu_num, 
ATOMIC_ORDER_RELAXED);
 
   /* test acquire barrier */
-  ATOMIC_LOAD_NO_BARRIER(int, Int, cpu_num, ATOMIC_ACQUIRE_BARRIER);
-
-  ATOMIC_LOAD_NO_BARRIER(long, Long, cpu_num, ATOMIC_ACQUIRE_BARRIER);
-
-  ATOMIC_LOAD_NO_BARRIER(ptr, Pointer, cpu_num, ATOMIC_ACQUIRE_BARRIER);
+  ATOMIC_LOAD_NO_BARRIER(uint, Uint, uint_fast32_t, cpu_num, 
ATOMIC_ORDER_ACQUIRE);
 
-  ATOMIC_LOAD_NO_BARRIER(32, Int32, cpu_num, ATOMIC_ACQUIRE_BARRIER);
+  ATOMIC_LOAD_NO_BARRIER(ptr, Pointer, unsigned long, cpu_num, 
ATOMIC_ORDER_ACQUIRE);
 
 //  ATOMIC_LOAD_NO_BARRIER(64, cpu_num);
 
diff --git a/testsuites/smptests/smpatomic02/tasks.c 
b/testsuites/smptests/smpatomic02/tasks.c
index a85f58c..8ece461 100644
--- a/testsuites/smptests/smpatomic02/tasks.c
+++ b/testsuites/smptests/smpatomic02/tasks.c
@@ -18,20 +18,21 @@
 #include stdlib.h
 #include rtems/rtems/atomic.h
 
-#define TEST_REPEAT 20
+#define TEST_REPEAT 1000
 
-#define ATOMIC_STORE_NO_BARRIER(NAME, TYPE, cpuid, mem_bar)\
+#define ATOMIC_STORE_NO_BARRIER(NAME, TYPE, R_TYPE, cpuid, mem_bar)\
 {\
-  Atomic_##TYPE t = (Atomic_##TYPE)-1, a = 0;\
+  Atomic_##TYPE t;   \
+  R_TYPE a;  \
+  R_TYPE b;  \
   unsigned int i;\
-  _Atomic_Store_##NAME(a, t, mem_bar);  \
-  rtems_test_assert(a == t); \
   for (i = 0; i  TEST_REPEAT; i++){ \
-t = (Atomic_##TYPE)rand();   \
-_Atomic_Store_##NAME(a, t, mem_bar);\
-rtems_test_assert(a == t);   \
+b = (R_TYPE)rand();  \
+_Atomic_Store_##NAME(t, b, mem_bar);\
+a = _Atomic_Load_##NAME(t, mem_bar);\
+rtems_test_assert(a == b);   \
   }  \
-  locked_printf(\nCPU%d _Atomic_Store_ #NAME : SUCCESS\n, cpuid); \
+  locked_printf(\nCPU%d Atomic_Store_ #NAME : SUCCESS\n, cpuid); \
 }
 
 rtems_task Test_task(
@@ -51,22 +52,14 @@ rtems_task Test_task(
 
   /* Print that 

[PATCH 1/6] New atomic API definition based on C11 atomic

2013-07-14 Thread WeiY
---
 cpukit/score/include/rtems/score/atomic.h |  445 +++--
 1 file changed, 232 insertions(+), 213 deletions(-)

diff --git a/cpukit/score/include/rtems/score/atomic.h 
b/cpukit/score/include/rtems/score/atomic.h
index 3b62cb1..80b9ea7 100644
--- a/cpukit/score/include/rtems/score/atomic.h
+++ b/cpukit/score/include/rtems/score/atomic.h
@@ -8,7 +8,7 @@
  */
 
 /*
- * COPYRIGHT (c) 2012 Deng Hengyi.
+ * COPYRIGHT (c) 2012-2013 Deng Hengyi.
  *
  * The license and distribution terms for this file may be
  * found in the file LICENSE in this distribution or at
@@ -32,241 +32,260 @@ extern C {
 /**@{*/
 
 /**
- * @brief the enumeration Atomic_Memory_barrier specifies the detailed regular
- * memory synchronization operations used in the atomic operation API 
- * definitions.  
+ * @brief Atomically load an atomic type value from atomic object.
+ *
+ * @param object an atomic type pointer of object.
+ * @param order a type of Atomic_Order. 
+ * 
+ * The order shall not be ATOMIC_ORDER_RELEASE.
  */
-typedef enum {
-  /** no operation orders memory. */
-  ATOMIC_RELAXED_BARRIER,
-  /** a load operation performs an acquire operation on the affected memory
-  * location. This flag guarantees that the effects of load operation are 
-  * completed before the effects of any later data accesses.
-  */
-  ATOMIC_ACQUIRE_BARRIER,
-  /** a store operation performs a release operation on the affected memory
-  * location. This flag guarantee that all effects of all previous data 
-  * accesses are completed before the store operation takes place.
-  */
-  ATOMIC_RELEASE_BARRIER
-} Atomic_Memory_barrier;
+RTEMS_INLINE_ROUTINE uint_fast32_t _Atomic_Load_uint(
+  volatile Atomic_Uint *object,
+  Atomic_Order order
+)
+{
+  return _CPU_atomic_Load_uint( object, order );
+}
+
+RTEMS_INLINE_ROUTINE uintptr_t _Atomic_Load_ptr(
+  volatile Atomic_Pointer *object,
+  Atomic_Order order
+)
+{
+  return _CPU_atomic_Load_ptr( object, order );
+}
 
 /**
- * @brief Atomically load an atomic type value from address @a address with
- * a type of Atomic_Memory_barrier @a memory_barrier. The @a memory_barrier
- * shall not be ATOMIC_RELEASE_BARRIER.
+ * @brief Atomically store an atomic type value into a atomic object.
+ *
+ * @param object an atomic type pointer of object.
+ * @param value a value to be stored into object.
+ * @param order a type of Atomic_Order. 
+ * 
+ * The order shall not be ATOMIC_ORDER_ACQUIRE.
  */
-RTEMS_INLINE_ROUTINE Atomic_Int _Atomic_Load_int(
-  volatile Atomic_Int *address,
-  Atomic_Memory_barrier memory_barrier
-);
-RTEMS_INLINE_ROUTINE Atomic_Long _Atomic_Load_long(
-  volatile Atomic_Long *address,
-  Atomic_Memory_barrier memory_barrier
-);
-RTEMS_INLINE_ROUTINE Atomic_Pointer _Atomic_Load_ptr(
-  volatile Atomic_Pointer *address,
-  Atomic_Memory_barrier memory_barrier
-);
-RTEMS_INLINE_ROUTINE Atomic_Int32 _Atomic_Load_32(
-  volatile Atomic_Int32 *address,
-  Atomic_Memory_barrier memory_barrier
-);
-RTEMS_INLINE_ROUTINE Atomic_Int64 _Atomic_Load_64(
-  volatile Atomic_Int64 *address,
-  Atomic_Memory_barrier memory_barrier
-);
+RTEMS_INLINE_ROUTINE void _Atomic_Store_uint(
+  volatile Atomic_Uint *object,
+  uint_fast32_t value,
+  Atomic_Order order
+)
+{
+  _CPU_atomic_Store_uint( object, value, order );
+}
+
+RTEMS_INLINE_ROUTINE void _Atomic_Store_ptr(
+  volatile Atomic_Pointer *object,
+  uintptr_t value,
+  Atomic_Order order
+)
+{
+  _CPU_atomic_Store_ptr( object, value, order );
+}
 
 /**
- * @brief Atomically store an atomic type value @a value into address @a 
- * address with a type of Atomic_Memory_barrier @a memory_barrier. The @a 
- * memory_barrier shall not be ATOMIC_ACQUIRE_BARRIER.
+ * @brief Atomically load-add-store an atomic type value into object
+ *
+ * @param object a atomic type pointer of object.
+ * @param value a value to be add and store into object.
+ * @param order a type of Atomic_Order. 
+ * 
+ * @retval a result value after add ops.
  */
-RTEMS_INLINE_ROUTINE void _Atomic_Store_int(
-  volatile Atomic_Int *address,
-  Atomic_Int value,
-  Atomic_Memory_barrier memory_barrier
-);
-RTEMS_INLINE_ROUTINE void _Atomic_Store_long(
-  volatile Atomic_Long *address,
-  Atomic_Long value,
-  Atomic_Memory_barrier memory_barrier
-);
-RTEMS_INLINE_ROUTINE void _Atomic_Store_ptr(
-  volatile Atomic_Pointer *address,
-  Atomic_Pointer value,
-  Atomic_Memory_barrier memory_barrier
-);
-RTEMS_INLINE_ROUTINE void _Atomic_Store_32(
-  volatile Atomic_Int32 *address,
-  Atomic_Int32 value,
-  Atomic_Memory_barrier memory_barrier
-);
-RTEMS_INLINE_ROUTINE void _Atomic_Store_64(
-  volatile Atomic_Int64 *address,
-  Atomic_Int64 value,
-  Atomic_Memory_barrier memory_barrier
-);
+RTEMS_INLINE_ROUTINE uint_fast32_t _Atomic_Fetch_add_uint(
+  volatile Atomic_Uint *object,
+  uint_fast32_t value,
+  Atomic_Order order
+)
+{
+  return _CPU_atomic_Fetch_add_uint( object, value, order );
+}
+
+RTEMS_INLINE_ROUTINE uintptr_t _Atomic_Fetch_add_ptr(
+  volatile 

[PATCH 2/6] A generic atomic implementation for smp architectures

2013-07-14 Thread WeiY
---
 cpukit/score/Makefile.am|1 +
 cpukit/score/include/rtems/score/cpustdatomic.h |  332 +++
 cpukit/score/preinstall.am  |4 +
 3 files changed, 337 insertions(+)
 create mode 100644 cpukit/score/include/rtems/score/cpustdatomic.h

diff --git a/cpukit/score/Makefile.am b/cpukit/score/Makefile.am
index 3f6e686..82bf26d 100644
--- a/cpukit/score/Makefile.am
+++ b/cpukit/score/Makefile.am
@@ -63,6 +63,7 @@ include_rtems_score_HEADERS += include/rtems/score/basedefs.h
 include_rtems_score_HEADERS += include/rtems/score/atomic.h
 include_rtems_score_HEADERS += include/rtems/score/genericcpuatomic.h
 include_rtems_score_HEADERS += include/rtems/score/genericatomicops.h
+include_rtems_score_HEADERS += include/rtems/score/cpustdatomic.h
 
 if HAS_PTHREADS
 include_rtems_score_HEADERS += include/rtems/score/corespinlock.h
diff --git a/cpukit/score/include/rtems/score/cpustdatomic.h 
b/cpukit/score/include/rtems/score/cpustdatomic.h
new file mode 100644
index 000..97cacc5
--- /dev/null
+++ b/cpukit/score/include/rtems/score/cpustdatomic.h
@@ -0,0 +1,332 @@
+/**
+ * @file  rtems/score/cpustdatomic.h
+ * 
+ * This include file defines the generic data struct and implementation
+ * based on stdatomic.h for all the support architectures. You should not
+ * include this header file directly, because it will be used by atomic.h
+ * which should be included by score components
+ */
+
+/*
+ * COPYRIGHT (c) 2013 Deng Hengyi.
+ *
+ * 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.
+ */
+
+#ifndef _RTEMS_SCORE_GENERAL_STDATOMIC_CPU_H_
+#define _RTEMS_SCORE_GENERAL_STDATOMIC_CPU_H_
+
+#include stdatomic.h
+#include rtems/score/types.h
+
+#ifdef __cplusplus
+extern C {
+#endif
+
+/**
+ * @defgroup RTEMS general stdatomic data type and implementation.
+ *
+ */
+
+/**@{*/
+
+/**
+ * @brief atomic operation unsigned integer type
+ */
+typedef atomic_uint_fast32_t Atomic_Uint;
+
+/**
+ * @brief atomic operation unsigned integer the size of a pointer type
+ */
+typedef atomic_uintptr_t Atomic_Pointer;
+
+/**
+ * @brief atomic operation flag type
+ */
+typedef atomic_flag Atomic_Flag;
+
+/**
+ * @brief the enumeration Atomic_Memory_barrier specifies the detailed regular
+ * memory synchronization operations used in the atomic operation API
+ * definitions.
+ */
+typedef enum {
+  /** no operation orders memory. */
+  ATOMIC_ORDER_RELAXED = memory_order_relaxed,
+  /** a load operation performs an acquire operation on the affected memory
+  * location. This flag guarantees that the effects of load operation are
+  * completed before the effects of any later data accesses.
+  */
+  ATOMIC_ORDER_ACQUIRE = memory_order_acquire,
+  /** a store operation performs a release operation on the affected memory
+  * location. This flag guarantee that all effects of all previous data
+  * accesses are completed before the store operation takes place.
+  */
+  ATOMIC_ORDER_RELEASE = memory_order_release
+} Atomic_Order;
+
+/**
+ * @brief Atomically load an atomic type value from atomic object.
+ *
+ * @param object an atomic type pointer of object.
+ * @param order a type of Atomic_Order. 
+ * 
+ * The order shall not be ATOMIC_ORDER_RELEASE.
+ */
+RTEMS_INLINE_ROUTINE uint_fast32_t _CPU_atomic_Load_uint(
+  volatile Atomic_Uint *object,
+  Atomic_Order order
+)
+{
+  return atomic_load_explicit( object, order );
+}
+
+RTEMS_INLINE_ROUTINE uintptr_t _CPU_atomic_Load_ptr(
+  volatile Atomic_Pointer *object,
+  Atomic_Order order
+)
+{
+  return atomic_load_explicit( object, order );
+}
+
+/**
+ * @brief Atomically store an atomic type value into a atomic object.
+ *
+ * @param object an atomic type pointer of object.
+ * @param value a value to be stored into object.
+ * @param order a type of Atomic_Order. 
+ * 
+ * The order shall not be ATOMIC_ORDER_ACQUIRE.
+ */
+RTEMS_INLINE_ROUTINE void _CPU_atomic_Store_uint(
+  volatile Atomic_Uint *object,
+  uint_fast32_t value,
+  Atomic_Order order
+)
+{
+  atomic_store_explicit( object, value, order );
+}
+
+RTEMS_INLINE_ROUTINE void _CPU_atomic_Store_ptr(
+  volatile Atomic_Pointer *object,
+  uintptr_t value,
+  Atomic_Order order
+)
+{
+  atomic_store_explicit( object, value, order );
+}
+
+/**
+ * @brief Atomically load-add-store an atomic type value into object
+ *
+ * @param object a atomic type pointer of object.
+ * @param value a value to be add and store into object.
+ * @param order a type of Atomic_Order. 
+ * 
+ * @retval a result value after add ops.
+ */
+RTEMS_INLINE_ROUTINE uint_fast32_t _CPU_atomic_Fetch_add_uint(
+  volatile Atomic_Uint *object,
+  uint_fast32_t value,
+  Atomic_Order order
+)
+{
+  return atomic_fetch_add_explicit( object, value, order );
+}
+
+RTEMS_INLINE_ROUTINE uintptr_t _CPU_atomic_Fetch_add_ptr(
+  volatile Atomic_Pointer *object,
+  uintptr_t value,
+  Atomic_Order order
+)
+{
+ 

Re: [GSOC] Help regarding deleting unused functions

2013-07-14 Thread Peter Dufault

On Jul 14, 2013, at 04:01 , Vipul Nayyar nayyar_vi...@yahoo.com wrote:

 Hello,
 
 While doing my current task of removing legacy code, after compilation, I 
 receive warnings for a certain function, that is defined but not used. As 
 suggested by Sebastian, I delete it, after checking whether it's really been 
 not called anywhere in the current file, and outside it. Most of the 
 functions that I'm talking about right now are static, or supposed to be 
 static.
 
 After re-compilation, warning for that deleted function is obviously gone, 
 but there are new warnings of functions defined but not used. So, ultimately 
 I have to delete these static functions who are inter-related(calling each 
 other), in order to remove the warnings. Currently I was trying my hand on 
 i386 pc386 BSP, where I encountered this thing. 
 
 I really don't know whether deleting these multiple inter-related static 
 functions is the right way to go or a horribly wrong one.
 
 Hoping to hear soon.
 
 Regards
 Vipul Nayyar 
 
 ___


This is hard to answer.  The question is whether the functionality that this is 
implementing is of any use in the future, as it apparently was of some use in 
the past.

When confronted with this I usually choose  a pre-processor define to associate 
with the static functions.  Then I go through and conditionally disable the 
entire family of functions.  After that I have a good understanding of its 
scope what it is doing, and I can then go and remove it completely or decide 
that there is some reason I still want to keep it around.

If I do want to keep it around I do not leave conditionally compiled, 
completely unused code intact in a source files.  Since it will never be 
compiled on RTEMS  it will rot quickly and just become confusing, uncompilable 
cruft. 

However, let's say this code implements hooks for some sort of memory 
protection that it isn't implemented in RTEMS, but as we know there is work 
going on on this.  So if I wanted to keep it around I would move the code to a 
new .c file, add a public interface so the static functions were used, remove 
the conditional compilation, and describe why I kept it and that it isn't 
really tested.  It would then be compiled so it won't get any worse over time.

The reason to move it to another file is so it is still compiled, but it won't 
increase code footprint. Many RTEMS applications are memory constrained.

Joel might have a different answer.  I know he is concerned with coverage and 
this complicates that.,

 The code already can't be trusted, it hasn't been used for who knows how 
long, remove it with extreme prejudice is a much simpler and perfectly 
defendable answer.

Peter
-
Peter Dufault
HD Associates, Inc.  Software and System Engineering

___
rtems-devel mailing list
rtems-devel@rtems.org
http://www.rtems.org/mailman/listinfo/rtems-devel


BSP lm3s6965 broken

2013-07-14 Thread emanuel stiebler

Making all in lm3s6965
gmake[2]: Entering directory 
`/AD1/SHARED/RTEMS/BUILD/arm-rtems4.11/c/lm3s6965'

gmake[2]: *** No rule to make target `all'.  Stop.
gmake[2]: Leaving directory 
`/AD1/SHARED/RTEMS/BUILD/arm-rtems4.11/c/lm3s6965'

gmake[1]: *** [all-recursive] Error 1
gmake[1]: Leaving directory `/AD1/SHARED/RTEMS/BUILD/arm-rtems4.11/c'
make: *** [all-recursive] Error 1

I think it was working days/week ago. Was this broken during the cleanup?

lm3s6965_qemu and lm3s3749 are still working.

Cheers

___
rtems-devel mailing list
rtems-devel@rtems.org
http://www.rtems.org/mailman/listinfo/rtems-devel