<commit_before>/*
 * Copyright (c) 2015-2016 The Khronos Group Inc.
 * Copyright (c) 2015-2016 Valve Corporation
 * Copyright (c) 2015-2016 LunarG, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Author: <NAME> <<EMAIL>>
 * Author: <NAME> <<EMAIL>>
 * Author: <NAME> <<EMAIL>>
 */

#include "vktestframework.h"
#include "vkrenderframework.h"
// TODO FIXME remove this once glslang doesn't define this
#undef BadValue
#include "SPIRV/GlslangToSpv.h"
#include "SPIRV/SPVRemapper.h"
#include <limits.h>
#include <math.h>

#if defined(PATH_MAX) && !defined(MAX_PATH)
#define MAX_PATH PATH_MAX
#endif

#ifdef _WIN32
#define ERR_EXIT(err_msg, err_class)                                           \
    do {                                                                       \
        MessageBox(NULL, err_msg, err_class, MB_OK);                           \
        exit(1);                                                               \
    } while (0)
#else // _WIN32

#define ERR_EXIT(err_msg, err_class)                                           \
    do {                                                                       \
        printf(err_msg);                                                       \
        fflush(stdout);                                                        \
        exit(1);                                                               \
    } while (0)
#endif // _WIN32

#define GET_INSTANCE_PROC_ADDR(inst, entrypoint)                               \
    {                                                                          \
        m_fp##entrypoint =                                                     \
            (PFN_vk##entrypoint)vkGetInstanceProcAddr(inst, "vk" #entrypoint); \
        if (m_fp##entrypoint == NULL) {                                        \
            ERR_EXIT("vkGetInstanceProcAddr failed to find vk" #entrypoint,    \
                     "vkGetInstanceProcAddr Failure");                         \
        }                                                                      \
    }

#define GET_DEVICE_PROC_ADDR(dev, entrypoint)                                  \
    {                                                                          \
        m_fp##entrypoint =                                                     \
            (PFN_vk##entrypoint)vkGetDeviceProcAddr(dev, "vk" #entrypoint);    \
        if (m_fp##entrypoint == NULL) {                                        \
            ERR_EXIT("vkGetDeviceProcAddr failed to find vk" #entrypoint,      \
                     "vkGetDeviceProcAddr Failure");                           \
        }                                                                      \
    }

// Command-line options
enum TOptions {
    EOptionNone = 0x000,
    EOptionIntermediate = 0x001,
    EOptionSuppressInfolog = 0x002,
    EOptionMemoryLeakMode = 0x004,
    EOptionRelaxedErrors = 0x008,
    EOptionGiveWarnings = 0x010,
    EOptionLinkProgram = 0x020,
    EOptionMultiThreaded = 0x040,
    EOptionDumpConfig = 0x080,
    EOptionDumpReflection = 0x100,
    EOptionSuppressWarnings = 0x200,
    EOptionDumpVersions = 0x400,
    EOptionSpv = 0x800,
    EOptionDefaultDesktop = 0x1000,
};

typedef struct _SwapchainBuffers {
    VkImage image;
    VkCommandBuffer cmd;
    VkImageView view;
} SwapchainBuffers;

#ifndef _WIN32

#include <errno.h>

int fopen_s(FILE **pFile, const char *filename, const char *mode) {
    if (!pFile || !filename || !mode) {
        return EINVAL;
    }

    FILE *f = fopen(filename, mode);
    if (!f) {
        if (errno != 0) {
            return errno;
        } else {
            return ENOENT;
        }<commit_msg>tests: GH7, Fix invalid variable names<commit_after>/*
 * Copyright (c) 2015-2016 The Khronos Group Inc.
 * Copyright (c) 2015-2016 Valve Corporation
 * Copyright (c) 2015-2016 LunarG, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Author: <NAME> <<EMAIL>>
 * Author: <NAME> <<EMAIL>>
 * Author: <NAME> <<EMAIL>>
 */

#include "vktestframework.h"
#include "vkrenderframework.h"
// TODO FIXME remove this once glslang doesn't define this
#undef BadValue
#include "SPIRV/GlslangToSpv.h"
#include "SPIRV/SPVRemapper.h"
#include <limits.h>
#include <math.h>

#if defined(PATH_MAX) && !defined(MAX_PATH)
#define MAX_PATH PATH_MAX
#endif

#ifdef _WIN32
#define ERR_EXIT(err_msg, err_class)                                           \
    do {                                                                       \
        MessageBox(NULL, err_msg, err_class, MB_OK);                           \
        exit(1);                                                               \
    } while (0)
#else // _WIN32

#define ERR_EXIT(err_msg, err_class)                                           \
    do {                                                                       \
        printf(err_msg);                                                       \
        fflush(stdout);                                                        \
        exit(1);                                                               \
    } while (0)
#endif // _WIN32

#define GET_INSTANCE_PROC_ADDR(inst, entrypoint)                               \
    {                                                                          \
        m_fp##entrypoint =                                                     \
            (PFN_vk##entrypoint)vkGetInstanceProcAddr(inst, "vk" #entrypoint); \
        if (m_fp##entrypoint == NULL) {                                        \
            ERR_EXIT("vkGetInstanceProcAddr failed to find vk" #entrypoint,    \
                     "vkGetInstanceProcAddr Failure");                         \
        }                                                                      \
    }

#define GET_DEVICE_PROC_ADDR(dev, entrypoint)                                  \
    {                                                                          \
        m_fp##entrypoint =                                                     \
            (PFN_vk##entrypoint)vkGetDeviceProcAddr(dev, "vk" #entrypoint);    \
        if (m_fp##entrypoint == NULL) {                                        \
            ERR_EXIT("vkGetDeviceProcAddr failed to find vk" #entrypoint,      \
                     "vkGetDeviceProcAddr Failure");                           \
        }                                                                      \
    }

// Command-line options
enum TOptions {
    EOptionNone = 0x000,
    EOptionIntermediate = 0x001,
    EOptionSuppressInfolog = 0x002,
    EOptionMemoryLeakMode = 0x004,
    EOptionRelaxedErrors = 0x008,
    EOptionGiveWarnings = 0x010,
    EOptionLinkProgram = 0x020,
    EOptionMultiThreaded = 0x040,
    EOptionDumpConfig = 0x080,
    EOptionDumpReflection = 0x100,
    EOptionSuppressWarnings = 0x200,
    EOptionDumpVersions = 0x400,
    EOptionSpv = 0x800,
    EOptionDefaultDesktop = 0x1000,
};

struct SwapchainBuffers {
    VkImage image;
    VkCommandBuffer cmd;
    VkImageView view;
};

#ifndef _WIN32

#include <errno.h>

int fopen_s(FILE **pFile, const char *filename, const char *mode) {
    if (!pFile || !filename || !mode) {
        return EINVAL;
    }

    FILE *f = fopen(filename, mode);
    if (!f) {
        if (errno != 0) {
            return errno;
        } else {
            return ENOENT;
        }
{'fraction_non_alphanumeric': 0.08326394671107411, 'fraction_numerical': 0.023432853574402283, 'mean_word_length': 1.2243386243386243, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 68, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4594317', 'n_tokens_mistral': 2268, 'n_tokens_neox': 2095, 'n_words': 547}