Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
Add throw specifier for GCC
Browse files Browse the repository at this point in the history
/usr/include/string.h:43:28: error: declaration of ‘void* memcpy(void*, const void*, size_t) throw ()’ has a different exception specifier
        size_t __n) __THROW __nonnull ((1, 2));
  • Loading branch information
franksinankaya committed Jan 30, 2019
1 parent 6fadc62 commit e1a34ee
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
8 changes: 7 additions & 1 deletion src/pal/inc/mbusafecrt.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ typedef int errno_t;
// define the return value for success
#define SAFECRT_SUCCESS 0

#if defined(_MSC_VER) || defined(__llvm__)
#define THROW_DECL
#else
#define THROW_DECL throw()
#endif

#ifdef __cplusplus
extern "C" {
#endif
Expand Down Expand Up @@ -98,7 +104,7 @@ extern int swscanf_s( const WCHAR *string, const WCHAR *format, ... );
extern int _snscanf_s( const char *string, size_t count, const char *format, ... );
extern int _snwscanf_s( const WCHAR *string, size_t count, const WCHAR *format, ... );

extern errno_t memcpy_s( void * dst, size_t sizeInBytes, const void * src, size_t count );
extern errno_t memcpy_s( void * dst, size_t sizeInBytes, const void * src, size_t count ) THROW_DECL;
extern errno_t memmove_s( void * dst, size_t sizeInBytes, const void * src, size_t count );

#ifdef __cplusplus
Expand Down
21 changes: 13 additions & 8 deletions src/pal/inc/pal.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ typedef void * NATIVE_LIBRARY_HANDLE;
#define LANG_THAI 0x1e

/******************* Compiler-specific glue *******************************/
#if defined(_MSC_VER) || defined(__llvm__)
#define THROW_DECL
#else
#define THROW_DECL throw()
#endif

#ifndef _MSC_VER
#if defined(CORECLR)
Expand Down Expand Up @@ -4324,7 +4329,7 @@ PALIMPORT int __cdecl memcmp(const void *, const void *, size_t);
PALIMPORT void * __cdecl memset(void *, int, size_t);
PALIMPORT void * __cdecl memmove(void *, const void *, size_t);
PALIMPORT void * __cdecl memchr(const void *, int, size_t);
PALIMPORT long long int __cdecl atoll(const char *);
PALIMPORT long long int __cdecl atoll(const char *) THROW_DECL;
PALIMPORT size_t __cdecl strlen(const char *);
PALIMPORT int __cdecl strcmp(const char*, const char *);
PALIMPORT int __cdecl strncmp(const char*, const char *, size_t);
Expand Down Expand Up @@ -4363,7 +4368,7 @@ PALIMPORT int __cdecl toupper(int);
#define _TRUNCATE ((size_t)-1)
#endif

PALIMPORT errno_t __cdecl memcpy_s(void *, size_t, const void *, size_t);
PALIMPORT errno_t __cdecl memcpy_s(void *, size_t, const void *, size_t) THROW_DECL;
PALIMPORT errno_t __cdecl memmove_s(void *, size_t, const void *, size_t);
PALIMPORT char * __cdecl _strlwr(char *);
PALIMPORT int __cdecl _stricmp(const char *, const char *);
Expand Down Expand Up @@ -4503,10 +4508,10 @@ PALIMPORT double __cdecl acos(double);
PALIMPORT double __cdecl acosh(double);
PALIMPORT double __cdecl asin(double);
PALIMPORT double __cdecl asinh(double);
PALIMPORT double __cdecl atan(double);
PALIMPORT double __cdecl atanh(double);
PALIMPORT double __cdecl atan(double) THROW_DECL;
PALIMPORT double __cdecl atanh(double) THROW_DECL;
PALIMPORT double __cdecl atan2(double, double);
PALIMPORT double __cdecl cbrt(double);
PALIMPORT double __cdecl cbrt(double) THROW_DECL;
PALIMPORT double __cdecl ceil(double);
PALIMPORT double __cdecl cos(double);
PALIMPORT double __cdecl cosh(double);
Expand Down Expand Up @@ -4536,10 +4541,10 @@ PALIMPORT float __cdecl acosf(float);
PALIMPORT float __cdecl acoshf(float);
PALIMPORT float __cdecl asinf(float);
PALIMPORT float __cdecl asinhf(float);
PALIMPORT float __cdecl atanf(float);
PALIMPORT float __cdecl atanhf(float);
PALIMPORT float __cdecl atanf(float) THROW_DECL;
PALIMPORT float __cdecl atanhf(float) THROW_DECL;
PALIMPORT float __cdecl atan2f(float, float);
PALIMPORT float __cdecl cbrtf(float);
PALIMPORT float __cdecl cbrtf(float) THROW_DECL;
PALIMPORT float __cdecl ceilf(float);
PALIMPORT float __cdecl cosf(float);
PALIMPORT float __cdecl coshf(float);
Expand Down
2 changes: 1 addition & 1 deletion src/pal/src/safecrt/memcpy_s.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ errno_t __cdecl memcpy_s(
size_t sizeInBytes,
const void * src,
size_t count
)
) THROW_DECL
{
if (count == 0)
{
Expand Down

0 comments on commit e1a34ee

Please sign in to comment.