diff options
author | Andris Zeila <andris.zeila@zabbix.com> | 2019-12-02 10:41:34 +0300 |
---|---|---|
committer | Andris Zeila <andris.zeila@zabbix.com> | 2019-12-02 10:44:14 +0300 |
commit | 3b74170245fd7aac5d6fd17ca0a9aecacdb446f5 (patch) | |
tree | d22a5a5034a4be4e4f7ec5316f3bb62bfa6b6133 /include | |
parent | a96e87c1a9f6114fe2088c4f3757a35e7b6bc9c5 (diff) |
...G...... [ZBXNEXT-5609] added agent2 windows build support
* commit '636b601d1dec2d9b3bf4d423877c0477ba7a7fe0': (39 commits)
.......... [ZBXNEXT-5609] fixed coding style
.......... [ZBXNEXT-5609] added changelog entry
.......... [DEV-1333] fixed compilation on windows
.......... [DEV-1333] removed unused function
.......... [DEV-1333] fixed log monitoring crash
.......... [DEV-1333] added empty scheduler update when host is disabled
.......... [DEV-1333] removed mtime from eventlog result
.......... [DEV-1333] fixed version remote command format
.......... [DEV-1333] fixed 64 bit architecture setting
.......... [DEV-1333] added compile date/time/os/arch variable support
.......... [DEV-1333] fixed logrt not working on windows due to file being opened in text mode instead of binary and path separator being unix style
.......... [DEV-1333] reworked windows command execution to use undocumented (but widely used) NtResumeProcess() function from ntdll.dll
.......... [DEV-1333] fixed logrt on windows
.......... [DEV-1333] added application starting directory as default location for agent configuration file on windows
.......... [DEV-1333] added current directory as default location for agent configuration file on windows
.......... [DEV-1333] added comment, minor refactoring
.......... [DEV-1333] removed global system.run related configuration settings
.......... [DEV-1333] fixed command execution on 32 bit windows, added check for process exit code as a workaround for race condition when started process finished before a job is assigned
.......... [DEV-1333] fixed not to support PID file on Windows
.......... [DEV-1333] fixed not to support PID file on Windows
...
(cherry picked from commit 014f43c2a00bf7286c70cd14ecc1cddfa9254e6e)
Diffstat (limited to 'include')
-rw-r--r-- | include/common.h | 11 | ||||
-rw-r--r-- | include/perfmon.h | 2 | ||||
-rw-r--r-- | include/symbols.h | 2 | ||||
-rw-r--r-- | include/sysinfo.h | 8 | ||||
-rw-r--r-- | include/threads.h | 4 | ||||
-rw-r--r-- | include/zbxtypes.h | 31 |
6 files changed, 31 insertions, 27 deletions
diff --git a/include/common.h b/include/common.h index f82f5d98e7e..5ef1218bf86 100644 --- a/include/common.h +++ b/include/common.h @@ -25,6 +25,11 @@ #include "version.h" #include "md5.h" +#if defined(__MINGW32__) +# define __try +# define __except(x) if (0) +#endif + #ifndef va_copy # if defined(__va_copy) # define va_copy(d, s) __va_copy(d, s) @@ -1181,7 +1186,7 @@ void uint64_array_remove(zbx_uint64_t *values, int *num, const zbx_uint64_t *rm_ const char *zbx_event_value_string(unsigned char source, unsigned char object, unsigned char value); -#ifdef _WINDOWS +#if defined(_WINDOWS) || defined(__MINGW32__) const OSVERSIONINFOEX *zbx_win_getversion(void); void zbx_wmi_get(const char *wmi_namespace, const char *wmi_query, char **utf8_value); wchar_t *zbx_acp_to_unicode(const char *acp_string); @@ -1194,7 +1199,7 @@ int _wis_uint(const wchar_t *wide_string); #endif void zbx_strlower(char *str); void zbx_strupper(char *str); -#if defined(_WINDOWS) || defined(HAVE_ICONV) +#if defined(_WINDOWS) || defined(__MINGW32__) || defined(HAVE_ICONV) char *convert_to_utf8(char *in, size_t in_size, const char *encoding); #endif /* HAVE_ICONV */ #define ZBX_MAX_BYTES_IN_UTF8_CHAR 4 @@ -1558,7 +1563,7 @@ char *zbx_create_token(zbx_uint64_t seed); int zbx_variant_to_value_type(zbx_variant_t *value, unsigned char value_type, char **errmsg); -#ifdef _WINDOWS +#if defined(_WINDOWS) || defined(__MINGW32__) #define ZBX_PCRE_RECURSION_LIMIT 2000 /* assume ~1 MB stack and ~500 bytes per recursion */ #endif diff --git a/include/perfmon.h b/include/perfmon.h index 128e4ed13c8..e45a706177b 100644 --- a/include/perfmon.h +++ b/include/perfmon.h @@ -20,7 +20,7 @@ #ifndef ZABBIX_PERFMON_H #define ZABBIX_PERFMON_H -#ifndef _WINDOWS +#if !defined(_WINDOWS) && !defined(__MINGW32__) # error "This module is only available for Windows OS" #endif diff --git a/include/symbols.h b/include/symbols.h index 6863b45aca9..600e825c043 100644 --- a/include/symbols.h +++ b/include/symbols.h @@ -20,7 +20,7 @@ #ifndef ZABBIX_SYMBOLS_H #define ZABBIX_SYMBOLS_H -#if defined(_WINDOWS) +#if defined(_WINDOWS) || defined(__MINGW32__) /* some definitions which are not available on older MS Windows versions */ typedef enum { diff --git a/include/sysinfo.h b/include/sysinfo.h index 16d236662de..4d040ab9a8c 100644 --- a/include/sysinfo.h +++ b/include/sysinfo.h @@ -141,7 +141,7 @@ extern int CONFIG_UNSAFE_USER_PARAMETERS; #define ZBX_AVG15 2 #define ZBX_AVG_COUNT 3 -#ifdef _WINDOWS +#if defined(_WINDOWS) # define MAX_COLLECTOR_PERIOD (15 * SEC_PER_MIN) #endif @@ -269,7 +269,7 @@ int VFS_FS_SIZE(AGENT_REQUEST *request, AGENT_RESULT *result); int VFS_FS_DISCOVERY(AGENT_REQUEST *request, AGENT_RESULT *result); int VM_MEMORY_SIZE(AGENT_REQUEST *request, AGENT_RESULT *result); -#ifdef _WINDOWS +#if defined(_WINDOWS) || defined(__MINGW32__) int USER_PERF_COUNTER(AGENT_REQUEST *request, AGENT_RESULT *result); int PERF_COUNTER(AGENT_REQUEST *request, AGENT_RESULT *result); int PERF_COUNTER_EN(AGENT_REQUEST *request, AGENT_RESULT *result); @@ -288,7 +288,7 @@ int VM_VMEMORY_SIZE(AGENT_REQUEST *request, AGENT_RESULT *result); int SYSTEM_STAT(AGENT_REQUEST *request, AGENT_RESULT *result); #endif -#ifdef _WINDOWS +#if defined(_WINDOWS) || defined(__MINGW32__) typedef int (*zbx_metric_func_t)(AGENT_REQUEST *request, AGENT_RESULT *result, HANDLE timeout_event); #else typedef int (*zbx_metric_func_t)(AGENT_REQUEST *request, AGENT_RESULT *result); @@ -310,7 +310,7 @@ int zbx_execute_threaded_metric(zbx_metric_func_t metric_func, AGENT_REQUEST *re #define ZBX_SYSINFO_PROC_CMDLINE 0x0004 #define ZBX_SYSINFO_PROC_USER 0x0008 -#ifdef _WINDOWS +#if defined(_WINDOWS) || defined(__MINGW32__) #define ZBX_MUTEX_ALL_ALLOW 0 #define ZBX_MUTEX_THREAD_DENIED 1 #define ZBX_MUTEX_LOGGING_DENIED 2 diff --git a/include/threads.h b/include/threads.h index c3b6d451ead..304cca93ecd 100644 --- a/include/threads.h +++ b/include/threads.h @@ -22,7 +22,7 @@ #include "common.h" -#if defined(_WINDOWS) +#if defined(_WINDOWS) || defined(__MINGW32__) /* the ZBXEndThread function is implemented in service.c file */ void CALLBACK ZBXEndThread(ULONG_PTR dwParam); @@ -82,7 +82,7 @@ typedef struct int process_num; unsigned char process_type; void *args; -#ifdef _WINDOWS +#if defined(_WINDOWS) || defined(__MINGW32__) ZBX_THREAD_ENTRY_POINTER(entry); #endif } diff --git a/include/zbxtypes.h b/include/zbxtypes.h index 4007906c095..e51a3e0c6c8 100644 --- a/include/zbxtypes.h +++ b/include/zbxtypes.h @@ -23,23 +23,28 @@ #if defined(_WINDOWS) # define ZBX_THREAD_LOCAL __declspec(thread) #else -# if defined(__GNUC__) || defined(__clang__) +# if defined(__GNUC__) || defined(__clang__) || defined(__MINGW32__) # define ZBX_THREAD_LOCAL __thread # else # define ZBX_THREAD_LOCAL # endif #endif -#define ZBX_FS_DBL "%lf" -#define ZBX_FS_DBL_EXT(p) "%." #p "lf" - -#define ZBX_PTR_SIZE sizeof(void *) +#if defined(_WINDOWS) +# define zbx_open(pathname, flags) __zbx_open(pathname, flags | O_BINARY) +# define PATH_SEPARATOR '\\' +#elif defined(__MINGW32__) +# define zbx_open(pathname, flags) open(pathname, flags | O_BINARY) +# define PATH_SEPARATOR '\\' +#else +# define zbx_open(pathname, flags) open(pathname, flags) +# define PATH_SEPARATOR '/' +#endif #if defined(_WINDOWS) # include <strsafe.h> # define zbx_stat(path, buf) __zbx_stat(path, buf) -# define zbx_open(pathname, flags) __zbx_open(pathname, flags | O_BINARY) # ifndef __UINT64_C # define __UINT64_C(x) x @@ -69,19 +74,13 @@ typedef unsigned __int32 zbx_uint32_t; typedef uint32_t zbx_uint32_t; # endif -# ifndef PATH_SEPARATOR -# define PATH_SEPARATOR '\\' -# endif - # define strcasecmp lstrcmpiA typedef __int64 zbx_offset_t; # define zbx_lseek(fd, offset, whence) _lseeki64(fd, (zbx_offset_t)(offset), whence) #else /* _WINDOWS */ - # define zbx_stat(path, buf) stat(path, buf) -# define zbx_open(pathname, flags) open(pathname, flags) # ifndef __UINT64_C # ifdef UINT64_C @@ -147,15 +146,15 @@ typedef __int64 zbx_offset_t; typedef uint32_t zbx_uint32_t; -# ifndef PATH_SEPARATOR -# define PATH_SEPARATOR '/' -# endif - typedef off_t zbx_offset_t; # define zbx_lseek(fd, offset, whence) lseek(fd, (zbx_offset_t)(offset), whence) #endif /* _WINDOWS */ +#define ZBX_FS_DBL "%lf" +#define ZBX_FS_DBL_EXT(p) "%." #p "lf" + +#define ZBX_PTR_SIZE sizeof(void *) #define ZBX_FS_SIZE_T ZBX_FS_UI64 #define ZBX_FS_SSIZE_T ZBX_FS_I64 #define ZBX_FS_TIME_T ZBX_FS_I64 |