diff options
author | Felipe Magno de Almeida <felipe@expertise.dev> | 2020-12-14 13:09:52 -0300 |
---|---|---|
committer | Felipe Magno de Almeida <felipe@expertise.dev> | 2020-12-14 13:29:16 -0300 |
commit | 7c74fc9b5fe14ae6f9abb3efc8889a815312230e (patch) | |
tree | db998dcb5bd4111297664c2998bc8791192e6cc6 | |
parent | 2368d2708965e77e39b3e8ae9def9a1d43a5a685 (diff) | |
download | efl-7c74fc9b5fe14ae6f9abb3efc8889a815312230e.tar.gz |
exactness: Use EXPORTAPI for symbols that will replace in library
We can export always because our declaration is always a definition in
exactness programs. So it doesn't make sense to condition on building
one library or another.
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>
-rw-r--r-- | src/bin/exactness/player.c | 12 | ||||
-rw-r--r-- | src/bin/exactness/recorder.c | 12 |
2 files changed, 12 insertions, 12 deletions
diff --git a/src/bin/exactness/player.c b/src/bin/exactness/player.c index 44b3f36303..af73df423b 100644 --- a/src/bin/exactness/player.c +++ b/src/bin/exactness/player.c @@ -1042,7 +1042,7 @@ _write_unit_file(void) #define ORIGINAL_CALL(name, ...) \ ORIGINAL_CALL_T(int, name, __VA_ARGS__) -EAPI int +EXPORTAPI int eina_init(void) { int original_return; @@ -1085,7 +1085,7 @@ eina_init(void) return original_return; } -EAPI int +EXPORTAPI int ecore_evas_init(void) { int original_return; @@ -1101,7 +1101,7 @@ ecore_evas_init(void) } //hook, to hook in our theme -EAPI int +EXPORTAPI int elm_init(int argc, char **argv) { int original_return; @@ -1113,7 +1113,7 @@ elm_init(int argc, char **argv) return original_return; } -EAPI void +EXPORTAPI void ecore_main_loop_begin(void) { int original_return; @@ -1123,7 +1123,7 @@ ecore_main_loop_begin(void) (void)original_return; } -EAPI Eina_Value* +EXPORTAPI Eina_Value* efl_loop_begin(Eo *obj) { Eina_Value *original_return; @@ -1133,7 +1133,7 @@ efl_loop_begin(Eo *obj) return original_return; } -EAPI int +EXPORTAPI int eina_shutdown(void) { int original_return; diff --git a/src/bin/exactness/recorder.c b/src/bin/exactness/recorder.c index 6936521d7a..c5b181078c 100644 --- a/src/bin/exactness/recorder.c +++ b/src/bin/exactness/recorder.c @@ -308,7 +308,7 @@ _setup_ee_creation(void) #define ORIGINAL_CALL(name, ...) \ ORIGINAL_CALL_T(int, name, __VA_ARGS__) -EAPI int +EXPORTAPI int eina_init(void) { int original_return; @@ -332,7 +332,7 @@ eina_init(void) return original_return; } -EAPI int +EXPORTAPI int ecore_evas_init(void) { int original_return; @@ -349,7 +349,7 @@ ecore_evas_init(void) } //hook, to hook in our theme -EAPI int +EXPORTAPI int elm_init(int argc, char **argv) { int original_return; @@ -361,7 +361,7 @@ elm_init(int argc, char **argv) return original_return; } -EAPI void +EXPORTAPI void ecore_main_loop_begin(void) { int original_return; @@ -371,7 +371,7 @@ ecore_main_loop_begin(void) (void)original_return; } -EAPI Eina_Value* +EXPORTAPI Eina_Value* efl_loop_begin(Eo *obj) { Eina_Value *original_return; @@ -381,7 +381,7 @@ efl_loop_begin(Eo *obj) return original_return; } -EAPI int +EXPORTAPI int eina_shutdown(void) { int original_return; |