changeset 17434:e89e86e1a551

eliminate unnecessary volatile declarations * byte-swap.h (swap_bytes<T>): Don't declare point arg as volatile. Update all instantiations. * data-conv.cc: Delete explicit instantiations of byte_swap template.
author John W. Eaton <jwe@octave.org>
date Thu, 12 Sep 2013 14:10:41 -0400
parents 95bfa04ab514
children 499fc170bca3 3856298f1ff8
files liboctave/util/byte-swap.h liboctave/util/data-conv.cc
diffstat 2 files changed, 10 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/util/byte-swap.h
+++ b/liboctave/util/byte-swap.h
@@ -23,13 +23,10 @@
 #if !defined (octave_byte_swap_h)
 #define octave_byte_swap_h 1
 
-// FIXME -- not sure these volatile qualifiers are really
-// needed or appropriate here.
-
 static inline void
-swap_bytes (volatile void *ptr, unsigned int i, unsigned int j)
+swap_bytes (void *ptr, unsigned int i, unsigned int j)
 {
-  volatile char *t = static_cast<volatile char *> (ptr);
+  char *t = static_cast<char *> (ptr);
 
   char tmp = t[i];
   t[i] = t[j];
@@ -38,7 +35,7 @@
 
 template <int n>
 void
-swap_bytes (volatile void *ptr)
+swap_bytes (void *ptr)
 {
   for (int i = 0; i < n/2; i++)
     swap_bytes (ptr, i, n-1-i);
@@ -46,20 +43,20 @@
 
 template <>
 inline void
-swap_bytes <1> (volatile void *)
+swap_bytes<1> (void *)
 {
 }
 
 template <>
 inline void
-swap_bytes <2> (volatile void *ptr)
+swap_bytes<2> (void *ptr)
 {
   swap_bytes (ptr, 0, 1);
 }
 
 template <>
 inline void
-swap_bytes <4> (volatile void *ptr)
+swap_bytes<4> (void *ptr)
 {
   swap_bytes (ptr, 0, 3);
   swap_bytes (ptr, 1, 2);
@@ -67,7 +64,7 @@
 
 template <>
 inline void
-swap_bytes <8> (volatile void *ptr)
+swap_bytes<8> (void *ptr)
 {
   swap_bytes (ptr, 0, 7);
   swap_bytes (ptr, 1, 6);
@@ -77,9 +74,9 @@
 
 template <int n>
 void
-swap_bytes (volatile void *ptr, int len)
+swap_bytes (void *ptr, int len)
 {
-  volatile char *t = static_cast<volatile char *> (ptr);
+  char *t = static_cast<char *> (ptr);
 
   for (int i = 0; i < len; i++)
     {
@@ -90,7 +87,7 @@
 
 template <>
 inline void
-swap_bytes<1> (volatile void *, int)
+swap_bytes<1> (void *, int)
 {
 }
 
--- a/liboctave/util/data-conv.cc
+++ b/liboctave/util/data-conv.cc
@@ -37,10 +37,6 @@
 #include "lo-ieee.h"
 #include "oct-locbuf.h"
 
-template void swap_bytes<2> (volatile void *, int);
-template void swap_bytes<4> (volatile void *, int);
-template void swap_bytes<8> (volatile void *, int);
-
 #if defined HAVE_LONG_LONG_INT
 #define FIND_SIZED_INT_TYPE(VAL, BITS, TQ, Q) \
   do \