ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/kpx_cpu/sheepshaver_glue.cpp
(Generate patch)

Comparing SheepShaver/src/kpx_cpu/sheepshaver_glue.cpp (file contents):
Revision 1.30 by gbeauche, 2004-02-24T11:12:54Z vs.
Revision 1.31 by gbeauche, 2004-02-24T14:09:12Z

# Line 40 | Line 40
40   #include "ether.h"
41  
42   #include <stdio.h>
43 + #include <stdlib.h>
44  
45   #if ENABLE_MON
46   #include "mon.h"
# Line 167 | Line 168 | void *operator new(size_t size)
168   {
169          void *p;
170  
171 <        /* XXX: try different approaches */
171 > #if defined(HAVE_POSIX_MEMALIGN)
172          if (posix_memalign(&p, 16, size) != 0)
173                  throw std::bad_alloc();
174 + #elif defined(HAVE_MEMALIGN)
175 +        p = memalign(16, size);
176 + #elif defined(HAVE_VALLOC)
177 +        p = valloc(size); // page-aligned!
178 + #else
179 +        /* XXX: handle padding ourselves */
180 +        p = malloc(size);
181 + #endif
182  
183          return p;
184   }
185  
186   void operator delete(void *p)
187   {
188 + #if defined(HAVE_MEMALIGN) || defined(HAVE_VALLOC)
189 + #if defined(__GLIBC__)
190 +        // this is known to work only with GNU libc
191 +        free(p);
192 + #endif
193 + #else
194          free(p);
195 + #endif
196   }
197  
198   sheepshaver_cpu::sheepshaver_cpu()

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines