Commit 3d1306f7 authored by Ajo Robert's avatar Ajo Robert

Bug#21770366 backport bug#21657078 to 5.5 and 5.6

Problem Statement
=========
Fix various issues when building MySQL with Visual Studio 2015.

Fix:
=======
- Visual Studio 2015 adds support for timespec. Add check and
  related code to use this and only use our replacement if
  timespec is not defined.
- Rename lfind/lsearch to my* to avoid redefinition problems.
- Set default value for TMPDIR to "" on Windows as P_tmpdir
  no longer exists.
- using VS definition of snprintf if available
- tzname are now renamed to _tzname.
parent 8c65e082
# Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -328,9 +328,16 @@ IF(SYSCONFDIR)
SET(DEFAULT_SYSCONFDIR "${SYSCONFDIR}")
ENDIF()
SET(TMPDIR "P_tmpdir"
IF(WIN32) # P_tmpdir is not defined on Windows as of VS2015.
SET(TMPDIR "" # So we use empty path as default. In practice TMP/TEMP is used
CACHE PATH
"PATH to MySQL TMP dir")
ELSE()
SET(TMPDIR "P_tmpdir"
CACHE PATH
"PATH to MySQL TMP dir. Defaults to the P_tmpdir macro in <stdio.h>")
ENDIF()
IF(TMPDIR STREQUAL "P_tmpdir")
# Do not quote it, to refer to the P_tmpdir macro.
SET(DEFAULT_TMPDIR "P_tmpdir")
......
# Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -185,6 +185,8 @@ CHECK_SYMBOL_REPLACEMENT(SIGQUIT SIGTERM signal.h)
CHECK_SYMBOL_REPLACEMENT(SIGPIPE SIGINT signal.h)
CHECK_SYMBOL_REPLACEMENT(isnan _isnan float.h)
CHECK_SYMBOL_REPLACEMENT(finite _finite float.h)
CHECK_SYMBOL_REPLACEMENT(tzname _tzname time.h)
CHECK_SYMBOL_REPLACEMENT(snprintf _snprintf stdio.h)
CHECK_FUNCTION_REPLACEMENT(popen _popen)
CHECK_FUNCTION_REPLACEMENT(pclose _pclose)
CHECK_FUNCTION_REPLACEMENT(access _access)
......
# Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -227,7 +227,6 @@ SET(HAVE_SIZEOF_ULONG FALSE CACHE INTERNAL "")
SET(HAVE_SIZEOF_U_INT32_T FALSE CACHE INTERNAL "")
SET(HAVE_SIZE_OF_SSIZE_T FALSE CACHE INTERNAL "")
SET(HAVE_SLEEP CACHE INTERNAL "")
SET(HAVE_SNPRINTF CACHE INTERNAL "")
SET(HAVE_SOCKADDR_STORAGE_SS_FAMILY 1 CACHE INTERNAL "")
SET(HAVE_SOLARIS_STYLE_GETHOST CACHE INTERNAL "")
SET(STACK_DIRECTION -1 CACHE INTERNAL "")
......@@ -301,7 +300,7 @@ SET(HAVE_TIME 1 CACHE INTERNAL "")
SET(HAVE_TIMES CACHE INTERNAL "")
SET(HAVE_TIMESPEC_TS_SEC CACHE INTERNAL "")
SET(HAVE_TIME_H 1 CACHE INTERNAL "")
SET(HAVE_TZNAME 1 CACHE INTERNAL "")
SET(HAVE__tzname 1 CACHE INTERNAL "")
SET(HAVE_UNISTD_H CACHE INTERNAL "")
SET(HAVE_UTIME_H CACHE INTERNAL "")
SET(HAVE_VALLOC CACHE INTERNAL "")
......
/* Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
/* Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -376,6 +376,7 @@
#cmakedefine HAVE_UINT64 1
#cmakedefine SIZEOF_BOOL @SIZEOF_BOOL@
#cmakedefine HAVE_BOOL 1
#cmakedefine HAVE_STRUCT_TIMESPEC
#cmakedefine SOCKET_SIZE_TYPE @SOCKET_SIZE_TYPE@
......@@ -497,6 +498,7 @@
#cmakedefine strtok_r @strtok_r@
#cmakedefine strtoll @strtoll@
#cmakedefine strtoull @strtoull@
#cmakedefine tzname @tzname@
#cmakedefine vsnprintf @vsnprintf@
#if (_MSC_VER > 1310)
# define HAVE_SETENV
......
# Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -561,7 +561,7 @@ MY_CHECK_TYPE_SIZE(char CHAR)
MY_CHECK_TYPE_SIZE(short SHORT)
MY_CHECK_TYPE_SIZE(int INT)
MY_CHECK_TYPE_SIZE("long long" LONG_LONG)
SET(CMAKE_EXTRA_INCLUDE_FILES stdio.h sys/types.h)
SET(CMAKE_EXTRA_INCLUDE_FILES stdio.h sys/types.h time.h)
MY_CHECK_TYPE_SIZE(off_t OFF_T)
MY_CHECK_TYPE_SIZE(uchar UCHAR)
MY_CHECK_TYPE_SIZE(uint UINT)
......@@ -576,6 +576,7 @@ MY_CHECK_TYPE_SIZE(u_int32_t U_INT32_T)
MY_CHECK_TYPE_SIZE(int64 INT64)
MY_CHECK_TYPE_SIZE(uint64 UINT64)
MY_CHECK_TYPE_SIZE(time_t TIME_T)
MY_CHECK_TYPE_SIZE("struct timespec" STRUCT_TIMESPEC)
SET (CMAKE_EXTRA_INCLUDE_FILES sys/types.h)
MY_CHECK_TYPE_SIZE(bool BOOL)
SET(CMAKE_EXTRA_INCLUDE_FILES)
......
/* Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
/* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -90,6 +90,7 @@ typedef volatile LONG my_pthread_once_t;
windows implementation of pthread_cond_timedwait
*/
#ifndef HAVE_STRUCT_TIMESPEC
/*
Declare a union to make sure FILETIME is properly aligned
so it can be used directly as a 64 bit value. The value
......@@ -128,6 +129,7 @@ struct timespec {
((TS1.tv.i64 > TS2.tv.i64) ? 1 : \
((TS1.tv.i64 < TS2.tv.i64) ? -1 : 0))
#endif
int win_pthread_mutex_trylock(pthread_mutex_t *mutex);
int pthread_create(pthread_t *, const pthread_attr_t *, pthread_handler, void *);
......@@ -433,13 +435,7 @@ int my_pthread_mutex_trylock(pthread_mutex_t *mutex);
#endif /* !set_timespec_nsec */
#else
#ifndef set_timespec
#define set_timespec(ABSTIME,SEC) \
{\
struct timeval tv;\
gettimeofday(&tv,0);\
(ABSTIME).tv_sec=tv.tv_sec+(time_t) (SEC);\
(ABSTIME).tv_nsec=tv.tv_usec*1000;\
}
#define set_timespec(ABSTIME,SEC) set_timespec_nsec((ABSTIME),(SEC)*1000000000ULL)
#endif /* !set_timespec */
#ifndef set_timespec_nsec
#define set_timespec_nsec(ABSTIME,NSEC) \
......
/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
/* Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -43,7 +43,7 @@ typedef struct {
/*
a structure to pass the context (pointers two the three successive elements
in a list) from lfind to linsert/ldelete
in a list) from my_lfind to linsert/ldelete
*/
typedef struct {
intptr volatile *prev;
......@@ -70,7 +70,7 @@ typedef struct {
cursor is positioned in either case
pins[0..2] are used, they are NOT removed on return
*/
static int lfind(LF_SLIST * volatile *head, CHARSET_INFO *cs, uint32 hashnr,
static int my_lfind(LF_SLIST * volatile *head, CHARSET_INFO *cs, uint32 hashnr,
const uchar *key, uint keylen, CURSOR *cursor, LF_PINS *pins)
{
uint32 cur_hashnr;
......@@ -138,7 +138,7 @@ retry:
/*
DESCRIPTION
insert a 'node' in the list that starts from 'head' in the correct
position (as found by lfind)
position (as found by my_lfind)
RETURN
0 - inserted
......@@ -156,7 +156,7 @@ static LF_SLIST *linsert(LF_SLIST * volatile *head, CHARSET_INFO *cs,
for (;;)
{
if (lfind(head, cs, node->hashnr, node->key, node->keylen,
if (my_lfind(head, cs, node->hashnr, node->key, node->keylen,
&cursor, pins) &&
(flags & LF_HASH_UNIQUE))
{
......@@ -207,7 +207,7 @@ static int ldelete(LF_SLIST * volatile *head, CHARSET_INFO *cs, uint32 hashnr,
for (;;)
{
if (!lfind(head, cs, hashnr, key, keylen, &cursor, pins))
if (!my_lfind(head, cs, hashnr, key, keylen, &cursor, pins))
{
res= 1; /* not found */
break;
......@@ -231,7 +231,7 @@ static int ldelete(LF_SLIST * volatile *head, CHARSET_INFO *cs, uint32 hashnr,
(to ensure the number of "set DELETED flag" actions
is equal to the number of "remove from the list" actions)
*/
lfind(head, cs, hashnr, key, keylen, &cursor, pins);
my_lfind(head, cs, hashnr, key, keylen, &cursor, pins);
}
res= 0;
break;
......@@ -257,12 +257,12 @@ static int ldelete(LF_SLIST * volatile *head, CHARSET_INFO *cs, uint32 hashnr,
it uses pins[0..2], on return the pin[2] keeps the node found
all other pins are removed.
*/
static LF_SLIST *lsearch(LF_SLIST * volatile *head, CHARSET_INFO *cs,
static LF_SLIST *my_lsearch(LF_SLIST * volatile *head, CHARSET_INFO *cs,
uint32 hashnr, const uchar *key, uint keylen,
LF_PINS *pins)
{
CURSOR cursor;
int res= lfind(head, cs, hashnr, key, keylen, &cursor, pins);
int res= my_lfind(head, cs, hashnr, key, keylen, &cursor, pins);
if (res)
_lf_pin(pins, 2, cursor.curr);
_lf_unpin(pins, 0);
......@@ -443,7 +443,7 @@ int lf_hash_delete(LF_HASH *hash, LF_PINS *pins, const void *key, uint keylen)
MY_ERRPTR if OOM
NOTE
see lsearch() for pin usage notes
see my_lsearch() for pin usage notes
*/
void *lf_hash_search(LF_HASH *hash, LF_PINS *pins, const void *key, uint keylen)
{
......@@ -457,7 +457,7 @@ void *lf_hash_search(LF_HASH *hash, LF_PINS *pins, const void *key, uint keylen)
return MY_ERRPTR;
if (*el == NULL && unlikely(initialize_bucket(hash, el, bucket, pins)))
return MY_ERRPTR;
found= lsearch(el, hash->charset, my_reverse_bits(hashnr) | 1,
found= my_lsearch(el, hash->charset, my_reverse_bits(hashnr) | 1,
(uchar *)key, keylen, pins);
lf_rwunlock_by_pins(pins);
return found ? found+1 : 0;
......
/* Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
/* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -88,6 +88,7 @@ static void check_native_cond_availability(void)
static DWORD get_milliseconds(const struct timespec *abstime)
{
#ifndef HAVE_STRUCT_TIMESPEC
long long millis;
union ft64 now;
......@@ -118,6 +119,17 @@ static DWORD get_milliseconds(const struct timespec *abstime)
millis= UINT_MAX;
return (DWORD)millis;
#else
/*
Convert timespec to millis and subtract current time.
my_getsystime() returns time in 100 ns units.
*/
if (abstime == NULL)
return INFINITE;
return (DWORD)(abstime->tv_sec * 1000 + abstime->tv_nsec / 1000000 -
my_getsystime() / 10000);
#endif
}
......
/* Copyright (C) 2007 Google Inc.
Copyright (c) 2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
Use is subject to license terms.
Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -48,7 +47,7 @@ static int getWaitTime(const struct timespec& start_ts);
static unsigned long long timespec_to_usec(const struct timespec *ts)
{
#ifndef __WIN__
#ifdef HAVE_STRUCT_TIMESPEC
return (unsigned long long) ts->tv_sec * TIME_MILLION + ts->tv_nsec / TIME_THOUSAND;
#else
return ts->tv.i64 / 10;
......@@ -683,7 +682,7 @@ int ReplSemiSyncMaster::commitTrx(const char* trx_wait_binlog_name,
}
/* Calcuate the waiting period. */
#ifdef __WIN__
#ifndef HAVE_STRUCT_TIMESPEC
abstime.tv.i64 = start_ts.tv.i64 + (__int64)wait_timeout_ * TIME_THOUSAND * 10;
abstime.max_timeout_msec= (long)wait_timeout_;
#else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment