windows: Replace EAPI with EVIL_API in evil library

This commit is contained in:
Felipe Magno de Almeida 2020-05-02 23:29:08 -03:00
parent a5caa53f8f
commit 3c1425c23e
25 changed files with 105 additions and 115 deletions

24
src/lib/evil/evil_api.h Normal file
View File

@ -0,0 +1,24 @@
#ifndef EVIL_API_H
#define EVIL_API_H
#ifdef EVIL_API
#error EVIL_API cant be already defined
#endif
#ifdef _MSC_VER
# ifndef EVIL_DLL
# define EVIL_API
# elif defined(EVIL_BUILD)
# define EVIL_API __declspec(dllexport)
# else
# define EVIL_API __declspec(dllimport)
# endif
#else
# if __GNUC__ >= 4
# define EVIL_API __attribute__ ((visibility("default")))
# else
# define EVIL_API
# endif
#endif
#endif

View File

@ -2,6 +2,7 @@
#define __EVIL_DLFCN_H__
#include "evil_api.h"
#include <limits.h>
@ -142,7 +143,8 @@ struct Dl_info
*
* @ingroup Evil_Dlfcn
*/
EAPI void *dlopen(const char* path, int mode);
EVIL_API void *dlopen(const char* path, int mode);
#ifndef HAVE_DLOPEN
# define HAVE_DLOPEN 1
#endif
@ -168,7 +170,7 @@ EAPI void *dlopen(const char* path, int mode);
*
* @ingroup Evil_Dlfcn
*/
EAPI int dlclose(void* handle);
EVIL_API int dlclose(void* handle);
/**
* @brief Get the address of a symbol.
@ -192,7 +194,8 @@ EAPI int dlclose(void* handle);
*
* @ingroup Evil_Dlfcn
*/
EAPI void *dlsym(void* handle, const char* symbol);
EVIL_API void *dlsym(void* handle, const char* symbol);
#ifndef HAVE_DLSYM
#define HAVE_DLSYM 1
#endif
@ -221,7 +224,8 @@ EAPI void *dlsym(void* handle, const char* symbol);
*
* @ingroup Evil_Dlfcn
*/
EAPI int dladdr (const void *addr, Dl_info *info);
EVIL_API int dladdr(const void *addr, Dl_info *info);
#ifndef HAVE_DLADDR
#define HAVE_DLADDR 1
#endif
@ -248,7 +252,7 @@ EAPI int dladdr (const void *addr, Dl_info *info);
*
* @ingroup Evil_Dlfcn
*/
EAPI char *dlerror (void);
EVIL_API char *dlerror(void);
#endif /* __EVIL_DLFCN_H__ */

View File

@ -1,18 +0,0 @@
#ifndef EVIL_EAPI
#define EVIL_EAPI
#ifdef EAPI
# undef EAPI
#endif
#ifdef EFL_BUILD
# ifdef DLL_EXPORT
# define EAPI __declspec(dllexport)
# else
# define EAPI
# endif
#else
# define EAPI __declspec(dllimport)
#endif
#endif

View File

@ -2,6 +2,8 @@
# include "config.h"
#endif /* HAVE_CONFIG_H */
#include <define_lean_and_mean.h>
#include <stdio.h>
#include <sys/locking.h>
@ -10,6 +12,8 @@
#include "evil_private.h"
#include <undefine_lean_and_mean.h>
/* SOCKET is defined as a uintptr_t, so passing a fd (int) is not a problem */
static int
_is_socket(SOCKET s)

View File

@ -107,7 +107,7 @@ struct flock
*
* @ingroup Evil
*/
EAPI int fcntl(int fd, int cmd, ...);
EVIL_API int fcntl(int fd, int cmd, ...);
#endif /* __EVIL_FCNTL_H__ */

View File

@ -39,7 +39,7 @@ enum {
# define CODESET _NL_CTYPE_CODESET
# define RADIXCHAR _NL_NUMERIC_RADIXCHAR
EAPI char *nl_langinfo(nl_item index);
EVIL_API char *nl_langinfo(nl_item index);
#endif /*__EVIL_LANGINFO_H__ */

View File

@ -2,31 +2,13 @@
# include "config.h"
#endif
#include "evil_private.h" /* LC_MESSAGES */
#include <string.h>
#include <locale.h>
#include <errno.h>
#ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#undef WIN32_LEAN_AND_MEAN
#ifdef EAPI
# undef EAPI
#endif
#ifdef EFL_BUILD
# ifdef DLL_EXPORT
# define EAPI __declspec(dllexport)
# else
# define EAPI
# endif
#else
# define EAPI __declspec(dllimport)
#endif
#include "evil_locale.h" /* LC_MESSAGES */
#include <evil_windows.h>
/*
* LOCALE_SISO639LANGNAME and LOCALE_SISO3166CTRYNAME need at least a buffer

View File

@ -48,7 +48,7 @@
*
* @since 1.16
*/
EAPI char *evil_setlocale(int category, const char *locale);
EVIL_API char *evil_setlocale(int category, const char *locale);
/**

View File

@ -100,7 +100,7 @@
* When Evil is not used anymore, call evil_shutdown() to shut down
* the Evil library.
*/
EAPI int evil_init(void);
EVIL_API int evil_init(void);
/**
* @brief Shut down the Evil library.
@ -116,7 +116,7 @@ EAPI int evil_init(void);
* documentation anymore . You must call evil_init() again to use these
* functions again.
*/
EAPI int evil_shutdown(void);
EVIL_API int evil_shutdown(void);
/**

View File

@ -107,7 +107,7 @@
*
* @ingroup Evil_Mman
*/
EAPI void *mmap(void *addr,
EVIL_API void *mmap(void *addr,
size_t len,
int prot,
int flags,
@ -138,7 +138,7 @@ EAPI void *mmap(void *addr,
*
* @ingroup Evil_Mman
*/
EAPI int munmap(void *addr,
EVIL_API int munmap(void *addr,
size_t len);
/**
@ -159,7 +159,7 @@ EAPI int munmap(void *addr,
*
* @ingroup Evil_Mman
*/
EAPI int mprotect(void *addr, size_t len, int prot);
EVIL_API int mprotect(void *addr, size_t len, int prot);
#endif /* __EVIL_SYS_MMAN_H__ */

View File

@ -21,16 +21,14 @@ extern "C" {
#define EVIL_UNUSED
#endif
#ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#undef WIN32_LEAN_AND_MEAN
#include <evil_windows.h>
#include <stdint.h> /* for mode_t in */
#include <sys/stat.h> /* for mkdir in evil_macro_wrapper */
#include <sys/types.h> /* for mode_t in */
#include "evil_eapi.h"
#include <evil_api.h>
#ifndef PATH_MAX
@ -54,9 +52,6 @@ extern "C" {
#include "evil_macro_wrapper.h"
#undef EAPI
#define EAPI
#ifdef __cplusplus
}
#endif

View File

@ -2,7 +2,6 @@
# include "config.h"
#endif /* HAVE_CONFIG_H */
#include <sys/types.h>
#include <direct.h>
#include "evil_private.h"

View File

@ -1,6 +1,7 @@
#ifndef __EVIL_STDIO_H__
#define __EVIL_STDIO_H__
#include <sys/types.h>
/**
* @file evil_stdio.h
@ -41,7 +42,7 @@
*
* @since 1.8
*/
EAPI int evil_rename(const char *src, const char *dst);
EVIL_API int evil_rename(const char *src, const char *dst);
#ifndef HAVE_CYGWIN
typedef int mode_t;
@ -58,7 +59,7 @@ typedef int mode_t;
*
* @since 1.15
*/
EAPI int evil_mkdir(const char *dirname, mode_t mode);
EVIL_API int evil_mkdir(const char *dirname, mode_t mode);
#endif /* __EVIL_STDIO_H__ */

View File

@ -119,7 +119,7 @@ _mkstemp(char *suffix, int val)
return val;
}
EAPI char *
EVIL_API char *
mkdtemp(char *__template)
{
char *suffix;

View File

@ -1,7 +1,7 @@
#ifndef __EVIL_STDLIB_H__
#define __EVIL_STDLIB_H__
#include <evil_private.h>
#include "evil_api.h"
/**
* @file evil_stdlib.h
@ -41,7 +41,7 @@
*
* Supported OS: Windows XP.
*/
EAPI int setenv(const char *name,
EVIL_API int setenv(const char *name,
const char *value,
int overwrite);
@ -60,7 +60,7 @@ EAPI int setenv(const char *name,
*
* Supported OS: Windows XP.
*/
EAPI int unsetenv(const char *name);
EVIL_API int unsetenv(const char *name);
/*
@ -73,7 +73,7 @@ EAPI int unsetenv(const char *name);
*
* @since 1.8.0
*/
EAPI char *mkdtemp(char *__template);
EVIL_API char *mkdtemp(char *__template);
/**
* @brief Create a unique temporary file name with a suffix.
@ -84,7 +84,7 @@ EAPI char *mkdtemp(char *__template);
*
* @since 1.10.0
*/
EAPI int mkstemps(char *__template, int suffixlen);
EVIL_API int mkstemps(char *__template, int suffixlen);
/**
* @brief Return an absolute or full path name for a specified relative path name.
@ -115,7 +115,7 @@ EAPI int mkstemps(char *__template, int suffixlen);
*
* Supported OS: Windows XP.
*/
EAPI char *realpath(const char *file_name, char *resolved_name);
EVIL_API char *realpath(const char *file_name, char *resolved_name);
#ifndef HAVE_REALPATH
# define HAVE_REALPATH 1
#endif

View File

@ -35,7 +35,7 @@
*
* Supported OS: Windows XP.
*/
EAPI char *strcasestr(const char *haystack, const char *needle);
EVIL_API char *strcasestr(const char *haystack, const char *needle);
/**
* @brief Implements the strsep function which is used to separate strings.
@ -61,6 +61,6 @@ EAPI char *strcasestr(const char *haystack, const char *needle);
* @since 1.8
*
*/
EAPI char *strsep(char **stringp, const char *delim);
EVIL_API char *strsep(char **stringp, const char *delim);
#endif /* __EVIL_STRING_H__ */

View File

@ -34,7 +34,7 @@
*
* Supported OS: Windows XP.
*/
EAPI char *strptime(const char *buf, const char *fmt, struct tm *tm);
EVIL_API char *strptime(const char *buf, const char *fmt, struct tm *tm);
/**

View File

@ -2,18 +2,18 @@
# include "config.h"
#endif /* HAVE_CONFIG_H */
#include <errno.h>
#include <direct.h>
# include <sys/time.h>
#ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
#endif
#include <winsock2.h>
#undef WIN32_LEAN_AND_MEAN
#include "evil_private.h"
#include <define_lean_and_mean.h>
#include <errno.h>
#include <define_lean_and_mean.h>
#include <direct.h>
#include <define_lean_and_mean.h>
#include <sys/time.h>
#include <define_lean_and_mean.h>
//#include <winsock2.h>
#include <undefine_lean_and_mean.h>
LONGLONG _evil_time_freq;
LONGLONG _evil_time_count;

View File

@ -1,7 +1,7 @@
#ifndef __EVIL_UNISTD_H__
#define __EVIL_UNISTD_H__
#include "evil_eapi.h"
#include "evil_api.h"
/**
* @file evil_unistd.h
@ -35,7 +35,7 @@
*
* Supported OS: Windows XP.
*/
EAPI double evil_time_get(void);
EVIL_API double evil_time_get(void);
/*
* Sockets and pipe related functions
@ -54,7 +54,7 @@ EAPI double evil_time_get(void);
*
* Supported OS: Windows XP.
*/
EAPI int evil_sockets_init(void);
EVIL_API int evil_sockets_init(void);
/**
* @brief Shutdown the Windows socket system.
@ -65,7 +65,7 @@ EAPI int evil_sockets_init(void);
*
* Supported OS: Windows XP.
*/
EAPI void evil_sockets_shutdown(void);
EVIL_API void evil_sockets_shutdown(void);
/**
* @brief Create a pair of sockets.
@ -81,7 +81,7 @@ EAPI void evil_sockets_shutdown(void);
*
* Supported OS: Windows XP.
*/
EAPI int evil_pipe(int *fds);
EVIL_API int evil_pipe(int *fds);
/**

View File

@ -19,7 +19,7 @@
*
* @ingroup Evil
*/
EAPI wchar_t *evil_char_to_wchar(const char *text);
EVIL_API wchar_t *evil_char_to_wchar(const char *text);
/**
* @brief Convert a string from wchar_t * to char *.
@ -38,7 +38,7 @@ EAPI wchar_t *evil_char_to_wchar(const char *text);
*
* @ingroup Evil
*/
EAPI char *evil_wchar_to_char(const wchar_t *text);
EVIL_API char *evil_wchar_to_char(const wchar_t *text);
/**
* @brief Convert a string from UTF-16 to UTF-8.
@ -57,7 +57,7 @@ EAPI char *evil_wchar_to_char(const wchar_t *text);
*
* @ingroup Evil
*/
EAPI char *evil_utf16_to_utf8(const wchar_t *text);
EVIL_API char *evil_utf16_to_utf8(const wchar_t *text);
/**
* @brief Convert a string from UTF-8 to UTF-16.
@ -75,11 +75,11 @@ EAPI char *evil_utf16_to_utf8(const wchar_t *text);
*
* @ingroup Evil
*/
EAPI wchar_t *evil_utf8_to_utf16(const char *text);
EVIL_API wchar_t *evil_utf8_to_utf16(const char *text);
EAPI const char *evil_format_message(long err);
EVIL_API const char *evil_format_message(long err);
EAPI const char *evil_last_error_get(void);
EVIL_API const char *evil_last_error_get(void);
/**
* @brief check if the given path is absolute.
@ -102,6 +102,6 @@ EAPI const char *evil_last_error_get(void);
*
* @ingroup Evil
*/
EAPI int evil_path_is_absolute(const char *path);
EVIL_API int evil_path_is_absolute(const char *path);
#endif /* __EVIL_UTIL_H__ */

View File

@ -0,0 +1,11 @@
#ifndef __EVIL_WINDOWS_H__
#define __EVIL_WINDOWS_H__
#ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
#endif
#include <winsock2.h>
#include <windows.h>
#endif

View File

@ -28,6 +28,7 @@ if target_machine.system() == 'windows'
evil_pub_deps = [psapi, ole32, ws2_32, secur32, uuid, pcre_dep, evil_unposix]
evil_lib = library('evil', evil_src,
c_args : ['-DEVIL_BUILD', '-DEVIL_DLL'],
dependencies : evil_deps,
include_directories : [config_dir],
install: true,
@ -41,7 +42,6 @@ if target_machine.system() == 'windows'
)
else
evil = declare_dependency()
evil_unposix = declare_dependency()
endif
automatic_pkgfile = false

View File

@ -1,17 +1,10 @@
#ifndef UNPOSIX_LIMITS_H
#define UNPOSIX_LIMITS_H
#ifdef _WIN32
# ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
# endif
# include <windows.h>
# undef WIN32_LEAN_AND_MEAN
# include_next <limits.h>
# ifndef PATH_MAX
# define PATH_MAX MAX_PATH
# endif
#include <evil_windows.h>
#include_next <limits.h>
#ifndef PATH_MAX
# define PATH_MAX MAX_PATH
#endif
#endif

View File

@ -1,12 +1,7 @@
#ifndef UNPOSIX_SYS_STAT_H
#define UNPOSIX_SYS_STAT_H
#ifdef _WIN32
# ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
# endif
# include <windows.h>
#endif
#include <evil_windows.h>
#include <../ucrt/sys/types.h>
#include_next <sys/stat.h>
#include <corecrt.h>

View File

@ -5,7 +5,7 @@
# define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#include <evil_windows.h>
#include <winsock2.h>
#include <minwinbase.h>
#include <sysinfoapi.h>