NEURON
listimpl.cpp
Go to the documentation of this file.
1 #ifdef HAVE_CONFIG_H
2 #include <../../config.h>
3 #endif
4 /*
5  * Copyright (c) 1991 Stanford University
6  * Copyright (c) 1991 Silicon Graphics, Inc.
7  *
8  * Permission to use, copy, modify, distribute, and sell this software and
9  * its documentation for any purpose is hereby granted without fee, provided
10  * that (i) the above copyright notices and this permission notice appear in
11  * all copies of the software and related documentation, and (ii) the names of
12  * Stanford and Silicon Graphics may not be used in any advertising or
13  * publicity relating to the software without the specific, prior written
14  * permission of Stanford and Silicon Graphics.
15  *
16  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
18  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
19  *
20  * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR
21  * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
22  * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
23  * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
24  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
25  * OF THIS SOFTWARE.
26  */
27 
28 /*
29  * Support routines for lists.
30  */
31 
32 #include <OS/list.h>
33 #include <stdio.h>
34 #include <stdlib.h>
35 
36 implementList(__AnyPtrList,__AnyPtr)
37 
38 static long ListImpl_best_new_sizes[] = {
39  48, 112, 240, 496, 1008, 2032, 4080, 8176,
40  16368, 32752, 65520, 131056, 262128, 524272, 1048560,
41  2097136, 4194288, 8388592, 16777200, 33554416, 67108848,
42  134217712, 268435440, 536870896, 1073741808, 2147483632
43 };
44 
45 long ListImpl_best_new_count(long count, unsigned int size, unsigned int m) {
46  for (int i = 0; i < sizeof(ListImpl_best_new_sizes)/sizeof(long); i++) {
47  if (count * size < ListImpl_best_new_sizes[i]) {
48  return ListImpl_best_new_sizes[i] / size;
49  }
50  }
51  return count*m;
52 }
53 
54 void ListImpl_range_error(long i) {
55 #if defined(WIN32) || MAC
56  printf("internal error: list index %ld out of range\n", i);
57 #else
58  fprintf(stderr, "internal error: list index %ld out of range\n", i);
59 #endif
60  abort();
61 }
void * __AnyPtr
Definition: list.h:143
#define printf
Definition: mwprefix.h:26
implementList(__AnyPtrList, __AnyPtr) static long ListImpl_best_new_sizes[]
fprintf(stderr, "Don't know the location of params at %p\, pp)
long ListImpl_best_new_count(long count, unsigned int size, unsigned int m)
Definition: listimpl.cpp:45
#define i
Definition: md1redef.h:12
void ListImpl_range_error(long i)
Definition: listimpl.cpp:54