OLD | NEW |
1 // Copyright (c) 2005, Google Inc. | 1 // Copyright (c) 2005, Google Inc. |
2 // All rights reserved. | 2 // All rights reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
6 // met: | 6 // met: |
7 // | 7 // |
8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
(...skipping 28 matching lines...) Expand all Loading... |
39 // the bits every time. | 39 // the bits every time. |
40 // | 40 // |
41 // The BITS parameter should be the number of bits required to hold | 41 // The BITS parameter should be the number of bits required to hold |
42 // a page number. E.g., with 32 bit pointers and 4K pages (i.e., | 42 // a page number. E.g., with 32 bit pointers and 4K pages (i.e., |
43 // page offset fits in lower 12 bits), BITS == 20. | 43 // page offset fits in lower 12 bits), BITS == 20. |
44 | 44 |
45 #ifndef TCMALLOC_PAGEMAP_H_ | 45 #ifndef TCMALLOC_PAGEMAP_H_ |
46 #define TCMALLOC_PAGEMAP_H_ | 46 #define TCMALLOC_PAGEMAP_H_ |
47 | 47 |
48 #include "config.h" | 48 #include "config.h" |
| 49 |
| 50 #include <stddef.h> // for NULL, size_t |
| 51 #include <string.h> // for memset |
49 #if defined HAVE_STDINT_H | 52 #if defined HAVE_STDINT_H |
50 #include <stdint.h> | 53 #include <stdint.h> |
51 #elif defined HAVE_INTTYPES_H | 54 #elif defined HAVE_INTTYPES_H |
52 #include <inttypes.h> | 55 #include <inttypes.h> |
53 #else | 56 #else |
54 #include <sys/types.h> | 57 #include <sys/types.h> |
55 #endif | 58 #endif |
56 #ifdef WIN32 | 59 #ifdef WIN32 |
57 // TODO(jar): This is not needed when TCMalloc_PageMap1_LazyCommit has an API | 60 // TODO(jar): This is not needed when TCMalloc_PageMap1_LazyCommit has an API |
58 // supporting commit and reservation of memory. | 61 // supporting commit and reservation of memory. |
59 #include "common.h" | 62 #include "common.h" |
60 #endif | 63 #endif |
61 | 64 |
62 #include "internal_logging.h" | 65 #include "internal_logging.h" // for ASSERT |
63 | 66 |
64 // Single-level array | 67 // Single-level array |
65 template <int BITS> | 68 template <int BITS> |
66 class TCMalloc_PageMap1 { | 69 class TCMalloc_PageMap1 { |
67 private: | 70 private: |
68 static const int LENGTH = 1 << BITS; | 71 static const int LENGTH = 1 << BITS; |
69 | 72 |
70 void** array_; | 73 void** array_; |
71 | 74 |
72 public: | 75 public: |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 } | 515 } |
513 // Advance to next interior entry | 516 // Advance to next interior entry |
514 k = ((k >> LEAF_BITS) + 1) << LEAF_BITS; | 517 k = ((k >> LEAF_BITS) + 1) << LEAF_BITS; |
515 } | 518 } |
516 } | 519 } |
517 return NULL; | 520 return NULL; |
518 } | 521 } |
519 }; | 522 }; |
520 | 523 |
521 #endif // TCMALLOC_PAGEMAP_H_ | 524 #endif // TCMALLOC_PAGEMAP_H_ |
OLD | NEW |