summaryrefslogtreecommitdiff
path: root/source/core/secure-crt.h
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2018-10-25 11:24:16 -0400
committerGitHub <noreply@github.com>2018-10-25 11:24:16 -0400
commit4f0415e338862ffec50c2d47eddea958255b504e (patch)
tree084c8e25552e328ed14eafcf0431493f58f973e8 /source/core/secure-crt.h
parent2700a89f8c80620f1d523563cc80ec0da39e9761 (diff)
Feature/premake linux (#689)
* Premake work in progress for linux. * Added dump function. * Remove examples on linux Small warning fix. * * Don't build render-test on linux * Removed work around virtual destructor warning, and just used virtual dtor for simplicity * Git ignore obj directories * Fix premake working on windows. * * Fix sprintf_s functions * Make generates arg parsing more robust * Added FloatIntUnion to avoid type punning/strong aliasing issues, and repeated union definitions. * Work around problems building on linux with getClass claiming a strict aliasing issue. * Fix for targetBlock appearing potentiall used unintialized to gcc. * Linux slang link options -fPIC to make dll. * Add -fPIC to build options on linux. * Add -ldl for linux on slang. * Fixes to try and get premake working with .so on linux. * Make core compile with -fPIC * Try to fix linux linking with --no-as-needed before -ldl * Add rpath back. * Remove render-gl from linux build. * Re-add location for linux. * Don't include <malloc.h> except on windows. * Remove unused line to fix warning on osx. * Remove ambiguity on OSX for operator <<. * Fixing ambiguity with operator overloading and Int types for OSX. * Fix ambiguity around UInt and operator * Fix ambiguity of UInt conversion for OSX. * Added UnambiguousInt and UnambiguousUInt to make it easier to work around OSX integer coercion for UInt/Int types.
Diffstat (limited to 'source/core/secure-crt.h')
-rw-r--r--source/core/secure-crt.h20
1 files changed, 16 insertions, 4 deletions
diff --git a/source/core/secure-crt.h b/source/core/secure-crt.h
index a76fb2679..52a0d4870 100644
--- a/source/core/secure-crt.h
+++ b/source/core/secure-crt.h
@@ -5,6 +5,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <strings.h>
+
#include <wchar.h>
inline void memcpy_s(void *dest, size_t numberOfElements, const void * src, size_t count)
@@ -30,16 +32,26 @@ inline size_t wcsnlen_s(const wchar_t * str, size_t /*numberofElements*/)
return wcslen(str);
}
-inline size_t strnlen_s(const char * str, size_t numberofElements)
+inline size_t strnlen_s(const char * str, size_t numberOfElements)
{
- return strnlen(str, numberofElements);
+#if defined( __CYGWIN__ )
+ const char* cur = str;
+ if (str)
+ {
+ const char*const end = str + numberOfElements;
+ while (*cur && cur < end) cur++;
+ }
+ return size_t(cur - str);
+#else
+ return strnlen(str, numberOfElements);
+#endif
}
inline int sprintf_s(char * buffer, size_t sizeOfBuffer, const char * format, ...)
{
va_list argptr;
va_start(argptr, format);
- int rs = snprintf(buffer, sizeOfBuffer, format, argptr);
+ int rs = vsnprintf(buffer, sizeOfBuffer, format, argptr);
va_end(argptr);
return rs;
}
@@ -48,7 +60,7 @@ inline int swprintf_s(wchar_t * buffer, size_t sizeOfBuffer, const wchar_t * for
{
va_list argptr;
va_start(argptr, format);
- int rs = swprintf(buffer, sizeOfBuffer, format, argptr);
+ int rs = vswprintf(buffer, sizeOfBuffer, format, argptr);
va_end(argptr);
return rs;
}