summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelipe Magno de Almeida <felipe@expertise.dev>2020-12-15 11:31:27 -0300
committerFelipe Magno de Almeida <felipe@expertise.dev>2020-12-15 11:36:42 -0300
commit75f07e41c0242123f9e4e5dcbc303ad46ea0849b (patch)
treecb6c78d771c948b94c762816fc8e1e50f13f7949
parent1f9e528b50569eeaa1cb9502ec0db4c985c7b043 (diff)
downloadefl-75f07e41c0242123f9e4e5dcbc303ad46ea0849b.tar.gz
ecore_audio: Rename EAPI macro to ECORE_AUDIO_API in Ecore Audio library
Summary: Patch from a series of patches to rename EAPI symbols to specific library DSOs. = The Rationale = This patch is from a series of patches to rename EAPI symbols to specific library DSOs. EAPI was designed to be able to pass `__attribute__ ((visibility ("default")))` for symbols with GCC, which would mean that even if -fvisibility=hidden was used when compiling the library, the needed symbols would get exported. MSVC __almost__ works like GCC (or mingw) in which you can declare everything as export and it will just work (slower, but it will work). But there's a caveat: global variables will not work the same way for MSVC, but works for mingw and GCC. For global variables (as opposed to functions), MSVC requires correct DSO visibility for MSVC: instead of declaring a symbol as export for everything, you need to declare it as import when importing from another DSO and export when defining it locally. With current EAPI definitions, we get the following example working in mingw and MSVC (observe it doesn't define any global variables as exported symbols). Example 1: dll1: ``` EAPI void foo(void); EAPI void bar() { foo(); } ``` dll2: ``` EAPI void foo() { printf ("foo\n"); } ``` This works fine with API defined as __declspec(dllexport) in both cases and for gcc defining as `__atttribute__((visibility("default")))`. However, the following: Example 2: dll1: ``` EAPI extern int foo; EAPI void foobar(void); EAPI void bar() { foo = 5; foobar(); } ``` dll2: ``` EAPI int foo = 0; EAPI void foobar() { printf ("foo %d\n", foo); } ``` This will work on mingw but will not work for MSVC. And that's why LIBAPI is the only solution that works for MSVC. Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com> Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com> Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev> Reviewers: vtorri, woohyun, lucas, jptiz Reviewed By: vtorri, lucas Subscribers: vtorri, cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D12212
-rw-r--r--src/lib/ecore_audio/Ecore_Audio.h43
-rw-r--r--src/lib/ecore_audio/ecore_audio.c8
-rw-r--r--src/lib/ecore_audio/meson.build3
3 files changed, 27 insertions, 27 deletions
diff --git a/src/lib/ecore_audio/Ecore_Audio.h b/src/lib/ecore_audio/Ecore_Audio.h
index 717c36c3fd..35b59d3c6e 100644
--- a/src/lib/ecore_audio/Ecore_Audio.h
+++ b/src/lib/ecore_audio/Ecore_Audio.h
@@ -4,30 +4,32 @@
#include <Eina.h>
#include <Eo.h>
-#ifdef EAPI
-#undef EAPI
+#ifdef ECORE_AUDIO_API
+#error ECORE_AUDIO_API should not be already defined
#endif
#ifdef _WIN32
-# ifdef EFL_BUILD
-# ifdef DLL_EXPORT
-# define EAPI __declspec(dllexport)
+# ifndef ECORE_AUDIO_STATIC
+# ifdef ECORE_AUDIO_BUILD
+# define ECORE_AUDIO_API __declspec(dllexport)
# else
-# define EAPI
+# define ECORE_AUDIO_API __declspec(dllimport)
# endif
# else
-# define EAPI __declspec(dllimport)
+# define ECORE_AUDIO_API
# endif
-#else
-# ifdef __GNUC__
-# if __GNUC__ >= 4
-# define EAPI __attribute__ ((visibility("default")))
-# else
-# define EAPI
-# endif
+# define ECORE_AUDIO_API_WEAK
+#elif __GNUC__
+# if __GNUC__ >= 4
+# define ECORE_AUDIO_API __attribute__ ((visibility("default")))
+# define ECORE_AUDIO_API_WEAK __attribute__ ((weak))
# else
-# define EAPI
+# define ECORE_AUDIO_API
+# define ECORE_AUDIO_API_WEAK
# endif
+#else
+# define ECORE_AUDIO_API
+# define ECORE_AUDIO_API_WEAK
#endif
/**
@@ -176,7 +178,7 @@ typedef struct _Ecore_Audio_Vio Ecore_Audio_Vio;
* When Ecore_Audio is not used anymore, call ecore_audio_shutdown()
* to shut down the Ecore_Audio library.
*/
-EAPI int ecore_audio_init(void);
+ECORE_AUDIO_API int ecore_audio_init(void);
/**
* @brief Shuts down the Ecore_Audio library.
@@ -190,7 +192,7 @@ EAPI int ecore_audio_init(void);
* been called the same number of times than ecore_audio_init(). In that case
* it shuts down all the services it uses.
*/
-EAPI int ecore_audio_shutdown(void);
+ECORE_AUDIO_API int ecore_audio_shutdown(void);
//Legacy compatibility code
@@ -200,14 +202,14 @@ EAPI int ecore_audio_shutdown(void);
* @since 1.8
*
*/
-EAPI const char* ecore_audio_obj_name_get(const Efl_Object* obj);
+ECORE_AUDIO_API const char* ecore_audio_obj_name_get(const Efl_Object* obj);
/**
* @brief Name of the object
*
* @since 1.8
*
*/
-EAPI void ecore_audio_obj_name_set(Efl_Object* obj, const char *name);
+ECORE_AUDIO_API void ecore_audio_obj_name_set(Efl_Object* obj, const char *name);
#include <ecore_audio_obj.h>
#include <ecore_audio_obj_in.h>
@@ -230,7 +232,4 @@ EAPI void ecore_audio_obj_name_set(Efl_Object* obj, const char *n
}
#endif
-#undef EAPI
-#define EAPI
-
#endif
diff --git a/src/lib/ecore_audio/ecore_audio.c b/src/lib/ecore_audio/ecore_audio.c
index be2e40c74c..91bf99b364 100644
--- a/src/lib/ecore_audio/ecore_audio.c
+++ b/src/lib/ecore_audio/ecore_audio.c
@@ -27,7 +27,7 @@ Ecore_Audio_Lib_Sndfile *ecore_audio_sndfile_lib = NULL;
/* externally accessible functions */
-EAPI int
+ECORE_AUDIO_API int
ecore_audio_init(void)
{
@@ -60,7 +60,7 @@ ecore_audio_init(void)
return _ecore_audio_init_count;
}
-EAPI int
+ECORE_AUDIO_API int
ecore_audio_shutdown(void)
{
DBG("Ecore_Audio shutdown");
@@ -263,13 +263,13 @@ ecore_audio_sndfile_lib_unload(void)
#endif /* HAVE_SNDFILE */
-EAPI const char*
+ECORE_AUDIO_API const char*
ecore_audio_obj_name_get(const Efl_Object* obj)
{
return efl_name_get(obj);
}
-EAPI void
+ECORE_AUDIO_API void
ecore_audio_obj_name_set(Efl_Object* obj, const char *name)
{
efl_name_set(obj, name);
diff --git a/src/lib/ecore_audio/meson.build b/src/lib/ecore_audio/meson.build
index 0376968a4b..95ffddf5b5 100644
--- a/src/lib/ecore_audio/meson.build
+++ b/src/lib/ecore_audio/meson.build
@@ -24,6 +24,7 @@ foreach eo_file : pub_eo_files
'-o', 'h:' + join_paths(meson.current_build_dir(), eo_file + '.h'),
'-o', 'c:' + join_paths(meson.current_build_dir(), eo_file + '.c'),
'-o', 'd:' + join_paths(meson.current_build_dir(), eo_file + '.d'),
+ '-e', 'ECORE_AUDIO_API',
'-gchd', '@INPUT@'])
endforeach
@@ -80,7 +81,7 @@ endif
ecore_audio_lib = library('ecore_audio',
ecore_audio_src, pub_eo_file_target,
- c_args : package_c_args,
+ c_args : [package_c_args, '-DECORE_AUDIO_BUILD'],
dependencies: ecore_audio_pub_deps + ecore_audio_deps + ecore_audio_ext_deps,
include_directories : config_dir,
install: true,