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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 void InitialPreMMapHook(const void* start, | 120 void InitialPreMMapHook(const void* start, |
121 size_t size, | 121 size_t size, |
122 int protection, | 122 int protection, |
123 int flags, | 123 int flags, |
124 int fd, | 124 int fd, |
125 off_t offset) { | 125 off_t offset) { |
126 perftools_pthread_once(&once, &RemoveInitialHooksAndCallInitializers); | 126 perftools_pthread_once(&once, &RemoveInitialHooksAndCallInitializers); |
127 MallocHook::InvokePreMmapHook(start, size, protection, flags, fd, offset); | 127 MallocHook::InvokePreMmapHook(start, size, protection, flags, fd, offset); |
128 } | 128 } |
129 | 129 |
130 void InitialPreSbrkHook(ptrdiff_t increment) { | 130 void InitialPreSbrkHook(std::ptrdiff_t increment) { |
131 perftools_pthread_once(&once, &RemoveInitialHooksAndCallInitializers); | 131 perftools_pthread_once(&once, &RemoveInitialHooksAndCallInitializers); |
132 MallocHook::InvokePreSbrkHook(increment); | 132 MallocHook::InvokePreSbrkHook(increment); |
133 } | 133 } |
134 | 134 |
135 // This function is called at most once by one of the above initial malloc | 135 // This function is called at most once by one of the above initial malloc |
136 // hooks. It removes all initial hooks and initializes all other clients that | 136 // hooks. It removes all initial hooks and initializes all other clients that |
137 // want to get control at the very first memory allocation. The initializers | 137 // want to get control at the very first memory allocation. The initializers |
138 // may assume that the initial malloc hooks have been removed. The initializers | 138 // may assume that the initial malloc hooks have been removed. The initializers |
139 // may set up malloc hooks and allocate memory. | 139 // may set up malloc hooks and allocate memory. |
140 void RemoveInitialHooksAndCallInitializers() { | 140 void RemoveInitialHooksAndCallInitializers() { |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 void MallocHook::InvokeMremapHookSlow(const void* result, | 574 void MallocHook::InvokeMremapHookSlow(const void* result, |
575 const void* old_addr, | 575 const void* old_addr, |
576 size_t old_size, | 576 size_t old_size, |
577 size_t new_size, | 577 size_t new_size, |
578 int flags, | 578 int flags, |
579 const void* new_addr) { | 579 const void* new_addr) { |
580 INVOKE_HOOKS(MremapHook, mremap_hooks_, (result, old_addr, old_size, new_size, | 580 INVOKE_HOOKS(MremapHook, mremap_hooks_, (result, old_addr, old_size, new_size, |
581 flags, new_addr)); | 581 flags, new_addr)); |
582 } | 582 } |
583 | 583 |
584 void MallocHook::InvokePreSbrkHookSlow(ptrdiff_t increment) { | 584 void MallocHook::InvokePreSbrkHookSlow(std::ptrdiff_t increment) { |
585 INVOKE_HOOKS(PreSbrkHook, presbrk_hooks_, (increment)); | 585 INVOKE_HOOKS(PreSbrkHook, presbrk_hooks_, (increment)); |
586 } | 586 } |
587 | 587 |
588 void MallocHook::InvokeSbrkHookSlow(const void* result, ptrdiff_t increment) { | 588 void MallocHook::InvokeSbrkHookSlow(const void* result, std::ptrdiff_t increment
) { |
589 INVOKE_HOOKS(SbrkHook, sbrk_hooks_, (result, increment)); | 589 INVOKE_HOOKS(SbrkHook, sbrk_hooks_, (result, increment)); |
590 } | 590 } |
591 | 591 |
592 #undef INVOKE_HOOKS | 592 #undef INVOKE_HOOKS |
593 | 593 |
594 DEFINE_ATTRIBUTE_SECTION_VARS(google_malloc); | 594 DEFINE_ATTRIBUTE_SECTION_VARS(google_malloc); |
595 DECLARE_ATTRIBUTE_SECTION_VARS(google_malloc); | 595 DECLARE_ATTRIBUTE_SECTION_VARS(google_malloc); |
596 // actual functions are in debugallocation.cc or tcmalloc.cc | 596 // actual functions are in debugallocation.cc or tcmalloc.cc |
597 DEFINE_ATTRIBUTE_SECTION_VARS(malloc_hook); | 597 DEFINE_ATTRIBUTE_SECTION_VARS(malloc_hook); |
598 DECLARE_ATTRIBUTE_SECTION_VARS(malloc_hook); | 598 DECLARE_ATTRIBUTE_SECTION_VARS(malloc_hook); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
714 | 714 |
715 /*static*/int MallocHook::UnhookedMUnmap(void *start, size_t length) { | 715 /*static*/int MallocHook::UnhookedMUnmap(void *start, size_t length) { |
716 int result; | 716 int result; |
717 if (!MallocHook::InvokeMunmapReplacement(start, length, &result)) { | 717 if (!MallocHook::InvokeMunmapReplacement(start, length, &result)) { |
718 result = munmap(start, length); | 718 result = munmap(start, length); |
719 } | 719 } |
720 return result; | 720 return result; |
721 } | 721 } |
722 | 722 |
723 #endif | 723 #endif |
OLD | NEW |