~ubuntu-branches/ubuntu/utopic/fftw3/utopic

« back to all changes in this revision

Viewing changes to libbench2/util.c

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2011-12-14 13:21:22 UTC
  • mfrom: (3.1.5 sid)
  • Revision ID: package-import@ubuntu.com-20111214132122-l4avyl2kkr7vq5aj
Tags: 3.3-1ubuntu1
* Merge with Debian; remaining changes:
  - Revert the ARM workaround.

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
{
51
51
     return drand48() - 0.5;
52
52
}
 
53
#  if defined(HAVE_DECL_SRAND48) && !HAVE_DECL_SRAND48
 
54
extern void srand48(long);
 
55
#  endif
53
56
void bench_srand(int seed)
54
57
{
55
58
     srand48(seed);
180
183
     void *p;
181
184
     if (n == 0) n = 1;
182
185
 
183
 
#if defined(WITH_OUR_MALLOC16) && (MIN_ALIGNMENT == 16)
184
 
     /* Our own 16-byte aligned malloc/free.  Assumes sizeof(void*) is
 
186
#if defined(WITH_OUR_MALLOC)
 
187
     /* Our own aligned malloc/free.  Assumes sizeof(void*) is
185
188
        a power of two <= 8 and that malloc is at least
186
189
        sizeof(void*)-aligned.  Assumes size_t = uintptr_t.  */
187
190
     {
188
191
          void *p0;
189
 
          if ((p0 = malloc(n + 16))) {
190
 
               p = (void *) (((size_t) p0 + 16) & (~((size_t) 15)));
 
192
          if ((p0 = malloc(n + MIN_ALIGNMENT))) {
 
193
               p = (void *) (((size_t) p0 + MIN_ALIGNMENT) & (~((size_t) (MIN_ALIGNMENT - 1))));
191
194
               *((void **) p - 1) = p0;
192
195
          }
193
196
          else
194
197
               p = (void *) 0;
195
198
     }
196
 
#    define OUR_FREE16     
197
199
#elif defined(HAVE_MEMALIGN)
198
200
     p = memalign(MIN_ALIGNMENT, n);
199
201
#elif defined(HAVE_POSIX_MEMALIGN)
217
219
 
218
220
void bench_free(void *p)
219
221
{
220
 
#ifdef OUR_FREE16
 
222
#ifdef WITH_OUR_MALLOC
221
223
     if (p) free(*((void **) p - 1));
222
224
#else
223
225
     real_free(p);