diff --git a/src/lib/evil/evil_dlfcn.c b/src/lib/evil/evil_dlfcn.c index ef161cc782..a6ee3e1c9c 100644 --- a/src/lib/evil/evil_dlfcn.c +++ b/src/lib/evil/evil_dlfcn.c @@ -39,7 +39,7 @@ _dl_get_last_error(char *desc) _dl_err_viewed = 0; } -void * +EVIL_API void * dlopen(const char* path, int mode EVIL_UNUSED) { HMODULE module = NULL; @@ -95,7 +95,7 @@ dlopen(const char* path, int mode EVIL_UNUSED) return module; } -int +EVIL_API int dlclose(void* handle) { if (FreeLibrary(handle)) @@ -107,7 +107,7 @@ dlclose(void* handle) } } -void * +EVIL_API void * dlsym(void *handle, const char *symbol) { FARPROC fp = NULL; @@ -157,7 +157,7 @@ dlsym(void *handle, const char *symbol) return fp; } -char * +EVIL_API char * dlerror (void) { if (!_dl_err_viewed) @@ -184,7 +184,7 @@ _dladdr_comp(const void *p1, const void *p2) return ( *(int *)p1 - *(int *)p2); } -int +EVIL_API int dladdr (const void *addr, Dl_info *info) { TCHAR tpath[PATH_MAX]; diff --git a/src/lib/evil/evil_dlfcn.h b/src/lib/evil/evil_dlfcn.h index c55ce2562e..3b274e0aa6 100644 --- a/src/lib/evil/evil_dlfcn.h +++ b/src/lib/evil/evil_dlfcn.h @@ -2,6 +2,7 @@ #define __EVIL_DLFCN_H__ +#include "evil_private.h" #include @@ -142,7 +143,7 @@ struct Dl_info * * @ingroup Evil_Dlfcn */ -EAPI void *dlopen(const char* path, int mode); +EVIL_API void *dlopen(const char* path, int mode); #ifndef HAVE_DLOPEN # define HAVE_DLOPEN 1 #endif @@ -168,7 +169,7 @@ EAPI void *dlopen(const char* path, int mode); * * @ingroup Evil_Dlfcn */ -EAPI int dlclose(void* handle); +EVIL_API int dlclose(void* handle); /** * @brief Get the address of a symbol. @@ -192,7 +193,7 @@ EAPI int dlclose(void* handle); * * @ingroup Evil_Dlfcn */ -EAPI void *dlsym(void* handle, const char* symbol); +EVIL_API void *dlsym(void* handle, const char* symbol); #ifndef HAVE_DLSYM # define HAVE_DLSYM 1 #endif @@ -221,7 +222,7 @@ EAPI void *dlsym(void* handle, const char* symbol); * * @ingroup Evil_Dlfcn */ -EAPI int dladdr (const void *addr, Dl_info *info); +EVIL_API int dladdr(const void *addr, Dl_info *info); #ifndef HAVE_DLADDR # define HAVE_DLADDR 1 #endif @@ -248,7 +249,7 @@ EAPI int dladdr (const void *addr, Dl_info *info); * * @ingroup Evil_Dlfcn */ -EAPI char *dlerror (void); +EVIL_API char *dlerror(void); #endif /* __EVIL_DLFCN_H__ */ diff --git a/src/lib/evil/evil_fcntl.c b/src/lib/evil/evil_fcntl.c index dd23b7b838..14d10b111c 100644 --- a/src/lib/evil/evil_fcntl.c +++ b/src/lib/evil/evil_fcntl.c @@ -31,7 +31,8 @@ _is_socket(SOCKET s) * */ -int fcntl(int fd, int cmd, ...) +EVIL_API int +fcntl(int fd, int cmd, ...) { va_list va; int res = -1; diff --git a/src/lib/evil/evil_fcntl.h b/src/lib/evil/evil_fcntl.h index a54569681f..1930a18e7f 100644 --- a/src/lib/evil/evil_fcntl.h +++ b/src/lib/evil/evil_fcntl.h @@ -105,7 +105,7 @@ struct flock * * @ingroup Evil */ -EAPI int fcntl(int fd, int cmd, ...); +EVIL_API int fcntl(int fd, int cmd, ...); #endif /* __EVIL_FCNTL_H__ */ diff --git a/src/lib/evil/evil_langinfo.c b/src/lib/evil/evil_langinfo.c index 5e0a344404..11b534dc5f 100644 --- a/src/lib/evil/evil_langinfo.c +++ b/src/lib/evil/evil_langinfo.c @@ -19,7 +19,7 @@ replace(char *prev, char *value) return strdup (value); } -char * +EVIL_API char * nl_langinfo(nl_item index) { static char *result = NULL; diff --git a/src/lib/evil/evil_langinfo.h b/src/lib/evil/evil_langinfo.h index b9f35029a4..26dc14d047 100644 --- a/src/lib/evil/evil_langinfo.h +++ b/src/lib/evil/evil_langinfo.h @@ -39,7 +39,7 @@ enum { # define CODESET _NL_CTYPE_CODESET # define RADIXCHAR _NL_NUMERIC_RADIXCHAR -EAPI char *nl_langinfo(nl_item index); +EVIL_API char *nl_langinfo(nl_item index); #endif /*__EVIL_LANGINFO_H__ */ diff --git a/src/lib/evil/evil_locale.c b/src/lib/evil/evil_locale.c index c932b27a69..388c7f5ef3 100644 --- a/src/lib/evil/evil_locale.c +++ b/src/lib/evil/evil_locale.c @@ -12,21 +12,7 @@ #include #undef WIN32_LEAN_AND_MEAN -#ifdef EAPI -# undef EAPI -#endif - -#ifdef EFL_BUILD -# ifdef DLL_EXPORT -# define EAPI __declspec(dllexport) -# else -# define EAPI -# endif -#else -# define EAPI __declspec(dllimport) -#endif - -#include "evil_locale.h" /* LC_MESSAGES */ +#include "evil_private.h" /* LC_MESSAGES */ /* * LOCALE_SISO639LANGNAME and LOCALE_SISO3166CTRYNAME need at least a buffer @@ -37,7 +23,8 @@ static char _evil_locale_buf[18]; #undef setlocale -char *evil_setlocale(int category, const char *locale) +EVIL_API char * +evil_setlocale(int category, const char *locale) { char buf[9]; int l1; diff --git a/src/lib/evil/evil_locale.h b/src/lib/evil/evil_locale.h index 6b12428428..87497bcfec 100644 --- a/src/lib/evil/evil_locale.h +++ b/src/lib/evil/evil_locale.h @@ -48,7 +48,7 @@ * * @since 1.16 */ -EAPI char *evil_setlocale(int category, const char *locale); +EVIL_API char *evil_setlocale(int category, const char *locale); /** diff --git a/src/lib/evil/evil_main.h b/src/lib/evil/evil_main.h index 40fd38f15f..cecc1de28d 100644 --- a/src/lib/evil/evil_main.h +++ b/src/lib/evil/evil_main.h @@ -99,7 +99,7 @@ * When Evil is not used anymore, call evil_shutdown() to shut down * the Evil library. */ -EAPI int evil_init(void); +EVIL_API int evil_init(void); /** * @brief Shut down the Evil library. @@ -115,7 +115,7 @@ EAPI int evil_init(void); * documentation anymore . You must call evil_init() again to use these * functions again. */ -EAPI int evil_shutdown(void); +EVIL_API int evil_shutdown(void); /** diff --git a/src/lib/evil/evil_mman.c b/src/lib/evil/evil_mman.c index 42f8021e59..f132a173fe 100644 --- a/src/lib/evil/evil_mman.c +++ b/src/lib/evil/evil_mman.c @@ -45,7 +45,7 @@ _evil_mmap_protection_get(int prot) /***** API *****/ -void * +EVIL_API void * mmap(void *addr EVIL_UNUSED, size_t len, int prot, @@ -133,7 +133,7 @@ mmap(void *addr EVIL_UNUSED, return data; } -int +EVIL_API int munmap(void *addr, size_t len EVIL_UNUSED) { @@ -147,7 +147,7 @@ munmap(void *addr, return (res == 0) ? -1 : 0; } -int +EVIL_API int mprotect(void *addr, size_t len, int prot) { DWORD old; diff --git a/src/lib/evil/evil_mman.h b/src/lib/evil/evil_mman.h index 97f56681b0..09c0b3269f 100644 --- a/src/lib/evil/evil_mman.h +++ b/src/lib/evil/evil_mman.h @@ -107,7 +107,7 @@ * * @ingroup Evil_Mman */ -EAPI void *mmap(void *addr, +EVIL_API void *mmap(void *addr, size_t len, int prot, int flags, @@ -138,7 +138,7 @@ EAPI void *mmap(void *addr, * * @ingroup Evil_Mman */ -EAPI int munmap(void *addr, +EVIL_API int munmap(void *addr, size_t len); /** @@ -159,7 +159,7 @@ EAPI int munmap(void *addr, * * @ingroup Evil_Mman */ -EAPI int mprotect(void *addr, size_t len, int prot); +EVIL_API int mprotect(void *addr, size_t len, int prot); #endif /* __EVIL_SYS_MMAN_H__ */ diff --git a/src/lib/evil/evil_private.h b/src/lib/evil/evil_private.h index d87ac75423..15402568e9 100644 --- a/src/lib/evil/evil_private.h +++ b/src/lib/evil/evil_private.h @@ -26,18 +26,42 @@ extern "C" { #include /* for mkdir in evil_macro_wrapper */ -#ifdef EAPI -# undef EAPI +#ifdef EVIL_API +#error EVIL_API should not be already defined #endif -#ifdef EFL_BUILD -# ifdef DLL_EXPORT -# define EAPI __declspec(dllexport) +#ifdef _WIN32 +# ifndef EVIL_STATIC +# ifdef EVIL_BUILD +# define EVIL_API __declspec(dllexport) +# else +# define EVIL_API __declspec(dllimport) +# endif # else -# define EAPI +# define EVIL_API +# endif +# define EVIL_API_WEAK +#elif defined(__GNUC__) +# if __GNUC__ >= 4 +# define EVIL_API __attribute__ ((visibility("default"))) +# define EVIL_API_WEAK __attribute__ ((weak)) +# else +# define EVIL_API +# define EVIL_API_WEAK # endif #else -# define EAPI __declspec(dllimport) +/** + * @def EVIL_API + * @brief Used to export functions (by changing visibility). + */ +# define EVIL_API +/** + * @def EINA_API_WEAK + * @brief Weak symbol, primarily useful in defining library functions which + * can be overridden in user code. + * Note: Not supported on all platforms. + */ +# define EINA_API_WEAK #endif #ifndef PATH_MAX @@ -61,9 +85,6 @@ extern "C" { #include "evil_macro_wrapper.h" -#undef EAPI -#define EAPI - #ifdef __cplusplus } #endif diff --git a/src/lib/evil/evil_stdio.c b/src/lib/evil/evil_stdio.c index 61afe7ce3b..74ea8297d9 100644 --- a/src/lib/evil/evil_stdio.c +++ b/src/lib/evil/evil_stdio.c @@ -9,7 +9,7 @@ #undef rename -int +EVIL_API int evil_rename(const char *src, const char* dst) { DWORD res; @@ -24,7 +24,7 @@ evil_rename(const char *src, const char* dst) return MoveFileEx(src, dst, MOVEFILE_REPLACE_EXISTING) ? 0 : -1; } -int +EVIL_API int evil_mkdir(const char *dirname, mode_t mode EVIL_UNUSED) { return _mkdir(dirname); diff --git a/src/lib/evil/evil_stdio.h b/src/lib/evil/evil_stdio.h index 64b09af9bc..4a2ed57fd3 100644 --- a/src/lib/evil/evil_stdio.h +++ b/src/lib/evil/evil_stdio.h @@ -41,7 +41,7 @@ * * @since 1.8 */ -EAPI int evil_rename(const char *src, const char *dst); +EVIL_API int evil_rename(const char *src, const char *dst); /** * @brief Wrap the _mkdir() function on Windows. @@ -54,7 +54,7 @@ EAPI int evil_rename(const char *src, const char *dst); * * @since 1.15 */ -EAPI int evil_mkdir(const char *dirname, mode_t mode); +EVIL_API int evil_mkdir(const char *dirname, mode_t mode); /** * @} diff --git a/src/lib/evil/evil_stdlib.c b/src/lib/evil/evil_stdlib.c index ea8f3356b7..f2edd03df9 100644 --- a/src/lib/evil/evil_stdlib.c +++ b/src/lib/evil/evil_stdlib.c @@ -22,7 +22,7 @@ * */ -int +EVIL_API int setenv(const char *name, const char *value, int overwrite) @@ -65,7 +65,7 @@ setenv(const char *name, return res; } -int +EVIL_API int unsetenv(const char *name) { return setenv(name, NULL, 1); @@ -77,7 +77,7 @@ unsetenv(const char *name) * */ -char * +EVIL_API char * realpath(const char *file_name, char *resolved_name) { char *retname = NULL; /* we will return this, if we fail */ diff --git a/src/lib/evil/evil_stdlib.h b/src/lib/evil/evil_stdlib.h index cb35a570b0..e836cb4732 100644 --- a/src/lib/evil/evil_stdlib.h +++ b/src/lib/evil/evil_stdlib.h @@ -1,6 +1,7 @@ #ifndef __EVIL_STDLIB_H__ #define __EVIL_STDLIB_H__ +#include "evil_private.h" /** * @file evil_stdlib.h @@ -40,7 +41,7 @@ * * Supported OS: Windows XP. */ -EAPI int setenv(const char *name, +EVIL_API int setenv(const char *name, const char *value, int overwrite); @@ -59,7 +60,7 @@ EAPI int setenv(const char *name, * * Supported OS: Windows XP. */ -EAPI int unsetenv(const char *name); +EVIL_API int unsetenv(const char *name); /* @@ -96,7 +97,7 @@ EAPI int unsetenv(const char *name); * * Supported OS: Windows XP. */ -EAPI char *realpath(const char *file_name, char *resolved_name); +EVIL_API char *realpath(const char *file_name, char *resolved_name); #ifndef HAVE_REALPATH # define HAVE_REALPATH 1 #endif diff --git a/src/lib/evil/evil_string.c b/src/lib/evil/evil_string.c index d135454338..59b517d88a 100644 --- a/src/lib/evil/evil_string.c +++ b/src/lib/evil/evil_string.c @@ -14,7 +14,7 @@ * */ -char *strcasestr(const char *haystack, const char *needle) +EVIL_API char *strcasestr(const char *haystack, const char *needle) { size_t length_needle; size_t length_haystack; @@ -50,7 +50,7 @@ char *strcasestr(const char *haystack, const char *needle) return NULL; } -char * +EVIL_API char * strsep (char **stringp, const char *delim) { char *begin, *end; diff --git a/src/lib/evil/evil_string.h b/src/lib/evil/evil_string.h index a6ff858eed..ae3ccce380 100644 --- a/src/lib/evil/evil_string.h +++ b/src/lib/evil/evil_string.h @@ -35,7 +35,7 @@ * * Supported OS: Windows XP. */ -EAPI char *strcasestr(const char *haystack, const char *needle); +EVIL_API char *strcasestr(const char *haystack, const char *needle); /** * @brief Implements the strsep function which is used to separate strings. @@ -61,7 +61,7 @@ EAPI char *strcasestr(const char *haystack, const char *needle); * @since 1.8 * */ -EAPI char *strsep(char **stringp, const char *delim); +EVIL_API char *strsep(char **stringp, const char *delim); /** * @} diff --git a/src/lib/evil/evil_time.c b/src/lib/evil/evil_time.c index 7d8de8f37c..2262fc1a7b 100644 --- a/src/lib/evil/evil_time.c +++ b/src/lib/evil/evil_time.c @@ -173,7 +173,7 @@ conv_num(const unsigned char *buf, int *dest, unsigned int llim, unsigned int ul return buf; } -char * +EVIL_API char * strptime(const char *buf, const char *fmt, struct tm *tm) { unsigned char c; diff --git a/src/lib/evil/evil_time.h b/src/lib/evil/evil_time.h index e61692e079..591900df4f 100644 --- a/src/lib/evil/evil_time.h +++ b/src/lib/evil/evil_time.h @@ -38,7 +38,7 @@ struct timezone * * @since 1.25 */ -EAPI int evil_gettimeofday(struct timeval *tv, struct timezone *tz); +EVIL_API int evil_gettimeofday(struct timeval *tv, struct timezone *tz); #ifndef HAVE_GETTIMEOFDAY # define HAVE_GETTIMEOFDAY 1 #endif @@ -61,7 +61,7 @@ EAPI int evil_gettimeofday(struct timeval *tv, struct timezone *tz); * * Supported OS: Windows XP. */ -EAPI char *strptime(const char *buf, const char *fmt, struct tm *tm); +EVIL_API char *strptime(const char *buf, const char *fmt, struct tm *tm); /** diff --git a/src/lib/evil/evil_unistd.c b/src/lib/evil/evil_unistd.c index 535ef71231..02f01baaef 100644 --- a/src/lib/evil/evil_unistd.c +++ b/src/lib/evil/evil_unistd.c @@ -23,7 +23,7 @@ LONGLONG _evil_time_count; * */ -double +EVIL_API double evil_time_get(void) { LARGE_INTEGER count; @@ -39,7 +39,7 @@ evil_time_get(void) * */ -int +EVIL_API int evil_sockets_init(void) { WSADATA wsa_data; @@ -61,7 +61,7 @@ evil_sockets_init(void) return 0; } -void +EVIL_API void evil_sockets_shutdown(void) { WSACleanup(); @@ -71,7 +71,7 @@ evil_sockets_shutdown(void) * The code of the following functions has been kindly offered * by Tor Lillqvist. */ -int +EVIL_API int evil_pipe(int *fds) { struct sockaddr_in saddr; diff --git a/src/lib/evil/evil_unistd.h b/src/lib/evil/evil_unistd.h index a227e14fc2..5f8f006f87 100644 --- a/src/lib/evil/evil_unistd.h +++ b/src/lib/evil/evil_unistd.h @@ -1,6 +1,7 @@ #ifndef __EVIL_UNISTD_H__ #define __EVIL_UNISTD_H__ +#include "evil_private.h" /** * @file evil_unistd.h @@ -34,7 +35,7 @@ * * Supported OS: Windows XP. */ -EAPI double evil_time_get(void); +EVIL_API double evil_time_get(void); /* * Sockets and pipe related functions @@ -53,7 +54,7 @@ EAPI double evil_time_get(void); * * Supported OS: Windows XP. */ -EAPI int evil_sockets_init(void); +EVIL_API int evil_sockets_init(void); /** * @brief Shutdown the Windows socket system. @@ -64,7 +65,7 @@ EAPI int evil_sockets_init(void); * * Supported OS: Windows XP. */ -EAPI void evil_sockets_shutdown(void); +EVIL_API void evil_sockets_shutdown(void); /** * @brief Create a pair of sockets. @@ -80,7 +81,7 @@ EAPI void evil_sockets_shutdown(void); * * Supported OS: Windows XP. */ -EAPI int evil_pipe(int *fds); +EVIL_API int evil_pipe(int *fds); /** diff --git a/src/lib/evil/evil_util.c b/src/lib/evil/evil_util.c index 19ab64ac5d..2223a27cc1 100644 --- a/src/lib/evil/evil_util.c +++ b/src/lib/evil/evil_util.c @@ -15,7 +15,7 @@ DWORD _evil_tls_index; /* static void _evil_error_display(const char *fct, LONG res); */ static void _evil_last_error_display(const char *fct); -wchar_t * +EVIL_API wchar_t * evil_char_to_wchar(const char *text) { wchar_t *wtext; @@ -44,7 +44,7 @@ evil_char_to_wchar(const char *text) return wtext; } -char * +EVIL_API char * evil_wchar_to_char(const wchar_t *text) { char *atext; @@ -74,7 +74,7 @@ evil_wchar_to_char(const wchar_t *text) return atext; } -char * +EVIL_API char * evil_utf16_to_utf8(const wchar_t *text16) { char *text8; @@ -107,7 +107,7 @@ evil_utf16_to_utf8(const wchar_t *text16) return text8; } -wchar_t * +EVIL_API wchar_t * evil_utf8_to_utf16(const char *text) { wchar_t *text16; @@ -135,7 +135,7 @@ evil_utf8_to_utf16(const char *text) return text16; } -const char * +EVIL_API const char * evil_format_message(long err) { char *buf; @@ -174,7 +174,7 @@ evil_format_message(long err) return (const char *)buf; } -const char * +EVIL_API const char * evil_last_error_get(void) { DWORD err; @@ -189,7 +189,7 @@ _evil_last_error_display(const char *fct) fprintf(stderr, "[Evil] [%s] ERROR: %s\n", fct, evil_last_error_get()); } -int +EVIL_API int evil_path_is_absolute(const char *path) { size_t length; diff --git a/src/lib/evil/evil_util.h b/src/lib/evil/evil_util.h index 55b42f6823..4d7db43b3f 100644 --- a/src/lib/evil/evil_util.h +++ b/src/lib/evil/evil_util.h @@ -19,7 +19,7 @@ * * @ingroup Evil */ -EAPI wchar_t *evil_char_to_wchar(const char *text); +EVIL_API wchar_t *evil_char_to_wchar(const char *text); /** * @brief Convert a string from wchar_t * to char *. @@ -38,7 +38,7 @@ EAPI wchar_t *evil_char_to_wchar(const char *text); * * @ingroup Evil */ -EAPI char *evil_wchar_to_char(const wchar_t *text); +EVIL_API char *evil_wchar_to_char(const wchar_t *text); /** * @brief Convert a string from UTF-16 to UTF-8. @@ -57,7 +57,7 @@ EAPI char *evil_wchar_to_char(const wchar_t *text); * * @ingroup Evil */ -EAPI char *evil_utf16_to_utf8(const wchar_t *text); +EVIL_API char *evil_utf16_to_utf8(const wchar_t *text); /** * @brief Convert a string from UTF-8 to UTF-16. @@ -75,11 +75,11 @@ EAPI char *evil_utf16_to_utf8(const wchar_t *text); * * @ingroup Evil */ -EAPI wchar_t *evil_utf8_to_utf16(const char *text); +EVIL_API wchar_t *evil_utf8_to_utf16(const char *text); -EAPI const char *evil_format_message(long err); +EVIL_API const char *evil_format_message(long err); -EAPI const char *evil_last_error_get(void); +EVIL_API const char *evil_last_error_get(void); /** * @brief check if the given path is absolute. @@ -102,6 +102,6 @@ EAPI const char *evil_last_error_get(void); * * @ingroup Evil */ -EAPI int evil_path_is_absolute(const char *path); +EVIL_API int evil_path_is_absolute(const char *path); #endif /* __EVIL_UTIL_H__ */ diff --git a/src/lib/evil/meson.build b/src/lib/evil/meson.build index deecb9e3cb..dc86e6af0b 100644 --- a/src/lib/evil/meson.build +++ b/src/lib/evil/meson.build @@ -29,7 +29,7 @@ if target_machine.system() == 'windows' evil_ext_deps += [psapi, ole32, ws2_32, secur32, uuid, regexp] evil_lib = library('evil', evil_src, - c_args : package_c_args, + c_args : [package_c_args, '-DEVIL_BUILD'], dependencies : evil_ext_deps, include_directories : [config_dir], install: true,