Program Listing for File hook-helper.h

Return to documentation for file (include\layer-system\hook-helper.h)

/******************************************************************************
© Intel Corporation.

This software and the related documents are Intel copyrighted materials,
and your use of them is governed by the express license under which they
were provided to you ("License"). Unless the License provides otherwise,
you may not use, modify, copy, publish, distribute, disclose or transmit
this software or the related documents without Intel's prior written
permission.


 This software and the related documents are provided as is, with no express
or implied warranties, other than those that are expressly stated in the
License.

******************************************************************************/
#pragma once

#include "igpa-config.h"
#include <stdint.h>

struct GPADispatchTable;

namespace gpa {

GPA_EXPORT GPADispatchTable const** ThreadDispatchTable();

GPA_EXPORT uint32_t* ThreadStackDepthCounter();

struct StackDepthHelper
{
    StackDepthHelper(uint32_t& pStackDepthCounter)
        : pSdc(pStackDepthCounter)
    {
        ++pSdc;
    }

    ~StackDepthHelper()
    {
        --pSdc;
    }

private:
    uint32_t& pSdc;
};

}  // namespace gpa

#define STACK_HELPER(counter) ::gpa::StackDepthHelper helper(counter)

#define UNLESS_TOP_OF_STACK_NO_RETURN(action)           \
    uint32_t& sdcRef = *gpa::ThreadStackDepthCounter(); \
    if (sdcRef) {                                       \
        action;                                         \
    }                                                   \
    ::gpa::StackDepthHelper helper(sdcRef);

#define UNLESS_TOP_OF_STACK(action)                     \
    uint32_t& sdcRef = *gpa::ThreadStackDepthCounter(); \
    if (sdcRef) {                                       \
        action;                                         \
        return;                                         \
    }                                                   \
    ::gpa::StackDepthHelper helper(sdcRef);

#define UNLESS_TOP_OF_STACK_RETURN(action)              \
    uint32_t& sdcRef = *gpa::ThreadStackDepthCounter(); \
    if (sdcRef) {                                       \
        return action;                                  \
    }                                                   \
    ::gpa::StackDepthHelper helper(sdcRef);