Changeset 1072 for trunk/dll/fortify.h


Ignore:
Timestamp:
Jul 17, 2008, 7:39:14 PM (17 years ago)
Author:
Steven Levine
Message:

Add Fortify_SetOwner Fortify_ChangeOwner to support cross thread allocations

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/fortify.h

    r1015 r1072  
    2727 */
    2828
    29 /* 
     29/*
    3030 *     If  you use this software at all, I'd love to hear from
    3131 * you.   All  questions,  criticisms, suggestions, praise and
    3232 * postcards are most welcome.
    33  * 
     33 *
    3434 *            email:    sbullen@cybergraphic.com.au
    35  * 
     35 *
    3636 *            snail:    Simon P. Bullen
    3737 *                      PO BOX 12138
     
    4141 */
    4242
     43 /* 06 May 08 SHL Rework scope logic to be MT capable
     44    17 Jul 08 SHL Add Fortify_SetOwner Fortify_ChangeOwner
     45 */
     46
    4347#ifndef __FORTIFY_H__
    4448#define __FORTIFY_H__
    4549
    4650#include <stdlib.h>                     // Must include before fortify defintions
    47 // 16 Jan 08 SHL Ensure 
     51// 16 Jan 08 SHL Ensure
    4852#ifdef __BORLANDC__
    4953#ifdef __OS2__
     
    5660#include "ufortify.h"
    5761
     62#if defined(__WATCOMC__) && defined(_MT)
     63#define MT_SCOPES 1
     64#endif
     65
    5866/* Ensure the configuration parameters have sensible defaults */
    5967#ifndef FORTIFY_STORAGE
     
    8088#endif
    8189
    82 #ifndef FORTIFY_FILL_ON_ALLOCATE_VALUE   
     90#ifndef FORTIFY_FILL_ON_ALLOCATE_VALUE
    8391    #define FORTIFY_FILL_ON_ALLOCATE_VALUE       0xA7
    8492#endif
     
    8997
    9098#ifndef FORTIFY_LOCK
    91     #define FORTIFY_LOCK()   
     99    #define FORTIFY_LOCK()
    92100#endif
    93101
    94102#ifndef FORTIFY_UNLOCK
    95     #define FORTIFY_UNLOCK() 
     103    #define FORTIFY_UNLOCK()
    96104#endif
    97105
     
    113121 */
    114122
    115 #ifdef __GNUG__ 
     123#ifdef __GNUG__
    116124    /* GCC configuration */
    117125    #define FORTIFY_PROVIDE_ARRAY_NEW
     
    181189void  Fortify_Disable(const char *file, unsigned long line);
    182190
     191#ifdef MT_SCOPES
     192void  Fortify_SetOwner(long lOwnerTID);
     193void  Fortify_ChangeOwner(void *pBlock);
     194#endif
     195
    183196/* Fortify versions of the ANSI C memory allocation functions */
    184197void *Fortify_malloc(size_t size, const char *file, unsigned long line);
     
    242255    #define Fortify_OutputStatistics()     Fortify_OutputStatistics(__FILE__, __LINE__)
    243256    #define Fortify_GetCurrentAllocation() Fortify_GetCurrentAllocation(__FILE__, __LINE__)
    244     #define Fortify_SetAllocationLimit(x)  Fortify_SetAllocationLimit(x, __FILE__, __LINE__)   
     257    #define Fortify_SetAllocationLimit(x)  Fortify_SetAllocationLimit(x, __FILE__, __LINE__)
    245258    #define Fortify_Disable()              Fortify_Disable(__FILE__, __LINE__)
    246259
     
    269282#else /* Define the special fortify functions away to nothing */
    270283
     284    // 17 Jul 08 SHL fixme to avoid spurious OpenWatcom warnings
    271285    #define Fortify_CheckAllMemory()       0
    272286    #define Fortify_ListAllMemory()        0
    273287    #define Fortify_DumpAllMemory()        0
    274     #define Fortify_CheckPointer(ptr)      1 
    275     #define Fortify_LabelPointer(ptr,str) 
     288    #define Fortify_CheckPointer(ptr)      1
     289    #define Fortify_LabelPointer(ptr,str)
    276290    #define Fortify_SetOutputFunc()        0
    277291    #define Fortify_SetMallocFailRate(p)   0
     
    282296    #define Fortify_SetAllocationLimit(x)  0
    283297    #define Fortify_Disable()              0
    284 
    285     #ifdef __cplusplus   
    286         #define Fortify_New                    new
    287         #define Fortify_Delete                 delete
     298    #define Fortify_SetOwner()             0
     299    #define Fortify_ChangeOwner            0
     300
     301    #ifdef __cplusplus
     302        #define Fortify_New                    new
     303        #define Fortify_Delete                 delete
    288304    #endif /* __cplusplus */
    289305
Note: See TracChangeset for help on using the changeset viewer.