comparison src/alloc.c @ 52453:62fcd311bb98

Use long instead of int when casting ABLOCKS_BUSY to avoid warning.
author Andreas Schwab <schwab@suse.de>
date Sun, 07 Sep 2003 19:15:32 +0000
parents 695cf19ef79e
children a3fd06a8c844
comparison
equal deleted inserted replaced
52452:b6ac55680b20 52453:62fcd311bb98
709 /* Pointer to the (not necessarily aligned) malloc block. */ 709 /* Pointer to the (not necessarily aligned) malloc block. */
710 #ifdef HAVE_POSIX_MEMALIGN 710 #ifdef HAVE_POSIX_MEMALIGN
711 #define ABLOCKS_BASE(abase) (abase) 711 #define ABLOCKS_BASE(abase) (abase)
712 #else 712 #else
713 #define ABLOCKS_BASE(abase) \ 713 #define ABLOCKS_BASE(abase) \
714 (1 & (int) ABLOCKS_BUSY (abase) ? abase : ((void**)abase)[-1]) 714 (1 & (long) ABLOCKS_BUSY (abase) ? abase : ((void**)abase)[-1])
715 #endif 715 #endif
716 716
717 /* The list of free ablock. */ 717 /* The list of free ablock. */
718 static struct ablock *free_ablock; 718 static struct ablock *free_ablock;
719 719
790 { 790 {
791 abase->blocks[i].abase = abase; 791 abase->blocks[i].abase = abase;
792 abase->blocks[i].x.next_free = free_ablock; 792 abase->blocks[i].x.next_free = free_ablock;
793 free_ablock = &abase->blocks[i]; 793 free_ablock = &abase->blocks[i];
794 } 794 }
795 ABLOCKS_BUSY (abase) = (struct ablocks *) aligned; 795 ABLOCKS_BUSY (abase) = (struct ablocks *) (long) aligned;
796 796
797 eassert (0 == ((EMACS_UINT)abase) % BLOCK_ALIGN); 797 eassert (0 == ((EMACS_UINT)abase) % BLOCK_ALIGN);
798 eassert (ABLOCK_ABASE (&abase->blocks[3]) == abase); /* 3 is arbitrary */ 798 eassert (ABLOCK_ABASE (&abase->blocks[3]) == abase); /* 3 is arbitrary */
799 eassert (ABLOCK_ABASE (&abase->blocks[0]) == abase); 799 eassert (ABLOCK_ABASE (&abase->blocks[0]) == abase);
800 eassert (ABLOCKS_BASE (abase) == base); 800 eassert (ABLOCKS_BASE (abase) == base);
801 eassert (aligned == (int)ABLOCKS_BUSY (abase)); 801 eassert (aligned == (long) ABLOCKS_BUSY (abase));
802 } 802 }
803 803
804 abase = ABLOCK_ABASE (free_ablock); 804 abase = ABLOCK_ABASE (free_ablock);
805 ABLOCKS_BUSY (abase) = (struct ablocks *) (2 + (int) ABLOCKS_BUSY (abase)); 805 ABLOCKS_BUSY (abase) = (struct ablocks *) (2 + (long) ABLOCKS_BUSY (abase));
806 val = free_ablock; 806 val = free_ablock;
807 free_ablock = free_ablock->x.next_free; 807 free_ablock = free_ablock->x.next_free;
808 808
809 #if GC_MARK_STACK && !defined GC_MALLOC_CHECK 809 #if GC_MARK_STACK && !defined GC_MALLOC_CHECK
810 if (val && type != MEM_TYPE_NON_LISP) 810 if (val && type != MEM_TYPE_NON_LISP)
832 #endif 832 #endif
833 /* Put on free list. */ 833 /* Put on free list. */
834 ablock->x.next_free = free_ablock; 834 ablock->x.next_free = free_ablock;
835 free_ablock = ablock; 835 free_ablock = ablock;
836 /* Update busy count. */ 836 /* Update busy count. */
837 ABLOCKS_BUSY (abase) = (struct ablocks *) (-2 + (int) ABLOCKS_BUSY (abase)); 837 ABLOCKS_BUSY (abase) = (struct ablocks *) (-2 + (long) ABLOCKS_BUSY (abase));
838 838
839 if (2 > (int) ABLOCKS_BUSY (abase)) 839 if (2 > (long) ABLOCKS_BUSY (abase))
840 { /* All the blocks are free. */ 840 { /* All the blocks are free. */
841 int i = 0, aligned = (int) ABLOCKS_BUSY (abase); 841 int i = 0, aligned = (long) ABLOCKS_BUSY (abase);
842 struct ablock **tem = &free_ablock; 842 struct ablock **tem = &free_ablock;
843 struct ablock *atop = &abase->blocks[aligned ? ABLOCKS_SIZE : ABLOCKS_SIZE - 1]; 843 struct ablock *atop = &abase->blocks[aligned ? ABLOCKS_SIZE : ABLOCKS_SIZE - 1];
844 844
845 while (*tem) 845 while (*tem)
846 { 846 {