summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
authorMichael Widenius <monty@askmonty.org>2010-12-06 10:25:44 +0200
committerMichael Widenius <monty@askmonty.org>2010-12-06 10:25:44 +0200
commitb7b25dc666a8d331d16231f9fb658af8c05ac694 (patch)
tree0c7798c2d187db0da7837a70f306a789afc16521 /mysys
parentab5e4eefd5d25c6e0755c2460dbb433a7a9e913b (diff)
parentb3c72b9a02e570a4a66ca0a64e94fe1116976c85 (diff)
downloadmariadb-git-b7b25dc666a8d331d16231f9fb658af8c05ac694.tar.gz
Merge with 5.1-release.
- Fixed problem with oqgraph and 'make dist' Note that after this merge we have a problem show in join_outer where we examine too many rows in one specific case (related to BUG#57024). This will be fixed when mwl#128 is merged into 5.3.
Diffstat (limited to 'mysys')
-rw-r--r--mysys/Makefile.am16
-rw-r--r--mysys/charset.c2
-rw-r--r--mysys/my_gethostbyname.c11
-rw-r--r--mysys/my_gethwaddr.c32
-rw-r--r--mysys/my_getopt.c3
-rw-r--r--mysys/my_redel.c33
-rw-r--r--mysys/my_symlink.c15
-rw-r--r--mysys/my_sync.c7
-rw-r--r--mysys/my_uuid.c2
-rw-r--r--mysys/sha1.c55
-rw-r--r--mysys/thr_mutex.c4
11 files changed, 121 insertions, 59 deletions
diff --git a/mysys/Makefile.am b/mysys/Makefile.am
index 95358883f4e..515791be7f1 100644
--- a/mysys/Makefile.am
+++ b/mysys/Makefile.am
@@ -19,10 +19,11 @@ MYSQLBASEdir= $(prefix)
INCLUDES = @ZLIB_INCLUDES@ -I$(top_builddir)/include \
-I$(top_srcdir)/include -I$(srcdir)
pkglib_LIBRARIES = libmysys.a
+noinst_LTLIBRARIES = libmysys.la
LDADD = libmysys.a $(top_builddir)/strings/libmystrings.a $(top_builddir)/dbug/libdbug.a
noinst_HEADERS = mysys_priv.h my_static.h my_handler_errors.h \
my_safehash.h
-libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \
+libmysys_la_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \
mf_path.c mf_loadpath.c my_file.c \
my_open.c my_create.c my_dup.c my_seek.c my_read.c \
my_pread.c my_write.c my_getpagesize.c \
@@ -57,19 +58,22 @@ libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \
my_memmem.c stacktrace.c \
my_windac.c my_access.c base64.c my_libwrap.c \
wqueue.c
+libmysys_la_LDFLAGS = $(AM_LDFLAGS) @WRAPLIBS@
+libmysys_la_LIBADD = $(ZLIB_LIBS)
if NEED_THREAD
# mf_keycache is used only in the server, so it is safe to leave the file
# out of the non-threaded library.
# In fact, it will currently not compile without thread support.
-libmysys_a_SOURCES += mf_keycache.c mf_keycaches.c
+libmysys_la_SOURCES += thr_alarm.c thr_lock.c thr_mutex.c thr_rwlock.c \
+ my_pthread.c my_thr_init.c waiting_threads.c \
+ mf_keycache.c mf_keycaches.c
endif
EXTRA_DIST = thr_alarm.c thr_lock.c my_pthread.c my_thr_init.c \
thr_mutex.c thr_rwlock.c waiting_threads.c \
CMakeLists.txt mf_soundex.c \
my_conio.c my_wincond.c my_winthread.c
-libmysys_a_LIBADD = @THREAD_LOBJECTS@
# test_dir_DEPENDENCIES= $(LIBRARIES)
# testhash_DEPENDENCIES= $(LIBRARIES)
# test_charset_DEPENDENCIES= $(LIBRARIES)
@@ -83,8 +87,6 @@ DEFS = -DDEFAULT_BASEDIR='"$(prefix)"' \
-DDEFAULT_SYSCONFDIR='"$(sysconfdir)"' \
@DEFS@
-libmysys_a_DEPENDENCIES= @THREAD_LOBJECTS@
-
# I hope this always does the right thing. Otherwise this is only test programs
FLAGS=$(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) @NOINST_LDFLAGS@
@@ -95,6 +97,10 @@ CLEANFILES = test_bitmap$(EXEEXT) test_priority_queue$(EXEEXT) \
testhash$(EXEEXT) test_gethwaddr$(EXEEXT) \
test_base64$(EXEEXT) test_thr_mutex$(EXEEXT)
+libmysys_a_SOURCES=
+libmysys.a: libmysys.la
+ $(CP) .libs/libmysys.a $@
+
#
# The CP .. RM stuff is to avoid problems with some compilers (like alpha ccc)
# which automaticly removes the object files you use to compile a final program
diff --git a/mysys/charset.c b/mysys/charset.c
index 153ef8b7e2c..7b72f1f5ae3 100644
--- a/mysys/charset.c
+++ b/mysys/charset.c
@@ -199,6 +199,7 @@ static my_bool simple_cs_is_full(CHARSET_INFO *cs)
}
+#if defined(HAVE_UCA_COLLATIONS) && (defined(HAVE_CHARSET_ucs2) || defined(HAVE_CHARSET_utf8))
static void
copy_uca_collation(struct charset_info_st *to, CHARSET_INFO *from)
{
@@ -212,6 +213,7 @@ copy_uca_collation(struct charset_info_st *to, CHARSET_INFO *from)
to->state|= MY_CS_AVAILABLE | MY_CS_LOADED |
MY_CS_STRNXFRM | MY_CS_UNICODE;
}
+#endif
static int add_collation(struct charset_info_st *cs)
diff --git a/mysys/my_gethostbyname.c b/mysys/my_gethostbyname.c
index abd388302be..12cf90271dd 100644
--- a/mysys/my_gethostbyname.c
+++ b/mysys/my_gethostbyname.c
@@ -91,12 +91,11 @@ extern pthread_mutex_t LOCK_gethostbyname_r;
is finished with the structure.
*/
-struct hostent *
-my_gethostbyname_r(const char *name,
- struct hostent *result __attribute__((unused)),
- char *buffer __attribute__((unused)),
- int buflen __attribute__((unused)),
- int *h_errnop)
+struct hostent *my_gethostbyname_r(const char *name,
+ struct hostent *res __attribute__((unused)),
+ char *buffer __attribute__((unused)),
+ int buflen __attribute__((unused)),
+ int *h_errnop)
{
struct hostent *hp;
pthread_mutex_lock(&LOCK_gethostbyname_r);
diff --git a/mysys/my_gethwaddr.c b/mysys/my_gethwaddr.c
index 00e0e90f1e4..90908bd1c0d 100644
--- a/mysys/my_gethwaddr.c
+++ b/mysys/my_gethwaddr.c
@@ -21,18 +21,6 @@
#ifndef MAIN
-#if defined(__FreeBSD__) || defined(__linux__)
-static my_bool memcpy_and_test(uchar *to, uchar *from, uint len)
-{
- uint i, res=1;
-
- for (i=0; i < len; i++)
- if ((*to++= *from++))
- res=0;
- return res;
-}
-#endif /* FreeBSD || linux */
-
#ifdef __FreeBSD__
#include <net/ethernet.h>
@@ -44,10 +32,11 @@ static my_bool memcpy_and_test(uchar *to, uchar *from, uint len)
my_bool my_gethwaddr(uchar *to)
{
size_t len;
- uchar *buf, *next, *end, *addr;
+ char *buf, *next, *end;
struct if_msghdr *ifm;
struct sockaddr_dl *sdl;
int res=1, mib[6]={CTL_NET, AF_ROUTE, 0, AF_LINK, NET_RT_IFLIST, 0};
+ char zero_array[ETHER_ADDR_LEN] = {0};
if (sysctl(mib, 6, NULL, &len, NULL, 0) == -1)
goto err;
@@ -63,9 +52,9 @@ my_bool my_gethwaddr(uchar *to)
ifm = (struct if_msghdr *)next;
if (ifm->ifm_type == RTM_IFINFO)
{
- sdl = (struct sockaddr_dl *)(ifm + 1);
- addr=LLADDR(sdl);
- res=memcpy_and_test(to, addr, ETHER_ADDR_LEN);
+ sdl= (struct sockaddr_dl *)(ifm + 1);
+ memcpy(to, LLADDR(sdl), ETHER_ADDR_LEN);
+ res= memcmp(to, zero_array, ETHER_ADDR_LEN) ? 0 : 1;
}
}
@@ -81,8 +70,9 @@ err:
my_bool my_gethwaddr(uchar *to)
{
- int fd, res=1;
+ int fd, res= 1;
struct ifreq ifr;
+ char zero_array[ETHER_ADDR_LEN] = {0};
fd = socket(AF_INET, SOCK_DGRAM, 0);
if (fd < 0)
@@ -91,9 +81,13 @@ my_bool my_gethwaddr(uchar *to)
bzero(&ifr, sizeof(ifr));
strnmov(ifr.ifr_name, "eth0", sizeof(ifr.ifr_name) - 1);
- do {
+ do
+ {
if (ioctl(fd, SIOCGIFHWADDR, &ifr) >= 0)
- res=memcpy_and_test(to, (uchar *)&ifr.ifr_hwaddr.sa_data, ETHER_ADDR_LEN);
+ {
+ memcpy(to, &ifr.ifr_hwaddr.sa_data, ETHER_ADDR_LEN);
+ res= memcmp(to, zero_array, ETHER_ADDR_LEN) ? 0 : 1;
+ }
} while (res && (errno == 0 || errno == ENODEV) && ifr.ifr_name[3]++ < '6');
close(fd);
diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c
index db6ccd230f2..5d0703f09a8 100644
--- a/mysys/my_getopt.c
+++ b/mysys/my_getopt.c
@@ -112,7 +112,7 @@ int handle_options(int *argc, char ***argv,
const struct my_option *longopts,
my_get_one_option get_one_option)
{
- uint opt_found, argvpos= 0, length;
+ uint UNINIT_VAR(opt_found), argvpos= 0, length;
my_bool end_of_options= 0, must_be_var, set_maximum_value,
option_is_loose;
char **pos, **pos_end, *optend, *opt_str, key_name[FN_REFLEN];
@@ -121,7 +121,6 @@ int handle_options(int *argc, char ***argv,
void *value;
int error, i;
- LINT_INIT(opt_found);
/* handle_options() assumes arg0 (program name) always exists */
DBUG_ASSERT(argc && *argc >= 1);
DBUG_ASSERT(argv && *argv);
diff --git a/mysys/my_redel.c b/mysys/my_redel.c
index cf0986a7821..2de989a2854 100644
--- a/mysys/my_redel.c
+++ b/mysys/my_redel.c
@@ -40,7 +40,8 @@ struct utimbuf {
#define REDEL_EXT ".BAK"
-int my_redel(const char *org_name, const char *tmp_name, myf MyFlags)
+int my_redel(const char *org_name, const char *tmp_name,
+ time_t backup_time_stamp, myf MyFlags)
{
int error=1;
DBUG_ENTER("my_redel");
@@ -51,13 +52,9 @@ int my_redel(const char *org_name, const char *tmp_name, myf MyFlags)
goto end;
if (MyFlags & MY_REDEL_MAKE_BACKUP)
{
- char name_buff[FN_REFLEN+20];
- char ext[20];
- ext[0]='-';
- get_date(ext+1,2+4,(time_t) 0);
- strmov(strend(ext),REDEL_EXT);
- if (my_rename(org_name, fn_format(name_buff, org_name, "", ext, 2),
- MyFlags))
+ char name_buff[FN_REFLEN + MY_BACKUP_NAME_EXTRA_LENGTH];
+ my_create_backup_name(name_buff, org_name, backup_time_stamp);
+ if (my_rename(org_name, name_buff, MyFlags))
goto end;
}
else if (my_delete_allow_opened(org_name, MyFlags))
@@ -149,3 +146,23 @@ int my_copystat(const char *from, const char *to, int MyFlags)
#endif
return 0;
} /* my_copystat */
+
+
+/**
+ Create a backup file name.
+ @fn my_create_backup_name()
+ @param to Store new file name here
+ @param from Original name
+
+ @info
+ The backup name is made by adding -YYMMDDHHMMSS.BAK to the file name
+*/
+
+void my_create_backup_name(char *to, const char *from, time_t backup_start)
+{
+ char ext[MY_BACKUP_NAME_EXTRA_LENGTH+1];
+ ext[0]='-';
+ get_date(ext+1, GETDATE_SHORT_DATE | GETDATE_HHMMSSTIME, backup_start);
+ strmov(strend(ext),REDEL_EXT);
+ strmov(strmov(to, from), ext);
+}
diff --git a/mysys/my_symlink.c b/mysys/my_symlink.c
index 33f45a882e1..164533ad765 100644
--- a/mysys/my_symlink.c
+++ b/mysys/my_symlink.c
@@ -113,7 +113,6 @@ int my_is_symlink(const char *filename __attribute__((unused)))
#endif
}
-
/*
Resolve all symbolic links in path
'to' may be equal to 'filename'
@@ -150,7 +149,21 @@ int my_realpath(char *to, const char *filename,
}
DBUG_RETURN(result);
#else
+#ifdef _WIN32
+ int ret= GetFullPathName(filename,FN_REFLEN, to, NULL);
+ if (ret == 0 || ret > FN_REFLEN)
+ {
+ if (ret > FN_REFLEN)
+ my_errno= ENAMETOOLONG;
+ else
+ my_errno= EACCES;
+ if (MyFlags & MY_WME)
+ my_error(EE_REALPATH, MYF(0), filename, my_errno);
+ return -1;
+ }
+#else
my_load_path(to, filename, NullS);
+#endif
return 0;
#endif
}
diff --git a/mysys/my_sync.c b/mysys/my_sync.c
index a2b615a8661..dae20b0163e 100644
--- a/mysys/my_sync.c
+++ b/mysys/my_sync.c
@@ -64,7 +64,7 @@ int my_sync(File fd, myf my_flags)
/* Some file systems don't support F_FULLFSYNC and fail above: */
DBUG_PRINT("info",("fcntl(F_FULLFSYNC) failed, falling back"));
#endif
-#if defined(HAVE_FDATASYNC)
+#if defined(HAVE_FDATASYNC) && HAVE_DECL_FDATASYNC
res= fdatasync(fd);
#elif defined(HAVE_FSYNC)
res= fsync(fd);
@@ -97,6 +97,7 @@ int my_sync(File fd, myf my_flags)
static const char cur_dir_name[]= {FN_CURLIB, 0};
+
/*
Force directory information to disk.
@@ -108,6 +109,7 @@ static const char cur_dir_name[]= {FN_CURLIB, 0};
RETURN
0 if ok, !=0 if error
*/
+
int my_sync_dir(const char *dir_name __attribute__((unused)),
myf my_flags __attribute__((unused)))
{
@@ -138,7 +140,6 @@ int my_sync_dir(const char *dir_name __attribute__((unused)),
#endif
}
-
/*
Force directory information to disk.
@@ -150,6 +151,7 @@ int my_sync_dir(const char *dir_name __attribute__((unused)),
RETURN
0 if ok, !=0 if error
*/
+
int my_sync_dir_by_file(const char *file_name __attribute__((unused)),
myf my_flags __attribute__((unused)))
{
@@ -162,4 +164,3 @@ int my_sync_dir_by_file(const char *file_name __attribute__((unused)),
return 0;
#endif
}
-
diff --git a/mysys/my_uuid.c b/mysys/my_uuid.c
index f115806b4e9..e2372391b06 100644
--- a/mysys/my_uuid.c
+++ b/mysys/my_uuid.c
@@ -50,7 +50,7 @@ static ulonglong uuid_time= 0;
static uchar uuid_suffix[2+6]; /* clock_seq and node */
#ifdef THREAD
-pthread_mutex_t LOCK_uuid_generator;
+static pthread_mutex_t LOCK_uuid_generator;
#endif
/*
diff --git a/mysys/sha1.c b/mysys/sha1.c
index 3469e480c26..e5b33a9ad13 100644
--- a/mysys/sha1.c
+++ b/mysys/sha1.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2004, 2006 MySQL AB
+/* Copyright (c) 2002, 2004, 2006 MySQL AB
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
@@ -6,26 +6,57 @@
This program 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
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
/*
Original Source from: http://www.faqs.org/rfcs/rfc3174.html
+ Copyright (C) The Internet Society (2001). All Rights Reserved.
+
+ This document and translations of it may be copied and furnished to
+ others, and derivative works that comment on or otherwise explain it
+ or assist in its implementation may be prepared, copied, published
+ and distributed, in whole or in part, without restriction of any
+ kind, provided that the above copyright notice and this paragraph are
+ included on all such copies and derivative works. However, this
+ document itself may not be modified in any way, such as by removing
+ the copyright notice or references to the Internet Society or other
+ Internet organizations, except as needed for the purpose of
+ developing Internet standards in which case the procedures for
+ copyrights defined in the Internet Standards process must be
+ followed, or as required to translate it into languages other than
+ English.
+
+ The limited permissions granted above are perpetual and will not be
+ revoked by the Internet Society or its successors or assigns.
+
+ This document and the information contained herein is provided on an
+ "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING
+ TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+ BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+ HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+
+ Acknowledgement
+ Funding for the RFC Editor function is currently provided by the
+ Internet Society.
+
DESCRIPTION
- This file implements the Secure Hashing Algorithm 1 as
- defined in FIPS PUB 180-1 published April 17, 1995.
-
- The SHA-1, produces a 160-bit message digest for a given data
- stream. It should take about 2**n steps to find a message with the
- same digest as a given message and 2**(n/2) to find any two
- messages with the same digest, when n is the digest size in bits.
- Therefore, this algorithm can serve as a means of providing a
- "fingerprint" for a message.
+ This file implements the Secure Hashing Algorithm 1 as
+ defined in FIPS PUB 180-1 published April 17, 1995.
+
+ The SHA-1, produces a 160-bit message digest for a given data
+ stream. It should take about 2**n steps to find a message with the
+ same digest as a given message and 2**(n/2) to find any two
+ messages with the same digest, when n is the digest size in bits.
+ Therefore, this algorithm can serve as a means of providing a
+ "fingerprint" for a message.
PORTABILITY ISSUES
SHA-1 is defined in terms of 32-bit "words". This code uses
diff --git a/mysys/thr_mutex.c b/mysys/thr_mutex.c
index 5ab1e443a88..77f2286b3d1 100644
--- a/mysys/thr_mutex.c
+++ b/mysys/thr_mutex.c
@@ -527,8 +527,8 @@ int safe_cond_wait(pthread_cond_t *cond, safe_mutex_t *mp, const char *file,
int safe_cond_timedwait(pthread_cond_t *cond, safe_mutex_t *mp,
- struct timespec *abstime,
- const char *file, uint line)
+ const struct timespec *abstime,
+ const char *file, uint line)
{
int error;
safe_mutex_t save_state;