My Project
Loading...
Searching...
No Matches
Macros | Functions | Variables
omTables.c File Reference
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include "omalloc/omConfig.h"
#include "omalloc/omDerivedConfig.h"
#include "omalloc/omStructs.h"
#include "omalloc/omAllocPrivate.h"

Go to the source code of this file.

Macros

#define MH_TABLES_C
 
#define _POSIX_SOURCE   1
 
#define MIN_BIN_BLOCKS   4
 
#define INCR_FACTOR   1
 
#define OM_MAX_BLOCK_SIZE   ((SIZEOF_OM_BIN_PAGE / MIN_BIN_BLOCKS) & ~(SIZEOF_STRICT_ALIGNMENT - 1))
 

Functions

void OutputSize2Bin (size_t *binSize, size_t max_block_size, int track)
 
void OutputSize2AlignedBin (size_t *binSize, size_t max_block_size, int track)
 
void OutputStaticBin (size_t *binSize, int max_bin_index, int track)
 
int GetMaxBlockThreshold ()
 
void CreateDenseBins ()
 
int main (int argc, char *argv[])
 

Variables

size_t om_BinSize [SIZEOF_OM_BIN_PAGE/MIN_BIN_BLOCKS]
 

Macro Definition Documentation

◆ _POSIX_SOURCE

#define _POSIX_SOURCE   1

Definition at line 11 of file omTables.c.

◆ INCR_FACTOR

#define INCR_FACTOR   1

Definition at line 27 of file omTables.c.

◆ MH_TABLES_C

#define MH_TABLES_C

Definition at line 9 of file omTables.c.

◆ MIN_BIN_BLOCKS

#define MIN_BIN_BLOCKS   4

Definition at line 26 of file omTables.c.

◆ OM_MAX_BLOCK_SIZE

#define OM_MAX_BLOCK_SIZE   ((SIZEOF_OM_BIN_PAGE / MIN_BIN_BLOCKS) & ~(SIZEOF_STRICT_ALIGNMENT - 1))

Definition at line 31 of file omTables.c.

Function Documentation

◆ CreateDenseBins()

void CreateDenseBins ( )

Definition at line 136 of file omTables.c.

137{
138 size_t size, align_size = SIZEOF_OM_ALIGNMENT;
139 int i = 1;
140#ifdef OM_ALIGNMENT_NEEDS_WORK
141 int n = GetMaxBlockThreshold();
142#endif
143
144 size = align_size;
145 om_BinSize[0] = align_size;
146 i = 1;
147 while (size < OM_MAX_BLOCK_SIZE)
148 {
149 size += align_size;
150#ifdef OM_ALIGNMENT_NEEDS_WORK
151 if (size >= n && align_size != SIZEOF_STRICT_ALIGNMENT)
152 {
153 align_size = SIZEOF_STRICT_ALIGNMENT;
154 size= OM_STRICT_ALIGN_SIZE(size);
155 }
156#endif
157 om_BinSize[i] = size;
158 if ((SIZEOF_OM_BIN_PAGE / (size + align_size)) < (SIZEOF_OM_BIN_PAGE /size))
159 {
160 i++;
161 }
162 }
163}
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
Definition: cf_ops.cc:600
int i
Definition: cfEzgcd.cc:132
#define SIZEOF_OM_BIN_PAGE
int GetMaxBlockThreshold()
Definition: omTables.c:123
size_t om_BinSize[SIZEOF_OM_BIN_PAGE/MIN_BIN_BLOCKS]
Definition: omTables.c:50
#define OM_MAX_BLOCK_SIZE
Definition: omTables.c:31

◆ GetMaxBlockThreshold()

int GetMaxBlockThreshold ( )

Definition at line 123 of file omTables.c.

124{
125 int i;
126 for (i=SIZEOF_OM_ALIGNMENT; i < OM_MAX_BLOCK_SIZE; i += SIZEOF_OM_ALIGNMENT)
127 {
128 if ((SIZEOF_OM_BIN_PAGE/i) == SIZEOF_OM_BIN_PAGE/(i + SIZEOF_OM_ALIGNMENT))
129 return i;
130 }
131 /* should never get here */
132 printf("error");fflush(stdout);
133 _exit(1);
134}

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 165 of file omTables.c.

166{
167 int max_bin_index = 0;
168 /* determine max_bin_index */
169#ifdef OM_HAVE_DENSE_BIN_DISTRIBUTION
171#endif
172 for(;;)
173 {
174 max_bin_index++;
175 if (om_BinSize[max_bin_index] == OM_MAX_BLOCK_SIZE) break;
176 }
177
178 printf(
179"#ifndef OM_TABLES_INC\n"
180"#define OM_TABLES_INC\n"
181);
182
183 /* Output om_StaticBin */
184 OutputStaticBin(om_BinSize, max_bin_index, 0);
185 /* Output om_Size2Bin */
187
188#ifdef OM_ALIGNMENT_NEEDS_WORK
190#endif
191
192 printf("\n#ifdef OM_HAVE_TRACK\n");
193 /* Output om_StaticBin */
194 OutputStaticBin(om_BinSize, max_bin_index, 1);
195 /* Output om_Size2Bin */
196#ifdef OM_ALIGNMENT_NEEDS_WORK
198#else
200#endif
201 printf("\n#endif /* OM_HAVE_TRACK */\n");
202
203 printf("\n#endif /* OM_TABLES_INC */\n");
204 return 0;
205}
void OutputSize2Bin(size_t *binSize, size_t max_block_size, int track)
Definition: omTables.c:65
void CreateDenseBins()
Definition: omTables.c:136
void OutputStaticBin(size_t *binSize, int max_bin_index, int track)
Definition: omTables.c:107
void OutputSize2AlignedBin(size_t *binSize, size_t max_block_size, int track)
Definition: omTables.c:81

◆ OutputSize2AlignedBin()

void OutputSize2AlignedBin ( size_t *  binSize,
size_t  max_block_size,
int  track 
)

Definition at line 81 of file omTables.c.

82{
83 long i, j;
84 if (OM_MAX_BLOCK_SIZE % 8 != 0)
85 {
86 fprintf(stderr, "OM_MAX_BLOCK_SIZE == %d not divisible by 8\n", OM_MAX_BLOCK_SIZE);fflush(stdout);
87 _exit(1);
88 }
89 printf("omBin om_Size2%sBin[/*%ld*/] = {\n",
90 (track ? "Track" : "Aligned"), (long)(max_block_size / SIZEOF_OM_ALIGNMENT));
91 i=0;
92 while (binSize[i] % SIZEOF_STRICT_ALIGNMENT != 0) i++;
93 j=SIZEOF_OM_ALIGNMENT;
94 while (j < max_block_size)
95 {
96 printf("&om_Static%sBin[%ld], /* %ld */ \n", (track ? "Track" : ""), i, j);
97 if (binSize[i] == j)
98 {
99 i++;
100 while (binSize[i] % SIZEOF_STRICT_ALIGNMENT != 0) i++;
101 }
102 j += SIZEOF_OM_ALIGNMENT;
103 }
104 printf("&om_Static%sBin[%ld] /* %ld */};\n\n", (track ? "Track" : ""), i, j);
105}
int j
Definition: facHensel.cc:110

◆ OutputSize2Bin()

void OutputSize2Bin ( size_t *  binSize,
size_t  max_block_size,
int  track 
)

Definition at line 65 of file omTables.c.

66{
67 long i, j;
68 printf("omBin om_Size2%sBin[/*%ld*/] = {\n",
69 (track? "Track" : ""), (long)(max_block_size / SIZEOF_OM_ALIGNMENT));
70 i=0;
71 j=SIZEOF_OM_ALIGNMENT;
72 while (j < max_block_size)
73 {
74 printf("&om_Static%sBin[%ld], /* %ld */ \n", (track? "Track" : ""), i, j);
75 if (binSize[i] == j) i++;
76 j += SIZEOF_OM_ALIGNMENT;
77 }
78 printf("&om_Static%sBin[%ld] /* %ld */};\n\n", (track? "Track" : ""), i, j);
79}

◆ OutputStaticBin()

void OutputStaticBin ( size_t *  binSize,
int  max_bin_index,
int  track 
)

Definition at line 107 of file omTables.c.

108{
109 long i;
110 printf("omBin_t om_Static%sBin[/*%d*/] = {\n", (track ? "Track" : ""), max_bin_index+1);
111
112 for (i=0; i< max_bin_index; i++)
113 {
114 printf("{om_ZeroPage, NULL, NULL, %ld, %ld, 0},\n",
115 (long)(binSize[i] / SIZEOF_LONG),
116 (long)(SIZEOF_OM_BIN_PAGE/binSize[i]));
117 }
118 printf("{om_ZeroPage, NULL, NULL, %ld, %ld, 0}\n};\n\n",
119 (long)(binSize[i] / SIZEOF_LONG),
120 (long)(SIZEOF_OM_BIN_PAGE/binSize[i]));
121}

Variable Documentation

◆ om_BinSize

size_t om_BinSize[SIZEOF_OM_BIN_PAGE/MIN_BIN_BLOCKS]
Initial value:
=
{ 8, 12, 16, 20,
24, 28, 32,
40, 48, 56, 64,
80, 96, 112, 128,
160, 192, 224,
((SIZEOF_OM_BIN_PAGE / (MIN_BIN_BLOCKS + INCR_FACTOR*9)) / SIZEOF_STRICT_ALIGNMENT)*SIZEOF_STRICT_ALIGNMENT,
((SIZEOF_OM_BIN_PAGE / (MIN_BIN_BLOCKS + INCR_FACTOR*6)) / SIZEOF_STRICT_ALIGNMENT)*SIZEOF_STRICT_ALIGNMENT,
((SIZEOF_OM_BIN_PAGE / (MIN_BIN_BLOCKS + INCR_FACTOR*4)) / SIZEOF_STRICT_ALIGNMENT)*SIZEOF_STRICT_ALIGNMENT,
((SIZEOF_OM_BIN_PAGE / (MIN_BIN_BLOCKS + INCR_FACTOR*2)) / SIZEOF_STRICT_ALIGNMENT)*SIZEOF_STRICT_ALIGNMENT,
((SIZEOF_OM_BIN_PAGE / (MIN_BIN_BLOCKS + INCR_FACTOR)) / SIZEOF_STRICT_ALIGNMENT)*SIZEOF_STRICT_ALIGNMENT,
#define MIN_BIN_BLOCKS
Definition: omTables.c:26
#define INCR_FACTOR
Definition: omTables.c:27

Definition at line 50 of file omTables.c.