- Timestamp:
- Oct 26, 1999, 5:06:13 PM (25 years ago)
- Branches:
- (u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'b4f17ed1d25f93d46dbe29e4b499baecc2fd51bb')
- Children:
- 49f0894e4677acc5c2de4645efa374c1f901dbe7
- Parents:
- 3ce7b66ce4f4c6aa1846f4edb90839c950a9c891
- Location:
- Singular
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/aso.h
r3ce7b6 rd6681d 4 4 * aso.h: Header file for generation of ALLOC_SIZE_OF_ macros 5 5 * 6 * Version: $Id: aso.h,v 1. 1 1999-10-14 14:46:48obachman Exp $6 * Version: $Id: aso.h,v 1.2 1999-10-26 15:06:09 obachman Exp $ 7 7 *******************************************************************/ 8 8 #ifndef ASO_H … … 12 12 #undef HAVE_ASO 13 13 #define HAVE_ASO 0 14 #define ASO_GENERATE 14 15 15 16 #include <stdio.h> … … 17 18 #include "mmtables.inc" 18 19 19 #define ASO(x) 20 do 21 { 22 int index = mmGetIndex(sizeof(x)); 23 if (index < 0) 24 { 25 fprintf(stderr, "sizeof(%s) == %d larger than MAX_BLOCK_SIZE\n", 26 #x, sizeof(x)); 27 exit(1); 28 } 29 printf("#define ALLOC_SIZE_OF_%s AllocHeapSizeOf(&mm_theList[%d], sizeof(%s) )\n", #x, index, #x);\30 printf("#define ALLOC0_SIZE_OF_%s Alloc0HeapSizeOf(&mm_theList[%d], sizeof(%s) )\n", #x, index, #x);\31 printf("#define FREE_SIZE_OF_%s(addr) FreeHeapSizeOf(addr, &mm_theList[%d], sizeof(%s))\n\n", #x, index, #x);\32 } 20 #define ASO(x) \ 21 do \ 22 { \ 23 int index = mmGetIndex(sizeof(x)); \ 24 if (index < 0) \ 25 { \ 26 fprintf(stderr, "sizeof(%s) == %d larger than MAX_BLOCK_SIZE\n", \ 27 #x, sizeof(x)); \ 28 exit(1); \ 29 } \ 30 printf("#define ALLOC_SIZE_OF_%s AllocHeapSizeOf(&mm_theList[%d], sizeof(%s), %s*)\n", #x, index, #x, #x); \ 31 printf("#define ALLOC0_SIZE_OF_%s Alloc0HeapSizeOf(&mm_theList[%d], sizeof(%s), %s*)\n", #x, index, #x, #x); \ 32 printf("#define FREE_SIZE_OF_%s(addr) FreeHeapSizeOf(addr, &mm_theList[%d], sizeof(%s))\n\n", #x, index, #x); \ 33 } \ 33 34 while (0) 34 35 -
Singular/cntrlc.cc
r3ce7b6 rd6681d 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: cntrlc.cc,v 1.2 5 1999-09-20 18:03:43obachman Exp $ */4 /* $Id: cntrlc.cc,v 1.26 1999-10-26 15:06:10 obachman Exp $ */ 5 5 /* 6 6 * ABSTRACT - interupt handling … … 23 23 #endif 24 24 25 /* undef, if you don't want GDB to come up on error */ 26 /* #define CALL_GDB */ 27 28 #if defined(__OPTIMIZE__) && defined(CALL_GDB) 29 #undef CALL_GDB 30 #endif 31 25 32 #ifdef unix 26 33 #ifndef hpux … … 46 53 #define INTERACTIVE 0 47 54 #define STACK_TRACE 1 48 #if ndef __OPTIMIZE__55 #ifdef __CALL_GDB__ 49 56 static void debug (int); 50 57 static void debug_stop (char **); 58 #endif 59 #ifndef __OPTIMIZE__ 51 60 static void stack_trace (char **); 52 61 static void stack_trace_sigchld (int); … … 124 133 } 125 134 #endif 126 #if ndef __OPTIMIZE__135 #ifdef CALL_GDB 127 136 if (sig!=SIGINT) debug(INTERACTIVE); 128 137 #endif … … 231 240 } 232 241 #endif 233 #if ndef __OPTIMIZE__242 #ifdef CALL_GDB 234 243 if (sig!=SIGINT) debug(STACK_TRACE); 235 244 #endif … … 278 287 #ifndef hpux 279 288 /* debug(..) does not work under HPUX (because ptrace does not work..) */ 280 #if ndef __OPTIMIZE__289 #ifdef CALL_GDB 281 290 #ifndef MSDOS 282 291 if (sig!=SIGINT) debug(STACK_TRACE); … … 439 448 #ifndef MSDOS 440 449 int si_stop_stack_trace_x; 441 450 #ifdef CALL_GDB 442 451 static void debug (int method) 443 452 { … … 481 490 _exit (0); 482 491 } 492 #endif 483 493 484 494 static int stack_trace_done; -
Singular/intvec.h
r3ce7b6 rd6681d 4 4 * Computer Algebra System SINGULAR * 5 5 ****************************************/ 6 /* $Id: intvec.h,v 1.1 0 1999-10-22 11:14:10 obachman Exp $ */6 /* $Id: intvec.h,v 1.11 1999-10-26 15:06:10 obachman Exp $ */ 7 7 /* 8 8 * ABSTRACT: class intvec: lists/vectors of integers … … 87 87 ~intvec() 88 88 { 89 #ifdef MDEBUG90 89 mmTestL(this); 91 #endif92 90 if (v!=NULL) 93 91 { … … 98 96 void ivTEST() 99 97 { 100 #ifdef MDEBUG101 98 mmTestL(this); 102 99 mmTest((ADDRESS)v,sizeof(int)*row*col); 103 #endif104 100 } 105 101 }; -
Singular/mmcheck.c
r3ce7b6 rd6681d 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: mmcheck.c,v 1.1 4 1999-10-22 09:07:04obachman Exp $ */4 /* $Id: mmcheck.c,v 1.15 1999-10-26 15:06:10 obachman Exp $ */ 5 5 6 6 /* … … 441 441 } 442 442 443 int mmTestHeaps()444 {445 int i = -1;446 447 do448 {449 i++;450 if (! mmCheckHeap(&mm_theList[i])) return 0;451 }452 while (mmGetSize(i) < MAX_BLOCK_SIZE);453 454 return 1;455 }456 443 457 444 static int mmIsAddrOnDList(DBMCB *what, DBMCB* list, int s) -
Singular/mmemory.h
r3ce7b6 rd6681d 4 4 * Computer Algebra System SINGULAR * 5 5 ****************************************/ 6 /* $Id: mmemory.h,v 1. 29 1999-10-25 16:07:35obachman Exp $ */6 /* $Id: mmemory.h,v 1.30 1999-10-26 15:06:11 obachman Exp $ */ 7 7 /* 8 8 * ABSTRACT … … 40 40 void mmFreeAlignedBlock( void*, size_t ); 41 41 #endif 42 #define AllocHeap(h) _AllocHeap(h) 43 #define Alloc0Heap(h) _Alloc0Heap(h) 44 #define AllocHeapType(h, t) (t) AllocHeap(h) 45 #define Alloc0HeapType(h, t) (t) Alloc0Heap(h) 42 46 #define FreeHeap mmFreeHeap 43 47 #define Alloc mmAllocBlock … … 81 85 #define AllocHeap(heap) mmDBAllocHeap(heap, __FILE__, __LINE__) 82 86 #define Alloc0Heap(heap) mmDBAlloc0Heap(heap, __FILE__, __LINE__) 87 #define AllocHeapType(heap,t) (t) mmDBAllocHeap(heap, __FILE__, __LINE__) 88 #define Alloc0HeapType(heap,t) (t) mmDBAlloc0Heap(heap, __FILE__, __LINE__) 83 89 #define FreeHeap(addr, heap) mmDBFreeHeap(addr, heap, __FILE__, __LINE__) 84 90 #define Alloc(s) mmDBAllocBlock(s, __FILE__, __LINE__) … … 120 126 void mmDBFreeHeapSizeOf(void* addr, memHeap heap, size_t size, 121 127 char* file, int line); 122 #define AllocHeapSizeOf(h, s ) mmDBAllocHeapSizeOf(h, s, __FILE__, __LINE__)123 #define Alloc0HeapSizeOf(h, s ) mmDBAlloc0HeapSizeOf(h, s, __FILE__, __LINE__)128 #define AllocHeapSizeOf(h, s, t) (t) mmDBAllocHeapSizeOf(h, s, __FILE__, __LINE__) 129 #define Alloc0HeapSizeOf(h, s, t) (t) mmDBAlloc0HeapSizeOf(h, s, __FILE__, __LINE__) 124 130 #define FreeHeapSizeOf(x, h, s) mmDBFreeHeapSizeOf(x, h, s, __FILE__, __LINE__) 125 131 #else /* ! (ASO_DEBUG || MDEBUG) */ 126 #define AllocHeapSizeOf(h, s ) AllocHeap(h)127 #define Alloc0HeapSizeOf(h, s ) Alloc0Heap(h)132 #define AllocHeapSizeOf(h, s, t) AllocHeapType(h, t) 133 #define Alloc0HeapSizeOf(h, s, t) Alloc0HeapType(h, t) 128 134 #define FreeHeapSizeOf(x, h, s) FreeHeap(x, h) 129 135 #endif /* ASO_DEBUG || MDEBUG */ … … 133 139 #define AllocSizeOf(x) Alloc(sizeof(x)) 134 140 #define Alloc0SizeOf(x) Alloc0(sizeof(x)) 135 #define FreeSizeOf(x, y) Free SizeOf(x, sizeof(y))141 #define FreeSizeOf(x, y) Free(x, sizeof(y)) 136 142 #endif /* HAVE_ASO */ 137 143 … … 171 177 172 178 int mmTestMemory(); 173 int mmTestHeaps();174 179 175 180 void mmPrintUsedList(); … … 192 197 #define mmTestLP(A) TRUE 193 198 #define mmTestMemory() TRUE 194 #define mmTestHeaps() TRUE195 199 #define mmMarkInitDBMCB() 196 200 #define mmTestList(a) … … 246 250 **********************************/ 247 251 #ifndef HEAP_DEBUG 248 #define mmAllocHeap(res, heap) _mmAllocHeap(res, heap) 249 #define mmFreeHeap(addr, heap) _mmFreeHeap(addr, heap) 252 #define mmAllocHeap(res, heap) _mmAllocHeap(res, heap, void*) 253 #define mmFreeHeap(addr, heap) _mmFreeHeap(addr, heap) 254 #define mmAllocHeapType(res, heap, type) _mmAllocHeap(res, heap, type) 250 255 #define mmCheckHeap(heap) 1 251 256 #define mmCheckHeapAddr(addr, heap) 1 252 257 #define mmTestHeaps() 1 253 258 #else 254 259 /* … … 261 266 extern int mm_HEAP_DEBUG; 262 267 263 #define mmAllocHeap(res, heap)\ 268 #define mmAllocHeapType(res, heap, type) \ 269 (res) = (type) mmDebugAllocHeap(heap, __FILE__, __LINE__) 270 #define mmAllocHeap(res, heap) \ 264 271 (res) = mmDebugAllocHeap(heap, __FILE__, __LINE__) 265 272 void * mmDebugAllocHeap(memHeap heap, const char*, int ); … … 277 284 int mmDebugCheckHeapAddr(void* addr, memHeap heap, int flag, 278 285 const char* fn, int l); 286 int mmTestHeaps(); 279 287 #endif /* HEAP_DEBUG */ 280 288 … … 311 319 312 320 /* Allocates memory block from a heap */ 313 #define _mmAllocHeap(what, heap )\321 #define _mmAllocHeap(what, heap, type) \ 314 322 do \ 315 323 { \ 316 324 register memHeap _heap = heap; \ 317 325 if ((_heap)->current == NULL) mmAllocNewHeapPage(_heap); \ 318 what = ( void *)((_heap)->current); \326 what = (type)((_heap)->current); \ 319 327 (_heap)->current = *((void**)(_heap)->current); \ 320 328 } \ … … 355 363 356 364 extern memHeapPage mmGetNewCurrentPage(memHeap heap); 357 extern void mmRearrangeHeapPages(memHeapPage page, memHeap heap, void* addr);365 extern void mmRearrangeHeapPages(memHeapPage page, void* addr, memHeap heap); 358 366 extern struct sip_memHeapPage mmZeroPage[]; 359 367 #ifndef mmGetPageOfAddr … … 362 370 #endif 363 371 364 #define _mmAllocHeap(what, heap )\372 #define _mmAllocHeap(what, heap, type) \ 365 373 do \ 366 374 { \ … … 368 376 if (_page->current == NULL) _page = mmGetNewCurrentPage(heap); \ 369 377 (_page->used_blocks)++; \ 370 what = ( void *)((_page)->current);\378 what = (type)((_page)->current); \ 371 379 (_page)->current = *((void**)(_page)->current); \ 372 380 } \ … … 377 385 { \ 378 386 register memHeapPage _page = mmGetPageOfAddr(addr); \ 379 _page->used_blocks--;\387 (_page->used_blocks)--; \ 380 388 if (_page->used_blocks == 0) \ 381 mmRearrangeHeapPages(_page, heap, addr); \389 mmRearrangeHeapPages(_page, addr, heap); \ 382 390 else \ 383 391 { \ 384 *((void**) addr) = _page->current; \385 _page->current = addr; \392 *((void**) (addr)) = _page->current; \ 393 _page->current = (addr); \ 386 394 } \ 387 395 } \ … … 636 644 637 645 #if ! defined(MDEBUG) 638 inline void* AllocHeap(memHeap heap)646 inline void* _AllocHeap(memHeap heap) 639 647 { 640 648 void* ptr; … … 642 650 return ptr; 643 651 } 644 inline void* Alloc0Heap(memHeap heap)652 inline void* _Alloc0Heap(memHeap heap) 645 653 { 646 654 void* ptr; -
Singular/mmheap.c
r3ce7b6 rd6681d 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: mmheap.c,v 1.1 4 1999-10-25 08:32:16obachman Exp $ */4 /* $Id: mmheap.c,v 1.15 1999-10-26 15:06:11 obachman Exp $ */ 5 5 #include <stdio.h> 6 6 #include "mod2.h" … … 275 275 } 276 276 } 277 int mmNumberOfAllocatedHeapPages(memHeap heap) 278 { 279 return mmListLength(heap->pages); 280 } 281 282 int mmNumberOfFreeHeapBlocks(memHeap heap) 283 { 284 mmListLength(heap->current); 285 } 277 286 278 287 #else /* HAVE_AUTOMATIC_GC */ 279 288 289 int mmNumberOfAllocatedHeapPages(memHeap heap) 290 { 291 return mmGListLength(heap->last_page, 292 (void*) &(heap->last_page->prev) - (void*)heap->last_page); 293 } 294 295 int mmNumberOfFreeHeapBlocks(memHeap heap) 296 { 297 int n = 0; 298 memHeapPage page; 299 300 if (heap->current_page == mmZeroPage) return 0; 301 302 page = heap->last_page; 303 do 304 { 305 n += mmListLength(page->current); 306 if (page == heap->current_page) break; 307 page = page->prev; 308 } 309 while (page != NULL); 310 311 return n; 312 } 313 314 280 315 memHeapPage mmGetNewCurrentPage(memHeap heap) 281 316 { 317 assume(heap->current_page->current == NULL); 282 318 if (heap->current_page == mmZeroPage) 283 319 { 284 320 memHeapPage new_page = mmAllocNewHeapPage(heap); 285 321 new_page->next = mmZeroPage; 286 new_page->prev = NULL; 322 new_page->prev = heap->last_page; 323 if (heap->last_page != NULL) 324 heap->last_page->next = new_page; 287 325 heap->current_page = new_page; 288 returnnew_page;326 heap->last_page = new_page; 289 327 } 290 328 else 291 329 { 292 330 heap->current_page->used_blocks = 1; 293 heap->current_page->current = (void*) heap;294 if (heap->current_page->next->current != NULL)295 {331 if (heap->current_page != heap->last_page) 332 { 333 assume(heap->current_page->next->current != NULL); 296 334 heap->current_page = heap->current_page->next; 297 return heap->current_page;298 335 } 299 336 else … … 301 338 memHeapPage new_page = mmAllocNewHeapPage(heap); 302 339 new_page->next = mmZeroPage; 303 heap->current_page->next = new_page;304 new_page->prev ious = heap->current_page;340 new_page->prev = heap->last_page; 341 new_page->prev->next = new_page; 305 342 heap->current_page = new_page; 306 return new_page; 307 } 308 } 343 heap->last_page = new_page; 344 } 345 } 346 #ifdef HEAP_DEBUG 347 if (mm_HEAP_DEBUG > 1) mmDebugCheckHeap(heap, __FILE__, __LINE__); 348 #endif 349 return heap->current_page; 309 350 } 310 351 … … 313 354 { 314 355 if (heap->current_page == page) heap->current_page = page->next; 356 if (heap->last_page == page) heap->last_page = page->prev; 315 357 if (page->prev != NULL) page->prev->next = page->next; 316 358 if (page->next != mmZeroPage) page->next->prev = page->prev; … … 319 361 static void mmInsertHeapPage(memHeapPage after, memHeapPage page, memHeap heap) 320 362 { 321 if (after == mmZeroPage) 322 { 363 if (after == NULL) 364 { 365 assume(heap->current_page == mmZeroPage); 323 366 page->next = mmZeroPage; 324 367 page->prev = NULL; 325 368 heap->current_page = page; 369 heap->last_page = page; 326 370 } 327 371 else 328 372 { 373 if (after == heap->last_page) heap->last_page = page; 374 page->prev = after; 329 375 page->next = after->next; 330 page->prev = after;331 376 if (after->next != mmZeroPage) after->next->prev = page; 332 after->next page; 333 } 334 } 335 336 void mmRearrangeHeapPages(memHeapPage page, void* addr) 337 { 338 memHeap heap; 339 if (mmGetPageOfAddr(page->current) == page) 340 { 377 after->next = page; 378 if (heap->current_page == mmZeroPage && page->current != NULL) 379 heap->current_page = page; 380 } 381 } 382 383 void mmRearrangeHeapPages(memHeapPage page, void* addr, memHeap heap) 384 { 385 assume(page->used_blocks == 0); 386 if (page->current != NULL) 387 { 388 // all blocks of page are now collected 341 389 // get heap 342 heap = (memHeap) *(page->current + 1); 343 mmTakeOutHeapPage(page, heap); 390 mmTakeOutHeapPage(page, heap); 344 391 // page can be freed 345 392 mmFreePage(page); … … 348 395 { 349 396 // page was full 350 heap = (memHeap) page->current; 351 page->current = addr; 352 page->used_blocks = (SIZE_OF_HEAP_PAGE / heap->block) - 1; 353 if (page->used_blocks <= 0) page->used_blocks = 1; 354 *(page->current + 1) = heap; 355 mmTakeOutHeapPage(page, heap); 397 if (heap->max_blocks == 1) 398 { 399 mmTakeOutHeapPage(page, heap); 400 mmFreePage(page); 401 } 402 else 403 { 404 page->current = addr; 405 page->used_blocks = heap->max_blocks - 1; 406 *((void**)addr) = NULL; 407 mmTakeOutHeapPage(page, heap); 356 408 #if defined(PAGE_BEFORE_CURRENT) 357 if (heap->current_page->prev != NULL) 358 { 359 mmInsertHeapPage(heap->current_page->prev, page); 360 } 361 else 362 { 363 mmInsertHeapPage(heap->current, page, heap); 364 } 365 heap->current = page; 409 if (heap->current_page->prev != NULL) 410 mmInsertHeapPage(heap->current_page->prev, page); 411 else 412 mmInsertHeapPage(heap->current_page, page, heap); 413 heap->current_page = page; 366 414 #elsif defined(PAGE_AFTER_CURRENT) 367 mmInsertHeapPage(heap->current, page, heap);415 mmInsertHeapPage(heap->current_page, page, heap); 368 416 #else 369 { 370 memPage lastpage = heap->current_page; 371 if (lastpage != mmZeroPage) 372 { 373 memPage lastpage = heap->current_page; 374 while (lastpage->next != mmZeroPage) 375 { 376 lastpage = lastpage->next; 377 } 378 } 379 mmInsertHeapPage(lastpage, page, heap); 380 } 417 mmInsertHeapPage(heap->last_page, page, heap); 381 418 #endif 382 } 383 } 384 385 386 387 388 389 390 if (page->used_blocks == 0) 391 { 392 if (heap->current_page == page) 393 heap->current_page = heap->current_page->next; 394 page->prev->next = page->next; 395 page->next->prev = page->prev; 396 if (SIZE_OF_HEAP_PAGE / heap->size > 0) 397 mmFreePage(page); 398 else 399 mmVfreeToSystem(page, heap->size + SIZE_OF_HEAP_PAGE_HEADER); 400 } 401 else 402 { 403 memHeapPage next_page = page->next; 404 405 if (heap->current_page->current == NULL) 406 heap->current_page = page; 407 else if (heap->current_page == page && next_page->current != NULL) 408 heap->current_page = next_page; 409 410 while (page->used_blocks < next_page->used_blocks) 411 next_page = next_page->next; 412 413 if (next_page != page->next) 414 { 415 page->prev->next = page->next; 416 page->next->prev = page->prev; 417 page->prev = next_page; 418 page->next = next_page->next; 419 next_page->next->prev = page; 420 next_page->next = page; 421 } 422 } 423 mmCheckHeap(heap); 424 } 419 } 420 } 421 #ifdef HEAP_DEBUG 422 if (mm_HEAP_DEBUG > 1) mmDebugCheckHeap(heap, __FILE__, __LINE__); 423 #endif 424 } 425 425 426 426 427 memHeap mmCreateHeap(size_t size) … … 428 429 memHeap heap = (memHeap) AllocSizeOf(ip_memHeap); 429 430 heap->current_page = mmZeroPage; 431 heap->last_page = NULL; 430 432 heap->size = size; 433 heap->max_blocks = SIZE_OF_HEAP_PAGE / size; 434 if (heap->max_blocks == 0) heap->max_blocks = 1; 431 435 return heap; 432 436 } … … 440 444 #ifdef HEAP_DEBUG 441 445 mmCheckHeap(heap); 442 if (heap->current_page != mmZeroPage && 443 (heap->current_page->used_blocks != 0 || 444 heap->current_page->next != heap->current_page || 445 heap->current_page->prev != heap->current_page)) 446 if (heap->current_page != mmZeroPage) 447 { 446 448 mmPrintHeapError("ClearHeap: Heap not empty", NULL, heap, file, line); 447 #endif 448 if (heap->current_page != mmZeroPage) 449 { 450 if (SIZE_OF_HEAP_PAGE / heap->size > 0) 451 mmFreePage(heap->current_page); 452 else 453 mmVfreeToSystem(heap->current_page, 454 heap->size + SIZE_OF_HEAP_PAGE_HEADER); 455 } 456 heap->current_page = mmZeroPage; 449 } 450 #endif 457 451 } 458 452 … … 551 545 } 552 546 547 553 548 #else /* HAVE_AUTOMATIC_GC */ 549 550 554 551 static int mmDebugCheckSingleHeapAddr(void* addr, memHeap heap, 555 552 const char* fn, int l) 556 553 { 557 void* page; 558 memHeapPage hpage; 554 memHeapPage page; 559 555 560 556 if (heap == NULL) … … 571 567 return mmPrintHeapError("Addr on freed page", addr, heap, fn, l); 572 568 573 #if 0574 569 page = mmGetPageOfAddr(addr); 575 570 576 if (! mmIsAddrOnList(page, heap->pages)) 577 return mmPrintHeapError("addr not on heap page", addr, heap, fn, l); 571 if (! mmIsAddrOnGList(page, heap->last_page, (void*) &page->prev - (void*) page)) 572 return mmPrintHeapError("addr not on page of this heap", 573 addr, heap, fn, l); 578 574 579 575 if ( (((long) (((char*) addr) - ((char*) page + SIZE_OF_HEAP_PAGE_HEADER))) 580 576 % heap->size) != 0) 581 577 return mmPrintHeapError("addr unaligned within heap", addr, heap, fn, l); 582 hpage = (memHeapPage) page;583 #endif584 578 return 1; 585 579 } … … 589 583 const char* fn, int l) 590 584 { 585 memHeapPage page = heap->last_page; 586 int where; 587 if (heap->current_page != mmZeroPage) where = 1; 588 else where = -1; 589 590 591 while (page != NULL && mmGetPageOfAddr(addr) != page) 592 { 593 if (page == heap->current_page) where = -1; 594 page = page->prev; 595 } 596 597 if (page == NULL) mmPrintHeapError("addr not from heap", addr, heap, fn, l); 598 591 599 if (flag == MM_HEAP_ADDR_FREE_FLAG) 592 600 { 593 if ( ! mmIsAddrOnList(addr, heap->current_page->current))594 return mmPrintHeapError(" addr not on heapfree list",601 if (where == -1 || ! mmIsAddrOnList(addr, heap->current_page->current)) 602 return mmPrintHeapError("free addr not on a page free list", 595 603 addr, heap, fn, l); 596 604 } 597 605 else if (flag == MM_HEAP_ADDR_USED_FLAG) 598 606 { 599 if ( mmIsAddrOnList(addr, heap->current_page->current))600 return mmPrintHeapError("used addr on heapfree list",607 if (where == 1 && mmIsAddrOnList(addr, heap->current_page->current)) 608 return mmPrintHeapError("used addr on a page free list", 601 609 addr, heap, fn, l); 602 610 } … … 607 615 { 608 616 void* p; 617 int where; 609 618 memHeapPage page; 610 long prev_used_blocks; 611 612 long has_changed = FALSE; 613 long max_blocks = SIZE_OF_HEAP_PAGE / heap->size; 614 if (max_blocks == 0) max_blocks = 1; 615 616 if (heap->current_page == mmZeroPage) return 1; 617 618 // check used_blocks 619 page = heap->current_page; 620 prev_used_blocks = heap->current_page->prev->used_blocks; 619 620 if (heap->last_page == NULL) 621 { 622 if (heap->current_page != mmZeroPage) 623 return mmPrintHeapError("last_page out of sunc", NULL, heap, fn, l); 624 return 1; 625 } 626 627 if (heap->last_page != mmGetPageOfAddr(heap->last_page)) 628 return mmPrintHeapError("last_page not page aligned", heap->last_page, 629 heap, fn, l); 630 631 if (heap->current_page != mmZeroPage && 632 mmGetPageOfAddr(heap->current_page) != heap->current_page) 633 return mmPrintHeapError("current_page not page aligned", 634 heap->current_page, 635 heap, fn, l); 636 637 638 if (heap->last_page->next != mmZeroPage) 639 return mmPrintHeapError("last_page out of sunc", NULL, heap, fn, l); 640 641 /* check page list for cycles */ 642 if (mmGListHasCycle(heap->last_page, (void*) &page->prev - (void*) page)) 643 return mmPrintHeapError("prev chain of heap has cycles", NULL, heap, fn,l); 644 page = heap->last_page; 645 while (page->prev != NULL) page = page->prev; 646 if (mmGListHasCycle(heap->last_page, (void*) &page->next - (void*) page)) 647 return mmPrintHeapError("next chain of heap has cycles", NULL, heap, fn,l); 648 649 /* check prev/next relations of pages */ 650 page = heap->last_page; 621 651 do 622 652 { 623 if (page->prev->next != page || page->next->prev != page) 624 return mmPrintHeapError("page list damaged", NULL, heap, fn, l); 625 if (page->used_blocks == 0) 626 return mmPrintHeapError("No used blocks", NULL, heap, fn, l); 627 if (page->used_blocks < 0 || page->used_blocks > max_blocks) 628 return mmPrintHeapError("used_blocks out of bounds", NULL, heap, fn, l); 629 if (max_blocks - mmListLength(page->current) != page->used_blocks) 630 { 631 fprintf(stderr, "used_blocks wrong: should be %ld, is %ld\n", 632 max_blocks - mmListLength(page->current), page->used_blocks); 633 return mmPrintHeapError("", NULL, heap, fn, l); 634 } 635 if (page->used_blocks > heap->current_page->used_blocks) 636 { 637 fprintf(stderr, "used_blocks %ld larger than %ld", page->used_blocks, 638 heap->current_page->used_blocks); 639 return mmPrintHeapError("", NULL, heap, fn, l); 640 } 641 if (prev_used_blocks < page->used_blocks) 642 { 643 if (has_changed) 644 { 645 fprintf(stderr, "pages not decr order with change at %ld and %ld\n", 646 has_changed, page->used_blocks); 647 return mmPrintHeapError("", NULL, heap, fn, l); 648 } 649 else 650 { 651 has_changed = page->used_blocks; 652 } 653 653 if (page != mmGetPageOfAddr(page)) 654 return mmPrintHeapError("page not aligned", page, heap, fn, l); 655 if (page->prev != NULL && page->prev->next != page) 656 return mmPrintHeapError("page list damaged (prev)", page, heap, fn, l); 657 if (page->next != mmZeroPage && page->next->prev != page) 658 return mmPrintHeapError("page list damaged (next)", page, heap, fn, l); 659 page = page->prev; 660 } 661 while (page != NULL); 662 663 /* check that current_page is on list of pages */ 664 if (heap->current_page != mmZeroPage && 665 ! mmIsAddrOnGList(heap->current_page, heap->last_page, 666 (void*) &page->prev - (void*) page)) 667 return mmPrintHeapError("current_page not in page list", 668 heap->current_page, heap, fn, l); 669 670 /* now check single pages */ 671 page = heap->last_page; 672 if (heap->current_page != mmZeroPage) where = 1; 673 else where = -1; 674 while (page != NULL) 675 { 676 if (page == heap->current_page) where = 0; 677 if (where > 0 && page->used_blocks <= 0) 678 return mmPrintHeapError("used_blocks of page <= 0", page, heap, fn, l); 679 680 if (where >= 0) 681 { 682 if (mmListHasCycle(page->current)) 683 return mmPrintHeapError("current of page has cycle", page, heap, fn, l); 684 685 if (heap->max_blocks - page->used_blocks != mmListLength(page->current)) 686 return mmPrintHeapError("used_blocks of fpage out of sync", 687 page, heap, fn, l); 688 } 689 else 690 { 691 if (page->used_blocks != 1) 692 return mmPrintHeapError("used_blocks of upage not 1", 693 page, heap, fn, l); 694 } 695 696 if (mm_HEAP_DEBUG > 2 && where >= 0) 697 { 654 698 p = page->current; 699 if (mmListHasCycle(p)) 700 return mmPrintHeapError("current list of fpage has cycle", page, 701 heap, fn, l); 655 702 while (p != NULL) 656 703 { 657 704 if (mmGetPageOfAddr(p) != page) 658 return mmPrintHeapError("addr in freelist not on page", 659 p, heap, fn, l); 660 if (!mmDebugCheckSingleHeapAddr(p, heap, fn, l) || 661 !mmDebugCheckHeapAddrContainment(p, heap, MM_HEAP_ADDR_FREE_FLAG, 662 fn, l)) 663 return 0; 705 return mmPrintHeapError("addr not on heap page", p, heap, fn, l); 664 706 p = *((void**) p); 665 707 } 666 708 } 667 prev_used_blocks = page->used_blocks; 668 page = page->next; 669 } 670 while(page != heap->current_page); 671 709 if (where == 0) where = -1; 710 page = page->prev; 711 } 672 712 return 1; 673 713 } … … 678 718 const char* fn, int l) 679 719 { 720 if (mm_HEAP_DEBUG > 2 && ! mmDebugCheckHeap(heap, fn, l)) return 0; 721 680 722 if (! mmDebugCheckSingleHeapAddr(addr, heap, fn, l)) return 0; 681 723 682 if (mm_HEAP_DEBUG > 1) 683 { 684 if (! mmDebugCheckHeap(heap, fn, l)) return 0; 685 } 686 687 if (mm_HEAP_DEBUG > 0) 688 return mmDebugCheckHeapAddrContainment(addr, heap, flag, fn, l); 689 else 690 return 1; 724 return mmDebugCheckHeapAddrContainment(addr, heap, flag, fn, l); 691 725 } 692 726 … … 694 728 { 695 729 void* res; 696 730 697 731 if (mm_HEAP_DEBUG > 1 && ! mmDebugCheckHeap(heap, fn, l)) 698 732 return NULL; 699 _mmAllocHeap(res, heap); 700 701 mmDebugCheckSingleHeapAddr(res, heap, fn, l); 702 733 734 _mmAllocHeap(res, heap, void*); 735 736 if (mm_HEAP_DEBUG > 2) 737 mmDebugCheckHeapAddr(res, heap, MM_HEAP_ADDR_USED_FLAG, fn, l); 738 739 return res; 740 } 741 742 void mmDebugFreeHeap(void* addr, memHeap heap, const char* fn, int l) 743 { 703 744 if (mm_HEAP_DEBUG > 0) 704 mmDebugCheckHeapAddrContainment(res, heap, MM_HEAP_ADDR_USED_FLAG, 705 fn, l); 706 return res; 707 } 708 709 void mmDebugFreeHeap(void* addr, memHeap heap, const char* fn, int l) 710 { 711 mmDebugCheckHeapAddr(addr, heap, MM_HEAP_ADDR_USED_FLAG, fn, l); 712 745 mmDebugCheckHeapAddr(addr, heap, MM_HEAP_ADDR_USED_FLAG, fn, l); 746 713 747 _mmFreeHeap(addr, heap); 714 } 715 716 #endif 748 749 if (mm_HEAP_DEBUG > 2) 750 mmDebugCheckHeapAddr(addr, heap, MM_HEAP_ADDR_FREE_FLAG, fn, l); 751 } 752 753 #endif /* HEAP_DEBUG */ -
Singular/mmisc.c
r3ce7b6 rd6681d 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: mmisc.c,v 1. 19 1999-10-22 09:07:05obachman Exp $ */4 /* $Id: mmisc.c,v 1.20 1999-10-26 15:06:11 obachman Exp $ */ 5 5 6 6 /* … … 39 39 s_heap 40 40 = mmFindInSortedGList(mm_SpecHeaps, 41 ((void* *) &s_heap->next) - ((void**) s_heap),42 ((void* *) &s_heap->size) - ((void**) s_heap),41 ((void*) &s_heap->next) - ((void*) s_heap), 42 ((void*) &s_heap->size) - ((void*) s_heap), 43 43 RealSizeFromSize(size)); 44 44 if (s_heap != NULL) … … 54 54 mm_SpecHeaps = 55 55 mmSortedInsertInGList(mm_SpecHeaps, 56 ((void* *) &s_heap->next) - ((void**) s_heap),57 ((void* *) &s_heap->size) - ((void**) s_heap),56 ((void*) &s_heap->next) - ((void*) s_heap), 57 ((void*) &s_heap->size) - ((void*) s_heap), 58 58 s_heap); 59 59 return s_heap->heap; … … 80 80 memSpecHeap s_heap 81 81 = mmFindInSortedGList(mm_SpecHeaps, 82 ((void* *) &s_heap->next) - ((void**) s_heap),83 ((void* *) &s_heap->size) - ((void**) s_heap),82 ((void*) &s_heap->next) - ((void*) s_heap), 83 ((void*) &s_heap->size) - ((void*) s_heap), 84 84 heap->size); 85 85 if (s_heap == NULL) … … 97 97 mm_SpecHeaps = 98 98 mmRemoveFromGList(mm_SpecHeaps, 99 ((void* *) &s_heap->next) - ((void**) s_heap),99 ((void*) &s_heap->next) - ((void*) s_heap), 100 100 s_heap); 101 101 mmDestroyHeap(&(s_heap->heap)); … … 112 112 mm_TempHeaps = 113 113 mmSortedInsertInGList(mm_TempHeaps, 114 ((void* *) &s_heap->next) - ((void**) s_heap),115 ((void* *) &s_heap->size) - ((void**) s_heap),114 ((void*) &s_heap->next) - ((void*) s_heap), 115 ((void*) &s_heap->size) - ((void*) s_heap), 116 116 s_heap); 117 117 return s_heap->heap; … … 129 129 s_heap = 130 130 mmFindInSortedGList(mm_TempHeaps, 131 ((void* *) &s_heap->next) - ((void**) s_heap),132 ((void* *) &s_heap->size) - ((void**) s_heap),131 ((void*) &s_heap->next) - ((void*) s_heap), 132 ((void*) &s_heap->size) - ((void*) s_heap), 133 133 heap->size); 134 134 if (s_heap == NULL) … … 143 143 mm_TempHeaps = 144 144 mmRemoveFromGList(mm_SpecHeaps, 145 ((void* *) &s_heap->next) - ((void**) s_heap),145 ((void*) &s_heap->next) - ((void*) s_heap), 146 146 s_heap); 147 147 mmDestroyHeap(&(s_heap->heap)); … … 283 283 extern memHeap mm_specHeap; 284 284 285 extern int mmNumberOfAllocatedHeapPages(memHeap heap); 286 extern int mmNumberOfFreeHeapBlocks(memHeap heap); 287 285 288 static void mmPrintHeapStat(memHeap heap, int i) 286 289 { 287 #ifndef HAVE_AUTOMATIC_GC288 290 long l,a; 289 291 if (i >= 0) printf("%d", i); … … 291 293 else if (i== -2) printf("T"); 292 294 printf("\t%ld", heap->size); 293 a = mm ListLength(heap->current);295 a = mmNumberOfFreeHeapBlocks(heap); 294 296 if (heap->size > MAX_HEAP_CHUNK_SIZE) 295 297 { 298 #ifndef HAVE_AUTOMATIC_GC 296 299 l = (int) heap->pages; 297 300 printf("\t%ld\t%d\t%ld\t%ld", … … 302 305 )*100.0)) 303 306 : 0), a, l-a); 307 #endif 304 308 } 305 309 else 306 310 { 307 l = mm ListLength(heap->pages);311 l = mmNumberOfAllocatedHeapPages(heap); 308 312 printf("\t%ld\t%d\t%ld\t%ld", 309 313 l, … … 311 315 ((double) a) 312 316 / 313 ((double) l*(SIZE_OF_ PAGE/heap->size))317 ((double) l*(SIZE_OF_HEAP_PAGE/heap->size)) 314 318 )*100.0)) 315 319 : 0), 316 320 a, 317 l*(SIZE_OF_ PAGE/heap->size) - a);321 l*(SIZE_OF_HEAP_PAGE/heap->size) - a); 318 322 } 319 323 if (heap == mm_specHeap) printf(" *"); … … 321 325 printf(" +"); 322 326 printf("\n"); 323 #endif324 327 fflush(stdout); 325 328 } … … 331 334 long l,a; 332 335 memSpecHeap s_heap; 333 336 337 mmTestHeaps(); 334 338 #ifdef HAVE_SBRK 335 339 printf("Physical:%dk ", (mmMemPhysical()+ 1023)/1024); … … 385 389 #endif 386 390 391 #ifdef HEAP_DEBUG 392 int mmTestHeaps() 393 { 394 int i = -1; 395 396 do 397 { 398 i++; 399 if (! mmCheckHeap(&mm_theList[i])) return 0; 400 } 401 while (mmGetSize(i) < MAX_BLOCK_SIZE); 402 403 return 1; 404 } 405 #endif 406 387 407 388 408 /********************************************************************** … … 479 499 { 480 500 l++; 481 list = *((void**) list + next);501 list = *((void**) (list + next)); 482 502 } 483 503 return l; … … 489 509 490 510 while (*((void**) memList) != NULL) 491 memList = *((void**) memList + next);511 memList = *((void**) (memList + next)); 492 512 493 513 return memList; … … 502 522 { 503 523 if (addr == list) return 1; 504 list = *((void**) list + next);524 list = *((void**) (list + next)); 505 525 } 506 526 return 0; … … 532 552 void* mmSortedInsertInGList(void* list, int next, int int_field, void* element) 533 553 { 534 int el_size = *((int *) ((void**) element + int_field));554 int el_size = *((int *) ((void**)(element + int_field))); 535 555 536 if (list == NULL || *((int *)((void**) list + int_field)) > el_size)537 { 538 *((void**) element + next) = list;556 if (list == NULL || *((int *)((void**)(list + int_field))) > el_size) 557 { 558 *((void**)(element + next)) = list; 539 559 return element; 540 560 } … … 542 562 { 543 563 void* prev = list; 544 void* curr = *((void**) list + next);564 void* curr = *((void**)(list + next)); 545 565 546 while (curr != NULL && *((int *)((void**) curr + int_field)) > el_size)566 while (curr != NULL && *((int *)((void**)(curr + int_field))) > el_size) 547 567 { 548 568 prev = curr; 549 curr = *((void**) curr + next);569 curr = *((void**)(curr + next)); 550 570 } 551 571 assume(prev != NULL); 552 *((void**) prev+ next) = element;553 *((void**) element+ next) = curr;572 *((void**)(prev+ next)) = element; 573 *((void**)(element+ next)) = curr; 554 574 return list; 555 575 } … … 560 580 while (1) 561 581 { 562 if (list == NULL || *((int *)((void**) list + int_field)) > what)582 if (list == NULL || *((int *)((void**) (list + int_field))) > what) 563 583 return NULL; 564 if (*((int *)((void**) list + int_field)) == what) return list;565 list = *((void**) list + next);584 if (*((int *)((void**)(list + int_field))) == what) return list; 585 list = *((void**) (list + next)); 566 586 } 567 587 } -
Singular/mmtables.c
r3ce7b6 rd6681d 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: mmtables.c,v 1. 5 1999-10-19 14:55:40obachman Exp $ */4 /* $Id: mmtables.c,v 1.6 1999-10-26 15:06:12 obachman Exp $ */ 5 5 6 6 /* … … 20 20 #include "mmpage.h" 21 21 22 #define MAX_INDEX ((MAX_BLOCK_SIZE - 1) >> 2) 22 23 23 #define MAX_INDEX ((MAX_BLOCK_SIZE - 1) >> 2) 24 #define HALF_MAX_BLOCK_SIZE (((MAX_BLOCK_SIZE) / 8)*4) 25 #define QUARTER_MAX_BLOCK_SIZE (((MAX_BLOCK_SIZE) / 16)*4) 26 #define EIGHTS_MAX_BLOCK_SIZE (((MAX_BLOCK_SIZE) / 32)*4) 24 #ifdef ALIGN_8 27 25 28 const size_t mm_mcbSizesAlign8 [] = 26 /* make sure these are all divisible by 8 */ 27 #define HALF_MAX_BLOCK_SIZE (((MAX_BLOCK_SIZE) / 16)*8) 28 #define QUARTER_MAX_BLOCK_SIZE (((MAX_BLOCK_SIZE) / 32)*8) 29 #define EIGHTS_MAX_BLOCK_SIZE (((MAX_BLOCK_SIZE) / 64)*8) 30 31 const size_t mm_mcbSizesAlign [] = 29 32 { 8, 16, 24, 32, 30 33 40, 48, 56, 64, … … 38 41 HALF_MAX_BLOCK_SIZE + QUARTER_MAX_BLOCK_SIZE + EIGHTS_MAX_BLOCK_SIZE, 39 42 MAX_BLOCK_SIZE}; 40 const size_t mm_mcbSizesAlign4 [] = 43 44 #else 45 46 #define HALF_MAX_BLOCK_SIZE (((MAX_BLOCK_SIZE) / 8)*4) 47 #define QUARTER_MAX_BLOCK_SIZE (((MAX_BLOCK_SIZE) / 16)*4) 48 #define EIGHTS_MAX_BLOCK_SIZE (((MAX_BLOCK_SIZE) / 32)*4) 49 50 const size_t mm_mcbSizesAlign [] = 41 51 { 8, 12, 16, 20, 42 52 24, 28, 32, … … 52 62 MAX_BLOCK_SIZE}; 53 63 54 char mm_IndiciesAlign8[MAX_INDEX + 1]; 55 char mm_IndiciesAlign4[MAX_INDEX + 1]; 64 #endif 56 65 57 int mmGetBinaryIndexAlign8( size_t size )58 {59 int j;60 61 if (size<81)62 {63 if (size<41)64 {65 if (size<25)66 {67 if(size<17)68 {69 if (size<9) j= 0;70 else j= 1;71 }72 else /*17..24*/73 {74 j= 2;75 }76 }77 else/*25..40*/78 {79 if(size<33)80 {81 j= 3;82 }83 else /*33..40*/84 {85 j= 4;86 }87 }88 }89 else/*41..80*/90 {91 if(size<57)92 {93 if (size<49) j= 5;94 else j= 6;95 }96 else /*57..80*/97 {98 if (size<65) j= 7;99 else j= 8;100 }101 }102 }103 else/*81..1024*/104 {105 if(size<161)106 {107 if (size<113)108 {109 if (size<97) j= 9;110 else j= 10;111 }112 else /*113..160*/113 {114 if (size<129) j= 11;115 else j= 12;116 }117 }118 else/*161..1024*/119 {120 if (size<257)121 {122 if (size<225)123 {124 if (size<193) j= 13;125 else j= 14;126 }127 else j= 15;128 }129 else/*257..1024*/130 {131 if(size<=MAX_BLOCK_SIZE)132 {133 if(size<=HALF_MAX_BLOCK_SIZE) j= 16;134 else j= 17;135 }136 else137 j= -1;138 }139 }140 }141 return j;142 }143 144 int mmGetBinaryIndex( size_t size )145 {146 int j;147 if (size<161)148 {149 if (size<41)150 {151 if (size<21)152 {153 if(size<13)154 {155 if (size<9) j= 0;156 else j= 1;157 }158 else /*13..20*/159 {160 if (size<17) j= 2;161 else j= 3;162 }163 }164 else/*21..40*/165 {166 if(size<29)167 {168 if (size<25) j= 4;169 else j= 5;170 }171 else /*29..40*/172 {173 if (size<33) j= 6;174 else j= 7;175 }176 }177 }178 else/*41..160*/179 {180 if (size<81)181 {182 if(size<57)183 {184 if (size<49) j= 8;185 else j= 9;186 }187 else /*57..80*/188 {189 if (size<65) j= 10;190 else j= 11;191 }192 }193 else/*81..160*/194 {195 if(size<113)196 {197 if (size<97) j= 12;198 else j= 13;199 }200 else /*113..160*/201 {202 if (size<129) j= 14;203 else j= 15;204 }205 }206 }207 }208 else/*161..1024*/209 {210 if (size<257)211 {212 if (size<225)213 {214 if (size<193) j= 16;215 else j= 17;216 }217 else j= 18;218 }219 else/*257..1024*/220 {221 if(size<=MAX_BLOCK_SIZE)222 {223 if(size<=HALF_MAX_BLOCK_SIZE) j= 19;224 else j= 20;225 }226 else227 j= -1;228 }229 }230 return j;231 }232 66 233 67 int GetIndex(size_t size, const size_t* size_table) … … 248 82 249 83 250 void mmInitIndexTable(char* index_table, const size_t* size_table, 251 int (*GetIndexFnc)(size_t size)) 84 void mmInitIndexTable(char* index_table, const size_t* size_table) 252 85 { 253 86 unsigned int i; … … 256 89 for (i=0; i<=MAX_INDEX; i++) 257 90 index_table[i] = GetIndex((size_t) i*4 + 1, size_table); 258 259 /* Check what we did */260 if (GetIndexFnc != NULL)261 {262 for (i=1; i<=MAX_BLOCK_SIZE + 5; i++)263 {264 unsigned int t_index, b_index;265 t_index = (i <= MAX_BLOCK_SIZE ? index_table[(i-1) >> 2] : -1);266 b_index = GetIndexFnc(i);267 268 if (t_index != b_index)269 {270 fprintf(stderr, "Error in mmInitIndexTable for size %d\n", i);271 GetIndexFnc(i);272 exit(1);273 }274 }275 }276 91 } 277 92 … … 289 104 } 290 105 291 #if 0292 void OutputIndexTable(char* index_table)293 {294 int i = -1;295 int l= -1;296 printf("const char mm_IndexTable[] = {\n");297 do298 {299 i++;300 l++;301 printf("%d,", index_table[i]);302 if (l==15) { printf("\n"); l=0; }303 }304 while (mmGetSize(i) < MAX_BLOCK_SIZE)305 printf("%d};\n", index_table[i]);306 }307 #endif308 309 106 void OutputTheListTable(const size_t *mm_mcbSizes) 310 107 { … … 317 114 printf("{NULL, NULL, NULL, %d},\n", mm_mcbSizes[i]); 318 115 #else 319 printf("{mmZeroPage, %d},\n", mm_mcbSizes[i]); 116 printf("{mmZeroPage, NULL, %d, %d},\n", mm_mcbSizes[i], 117 SIZE_OF_HEAP_PAGE/mm_mcbSizes[i]); 320 118 #endif 321 119 } … … 323 121 printf("{NULL, NULL, NULL, %d}\n};\n", mm_mcbSizes[i]); 324 122 #else 325 printf("{mmZeroPage, %d}\n};\n", mm_mcbSizes[i]); 123 printf("{mmZeroPage, NULL, %d, %d}\n};\n", mm_mcbSizes[i], 124 SIZE_OF_HEAP_PAGE/mm_mcbSizes[i]); 326 125 #endif 327 126 printf("#else /* MDEBUG */\n"); … … 331 130 printf("{NULL, NULL, NULL, %d},\n", RealSizeFromSize(mm_mcbSizes[i])); 332 131 #else 333 printf("{mmZeroPage, %d},\n",RealSizeFromSize(mm_mcbSizes[i])); 132 printf("{mmZeroPage, NULL, %d, %d},\n", RealSizeFromSize(mm_mcbSizes[i]), 133 SIZE_OF_HEAP_PAGE/RealSizeFromSize(mm_mcbSizes[i])); 334 134 #endif 335 135 } … … 337 137 printf("{NULL, NULL, NULL, %d}\n};\n", RealSizeFromSize(mm_mcbSizes[i])); 338 138 #else 339 printf("{mmZeroPage, %d}\n};\n",RealSizeFromSize(mm_mcbSizes[i])); 139 printf("{mmZeroPage, NULL, %d, %d}\n};\n", RealSizeFromSize(mm_mcbSizes[i]), 140 SIZE_OF_HEAP_PAGE/RealSizeFromSize(mm_mcbSizes[i])); 340 141 #endif 341 142 printf("#endif /* ! MDEBUG */\n"); … … 353 154 int main() 354 155 { 355 #if 0 356 mmInitIndexTable(mm_IndiciesAlign8, mm_mcbSizesAlign8, 357 mmGetBinaryIndexAlign8); 358 mmInitIndexTable(mm_IndiciesAlign4, mm_mcbSizesAlign4, 359 mmGetBinaryIndex); 360 #else 361 mmInitIndexTable(mm_IndiciesAlign8, mm_mcbSizesAlign8, 362 NULL); 363 mmInitIndexTable(mm_IndiciesAlign4, mm_mcbSizesAlign4, 364 NULL); 365 #endif 156 char mm_IndiciesAlign[MAX_INDEX + 1]; 157 mmInitIndexTable(mm_IndiciesAlign, mm_mcbSizesAlign); 366 158 367 159 printf("#ifndef MM_TABLES_INC\n#define MM_TABLES_INC\n"); … … 371 163 #include \"mmprivate.h\" 372 164 "); 165 printf("\n\n"); 373 166 #ifdef HAVE_AUTOMATIC_GC 374 167 printf("struct sip_memHeapPage mmZeroPage[] = {{0, NULL, NULL, NULL}};\n"); 168 printf("\n"); 375 169 #endif 376 printf("#ifdef ALIGN_8\n"); 377 OutputIndexTable(mm_IndiciesAlign8); 378 OutputSizeTable(mm_mcbSizesAlign8); 379 OutputTheListTable(mm_mcbSizesAlign8); 380 printf("#else /* ! ALIGN_8 */\n"); 381 OutputIndexTable(mm_IndiciesAlign4); 382 OutputSizeTable(mm_mcbSizesAlign4); 383 OutputTheListTable(mm_mcbSizesAlign4); 384 printf("#endif /* ALIGN_8 */\n"); 170 OutputIndexTable(mm_IndiciesAlign); 171 printf("\n"); 172 OutputSizeTable(mm_mcbSizesAlign); 173 printf("\n"); 174 OutputTheListTable(mm_mcbSizesAlign); 175 printf("\n"); 385 176 printf("#endif /* MM_TABLES_INC*/\n"); 386 177 return 0; -
Singular/mpr_base.cc
r3ce7b6 rd6681d 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: mpr_base.cc,v 1.1 2 1999-10-22 11:14:15obachman Exp $ */4 /* $Id: mpr_base.cc,v 1.13 1999-10-26 15:06:12 obachman Exp $ */ 5 5 6 6 /* … … 344 344 poly monomAt( poly p, int i ); 345 345 346 #if HAVE_ASO == 1346 #ifndef ASO_GENERATE 347 347 //<- 348 348 … … 3150 3150 //----------------------------------------------------------------------------- 3151 3151 3152 #endif // ! HAVE_ASO3152 #endif // ! ASO_GENERATE 3153 3153 3154 3154 // local Variables: *** -
Singular/pProcs.cc
r3ce7b6 rd6681d 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: pProcs.cc,v 1.1 0 1999-10-25 08:32:17obachman Exp $ */4 /* $Id: pProcs.cc,v 1.11 1999-10-26 15:06:13 obachman Exp $ */ 5 5 /* 6 6 * ABSTRACT - Routines for primitive poly arithmetic … … 14 14 15 15 // Define to us COMP_MACROS 16 // #define HAVE_COMP_MACROS 16 #define HAVE_COMP_MACROS 17 18 // #define HAVE_CHAR_P 19 20 #ifdef HAVE_CHAR_P 21 #include "modulop.h" 22 23 #undef nDelete 24 #define nDelete(n) 25 #define nMult(n1, n2) npMultM(n1, n2) 26 #define nAdd(n1, n2) npAddM(n1, n2) 27 #define nSub(n1, n2) npSubM(n1, n2) 28 #define nEqual(n1, n2) npEqualM(n1, n2) 29 #define nIsZero(n) npIsZeroM(n) 30 #endif 17 31 18 32 // Define to enable tests in this file 19 #define DEBUG_THIS33 // #define DEBUG_THIS 20 34 21 35 #if ! (defined(DEBUG_THIS) || (defined(PDEBUG) && PDEBUG > 0)) -
Singular/polys-impl.h
r3ce7b6 rd6681d 4 4 * Computer Algebra System SINGULAR * 5 5 ****************************************/ 6 /* $Id: polys-impl.h,v 1.3 8 1999-10-25 08:32:18obachman Exp $ */6 /* $Id: polys-impl.h,v 1.39 1999-10-26 15:06:13 obachman Exp $ */ 7 7 8 8 /*************************************************************** … … 489 489 // Divisiblity tests based on Short Exponent Vectors 490 490 // define to enable debugging of this 491 #define PDIV_DEBUG491 // #define PDIV_DEBUG 492 492 #if defined(PDEBUG) && ! defined(PDIV_DEBUG) 493 493 #define PDIV_DEBUG
Note: See TracChangeset
for help on using the changeset viewer.