]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Patch to deal with big endians (MAC)
authorcblume <cblume@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 18 Oct 2007 08:11:35 +0000 (08:11 +0000)
committercblume <cblume@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 18 Oct 2007 08:11:35 +0000 (08:11 +0000)
TRD/AliTRDRawStreamV2.cxx
TRD/AliTRDRawStreamV2.h

index 786c365757c528201ece02d7fcb9a11061b563a9..e13cb7a247452b041afd8491060efef176aefe98 100644 (file)
@@ -418,6 +418,33 @@ Int_t AliTRDRawStreamV2::Init()
   return kTRUE;
 }
 
+//____________________________________________________________________________
+void AliTRDRawStreamV2::SwapOnEndian()
+{
+  //
+  // Check the endian and swap if needed
+  //
+
+  int itemp = 1;
+  char* ptemp = (char*) &itemp;
+  if (ptemp[0] != 1)
+    {
+      // need to swap...
+      // assume we are at the begining of the buffer!
+      //AliDebug(5, "Swapping.");
+      UInt_t *pbegin = (UInt_t*)fPos;
+      UInt_t iutmp = 0;
+      for (UInt_t i = 0; i < fBufSize / fgkSizeWord; i++)
+       {
+         fDataWord = pbegin + i;
+         iutmp = (((*fDataWord & 0x000000ffU) << 24) | ((*fDataWord & 0x0000ff00U) <<  8) |
+                  ((*fDataWord & 0x00ff0000U) >>  8) | ((*fDataWord & 0xff000000U) >> 24));
+         // here we override the value in the buffer!
+         *fDataWord = iutmp;
+       }
+      fDataWord = pbegin;
+    }
+}
 //____________________________________________________________________________
 Int_t AliTRDRawStreamV2::NextData()
 {
@@ -433,6 +460,7 @@ Int_t AliTRDRawStreamV2::NextData()
          fBufSize = fRawReader->GetDataSize();
          fCountBytes = 0;        
          fDataWord = (UInt_t*)fPos;
+         SwapOnEndian();
          ChangeStatus(kNextSM);
          fWordCtr = 0;
          return kNextSM;
index 942f41a5f3a8315f896b7d97a2014b5dd0a82962..5c9ec027a65160246680457d21e2d9aed091c443 100644 (file)
@@ -71,6 +71,8 @@ class AliTRDRawStreamV2: public TObject {
     Int_t GetMaxCol() const      { return fColMax;  }
     Int_t GetNumberOfTimeBins() const 
                                  { return fTBins;   }
+    
+    void SwapOnEndian();
 
  protected: