You've already forked mariadb-connector-c
mirror of
https://github.com/mariadb-corporation/mariadb-connector-c.git
synced 2025-08-08 14:02:17 +03:00
Fixes for Solaris build (Bugs CONC-36,37 and 38)
This commit is contained in:
@@ -81,8 +81,32 @@ SET(SHAREDIR "share")
|
||||
SET(DEFAULT_CHARSET_HOME "${CMAKE_INSTALL_PREFIX}")
|
||||
SET(PLUGINDIR "${CMAKE_INSTALL_PREFIX}/lib/plugin")
|
||||
|
||||
#Check for threads
|
||||
INCLUDE(cmake/SearchLibrary.cmake)
|
||||
|
||||
IF(WITH_EXTERNAL_ZLIB)
|
||||
FIND_PACKAGE(ZLIB QUIET)
|
||||
IF(${ZLIB_FOUND})
|
||||
SET(LIBZ "-lz")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
IF(UNIX)
|
||||
SEARCH_LIBRARY(LIBNSL inet_ntoa "nsl_r;nsl")
|
||||
SEARCH_LIBRARY(LIBBIND bind "bind;socket")
|
||||
SEARCH_LIBRARY(LIBSOCKET setsockopt "socket")
|
||||
SEARCH_LIBRARY(LIBDL dlopen "dl")
|
||||
SEARCH_LIBRARY(LIBM floor m)
|
||||
SET(EXTRA_LIBS "${LIBNSL}" "${LIBBIND}" "${LIBSOCKET}" "${LIBDL}" "${LIBM}" "${LIBZ}")
|
||||
FIND_PACKAGE(Threads)
|
||||
SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${LIBNSL} ${LIBBIND}
|
||||
${LIBSOCKET} ${LIBDL} ${LIBM} ${CMAKE_THREAD_LIBS_INIT})
|
||||
#remove possible dups from required libraries
|
||||
LIST(LENGTH CMAKE_REQUIRED_LIBRARIES rllength)
|
||||
IF(${rllength} GREATER 0)
|
||||
LIST(REMOVE_DUPLICATES CMAKE_REQUIRED_LIBRARIES)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
|
||||
IF(CMAKE_HAVE_PTHREAD_H)
|
||||
SET(CMAKE_REQUIRED_INCLUDES pthread.h)
|
||||
@@ -97,14 +121,6 @@ ELSEIF()
|
||||
SET(HAVE_THREADS ${CMAKE_USE_PTHREADS})
|
||||
ENDIF()
|
||||
|
||||
IF(UNIX)
|
||||
FIND_LIBRARY(DL_LIBRARY dl)
|
||||
IF(DL_LIBRARY)
|
||||
SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${CMAKE_DL_LIBS})
|
||||
ENDIF()
|
||||
FIND_LIBRARY(MATH_LIBRARY m)
|
||||
ENDIF()
|
||||
|
||||
# check for various include files
|
||||
INCLUDE(${CMAKE_SOURCE_DIR}/cmake/CheckIncludeFiles.cmake)
|
||||
# check for various functions
|
||||
@@ -120,10 +136,6 @@ IF(WITH_SSL)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
IF(WITH_EXTERNAL_ZLIB)
|
||||
FIND_PACKAGE(ZLIB QUIET)
|
||||
ENDIF()
|
||||
|
||||
IF(WITH_SQLITE)
|
||||
ADD_DEFINITIONS(-DHAVE_SQLITE)
|
||||
ENDIF()
|
||||
|
@@ -92,7 +92,7 @@ ELSE(WIN32)
|
||||
IF (NOT SOCKET_SIZE_TYPE)
|
||||
CHECK_C_SOURCE_COMPILES("
|
||||
#include <sys/socket.h>
|
||||
int main()
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
getsockname(0, 0, (${CHECK_TYPE} *)0);
|
||||
return 0;
|
||||
|
23
cmake/SearchLibrary.cmake
Normal file
23
cmake/SearchLibrary.cmake
Normal file
@@ -0,0 +1,23 @@
|
||||
INCLUDE(CheckFunctionExists)
|
||||
INCLUDE(CheckLibraryExists)
|
||||
|
||||
FUNCTION(SEARCH_LIBRARY library_name function liblist)
|
||||
IF(${${library_name}})
|
||||
RETURN()
|
||||
ENDIF()
|
||||
CHECK_FUNCTION_EXISTS(${function} HAVE_${function}_IN_LIBC)
|
||||
# check if function is part of libc
|
||||
IF(HAVE_${function}_IN_LIBC)
|
||||
SET(${library_name} "" PARENT_SCOPE)
|
||||
RETURN()
|
||||
ENDIF()
|
||||
FOREACH(lib ${liblist})
|
||||
CHECK_LIBRARY_EXISTS(${lib} ${function} "" HAVE_${function}_IN_${lib})
|
||||
IF(HAVE_${function}_IN_${lib})
|
||||
SET(${library_name} ${lib} PARENT_SCOPE)
|
||||
SET(HAVE_${library_name} 1 PARENT_SCOPE)
|
||||
RETURN()
|
||||
ENDIF()
|
||||
ENDFOREACH()
|
||||
ENDFUNCTION()
|
||||
|
@@ -1,6 +1,4 @@
|
||||
|
||||
#define HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE 1
|
||||
|
||||
/*
|
||||
* Include file constants (processed in LibmysqlIncludeFiles.txt 1
|
||||
*/
|
||||
|
@@ -34,38 +34,6 @@ extern "C" {
|
||||
#endif
|
||||
#endif /* !defined(MSDOS) && !defined(_WIN32) */
|
||||
|
||||
/*
|
||||
Handling of gethostbyname_r()
|
||||
*/
|
||||
|
||||
#if !defined(HPUX)
|
||||
struct hostent;
|
||||
#endif /* HPUX */
|
||||
#if !defined(HAVE_GETHOSTBYNAME_R)
|
||||
struct hostent *my_gethostbyname_r(const char *name,
|
||||
struct hostent *result, char *buffer,
|
||||
int buflen, int *h_errnop);
|
||||
void my_gethostbyname_r_free(void);
|
||||
#elif defined(HAVE_PTHREAD_ATTR_CREATE) || defined(_AIX) || defined(HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE)
|
||||
#define my_gethostbyname_r_free()
|
||||
#if !defined(HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE) && !defined(HPUX)
|
||||
#define GETHOSTBYNAME_BUFF_SIZE sizeof(struct hostent_data)
|
||||
#endif /* !defined(HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE) */
|
||||
|
||||
#elif defined(HAVE_GETHOSTBYNAME_R_RETURN_INT)
|
||||
#define GETHOSTBYNAME_BUFF_SIZE sizeof(struct hostent_data)
|
||||
struct hostent *my_gethostbyname_r(const char *name,
|
||||
struct hostent *result, char *buffer,
|
||||
int buflen, int *h_errnop);
|
||||
#define my_gethostbyname_r_free()
|
||||
#else
|
||||
#define my_gethostbyname_r(A,B,C,D,E) gethostbyname_r((A),(B),(C),(D),(E))
|
||||
#define my_gethostbyname_r_free()
|
||||
#endif /* !defined(HAVE_GETHOSTBYNAME_R) */
|
||||
|
||||
#ifndef GETHOSTBYNAME_BUFF_SIZE
|
||||
#define GETHOSTBYNAME_BUFF_SIZE 2048
|
||||
#endif
|
||||
|
||||
/* On SCO you get a link error when refering to h_errno */
|
||||
#ifdef SCO
|
||||
|
@@ -56,7 +56,6 @@ my_div.c
|
||||
my_error.c
|
||||
my_fopen.c
|
||||
my_fstream.c
|
||||
my_gethostbyname.c
|
||||
my_getwd.c
|
||||
my_init.c
|
||||
my_lib.c
|
||||
|
@@ -364,7 +364,7 @@ mysql_load_plugin_v(MYSQL *mysql, const char *name, int type,
|
||||
name, SO_EXT, NullS);
|
||||
|
||||
/* Open new dll handle */
|
||||
if (!(dlhandle= dlopen(dlpath, RTLD_NOW)))
|
||||
if (!(dlhandle= dlopen((const char *)dlpath, RTLD_NOW)))
|
||||
{
|
||||
#ifdef _WIN32
|
||||
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
|
||||
|
@@ -317,9 +317,6 @@ static int DoTrace(CODE_STATE *cs);
|
||||
/* Test to see if file is writable */
|
||||
#if defined(HAVE_ACCESS)
|
||||
static BOOLEAN Writable(const char *pathname);
|
||||
/* Change file owner and group */
|
||||
static void ChangeOwner(CODE_STATE *cs, char *pathname);
|
||||
/* Allocate memory for runtime support */
|
||||
#endif
|
||||
|
||||
static void DoPrefix(CODE_STATE *cs, uint line);
|
||||
|
@@ -1625,10 +1625,12 @@ MYSQL *mthd_my_real_connect(MYSQL *mysql,const char *host, const char *user,
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* last call to connect 2 failed */
|
||||
if (rc)
|
||||
{
|
||||
my_set_error(mysql, CR_CONN_HOST_ERROR, SQLSTATE_UNKNOWN, ER(CR_CONN_HOST_ERROR),
|
||||
host, rc);
|
||||
closesocket(sock);
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
@@ -1,113 +0,0 @@
|
||||
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
|
||||
MA 02111-1307, USA */
|
||||
|
||||
/* Thread safe version of gethostbyname_r() */
|
||||
|
||||
#include "mysys_priv.h"
|
||||
#include <assert.h>
|
||||
#if !defined(MSDOS) && !defined(_WIN32)
|
||||
#include <netdb.h>
|
||||
#endif
|
||||
#include <my_net.h>
|
||||
|
||||
/* This file is not needed if my_gethostbyname_r is a macro */
|
||||
#if !defined(my_gethostbyname_r)
|
||||
|
||||
/*
|
||||
Emulate SOLARIS style calls, not because it's better, but just to make the
|
||||
usage of getbostbyname_r simpler.
|
||||
*/
|
||||
|
||||
#if defined(HAVE_GETHOSTBYNAME_R)
|
||||
|
||||
#if defined(HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE)
|
||||
|
||||
struct hostent *my_gethostbyname_r(const char *name,
|
||||
struct hostent *result, char *buffer,
|
||||
int buflen, int *h_errnop)
|
||||
{
|
||||
struct hostent *hp;
|
||||
dbug_assert((size_t) buflen >= sizeof(*result));
|
||||
if (gethostbyname_r(name,result, buffer, (size_t) buflen, &hp, h_errnop))
|
||||
return 0;
|
||||
return hp;
|
||||
}
|
||||
|
||||
#elif defined(HAVE_GETHOSTBYNAME_R_RETURN_INT)
|
||||
|
||||
struct hostent *my_gethostbyname_r(const char *name,
|
||||
struct hostent *result, char *buffer,
|
||||
int buflen, int *h_errnop)
|
||||
{
|
||||
dbug_assert(buflen >= sizeof(struct hostent_data));
|
||||
if (gethostbyname_r(name,result,(struct hostent_data *) buffer) == -1)
|
||||
{
|
||||
*h_errnop= errno;
|
||||
return 0;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
/* gethostbyname_r with similar interface as gethostbyname() */
|
||||
|
||||
struct hostent *my_gethostbyname_r(const char *name,
|
||||
struct hostent *result, char *buffer,
|
||||
int buflen, int *h_errnop)
|
||||
{
|
||||
struct hostent *hp;
|
||||
dbug_assert(buflen >= sizeof(struct hostent_data));
|
||||
hp= gethostbyname_r(name,result,(struct hostent_data *) buffer);
|
||||
*h_errnop= errno;
|
||||
return hp;
|
||||
}
|
||||
#endif /* GLIBC2_STYLE_GETHOSTBYNAME_R */
|
||||
|
||||
#else /* !HAVE_GETHOSTBYNAME_R */
|
||||
|
||||
#ifdef THREAD
|
||||
extern pthread_mutex_t LOCK_gethostbyname_r;
|
||||
#endif
|
||||
|
||||
/*
|
||||
No gethostbyname_r() function exists.
|
||||
In this case we have to keep a mutex over the call to ensure that no
|
||||
other thread is going to reuse the internal memory.
|
||||
|
||||
The user is responsible to call my_gethostbyname_r_free() when he
|
||||
is finished with the structure.
|
||||
*/
|
||||
|
||||
struct hostent *my_gethostbyname_r(const char *name,
|
||||
struct hostent *result, char *buffer,
|
||||
int buflen, int *h_errnop)
|
||||
{
|
||||
struct hostent *hp;
|
||||
pthread_mutex_lock(&LOCK_gethostbyname_r);
|
||||
hp= gethostbyname(name);
|
||||
*h_errnop= h_errno;
|
||||
return hp;
|
||||
}
|
||||
|
||||
void my_gethostbyname_r_free()
|
||||
{
|
||||
pthread_mutex_unlock(&LOCK_gethostbyname_r);
|
||||
}
|
||||
|
||||
#endif /* !HAVE_GETHOSTBYNAME_R */
|
||||
#endif /* !my_gethostbyname_r */
|
@@ -38,9 +38,6 @@ pthread_mutex_t LOCK_ssl_config;
|
||||
#ifndef HAVE_LOCALTIME_R
|
||||
pthread_mutex_t LOCK_localtime_r;
|
||||
#endif
|
||||
#ifndef HAVE_GETHOSTBYNAME_R
|
||||
pthread_mutex_t LOCK_gethostbyname_r;
|
||||
#endif
|
||||
#ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
|
||||
pthread_mutexattr_t my_fast_mutexattr;
|
||||
#endif
|
||||
@@ -82,9 +79,6 @@ my_bool my_thread_global_init(void)
|
||||
#endif
|
||||
#ifndef HAVE_LOCALTIME_R
|
||||
pthread_mutex_init(&LOCK_localtime_r,MY_MUTEX_INIT_SLOW);
|
||||
#endif
|
||||
#ifndef HAVE_GETHOSTBYNAME_R
|
||||
pthread_mutex_init(&LOCK_gethostbyname_r,MY_MUTEX_INIT_SLOW);
|
||||
#endif
|
||||
return my_thread_init();
|
||||
}
|
||||
@@ -103,9 +97,6 @@ void my_thread_global_end(void)
|
||||
#ifdef HAVE_OPENSSL
|
||||
pthread_mutex_destroy(&LOCK_ssl_config);
|
||||
#endif
|
||||
#ifndef HAVE_GETHOSTBYNAME_R
|
||||
pthread_mutex_destroy(&LOCK_gethostbyname_r);
|
||||
#endif
|
||||
}
|
||||
|
||||
static long thread_id=0;
|
||||
@@ -240,7 +231,7 @@ extern void **my_thread_var_dbug()
|
||||
if (! THR_KEY_mysys_initialized)
|
||||
return NULL;
|
||||
tmp= _my_thread_var();
|
||||
return tmp && tmp->initialized ? &tmp->dbug : 0;
|
||||
return tmp && tmp->initialized ? (void **)&tmp->dbug : 0;
|
||||
}
|
||||
#endif /* DBUG_OFF */
|
||||
|
||||
|
@@ -12,13 +12,15 @@ ENDFOREACH(dep)
|
||||
IF(UNIX)
|
||||
IF(OPENSSL_LIBRARIES)
|
||||
SET(extra_dynamic_LDFLAGS "${extra_dynamic_LDFLAGS} -lssl")
|
||||
ENDIF(OPENSSL_LIBRARIES)
|
||||
IF(DL_LIBRARY)
|
||||
SET(extra_dynamic_LDFLAGS "${extra_dynamic_LDFLAGS} -ldl")
|
||||
ENDIF(DL_LIBRARY)
|
||||
IF(MATH_LIBRARY)
|
||||
SET(extra_dynamic_LDFLAGS "${extra_dynamic_LDFLAGS} -lm")
|
||||
ENDIF(MATH_LIBRARY)
|
||||
ENDIF()
|
||||
SEARCH_LIBRARY(LIBNSL getaddrinfo "nsl_r;nsl")
|
||||
SEARCH_LIBRARY(LIBBIND bind "bind;socket")
|
||||
SEARCH_LIBRARY(LIBSOCKET setsockopt "socket")
|
||||
SEARCH_LIBRARY(LIBDL dlopen "dl")
|
||||
SEARCH_LIBRARY(LIBM floor m)
|
||||
FOREACH(lib ${EXTRA_LIBS})
|
||||
SET(extra_dynamic_LDFLAGS "${extra_dynamic_LDFLAGS} -l${lib}")
|
||||
ENDFOREACH()
|
||||
IF(WITH_SQLITE)
|
||||
SET(extra_dynamic_LDFLAGS "${extra_dynamic_LDFLAGS} -lsqlite")
|
||||
ENDIF()
|
||||
|
@@ -25,7 +25,7 @@ SET(API_TESTS "basic-t" "fetch" "charset" "logs" "cursor" "errors" "view" "ps" "
|
||||
|
||||
FOREACH(API_TEST ${API_TESTS})
|
||||
ADD_EXECUTABLE(${API_TEST} ${API_TEST}.c)
|
||||
TARGET_LINK_LIBRARIES(${API_TEST} mytap mariadbclient)
|
||||
TARGET_LINK_LIBRARIES(${API_TEST} mytap mariadbclient ${EXTRA_LIBS})
|
||||
ADD_TEST(${API_TEST} ${EXECUTABLE_OUTPUT_PATH}/${API_TEST})
|
||||
SET_TESTS_PROPERTIES(${API_TEST} PROPERTIES TIMEOUT 120)
|
||||
ENDFOREACH(API_TEST)
|
||||
|
Reference in New Issue
Block a user