diff options
author | Pali Rohár <pali.rohar@gmail.com> | 2021-02-03 21:01:24 +0100 |
---|---|---|
committer | Pali Rohár <pali.rohar@gmail.com> | 2021-02-03 21:01:24 +0100 |
commit | 9e40646cf3a7d0817b2298f915399a128fcb4d27 (patch) | |
tree | be6641139c2a09b59eb66bf92645be9d6b18241d /src | |
parent | 7da1054564609f3382869714432f54b63812d083 (diff) | |
download | dlfcn-win32-9e40646cf3a7d0817b2298f915399a128fcb4d27.tar.gz dlfcn-win32-9e40646cf3a7d0817b2298f915399a128fcb4d27.tar.bz2 dlfcn-win32-9e40646cf3a7d0817b2298f915399a128fcb4d27.zip |
Fix noinline for older compiler versions (e.g. Visual Studio 6.0)
Visual Studio 6.0 does not support __declspec(noinline) and throw error.
Add checks for compilers which support noinline to prevent compile errors.
Diffstat (limited to 'src')
-rw-r--r-- | src/dlfcn.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/dlfcn.c b/src/dlfcn.c index c4f410d..86f24df 100644 --- a/src/dlfcn.c +++ b/src/dlfcn.c | |||
@@ -61,6 +61,16 @@ typedef ULONG ULONG_PTR; | |||
61 | #endif | 61 | #endif |
62 | #include "dlfcn.h" | 62 | #include "dlfcn.h" |
63 | 63 | ||
64 | #if defined( _MSC_VER ) && _MSC_VER >= 1300 | ||
65 | /* https://docs.microsoft.com/en-us/cpp/cpp/noinline */ | ||
66 | #define DLFCN_NOINLINE __declspec( noinline ) | ||
67 | #elif defined( __GNUC__ ) && ( ( __GNUC__ > 3 ) || ( __GNUC__ == 3 && __GNUC_MINOR__ >= 1 ) ) | ||
68 | /* https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html */ | ||
69 | #define DLFCN_NOINLINE __attribute__(( noinline )) | ||
70 | #else | ||
71 | #define DLFCN_NOINLINE | ||
72 | #endif | ||
73 | |||
64 | /* Note: | 74 | /* Note: |
65 | * MSDN says these functions are not thread-safe. We make no efforts to have | 75 | * MSDN says these functions are not thread-safe. We make no efforts to have |
66 | * any kind of thread safety. | 76 | * any kind of thread safety. |
@@ -418,7 +428,7 @@ int dlclose( void *handle ) | |||
418 | return (int) ret; | 428 | return (int) ret; |
419 | } | 429 | } |
420 | 430 | ||
421 | __declspec(noinline) /* Needed for _ReturnAddress() */ | 431 | DLFCN_NOINLINE /* Needed for _ReturnAddress() */ |
422 | DLFCN_EXPORT | 432 | DLFCN_EXPORT |
423 | void *dlsym( void *handle, const char *name ) | 433 | void *dlsym( void *handle, const char *name ) |
424 | { | 434 | { |