forked from enlightenment/efl
ector: Rename EAPI macro to ECTOR_API in Ector 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 Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D12226
This commit is contained in:
parent
ff73049593
commit
6f23a9daa1
|
@ -6,31 +6,8 @@
|
|||
#ifdef EFL_BETA_API_SUPPORT
|
||||
#include <Efl.h>
|
||||
#endif
|
||||
#ifdef EAPI
|
||||
# undef EAPI
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
# ifdef EFL_BUILD
|
||||
# ifdef DLL_EXPORT
|
||||
# define EAPI __declspec(dllexport)
|
||||
# else
|
||||
# define EAPI
|
||||
# endif
|
||||
# else
|
||||
# define EAPI __declspec(dllimport)
|
||||
# endif
|
||||
#else
|
||||
# ifdef __GNUC__
|
||||
# if __GNUC__ >= 4
|
||||
# define EAPI __attribute__ ((visibility("default")))
|
||||
# else
|
||||
# define EAPI
|
||||
# endif
|
||||
# else
|
||||
# define EAPI
|
||||
# endif
|
||||
#endif
|
||||
#include <ector_api.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -133,7 +110,7 @@ typedef enum _Ector_Update_Type
|
|||
*
|
||||
* @see ector_shutfown()
|
||||
*/
|
||||
EAPI int ector_init(void);
|
||||
ECTOR_API int ector_init(void);
|
||||
|
||||
/**
|
||||
* @brief Shutdown the ector subsystem
|
||||
|
@ -141,7 +118,7 @@ EAPI int ector_init(void);
|
|||
*
|
||||
* @see ector_init()
|
||||
*/
|
||||
EAPI int ector_shutdown(void);
|
||||
ECTOR_API int ector_shutdown(void);
|
||||
|
||||
/**
|
||||
* @brief Registers OpenGL API calls with the internal Ector_GL_API.
|
||||
|
@ -156,7 +133,7 @@ EAPI int ector_shutdown(void);
|
|||
*
|
||||
* @see dlsym()
|
||||
*/
|
||||
EAPI Eina_Bool ector_glsym_set(void *(*glsym)(void *lib, const char *name), void *lib);
|
||||
ECTOR_API Eina_Bool ector_glsym_set(void *(*glsym)(void *lib, const char *name), void *lib);
|
||||
|
||||
/* Avoid redefinition of types */
|
||||
#define _ECTOR_SURFACE_EO_CLASS_TYPE
|
||||
|
@ -177,7 +154,4 @@ EAPI Eina_Bool ector_glsym_set(void *(*glsym)(void *lib, const char *name), void
|
|||
}
|
||||
#endif
|
||||
|
||||
#undef EAPI
|
||||
#define EAPI
|
||||
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
#ifndef _EFL_ECTOR_API_H
|
||||
#define _EFL_ECTOR_API_H
|
||||
|
||||
#ifdef ECTOR_API
|
||||
#error ECTOR_API should not be already defined
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
# ifndef ECTOR_STATIC
|
||||
# ifdef ECTOR_BUILD
|
||||
# define ECTOR_API __declspec(dllexport)
|
||||
# else
|
||||
# define ECTOR_API __declspec(dllimport)
|
||||
# endif
|
||||
# else
|
||||
# define ECTOR_API
|
||||
# endif
|
||||
# define ECTOR_API_WEAK
|
||||
#elif defined(__GNUC__)
|
||||
# if __GNUC__ >= 4
|
||||
# define ECTOR_API __attribute__ ((visibility("default")))
|
||||
# define ECTOR_API_WEAK __attribute__ ((weak))
|
||||
# else
|
||||
# define ECTOR_API
|
||||
# define ECTOR_API_WEAK
|
||||
# endif
|
||||
#else
|
||||
# define ECTOR_API
|
||||
# define ECTOR_API_WEAK
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -27,7 +27,7 @@ int _ector_log_dom_global = 0;
|
|||
|
||||
static int _ector_main_count = 0;
|
||||
|
||||
EAPI int
|
||||
ECTOR_API int
|
||||
ector_init(void)
|
||||
{
|
||||
if (EINA_LIKELY(_ector_main_count > 0))
|
||||
|
@ -62,7 +62,7 @@ donothing(void)
|
|||
{
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
ECTOR_API Eina_Bool
|
||||
ector_glsym_set(void *(*glsym)(void *lib, const char *name), void *lib)
|
||||
{
|
||||
Eina_Bool r = EINA_TRUE;
|
||||
|
@ -221,7 +221,7 @@ ector_glsym_set(void *(*glsym)(void *lib, const char *name), void *lib)
|
|||
return r;
|
||||
}
|
||||
|
||||
EAPI int
|
||||
ECTOR_API int
|
||||
ector_shutdown(void)
|
||||
{
|
||||
if (_ector_main_count <= 0)
|
||||
|
|
|
@ -3,31 +3,7 @@
|
|||
|
||||
#include <Ector.h>
|
||||
|
||||
#ifdef EAPI
|
||||
# undef EAPI
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
# ifdef EFL_BUILD
|
||||
# ifdef DLL_EXPORT
|
||||
# define EAPI __declspec(dllexport)
|
||||
# else
|
||||
# define EAPI
|
||||
# endif
|
||||
# else
|
||||
# define EAPI __declspec(dllimport)
|
||||
# endif
|
||||
#else
|
||||
# ifdef __GNUC__
|
||||
# if __GNUC__ >= 4
|
||||
# define EAPI __attribute__ ((visibility("default")))
|
||||
# else
|
||||
# define EAPI
|
||||
# endif
|
||||
# else
|
||||
# define EAPI
|
||||
# endif
|
||||
#endif
|
||||
#include "ector_api.h"
|
||||
|
||||
#ifdef EFL_BETA_API_SUPPORT
|
||||
|
||||
|
@ -48,7 +24,4 @@ typedef short GLshort;
|
|||
|
||||
#endif
|
||||
|
||||
#undef EAPI
|
||||
#define EAPI
|
||||
|
||||
#endif
|
||||
|
|
|
@ -31,6 +31,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', 'ECTOR_API',
|
||||
'-gchd', '@INPUT@'])
|
||||
endforeach
|
||||
|
||||
|
|
|
@ -46,6 +46,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', 'ECTOR_API',
|
||||
'-gchd', '@INPUT@'])
|
||||
endforeach
|
||||
|
||||
|
@ -76,6 +77,7 @@ foreach eo_file : pub_eo_types_files
|
|||
command : eolian_gen + [ '-I', meson.current_source_dir(), eolian_include_directories,
|
||||
'-o', 'h:' + join_paths(meson.current_build_dir(), eo_file + '.h'),
|
||||
'-o', 'd:' + join_paths(meson.current_build_dir(), eo_file + '.d'),
|
||||
'-e', 'ECTOR_API',
|
||||
'-ghd', '@INPUT@'])
|
||||
endforeach
|
||||
|
||||
|
@ -89,7 +91,7 @@ ector_ext_deps += ector_opt_lib_dep
|
|||
|
||||
ector_lib = library('ector',
|
||||
ector_src, pub_eo_file_target,
|
||||
c_args : package_c_args,
|
||||
c_args : [package_c_args, '-DECTOR_BUILD'],
|
||||
dependencies: ector_pub_deps + ector_ext_deps + ector_deps,
|
||||
include_directories : config_dir,
|
||||
install: true,
|
||||
|
|
|
@ -3,31 +3,7 @@
|
|||
|
||||
#include <Ector.h>
|
||||
|
||||
#ifdef EAPI
|
||||
# undef EAPI
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
# ifdef EFL_BUILD
|
||||
# ifdef DLL_EXPORT
|
||||
# define EAPI __declspec(dllexport)
|
||||
# else
|
||||
# define EAPI
|
||||
# endif
|
||||
# else
|
||||
# define EAPI __declspec(dllimport)
|
||||
# endif
|
||||
#else
|
||||
# ifdef __GNUC__
|
||||
# if __GNUC__ >= 4
|
||||
# define EAPI __attribute__ ((visibility("default")))
|
||||
# else
|
||||
# define EAPI
|
||||
# endif
|
||||
# else
|
||||
# define EAPI
|
||||
# endif
|
||||
#endif
|
||||
#include "ector_api.h"
|
||||
|
||||
#ifdef EFL_BETA_API_SUPPORT
|
||||
|
||||
|
@ -42,7 +18,4 @@
|
|||
|
||||
#endif
|
||||
|
||||
#undef EAPI
|
||||
#define EAPI
|
||||
|
||||
#endif
|
||||
|
|
|
@ -33,6 +33,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', 'ECTOR_API',
|
||||
'-gchd', '@INPUT@'])
|
||||
endforeach
|
||||
|
||||
|
|
Loading…
Reference in New Issue