summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
authorOleksandr Byelkin <sanja@mariadb.com>2020-03-06 23:28:26 +0100
committerOleksandr Byelkin <sanja@mariadb.com>2020-03-06 23:28:26 +0100
commit440452628d95476674922c6c097825509a002d8d (patch)
treec6bceadee16d4286de4d3f37eec43bb250077502 /mysys
parentf8ab5ca374243977f331cdf6e569386230a7fddb (diff)
parent75d286c2cc46092148f13b6b9026f52a54926a84 (diff)
downloadmariadb-git-440452628d95476674922c6c097825509a002d8d.tar.gz
Merge branch '10.2' into 10.3
Diffstat (limited to 'mysys')
-rw-r--r--mysys/my_addr_resolve.c12
-rw-r--r--mysys/my_default.c10
-rw-r--r--mysys/my_getncpus.c31
3 files changed, 52 insertions, 1 deletions
diff --git a/mysys/my_addr_resolve.c b/mysys/my_addr_resolve.c
index 7590d576a7c..3f20f535d37 100644
--- a/mysys/my_addr_resolve.c
+++ b/mysys/my_addr_resolve.c
@@ -56,6 +56,18 @@ static ElfW(Addr) offset= 0;
#define offset 0
#endif
+#ifndef bfd_get_section_flags
+#define bfd_get_section_flags(H, S) bfd_section_flags(S)
+#endif /* bfd_get_section_flags */
+
+#ifndef bfd_get_section_size
+#define bfd_get_section_size(S) bfd_section_size(S)
+#endif /* bfd_get_section_size */
+
+#ifndef bfd_get_section_vma
+#define bfd_get_section_vma(H, S) bfd_section_vma(S)
+#endif /* bfd_get_section_vma */
+
/**
finds a file name, a line number, and a function name corresponding to addr.
diff --git a/mysys/my_default.c b/mysys/my_default.c
index deeb9b4a5b8..7c6ef8fffa0 100644
--- a/mysys/my_default.c
+++ b/mysys/my_default.c
@@ -1035,6 +1035,11 @@ void my_print_default_files(const char *conf_file)
char name[FN_REFLEN], **ext;
puts("\nDefault options are read from the following files in the given order:");
+ if (my_defaults_file)
+ {
+ puts(my_defaults_file);
+ return;
+ }
if (dirname_length(conf_file))
fputs(conf_file,stdout);
@@ -1059,7 +1064,12 @@ void my_print_default_files(const char *conf_file)
if (**dirs)
pos= *dirs;
else if (my_defaults_extra_file)
+ {
pos= my_defaults_extra_file;
+ fputs(pos, stdout);
+ fputs(" ", stdout);
+ continue;
+ }
else
continue;
end= convert_dirname(name, pos, NullS);
diff --git a/mysys/my_getncpus.c b/mysys/my_getncpus.c
index 38585161c22..0ee03631da8 100644
--- a/mysys/my_getncpus.c
+++ b/mysys/my_getncpus.c
@@ -21,10 +21,36 @@
#include <unistd.h>
#endif
+#if defined(__FreeBSD__) && defined(HAVE_PTHREAD_GETAFFINITY_NP)
+#include <pthread_np.h>
+#include <sys/cpuset.h>
+#endif
+
static int ncpus=0;
-int my_getncpus()
+int my_getncpus(void)
{
+#if (defined(__linux__) || defined(__FreeBSD__)) && defined(HAVE_PTHREAD_GETAFFINITY_NP)
+ cpu_set_t set;
+
+ if (!ncpus)
+ {
+ if (pthread_getaffinity_np(pthread_self(), sizeof(set), &set) == 0)
+ {
+ ncpus= CPU_COUNT(&set);
+ }
+ else
+ {
+#ifdef _SC_NPROCESSORS_ONLN
+ ncpus= sysconf(_SC_NPROCESSORS_ONLN);
+#else
+ ncpus= 2;
+#endif
+ }
+ }
+
+#else /* __linux__ || FreeBSD && HAVE_PTHREAD_GETAFFINITY_NP */
+
if (!ncpus)
{
#ifdef _SC_NPROCESSORS_ONLN
@@ -46,5 +72,8 @@ int my_getncpus()
ncpus= 2;
#endif
}
+
+#endif /* __linux__ || FreeBSD && HAVE_PTHREAD_GETAFFINITY_NP */
+
return ncpus;
}