Blame SOURCES/Judy-1.0.5-undefined-behavior.patch

670ce7
diff -crb judy-1.0.5-orig/src/JudyCommon/JudyByCount.c judy-1.0.5/src/JudyCommon/JudyByCount.c
670ce7
*** judy-1.0.5-orig/src/JudyCommon/JudyByCount.c	2005-02-15 15:06:07.000000000 -0600
670ce7
--- judy-1.0.5/src/JudyCommon/JudyByCount.c	2014-02-18 13:45:35.225145230 -0600
670ce7
***************
670ce7
*** 817,823 ****
670ce7
  // Shorthand for where to find start of Index bytes array:
670ce7
  
670ce7
  #ifdef JUDY1
670ce7
! #define	PJI (Pjp->jp_1Index)
670ce7
  #else
670ce7
  #define	PJI (Pjp->jp_LIndex)
670ce7
  #endif
670ce7
--- 817,823 ----
670ce7
  // Shorthand for where to find start of Index bytes array:
670ce7
  
670ce7
  #ifdef JUDY1
670ce7
! #define	PJI (Pjp->jp_2Index)
670ce7
  #else
670ce7
  #define	PJI (Pjp->jp_LIndex)
670ce7
  #endif
670ce7
diff -crb judy-1.0.5-orig/src/JudyCommon/JudyGet.c judy-1.0.5/src/JudyCommon/JudyGet.c
670ce7
*** judy-1.0.5-orig/src/JudyCommon/JudyGet.c	2005-02-15 15:06:07.000000000 -0600
670ce7
--- judy-1.0.5/src/JudyCommon/JudyGet.c	2014-02-18 13:49:50.840632644 -0600
670ce7
***************
670ce7
*** 630,636 ****
670ce7
  #ifdef JUDY1
670ce7
  
670ce7
  #define CHECKINDEXNATIVE(LEAF_T, PJP, IDX, INDEX)                       \
670ce7
! if (((LEAF_T *)((PJP)->jp_1Index))[(IDX) - 1] == (LEAF_T)(INDEX))       \
670ce7
      return(1)
670ce7
  
670ce7
  #define CHECKLEAFNONNAT(LFBTS, PJP, INDEX, IDX, COPY)                   \
670ce7
--- 630,636 ----
670ce7
  #ifdef JUDY1
670ce7
  
670ce7
  #define CHECKINDEXNATIVE(LEAF_T, PJP, IDX, INDEX)                       \
670ce7
! if (((LEAF_T *)((PJP)->jp_2Index))[(IDX) - 1] == (LEAF_T)(INDEX))       \
670ce7
      return(1)
670ce7
  
670ce7
  #define CHECKLEAFNONNAT(LFBTS, PJP, INDEX, IDX, COPY)                   \
670ce7
diff -crb judy-1.0.5-orig/src/JudyCommon/JudyIns.c judy-1.0.5/src/JudyCommon/JudyIns.c
670ce7
*** judy-1.0.5-orig/src/JudyCommon/JudyIns.c	2005-02-15 15:06:07.000000000 -0600
670ce7
--- judy-1.0.5/src/JudyCommon/JudyIns.c	2014-02-18 13:00:49.871850635 -0600
670ce7
***************
670ce7
*** 1503,1509 ****
670ce7
              JU_BITMAPSETL(Pjlb, Index);
670ce7
  
670ce7
              for (offset = 0; offset < 15; ++offset)
670ce7
!                 JU_BITMAPSETL(Pjlb, Pjp->jp_1Index[offset]);
670ce7
  
670ce7
  //          Set jp_DcdPopO including the current pop0; incremented later:
670ce7
              DcdP0 = (Index & cJU_DCDMASK(1)) + 15 - 1;
670ce7
--- 1503,1510 ----
670ce7
              JU_BITMAPSETL(Pjlb, Index);
670ce7
  
670ce7
              for (offset = 0; offset < 15; ++offset)
670ce7
! //              JU_BITMAPSETL(Pjlb, Pjp->jp_1Index[offset]); // elements 8..15 are optimized out by gcc, so need to do the following
670ce7
!               JU_BITMAPSETL(Pjlb, Pjp->jp_2Index[offset]);
670ce7
  
670ce7
  //          Set jp_DcdPopO including the current pop0; incremented later:
670ce7
              DcdP0 = (Index & cJU_DCDMASK(1)) + 15 - 1;
670ce7
diff -crb judy-1.0.5-orig/src/JudyCommon/JudyPrevNext.c judy-1.0.5/src/JudyCommon/JudyPrevNext.c
670ce7
*** judy-1.0.5-orig/src/JudyCommon/JudyPrevNext.c	2005-02-15 15:06:07.000000000 -0600
670ce7
--- judy-1.0.5/src/JudyCommon/JudyPrevNext.c	2014-02-18 13:45:40.972875737 -0600
670ce7
***************
670ce7
*** 907,913 ****
670ce7
  // Shorthand for where to find start of Index bytes array:
670ce7
  
670ce7
  #ifdef JUDY1
670ce7
! #define	PJI (Pjp->jp_1Index)
670ce7
  #else
670ce7
  #define	PJI (Pjp->jp_LIndex)
670ce7
  #endif
670ce7
--- 907,913 ----
670ce7
  // Shorthand for where to find start of Index bytes array:
670ce7
  
670ce7
  #ifdef JUDY1
670ce7
! #define	PJI (Pjp->jp_2Index)
670ce7
  #else
670ce7
  #define	PJI (Pjp->jp_LIndex)
670ce7
  #endif
670ce7
diff -crb judy-1.0.5-orig/src/JudyCommon/JudyPrivateBranch.h judy-1.0.5/src/JudyCommon/JudyPrivateBranch.h
670ce7
*** judy-1.0.5-orig/src/JudyCommon/JudyPrivateBranch.h	2005-02-15 15:06:07.000000000 -0600
670ce7
--- judy-1.0.5/src/JudyCommon/JudyPrivateBranch.h	2014-02-18 13:00:39.510533765 -0600
670ce7
***************
670ce7
*** 86,91 ****
670ce7
--- 86,98 ----
670ce7
          } jpi_t;
670ce7
  
670ce7
  
670ce7
+ typedef struct _JUDY_POINTER_IMMED2      // JPI2.
670ce7
+         {
670ce7
+             uint8_t j_pi_2Index[2 * sizeof(Word_t) - 1];        // see above.
670ce7
+             uint8_t j_pi_Type;                  // JP type, 1 of cJ*_JPIMMED*.
670ce7
+         } jpi2_t;
670ce7
+ 
670ce7
+ 
670ce7
  // UNION OF JP TYPES:
670ce7
  //
670ce7
  // A branch is an array of cJU_BRANCHUNUMJPS (256) of this object, or an
670ce7
***************
670ce7
*** 97,102 ****
670ce7
--- 104,110 ----
670ce7
          {
670ce7
              jpo_t j_po;                 // other than immediate indexes.
670ce7
              jpi_t j_pi;                 // immediate indexes.
670ce7
+             jpi2_t j_pi2;               // immediate indexes using j_pi_LIndex as well
670ce7
          } jp_t, *Pjp_t;
670ce7
  
670ce7
  // For coding convenience:
670ce7
***************
670ce7
*** 105,110 ****
670ce7
--- 113,119 ----
670ce7
  
670ce7
  #define jp_1Index  j_pi.j_pi_1Index     // for storing Indexes in first  word.
670ce7
  #define jp_LIndex  j_pi.j_pi_LIndex     // for storing Indexes in second word.
670ce7
+ #define jp_2Index  j_pi2.j_pi_2Index     // for storing Indexes spanning both words.
670ce7
  #define jp_Addr    j_po.j_po_Addr
670ce7
  //#define       jp_DcdPop0 j_po.jpo_u.j_po_DcdPop0
670ce7
  #define jp_Type    j_po.jpo_u.j_po_Bytes[sizeof(Word_t) - 1]