Changeset 464
- Timestamp:
- Jul 28, 2003, 7:59:54 PM (22 years ago)
- Location:
- trunk/src/emx/src/emxomf
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/emx/src/emxomf/emxomf.c
-
Property cvs2svn:cvs-rev
changed from
1.14
to1.15
r463 r464 31 31 #include <sys/param.h> 32 32 #include <sys/emxload.h> 33 #include <sys/types.h> 34 #include <sys/stat.h> 33 35 #include <ar.h> 34 36 … … 261 263 /* This is the page size for OMF libraries. It is set by the -p 262 264 option. */ 263 static int page_size = 16;265 static int page_size = 0; 264 266 265 267 /* The index of the next OMF name, used by find_lname(). Name indices … … 3548 3550 if (!opt_x) 3549 3551 { 3552 /* calculate a page size based on the size of the aout library. 3553 Since we don't yet know the number of files it contains, we'll 3554 assum the converted library isn't more than the double it's size. 3555 Or at least we can hope it's not... */ 3556 struct stat s; 3557 int calculated_page_size = page_size; 3558 if (calculated_page_size <= 0) 3559 { /* For a better calculation we would need the file count. */ 3560 calculated_page_size = 16; 3561 if (!stat(src_fname, &s)) 3562 { 3563 int cbPage = (s.st_size * 2) / 65536; 3564 while (calculated_page_size < cbPage) 3565 calculated_page_size <<= 1; 3566 } 3567 if (1) 3568 printf("calculated page size %d\n", calculated_page_size); 3569 } 3570 3550 3571 make_out_fname (dst_fname, inp_fname, ".lib"); 3551 out_lib = omflib_create (out_fname, page_size, lib_errmsg);3572 out_lib = omflib_create (out_fname, calculated_page_size, lib_errmsg); 3552 3573 if (out_lib == NULL) 3553 3574 error (lib_errmsg); -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/emxomf/emxomfar.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r463 r464 24 24 #include <string.h> 25 25 #include <io.h> 26 #include <sys/types.h> 27 #include <sys/stat.h> 26 28 #include <sys/omflib.h> 29 27 30 28 31 #define FALSE 0 … … 154 157 155 158 159 160 /** 161 * Calculate the expected page size for a library based on the 162 * parameters which is specified. 163 * 164 * @returns 165 * @param papszFiles Pointer to a vector of files. 166 * @param chCmd The command we're processing. 167 * @remark Only applies when creating a new library. 168 */ 169 static int calc_pagesize(char **papszFiles, const char chCmd) 170 { 171 unsigned cFiles; 172 size_t cbFiles; 173 int cbPage; 174 int i; 175 176 /* if it's not a replace command return default size. */ 177 if (chCmd != 'r') 178 return 16; 179 180 /* 181 * Count the files and sum their sizes. 182 */ 183 for (i = 0, cFiles = 0, cbFiles = 0; papszFiles[i]; i++) 184 { 185 struct stat s; 186 cFiles++; 187 if (!stat(papszFiles[i], &s)) 188 cbFiles += s.st_size; 189 else 190 cbFiles += 128 * 1024; /* file not found? just guess a size, 128kb. */ 191 } 192 193 /* 194 * We'll need an approximation of this formula: 195 * cbPage = (cbPage * cFiles + cbFiles) / 65535; 196 * 197 * Let's do the calculation assuming cbPage being 256. 198 * We'll also add a few files (just for case that any of these were a library), 199 * and a couple extra of bytes too. 200 */ 201 cbFiles += cFiles * 4096; 202 cFiles += 64; 203 cbPage = (256 * cFiles + cbFiles) / 65536; 204 for (i = 16; i < cbPage; ) 205 i <<= 1; 206 207 if (verbose) 208 printf("calculated page size %d\n", i); 209 return i; 210 } 211 156 212 /* Cleanup, for atexit. */ 157 213 … … 196 252 _wildcard (&argc, &argv); 197 253 198 /* The default page size is 16. */ 199 200 page_size = 16; 254 /* The default page size was 16, now we'll calculate one with 255 a minimum of 16. */ 256 257 page_size = 0; 201 258 202 259 /* Parse the command line. First, check for an -p# option. */ … … 358 415 if (cmd == 'r' || cmd == 'd') 359 416 { 417 if (page_size <= 0) 418 page_size = calc_pagesize(&argv[i], cmd); 360 419 new_lib = omflib_create (new_fname, page_size, error); 361 420 if (new_lib == NULL) -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.