mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-08-05 20:55:46 +03:00
build: Fixed the Windows preprocessor macros and defines.
This commit is contained in:
@@ -16,9 +16,9 @@ set(SYSCONFDIR ${SYSCONF_INSTALL_DIR})
|
|||||||
set(BINARYDIR ${CMAKE_BINARY_DIR})
|
set(BINARYDIR ${CMAKE_BINARY_DIR})
|
||||||
set(SOURCEDIR ${CMAKE_SOURCE_DIR})
|
set(SOURCEDIR ${CMAKE_SOURCE_DIR})
|
||||||
|
|
||||||
if(CMAKE_COMPILER_IS_GNUCC)
|
if(CMAKE_COMPILER_IS_GNUCC AND NOT MINGW)
|
||||||
check_c_compiler_flag("-fvisibility=hidden" WITH_VISIBILITY_HIDDEN)
|
check_c_compiler_flag("-fvisibility=hidden" WITH_VISIBILITY_HIDDEN)
|
||||||
endif(CMAKE_COMPILER_IS_GNUCC)
|
endif(CMAKE_COMPILER_IS_GNUCC AND NOT MINGW)
|
||||||
|
|
||||||
# HEADER FILES
|
# HEADER FILES
|
||||||
check_include_file(argp.h HAVE_ARGP_H)
|
check_include_file(argp.h HAVE_ARGP_H)
|
||||||
@@ -36,11 +36,14 @@ if (WIN32)
|
|||||||
endif (HAVE_WSPIAPI_H OR HAVE_WS2TCPIP_H)
|
endif (HAVE_WSPIAPI_H OR HAVE_WS2TCPIP_H)
|
||||||
|
|
||||||
check_function_exists(vsnprintf HAVE_VSNPRINTF)
|
check_function_exists(vsnprintf HAVE_VSNPRINTF)
|
||||||
if(NOT HAVE_VSNPRINTF)
|
check_function_exists(snprintf HAVE_SNPRINTF)
|
||||||
|
|
||||||
|
if (WIN32)
|
||||||
check_function_exists(_vsnprintf_s HAVE__VSNPRINTF_S)
|
check_function_exists(_vsnprintf_s HAVE__VSNPRINTF_S)
|
||||||
check_function_exists(_vsnprintf HAVE__VSNPRINTF)
|
check_function_exists(_vsnprintf HAVE__VSNPRINTF)
|
||||||
endif(NOT HAVE_VSNPRINTF)
|
check_function_exists(_snprintf HAVE__SNPRINTF)
|
||||||
|
check_function_exists(_snprintf_s HAVE__SNPRINTF_S)
|
||||||
|
endif (WIN32)
|
||||||
check_function_exists(strncpy HAVE_STRNCPY)
|
check_function_exists(strncpy HAVE_STRNCPY)
|
||||||
|
|
||||||
set(HAVE_SELECT TRUE)
|
set(HAVE_SELECT TRUE)
|
||||||
|
@@ -38,16 +38,16 @@
|
|||||||
/*************************** FUNCTIONS ***************************/
|
/*************************** FUNCTIONS ***************************/
|
||||||
|
|
||||||
/* Define to 1 if you have the `vsnprintf' function. */
|
/* Define to 1 if you have the `vsnprintf' function. */
|
||||||
#cmakedefine HAVE_VSNPRINTF
|
#cmakedefine HAVE_VSNPRINTF 1
|
||||||
|
|
||||||
/* Define to 1 if you have the `_vsnprintf' function. */
|
/* Define to 1 if you have the `_vsnprintf' function. */
|
||||||
#cmakedefine HAVE__VSNPRINTF
|
#cmakedefine HAVE__VSNPRINTF 1
|
||||||
|
|
||||||
/* Define to 1 if you have the `_vsnprintf_s' function. */
|
/* Define to 1 if you have the `_vsnprintf_s' function. */
|
||||||
#cmakedefine HAVE__VSNPRINTF_S
|
#cmakedefine HAVE__VSNPRINTF_S 1
|
||||||
|
|
||||||
/* Define to 1 if you have the `strncpy' function. */
|
/* Define to 1 if you have the `strncpy' function. */
|
||||||
#cmakedefine HAVE_STRNCPY
|
#cmakedefine HAVE_STRNCPY 1
|
||||||
|
|
||||||
/* Define to 1 if you have the `cfmakeraw' function. */
|
/* Define to 1 if you have the `cfmakeraw' function. */
|
||||||
#cmakedefine HAVE_CFMAKERAW 1
|
#cmakedefine HAVE_CFMAKERAW 1
|
||||||
@@ -106,17 +106,3 @@
|
|||||||
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
|
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
|
||||||
significant byte first (like Motorola and SPARC, unlike Intel). */
|
significant byte first (like Motorola and SPARC, unlike Intel). */
|
||||||
#cmakedefine WORDS_BIGENDIAN 1
|
#cmakedefine WORDS_BIGENDIAN 1
|
||||||
|
|
||||||
/************************* MS Windows ***************************/
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
# ifdef _MSC_VER
|
|
||||||
/* On Microsoft compilers define inline to __inline on all others use inline */
|
|
||||||
# undef inline
|
|
||||||
# define inline __inline
|
|
||||||
|
|
||||||
# undef strdup
|
|
||||||
# define strdup _strdup
|
|
||||||
# endif // _MSC_VER
|
|
||||||
#endif /* _WIN32 */
|
|
||||||
|
|
||||||
|
@@ -32,46 +32,72 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _WIN32
|
||||||
|
|
||||||
/** Imitate define of inttypes.h */
|
/* Imitate define of inttypes.h */
|
||||||
|
# ifndef PRIdS
|
||||||
# define PRIdS "Id"
|
# define PRIdS "Id"
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifdef _MSC_VER
|
||||||
|
# include <stdio.h>
|
||||||
|
|
||||||
|
/* On Microsoft compilers define inline to __inline on all others use inline */
|
||||||
|
# undef inline
|
||||||
|
# define inline __inline
|
||||||
|
|
||||||
|
# undef strdup
|
||||||
|
# define strdup _strdup
|
||||||
|
|
||||||
# define strcasecmp _stricmp
|
# define strcasecmp _stricmp
|
||||||
# define strncasecmp _strnicmp
|
# define strncasecmp _strnicmp
|
||||||
# define strtoull _strtoui64
|
# define strtoull _strtoui64
|
||||||
# define isblank(ch) ((ch) == ' ' || (ch) == '\t' || (ch) == '\n' || (ch) == '\r')
|
# define isblank(ch) ((ch) == ' ' || (ch) == '\t' || (ch) == '\n' || (ch) == '\r')
|
||||||
|
|
||||||
#if _MSC_VER >= 1400
|
|
||||||
#define strdup _strdup
|
|
||||||
#endif
|
|
||||||
# define usleep(X) Sleep(((X)+1000)/1000)
|
# define usleep(X) Sleep(((X)+1000)/1000)
|
||||||
|
|
||||||
# undef strtok_r
|
# undef strtok_r
|
||||||
# define strtok_r strtok_s
|
# define strtok_r strtok_s
|
||||||
|
|
||||||
|
# if defined(HAVE__SNPRINTF_S)
|
||||||
# undef snprintf
|
# undef snprintf
|
||||||
# define snprintf(d, n, ...) _snprintf_s((d), (n), _TRUNCATE, __VA_ARGS__)
|
# define snprintf(d, n, ...) _snprintf_s((d), (n), _TRUNCATE, __VA_ARGS__)
|
||||||
|
# else /* HAVE__SNPRINTF_S */
|
||||||
|
# if defined(HAVE__SNPRINTF)
|
||||||
|
# undef snprintf
|
||||||
|
# define snprintf _snprintf
|
||||||
|
# else /* HAVE__SNPRINTF */
|
||||||
|
# if !defined(HAVE_SNPRINTF)
|
||||||
|
# error "no snprintf compatible function found"
|
||||||
|
# endif /* HAVE_SNPRINTF */
|
||||||
|
# endif /* HAVE__SNPRINTF */
|
||||||
|
# endif /* HAVE__SNPRINTF_S */
|
||||||
|
|
||||||
#ifndef HAVE_VSNPRINTF
|
# if defined(HAVE__VSNPRINTF_S)
|
||||||
#ifdef HAVE__VSNPRINTF_S
|
# undef vsnprintf
|
||||||
# define vsnprintf(s, n, f, v) _vsnprintf_s((s), (n), _TRUNCATE, (f), (v))
|
# define vsnprintf(s, n, f, v) _vsnprintf_s((s), (n), _TRUNCATE, (f), (v))
|
||||||
#elif HAVE__VSNPRINTF
|
# else /* HAVE__VSNPRINTF_S */
|
||||||
|
# if defined(HAVE__VSNPRINTF)
|
||||||
|
# undef vsnprintf
|
||||||
# define vsnprintf _vsnprintf
|
# define vsnprintf _vsnprintf
|
||||||
#else /* HAVE_VSNPRINTF */
|
# else
|
||||||
#error "No vsnprintf compatibel function found"
|
# if !defined(HAVE_VSNPRINTF)
|
||||||
#endif
|
# error "No vsnprintf compatible function found"
|
||||||
# endif /* HAVE_VSNPRINTF */
|
# endif /* HAVE_VSNPRINTF */
|
||||||
|
# endif /* HAVE__VSNPRINTF */
|
||||||
|
# endif /* HAVE__VSNPRINTF_S */
|
||||||
|
|
||||||
# ifndef HAVE_STRNCPY
|
# ifndef HAVE_STRNCPY
|
||||||
# define strncpy(d, s, n) strncpy_s((d), (n), (s), _TRUNCATE)
|
# define strncpy(d, s, n) strncpy_s((d), (n), (s), _TRUNCATE)
|
||||||
# endif
|
# endif
|
||||||
#else /* _MSC_VER */
|
# endif /* _MSC_VER */
|
||||||
|
|
||||||
|
#else /* _WIN32 */
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#define PRIdS "zd"
|
#define PRIdS "zd"
|
||||||
|
|
||||||
#endif /* _MSC_VER */
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
#include "libssh/libssh.h"
|
#include "libssh/libssh.h"
|
||||||
#include "libssh/callbacks.h"
|
#include "libssh/callbacks.h"
|
||||||
|
Reference in New Issue
Block a user