Skip to content

Commit

Permalink
Enable windows compiler warning for deprecated functions
Browse files Browse the repository at this point in the history
Signed-off-by: Brandon Yates <[email protected]>
  • Loading branch information
bmyates committed Feb 25, 2022
1 parent e559823 commit 45b20a5
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 10 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ if(MSVC)
string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")

# treat warnings as errors
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX /W3 /wd4996")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX /W3")

# enable multi-process compilation
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
Expand Down
17 changes: 12 additions & 5 deletions samples/zello_world/zello_world.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,32 @@ void print_loader_versions(){
delete[] versions;
}

#if defined(_WIN32)
#define putenv_safe _putenv
#else
#define putenv_safe putenv
#endif

//////////////////////////////////////////////////////////////////////////
int main( int argc, char *argv[] )
{

if( argparse( argc, argv, "-null", "--enable_null_driver" ) )
{
putenv( const_cast<char *>( "ZE_ENABLE_NULL_DRIVER=1" ) );
putenv_safe( const_cast<char *>( "ZE_ENABLE_NULL_DRIVER=1" ) );
}
if( argparse( argc, argv, "-ldr", "--force_loader_intercepts" ) )
{
putenv( const_cast<char *>( "ZE_ENABLE_LOADER_INTERCEPT=1" ) );
putenv_safe( const_cast<char *>( "ZE_ENABLE_LOADER_INTERCEPT=1" ) );
}
if( argparse( argc, argv, "-val", "--enable_validation_layer" ) )
{
putenv( const_cast<char *>( "ZE_ENABLE_VALIDATION_LAYER=1" ) );
putenv( const_cast<char *>( "ZE_ENABLE_PARAMETER_VALIDATION=1" ) );
putenv_safe( const_cast<char *>( "ZE_ENABLE_VALIDATION_LAYER=1" ) );
putenv_safe( const_cast<char *>( "ZE_ENABLE_PARAMETER_VALIDATION=1" ) );
}
if( argparse( argc, argv, "-trace", "--enable_tracing_layer" ) )
{
putenv( const_cast<char *>( "ZE_ENABLE_TRACING_LAYER=1" ) );
putenv_safe( const_cast<char *>( "ZE_ENABLE_TRACING_LAYER=1" ) );
}

ze_result_t status;
Expand Down
20 changes: 19 additions & 1 deletion source/drivers/null/ze_null.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,11 @@ namespace driver
ze_device_properties_t deviceProperties = {};
deviceProperties.stype = ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES;
deviceProperties.type = ZE_DEVICE_TYPE_GPU;
#if defined(_WIN32)
strcpy_s( deviceProperties.name, "Null Device" );
#else
strcpy( deviceProperties.name, "Null Device" );
#endif

*pDeviceProperties = deviceProperties;
return ZE_RESULT_SUCCESS;
Expand Down Expand Up @@ -235,7 +239,11 @@ namespace driver
if( nullptr != pExtensionProperties )
{
ze_driver_extension_properties_t driverExtensionProperties = {};
#if defined(_WIN32)
strcpy_s( driverExtensionProperties.name, ZET_API_TRACING_EXP_NAME );
#else
strcpy( driverExtensionProperties.name, ZET_API_TRACING_EXP_NAME );
#endif
driverExtensionProperties.version = ZET_API_TRACING_EXP_VERSION_1_0;

*pExtensionProperties = driverExtensionProperties;
Expand Down Expand Up @@ -267,7 +275,11 @@ namespace driver
metricGroupProperties.samplingType =
ZET_METRIC_GROUP_SAMPLING_TYPE_FLAG_EVENT_BASED |
ZET_METRIC_GROUP_SAMPLING_TYPE_FLAG_TIME_BASED;
#if defined(_WIN32)
strcpy_s( metricGroupProperties.name, "Null Metric Group" );
#else
strcpy( metricGroupProperties.name, "Null Metric Group" );
#endif

*pProperties = metricGroupProperties;
return ZE_RESULT_SUCCESS;
Expand Down Expand Up @@ -307,9 +319,15 @@ namespace driver
metricProperties.stype = ZET_STRUCTURE_TYPE_METRIC_PROPERTIES;
metricProperties.metricType = ZET_METRIC_TYPE_DURATION;
metricProperties.resultType = ZET_VALUE_TYPE_UINT32;
#if defined(_WIN32)
strcpy_s( metricProperties.name, "Null Metric" );
strcpy_s( metricProperties.resultUnits, "ns" );

#else
strcpy( metricProperties.name, "Null Metric" );
strcpy( metricProperties.resultUnits, "ns" );

#endif

*pProperties = metricProperties;
return ZE_RESULT_SUCCESS;
};
Expand Down
2 changes: 2 additions & 0 deletions source/inc/ze_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
# define LOAD_DRIVER_LIBRARY(NAME) LoadLibraryExA(NAME, nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32)
# define FREE_DRIVER_LIBRARY(LIB) if(LIB) FreeLibrary(LIB)
# define GET_FUNCTION_PTR(LIB, FUNC_NAME) GetProcAddress(LIB, FUNC_NAME)
# define string_copy_s strncpy_s
#else
# include <dlfcn.h>
# define HMODULE void*
Expand All @@ -29,6 +30,7 @@
# define LOAD_DRIVER_LIBRARY(NAME) dlopen(NAME, RTLD_LAZY|RTLD_LOCAL|RTLD_DEEPBIND)
# define FREE_DRIVER_LIBRARY(LIB) if(LIB) dlclose(LIB)
# define GET_FUNCTION_PTR(LIB, FUNC_NAME) dlsym(LIB, FUNC_NAME)
# define string_copy_s strncpy
#endif

inline std::string create_library_path(const char *name, const char *path){
Expand Down
2 changes: 1 addition & 1 deletion source/layers/tracing/ze_tracing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ zelLoaderGetVersion(zel_component_version_t *version)
{
if(version == nullptr)
return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
strncpy(version->component_name, TRACING_COMP_NAME, ZEL_COMPONENT_STRING_SIZE);
string_copy_s(version->component_name, TRACING_COMP_NAME, ZEL_COMPONENT_STRING_SIZE);
version->spec_version = ZE_API_VERSION_CURRENT;
version->component_lib_version.major = LOADER_VERSION_MAJOR;
version->component_lib_version.minor = LOADER_VERSION_MINOR;
Expand Down
2 changes: 1 addition & 1 deletion source/layers/validation/ze_validation_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ zelLoaderGetVersion(zel_component_version_t *version)
{
if(version == nullptr)
return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
strncpy(version->component_name, VALIDATION_COMP_NAME, ZEL_COMPONENT_STRING_SIZE);
string_copy_s(version->component_name, VALIDATION_COMP_NAME, ZEL_COMPONENT_STRING_SIZE);
version->spec_version = ZE_API_VERSION_CURRENT;
version->component_lib_version.major = LOADER_VERSION_MAJOR;
version->component_lib_version.minor = LOADER_VERSION_MINOR;
Expand Down
2 changes: 1 addition & 1 deletion source/loader/ze_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ namespace loader

void context_t::add_loader_version(){
zel_component_version_t version = {};
strncpy(version.component_name, LOADER_COMP_NAME, ZEL_COMPONENT_STRING_SIZE);
string_copy_s(version.component_name, LOADER_COMP_NAME, ZEL_COMPONENT_STRING_SIZE);
version.spec_version = ZE_API_VERSION_CURRENT;
version.component_lib_version.major = LOADER_VERSION_MAJOR;
version.component_lib_version.minor = LOADER_VERSION_MINOR;
Expand Down

0 comments on commit 45b20a5

Please sign in to comment.