diff options
author | Sergei Golubchik <sergii@pisem.net> | 2013-09-06 22:31:30 +0200 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2013-09-06 22:31:30 +0200 |
commit | b838d081ad346e52787753b1799c627922c4a6c7 (patch) | |
tree | dc8f1e21e6b40d5b72668571c570c9a3214fbf32 /mysys | |
parent | 824db55ce53963a64fcf648b54500df22c57e9b2 (diff) | |
parent | 72c36f4415815d55ddb82b23682f3c549906c00e (diff) | |
download | mariadb-git-b838d081ad346e52787753b1799c627922c4a6c7.tar.gz |
mysql-5.5.33 merge
Diffstat (limited to 'mysys')
-rw-r--r-- | mysys/CMakeLists.txt | 7 | ||||
-rw-r--r-- | mysys/my_getopt.c | 55 |
2 files changed, 55 insertions, 7 deletions
diff --git a/mysys/CMakeLists.txt b/mysys/CMakeLists.txt index 832cd01e263..37961a78fb6 100644 --- a/mysys/CMakeLists.txt +++ b/mysys/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2006, 2011, Oracle and/or its affiliates +# Copyright (c) 2006, 2013, Oracle and/or its affiliates # # 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 @@ -78,6 +78,11 @@ IF (WIN32) TARGET_LINK_LIBRARIES(mysys IPHLPAPI) ENDIF(WIN32) +# Need explicit pthread for gcc -fsanitize=address +IF(CMAKE_USE_PTHREADS_INIT AND CMAKE_C_FLAGS MATCHES "-fsanitize=") + TARGET_LINK_LIBRARIES(mysys pthread) +ENDIF() + ADD_EXECUTABLE(thr_lock thr_lock.c) TARGET_LINK_LIBRARIES(thr_lock mysys) SET_TARGET_PROPERTIES(thr_lock PROPERTIES COMPILE_FLAGS "-DMAIN") diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index 0645e413672..67e074e7e59 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -1,5 +1,6 @@ /* - Copyright (c) 2002, 2011, Oracle and/or its affiliates + Copyright (c) 2002, 2013, Oracle and/or its affiliates + Copyright (c) 2009, 2013, Monty Program 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 @@ -94,6 +95,35 @@ void my_getopt_register_get_addr(my_getopt_value func_addr) getopt_get_addr= func_addr; } +union ull_dbl +{ + ulonglong ull; + double dbl; +}; + +/** + Returns an ulonglong value containing a raw + representation of the given double value. +*/ +ulonglong getopt_double2ulonglong(double v) +{ + union ull_dbl u; + u.dbl= v; + compile_time_assert(sizeof(ulonglong) >= sizeof(double)); + return u.ull; +} + +/** + Returns the double value which corresponds to + the given raw representation. +*/ +double getopt_ulonglong2double(ulonglong v) +{ + union ull_dbl u; + u.ull= v; + return u.dbl; +} + /** Handle command line options. Sort options. @@ -810,6 +840,7 @@ static int findopt(char *optpat, uint length, { uint count; const struct my_option *opt= *opt_res; + my_bool is_prefix= FALSE; DBUG_ENTER("findopt"); for (count= 0; opt->name; opt++) @@ -819,11 +850,14 @@ static int findopt(char *optpat, uint length, (*opt_res)= opt; if (!opt->name[length]) /* Exact match */ DBUG_RETURN(1); + if (!count) { /* We only need to know one prev */ count= 1; *ffname= opt->name; + if (opt->name[length]) + is_prefix= TRUE; } else if (strcmp(*ffname, opt->name)) { @@ -835,6 +869,12 @@ static int findopt(char *optpat, uint length, } } } + if (is_prefix && count == 1) + my_getopt_error_reporter(WARNING_LEVEL, + "Using unique option prefix %.*s instead of %s " + "is deprecated and will be removed in a future " + "release. Please use the full name instead.", + length, optpat, *ffname); DBUG_RETURN(count); } @@ -1061,16 +1101,19 @@ double getopt_double_limit_value(double num, const struct my_option *optp, { my_bool adjusted= FALSE; double old= num; + double min, max; DBUG_ENTER("getopt_double_limit_value"); - if (optp->max_value && num > (double) optp->max_value) + max= getopt_ulonglong2double(optp->max_value); + min= getopt_ulonglong2double(optp->min_value); + if (max && num > max) { - num= (double) optp->max_value; + num= max; adjusted= TRUE; } - if (num < (double) optp->min_value) + if (num < min) { - num= (double) optp->min_value; + num= min; adjusted= TRUE; } if (fix) @@ -1153,7 +1196,7 @@ static void init_one_value(const struct my_option *option, void *variable, *((ulonglong*) variable)= (ulonglong) value; break; case GET_DOUBLE: - *((double*) variable)= ulonglong2double(value); + *((double*) variable)= getopt_ulonglong2double(value); break; case GET_STR: /* |