summaryrefslogtreecommitdiff
path: root/src/lib/ecore/ecore_internal.h
diff options
context:
space:
mode:
authorFelipe Magno de Almeida <felipe@expertise.dev>2021-05-23 20:08:05 +0100
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2021-05-23 20:47:23 +0100
commit74204bccd724fe9dee428056d4710f37bbc2cffb (patch)
tree8d35c3ca7c6e407503dd78d5000b520ac934b28a /src/lib/ecore/ecore_internal.h
parent1304d9571775ef740ac6b8978ea4a2025a52c99a (diff)
ecore: Rename EAPI macro to ECORE_API in Ecore library
Summary: = The Rationale = 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 EAPI is the only solution that worked for MSVC. Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com> Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev> Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com> Reviewers: vtorri, raster Reviewed By: raster Subscribers: raster, cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D12271
Diffstat (limited to 'src/lib/ecore/ecore_internal.h')
-rw-r--r--src/lib/ecore/ecore_internal.h33
1 files changed, 3 insertions, 30 deletions
diff --git a/src/lib/ecore/ecore_internal.h b/src/lib/ecore/ecore_internal.h
index 9f6e55eb24..731456bf5e 100644
--- a/src/lib/ecore/ecore_internal.h
+++ b/src/lib/ecore/ecore_internal.h
@@ -2,34 +2,10 @@
2#ifndef _ECORE_INTERNAL_H 2#ifndef _ECORE_INTERNAL_H
3#define _ECORE_INTERNAL_H 3#define _ECORE_INTERNAL_H
4 4
5#ifdef EAPI 5#include <ecore_api.h>
6# undef EAPI
7#endif
8
9#ifdef _WIN32
10# ifdef EFL_BUILD
11# ifdef DLL_EXPORT
12# define EAPI __declspec(dllexport)
13# else
14# define EAPI
15# endif
16# else
17# define EAPI __declspec(dllimport)
18# endif
19#else
20# ifdef __GNUC__
21# if __GNUC__ >= 4
22# define EAPI __attribute__ ((visibility("default")))
23# else
24# define EAPI
25# endif
26# else
27# define EAPI
28# endif
29#endif
30 6
31EAPI void ecore_loop_arguments_send(int argc, const char **argv); 7ECORE_API void ecore_loop_arguments_send(int argc, const char **argv);
32EAPI Eina_Bool efl_loop_message_process(Eo *obj); 8ECORE_API Eina_Bool efl_loop_message_process(Eo *obj);
33 9
34static inline Eina_Value 10static inline Eina_Value
35efl_model_list_value_get(Eina_List *childrens, 11efl_model_list_value_get(Eina_List *childrens,
@@ -162,7 +138,4 @@ _efl_future_all_repack(Eo *o EINA_UNUSED, void *data EINA_UNUSED, const Eina_Val
162 return eina_value_error_init(EFL_MODEL_ERROR_UNKNOWN); 138 return eina_value_error_init(EFL_MODEL_ERROR_UNKNOWN);
163} 139}
164 140
165#undef EAPI
166#define EAPI
167
168#endif 141#endif