Changeset 504


Ignore:
Timestamp:
Apr 18, 2011, 3:03:52 PM (6 years ago)
Author:
sam
Message:

lisp: always align the lisp allocator results, even on x86 or architectures
that have hardware realignment. Get rid of now useless bus_type.h.

Location:
abuse/trunk
Files:
1 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • abuse/trunk/osx/abuse.xcodeproj/project.pbxproj

    r481 r504  
    149149                B99CE1640D833D8F00E42436 /* automap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = automap.cpp; sourceTree = "<group>"; };
    150150                B99CE1650D833D8F00E42436 /* automap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = automap.h; sourceTree = "<group>"; };
    151                 B99CE1660D833D8F00E42436 /* bus_type.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = bus_type.h; sourceTree = "<group>"; };
    152151                B99CE1670D833D8F00E42436 /* cache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cache.cpp; sourceTree = "<group>"; };
    153152                B99CE1680D833D8F00E42436 /* cache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = cache.h; sourceTree = "<group>"; };
     
    444443                                B99CE1640D833D8F00E42436 /* automap.cpp */,
    445444                                B99CE1650D833D8F00E42436 /* automap.h */,
    446                                 B99CE1660D833D8F00E42436 /* bus_type.h */,
    447445                                B99CE1670D833D8F00E42436 /* cache.cpp */,
    448446                                B99CE1680D833D8F00E42436 /* cache.h */,
  • abuse/trunk/src/Makefile.am

    r481 r504  
    5555    crc.cpp crc.h \
    5656    gamma.cpp gamma.h \
    57     bus_type.h id.h netface.h isllist.h sbar.h \
     57    id.h netface.h isllist.h sbar.h \
    5858    nfserver.h exitproc.h \
    5959    \
  • abuse/trunk/src/lcache.cpp

    r495 r504  
    1919#include "lisp.h"
    2020#include "specs.h"
    21 #include "bus_type.h"
    2221
    2322size_t block_size(LObject *level)  // return size needed to recreate this block
  • abuse/trunk/src/lisp/lisp.cpp

    r502 r504  
    1818
    1919#define TYPE_CHECKING 1
    20 #include "bus_type.h"
    2120
    2221#include "lisp.h"
     
    4847
    4948uint8_t *space[4], *free_space[4];
    50 int space_size[4], print_level=0, trace_level=0, trace_print_level=1000;
     49size_t space_size[4];
     50int print_level = 0, trace_level = 0, trace_print_level = 1000;
    5151int total_user_functions;
    5252
     
    172172}
    173173
    174 static int get_free_size(int which_space)
    175 {
    176     return space_size[which_space]
    177             - (free_space[which_space] - space[which_space]);
    178 }
    179 
    180 void *lmalloc(int size, int which_space)
    181 {
    182 #ifdef WORD_ALIGN
    183   size=(size+3)&(~3);
    184 #endif
    185 
    186   if (size > get_free_size(which_space))
    187   {
    188     int fart = 1;
    189 
    190     if (which_space == PERM_SPACE || which_space == TMP_SPACE)
    191     {
    192       collect_space(which_space);
    193       if (size <= get_free_size(which_space))
    194         fart = 0;
    195     }
    196 
    197     if (fart)
    198     {
    199       lbreak("lisp: cannot malloc %d bytes in space #%d\n", size, which_space);
    200       exit(0);
    201     }
    202   }
    203   void *ret = (void *)free_space[which_space];
    204   free_space[which_space] += size;
    205   return ret;
     174static size_t get_free_size(int which_space)
     175{
     176    size_t used = free_space[which_space] - space[which_space];
     177    return space_size[which_space] > used ? space_size[which_space] - used : 0;
     178}
     179
     180static void *lmalloc(size_t size, int which_space)
     181{
     182    // Align allocation
     183    size = (size + sizeof(intptr_t) - 1) & ~(sizeof(intptr_t) - 1);
     184
     185    // Collect garbage if necessary
     186    if (size > get_free_size(which_space))
     187    {
     188        if (which_space == PERM_SPACE || which_space == TMP_SPACE)
     189            collect_space(which_space);
     190
     191        if (size > get_free_size(which_space))
     192        {
     193            lbreak("lisp: cannot find %d bytes in space #%d\n",
     194                   size, which_space);
     195            exit(0);
     196        }
     197    }
     198
     199    void *ret = (void *)free_space[which_space];
     200    free_space[which_space] += size;
     201    return ret;
    206202}
    207203
     
    31473143}
    31483144
    3149 void resize_perm(int new_size)
     3145void resize_perm(size_t new_size)
    31503146{
    31513147  if (new_size<((char *)free_space[PERM_SPACE]-(char *)space[PERM_SPACE]))
     
    31613157}
    31623158
    3163 void resize_tmp(int new_size)
     3159void resize_tmp(size_t new_size)
    31643160{
    31653161  if (new_size<((char *)free_space[TMP_SPACE]-(char *)space[TMP_SPACE]))
  • abuse/trunk/src/lisp/lisp.h

    r501 r504  
    218218void *eval_block(void *list);
    219219void *assoc(void *item, void *list);
    220 void resize_tmp(int new_size);
    221 void resize_perm(int new_size);
     220void resize_tmp(size_t new_size);
     221void resize_perm(size_t new_size);
    222222
    223223void push_onto_list(void *object, void *&list);
     
    244244
    245245extern uint8_t *space[4], *free_space[4];
    246 extern int space_size[4];
     246extern size_t space_size[4];
    247247void *nth(int num, void *list);
    248248int32_t lisp_atan2(int32_t dy, int32_t dx);
Note: See TracChangeset for help on using the changeset viewer.