summaryrefslogtreecommitdiff
path: root/src/lib
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 /src/lib
parent1f9e528b50569eeaa1cb9502ec0db4c985c7b043 (diff)
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
Diffstat (limited to 'src/lib')
-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 @@
4#include <Eina.h> 4#include <Eina.h>
5#include <Eo.h> 5#include <Eo.h>
6 6
7#ifdef EAPI 7#ifdef ECORE_AUDIO_API
8#undef EAPI 8#error ECORE_AUDIO_API should not be already defined
9#endif 9#endif
10 10
11#ifdef _WIN32 11#ifdef _WIN32
12# ifdef EFL_BUILD 12# ifndef ECORE_AUDIO_STATIC
13# ifdef DLL_EXPORT 13# ifdef ECORE_AUDIO_BUILD
14# define EAPI __declspec(dllexport) 14# define ECORE_AUDIO_API __declspec(dllexport)
15# else 15# else
16# define EAPI 16# define ECORE_AUDIO_API __declspec(dllimport)
17# endif 17# endif
18# else 18# else
19# define EAPI __declspec(dllimport) 19# define ECORE_AUDIO_API
20# endif 20# endif
21#else 21# define ECORE_AUDIO_API_WEAK
22# ifdef __GNUC__ 22#elif __GNUC__
23# if __GNUC__ >= 4 23# if __GNUC__ >= 4
24# define EAPI __attribute__ ((visibility("default"))) 24# define ECORE_AUDIO_API __attribute__ ((visibility("default")))
25# else 25# define ECORE_AUDIO_API_WEAK __attribute__ ((weak))
26# define EAPI
27# endif
28# else 26# else
29# define EAPI 27# define ECORE_AUDIO_API
28# define ECORE_AUDIO_API_WEAK
30# endif 29# endif
30#else
31# define ECORE_AUDIO_API
32# define ECORE_AUDIO_API_WEAK
31#endif 33#endif
32 34
33/** 35/**
@@ -176,7 +178,7 @@ typedef struct _Ecore_Audio_Vio Ecore_Audio_Vio;
176 * When Ecore_Audio is not used anymore, call ecore_audio_shutdown() 178 * When Ecore_Audio is not used anymore, call ecore_audio_shutdown()
177 * to shut down the Ecore_Audio library. 179 * to shut down the Ecore_Audio library.
178 */ 180 */
179EAPI int ecore_audio_init(void); 181ECORE_AUDIO_API int ecore_audio_init(void);
180 182
181/** 183/**
182 * @brief Shuts down the Ecore_Audio library. 184 * @brief Shuts down the Ecore_Audio library.
@@ -190,7 +192,7 @@ EAPI int ecore_audio_init(void);
190 * been called the same number of times than ecore_audio_init(). In that case 192 * been called the same number of times than ecore_audio_init(). In that case
191 * it shuts down all the services it uses. 193 * it shuts down all the services it uses.
192 */ 194 */
193EAPI int ecore_audio_shutdown(void); 195ECORE_AUDIO_API int ecore_audio_shutdown(void);
194 196
195//Legacy compatibility code 197//Legacy compatibility code
196 198
@@ -200,14 +202,14 @@ EAPI int ecore_audio_shutdown(void);
200 * @since 1.8 202 * @since 1.8
201 * 203 *
202 */ 204 */
203EAPI const char* ecore_audio_obj_name_get(const Efl_Object* obj); 205ECORE_AUDIO_API const char* ecore_audio_obj_name_get(const Efl_Object* obj);
204/** 206/**
205 * @brief Name of the object 207 * @brief Name of the object
206 * 208 *
207 * @since 1.8 209 * @since 1.8
208 * 210 *
209 */ 211 */
210EAPI void ecore_audio_obj_name_set(Efl_Object* obj, const char *name); 212ECORE_AUDIO_API void ecore_audio_obj_name_set(Efl_Object* obj, const char *name);
211 213
212#include <ecore_audio_obj.h> 214#include <ecore_audio_obj.h>
213#include <ecore_audio_obj_in.h> 215#include <ecore_audio_obj_in.h>
@@ -230,7 +232,4 @@ EAPI void ecore_audio_obj_name_set(Efl_Object* obj, const char *n
230} 232}
231#endif 233#endif
232 234
233#undef EAPI
234#define EAPI
235
236#endif 235#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;
27 27
28/* externally accessible functions */ 28/* externally accessible functions */
29 29
30EAPI int 30ECORE_AUDIO_API int
31ecore_audio_init(void) 31ecore_audio_init(void)
32{ 32{
33 33
@@ -60,7 +60,7 @@ ecore_audio_init(void)
60 return _ecore_audio_init_count; 60 return _ecore_audio_init_count;
61} 61}
62 62
63EAPI int 63ECORE_AUDIO_API int
64ecore_audio_shutdown(void) 64ecore_audio_shutdown(void)
65{ 65{
66 DBG("Ecore_Audio shutdown"); 66 DBG("Ecore_Audio shutdown");
@@ -263,13 +263,13 @@ ecore_audio_sndfile_lib_unload(void)
263#endif /* HAVE_SNDFILE */ 263#endif /* HAVE_SNDFILE */
264 264
265 265
266EAPI const char* 266ECORE_AUDIO_API const char*
267ecore_audio_obj_name_get(const Efl_Object* obj) 267ecore_audio_obj_name_get(const Efl_Object* obj)
268{ 268{
269 return efl_name_get(obj); 269 return efl_name_get(obj);
270} 270}
271 271
272EAPI void 272ECORE_AUDIO_API void
273ecore_audio_obj_name_set(Efl_Object* obj, const char *name) 273ecore_audio_obj_name_set(Efl_Object* obj, const char *name)
274{ 274{
275 efl_name_set(obj, name); 275 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
24 '-o', 'h:' + join_paths(meson.current_build_dir(), eo_file + '.h'), 24 '-o', 'h:' + join_paths(meson.current_build_dir(), eo_file + '.h'),
25 '-o', 'c:' + join_paths(meson.current_build_dir(), eo_file + '.c'), 25 '-o', 'c:' + join_paths(meson.current_build_dir(), eo_file + '.c'),
26 '-o', 'd:' + join_paths(meson.current_build_dir(), eo_file + '.d'), 26 '-o', 'd:' + join_paths(meson.current_build_dir(), eo_file + '.d'),
27 '-e', 'ECORE_AUDIO_API',
27 '-gchd', '@INPUT@']) 28 '-gchd', '@INPUT@'])
28endforeach 29endforeach
29 30
@@ -80,7 +81,7 @@ endif
80 81
81ecore_audio_lib = library('ecore_audio', 82ecore_audio_lib = library('ecore_audio',
82 ecore_audio_src, pub_eo_file_target, 83 ecore_audio_src, pub_eo_file_target,
83 c_args : package_c_args, 84 c_args : [package_c_args, '-DECORE_AUDIO_BUILD'],
84 dependencies: ecore_audio_pub_deps + ecore_audio_deps + ecore_audio_ext_deps, 85 dependencies: ecore_audio_pub_deps + ecore_audio_deps + ecore_audio_ext_deps,
85 include_directories : config_dir, 86 include_directories : config_dir,
86 install: true, 87 install: true,