aboutsummaryrefslogtreecommitdiffstats
path: root/community/sphinx/sphinx-pagesize.patch
blob: 83a63b0ad5451eb3a35ac8b902b08b1f500f2cb4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
diff --git a/src/sphinx.cpp b/src/sphinx.cpp
index 71f75f3..b65aeaa 100644
--- a/src/sphinx.cpp
+++ b/src/sphinx.cpp
@@ -8706,7 +8706,7 @@ protected:
 	static const int		MAX_BITS	= 12;
 	static const int		NUM_SIZES	= MAX_BITS-MIN_BITS+2;	///< one for 0 (empty pages), and one for each size from min to max
 
-	static const int		PAGE_SIZE	= 1<<MAX_BITS;
+	static const int		PAGE_SIZES	= 1<<MAX_BITS;
 	static const int		PAGE_ALLOCS	= 1<<( MAX_BITS-MIN_BITS);
 	static const int		PAGE_BITMAP	= ( PAGE_ALLOCS+8*sizeof(DWORD)-1 )/( 8*sizeof(DWORD) );
 
@@ -8820,9 +8820,9 @@ DWORD * CSphArena::ReInit ( int uMaxBytes )
 
 DWORD * CSphArena::Init ( int uMaxBytes )
 {
-	m_iPages = ( uMaxBytes+PAGE_SIZE-1 ) / PAGE_SIZE;
+	m_iPages = ( uMaxBytes+PAGE_SIZES-1 ) / PAGE_SIZES;
 
-	int iData = m_iPages*PAGE_SIZE; // data size, bytes
+	int iData = m_iPages*PAGE_SIZES; // data size, bytes
 	int iMyTaglist = sizeof(int) + MAX_TAGS*sizeof(TagDesc_t); // int length, TagDesc_t[] tags; NOLINT
 	int iMy = m_iPages*sizeof(PageDesc_t) + NUM_SIZES*sizeof(int) + iMyTaglist; // my internal structures size, bytes; NOLINT
 #if ARENADEBUG
@@ -8950,7 +8950,7 @@ int CSphArena::RawAlloc ( int iBytes )
 		pPage->m_uBitmap[i] |= ( 1<<iFree );
 
 		pPage->m_iUsed++;
-		if ( pPage->m_iUsed==( PAGE_SIZE >> pPage->m_iSizeBits ) )
+		if ( pPage->m_iUsed==( PAGE_SIZES >> pPage->m_iSizeBits ) )
 		{
 			// this page is full now, unchain from the free-list
 			assert ( m_pFreelistHeads[iSizeSlot]==pPage-m_pPages );
@@ -8970,7 +8970,7 @@ int CSphArena::RawAlloc ( int iBytes )
 
 		CheckFreelists ();
 
-		int iOffset = ( pPage-m_pPages )*PAGE_SIZE + ( i*32+iFree )*( 1<<iSizeBits ); // raw internal byte offset (FIXME! optimize with shifts?)
+		int iOffset = ( pPage-m_pPages )*PAGE_SIZES + ( i*32+iFree )*( 1<<iSizeBits ); // raw internal byte offset (FIXME! optimize with shifts?)
 		int iIndex = 2 + ( iOffset/sizeof(DWORD) ); // dword index with tag and backtrack fixup
 
 		m_pBasePtr[iIndex-1] = DWORD(-1); // untagged by default
@@ -8988,7 +8988,7 @@ void CSphArena::RawFree ( int iIndex )
 	CheckFreelists ();
 
 	int iOffset = (iIndex-2)*sizeof(DWORD); // remove tag fixup, and go to raw internal byte offset
-	int iPage = iOffset / PAGE_SIZE;
+	int iPage = iOffset / PAGE_SIZES;
 
 	if ( iPage<0 || iPage>m_iPages )
 	{
@@ -8997,8 +8997,8 @@ void CSphArena::RawFree ( int iIndex )
 	}
 
 	PageDesc_t * pPage = m_pPages + iPage;
-	int iBit = ( iOffset % PAGE_SIZE ) >> pPage->m_iSizeBits;
-	assert ( ( iOffset % PAGE_SIZE )==( iBit << pPage->m_iSizeBits ) && "internal error, freed offset is unaligned" );
+	int iBit = ( iOffset % PAGE_SIZES ) >> pPage->m_iSizeBits;
+	assert ( ( iOffset % PAGE_SIZES )==( iBit << pPage->m_iSizeBits ) && "internal error, freed offset is unaligned" );
 
 	if (!( pPage->m_uBitmap[iBit>>5] & ( 1UL<<(iBit & 31) ) ))
 	{
@@ -9018,7 +9018,7 @@ void CSphArena::RawFree ( int iIndex )
 
 	int iSizeSlot = pPage->m_iSizeBits-MIN_BITS+1;
 
-	if ( pPage->m_iUsed==( PAGE_SIZE >> pPage->m_iSizeBits )-1 )
+	if ( pPage->m_iUsed==( PAGE_SIZES >> pPage->m_iSizeBits )-1 )
 	{
 		// this page was full, but it's semi-free now
 		// chain to free-list