summaryrefslogtreecommitdiff
path: root/src/lib/emotion/emotion_webcam.c
diff options
context:
space:
mode:
authorFelipe Magno de Almeida <felipe@expertise.dev>2021-01-11 10:31:30 +0000
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2021-01-11 10:31:30 +0000
commitc118886043ffe2e4d95bcc0e0c2780c79237ca5c (patch)
treec30dd1da3047b7f1b54fc43b24643bfb113a5aec /src/lib/emotion/emotion_webcam.c
parent0472f219790b822a3f41c12621a4001d7e5dfb86 (diff)
emotion: emotion EAPI macro to EMOTION_API in Emotion library
Summary: Patch from a series of patches to rename EAPI symbols to specific library DSOs. = 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, woohyun, jptiz, lucas Reviewed By: vtorri, lucas Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D12227
Diffstat (limited to '')
-rw-r--r--src/lib/emotion/emotion_webcam.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/lib/emotion/emotion_webcam.c b/src/lib/emotion/emotion_webcam.c
index 8b46b9a724..65a012c6f5 100644
--- a/src/lib/emotion/emotion_webcam.c
+++ b/src/lib/emotion/emotion_webcam.c
@@ -18,9 +18,9 @@
18 18
19#include "emotion_private.h" 19#include "emotion_private.h"
20 20
21EAPI int EMOTION_WEBCAM_UPDATE = 0; 21EMOTION_API int EMOTION_WEBCAM_UPDATE = 0;
22EAPI int EMOTION_WEBCAM_ADD = 0; 22EMOTION_API int EMOTION_WEBCAM_ADD = 0;
23EAPI int EMOTION_WEBCAM_DEL = 0; 23EMOTION_API int EMOTION_WEBCAM_DEL = 0;
24 24
25typedef struct _Emotion_Webcams Emotion_Webcams; 25typedef struct _Emotion_Webcams Emotion_Webcams;
26 26
@@ -295,7 +295,7 @@ emotion_webcam_shutdown(void)
295#endif 295#endif
296} 296}
297 297
298EAPI const Eina_List * 298EMOTION_API const Eina_List *
299emotion_webcams_get(void) 299emotion_webcams_get(void)
300{ 300{
301 EINA_SAFETY_ON_NULL_RETURN_VAL(_emotion_webcams, NULL); 301 EINA_SAFETY_ON_NULL_RETURN_VAL(_emotion_webcams, NULL);
@@ -303,21 +303,21 @@ emotion_webcams_get(void)
303 return _emotion_webcams->webcams; 303 return _emotion_webcams->webcams;
304} 304}
305 305
306EAPI const char * 306EMOTION_API const char *
307emotion_webcam_name_get(const Emotion_Webcam *ew) 307emotion_webcam_name_get(const Emotion_Webcam *ew)
308{ 308{
309 EINA_SAFETY_ON_NULL_RETURN_VAL(ew, NULL); 309 EINA_SAFETY_ON_NULL_RETURN_VAL(ew, NULL);
310 return ew->name; 310 return ew->name;
311} 311}
312 312
313EAPI const char * 313EMOTION_API const char *
314emotion_webcam_device_get(const Emotion_Webcam *ew) 314emotion_webcam_device_get(const Emotion_Webcam *ew)
315{ 315{
316 EINA_SAFETY_ON_NULL_RETURN_VAL(ew, NULL); 316 EINA_SAFETY_ON_NULL_RETURN_VAL(ew, NULL);
317 return ew->device; 317 return ew->device;
318} 318}
319 319
320EAPI const char * 320EMOTION_API const char *
321emotion_webcam_custom_get(const char *device EINA_UNUSED) 321emotion_webcam_custom_get(const char *device EINA_UNUSED)
322{ 322{
323 return NULL; 323 return NULL;