diff options
author | Patrick Williams <iawillia@us.ibm.com> | 2013-04-28 18:39:46 -0500 |
---|---|---|
committer | A. Patrick Williams III <iawillia@us.ibm.com> | 2013-05-01 14:22:37 -0500 |
commit | 12bb660f69bc7d7bd4cab92621ee2d5b3963ab62 (patch) | |
tree | a5422e50ee94c990caf67afd3ee7654a98ec56f4 /src/include/util | |
parent | e319acb36befe9fbbdd71565ec570d5977be532b (diff) | |
download | talos-hostboot-12bb660f69bc7d7bd4cab92621ee2d5b3963ab62.tar.gz talos-hostboot-12bb660f69bc7d7bd4cab92621ee2d5b3963ab62.zip |
Enhance heap corruption detection.
Change-Id: I25ec156fe3c9088d2de2254017407dbadd2fac31
Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/4255
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Tested-by: Jenkins Server
Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/include/util')
-rw-r--r-- | src/include/util/lockfree/stack.H | 56 |
1 files changed, 31 insertions, 25 deletions
diff --git a/src/include/util/lockfree/stack.H b/src/include/util/lockfree/stack.H index 61120364b..e6b4daf09 100644 --- a/src/include/util/lockfree/stack.H +++ b/src/include/util/lockfree/stack.H @@ -1,29 +1,30 @@ -// IBM_PROLOG_BEGIN_TAG -// This is an automatically generated prolog. -// -// $Source: src/include/util/lockfree/stack.H $ -// -// IBM CONFIDENTIAL -// -// COPYRIGHT International Business Machines Corp. 2010 - 2011 -// -// p1 -// -// Object Code Only (OCO) source materials -// Licensed Internal Code Source Materials -// IBM HostBoot Licensed Internal Code -// -// The source code for this program is not published or other- -// wise divested of its trade secrets, irrespective of what has -// been deposited with the U.S. Copyright Office. -// -// Origin: 30 -// -// IBM_PROLOG_END +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/include/util/lockfree/stack.H $ */ +/* */ +/* IBM CONFIDENTIAL */ +/* */ +/* COPYRIGHT International Business Machines Corp. 2010,2013 */ +/* */ +/* p1 */ +/* */ +/* Object Code Only (OCO) source materials */ +/* Licensed Internal Code Source Materials */ +/* IBM HostBoot Licensed Internal Code */ +/* */ +/* The source code for this program is not published or otherwise */ +/* divested of its trade secrets, irrespective of what has been */ +/* deposited with the U.S. Copyright Office. */ +/* */ +/* Origin: 30 */ +/* */ +/* IBM_PROLOG_END_TAG */ #ifndef __UTIL_LOCKFREE_STACK_H #define __UTIL_LOCKFREE_STACK_H #include <stddef.h> +#include <assert.h> namespace Util { @@ -61,14 +62,18 @@ namespace Util { _T * _head = head; _T * h = (_T*) (((uint64_t)_head) & 0x00000000FFFFFFFF); - if (NULL == h) return h; + if (NULL == h) return h; uint64_t token = ((uint64_t)_head) >> 32; token++; - _T * h_next = (_T*) (((uint64_t)(h->next)) | (token << 32)); + uint64_t h_next_v = (uint64_t)(h->next); + _T * h_next = (_T*) ((h_next_v & 0x00000000FFFFFFFF) | + (token << 32)); if (!__sync_bool_compare_and_swap(&head, _head, h_next)) return pop(); + + crit_assert((h_next_v >> 32) == 0x5354414B); return h; } @@ -76,7 +81,8 @@ namespace Util void Stack<_T>::push(_T* p) { _T* _head = head; - p->next = (_T*) (((uint64_t)_head) & 0x00000000FFFFFFFF); + p->next = (_T*) ((((uint64_t)_head) & 0x00000000FFFFFFFF) | + 0x5354414B00000000); uint64_t token = ((uint64_t)_head) >> 32; token++; |