diff options
-rw-r--r-- | configure.in | 7 | ||||
-rw-r--r-- | include/my_global.h | 4 | ||||
-rw-r--r-- | isam/extra.c | 4 | ||||
-rw-r--r-- | myisam/mi_extra.c | 6 | ||||
-rw-r--r-- | sql/examples/ha_tina.cc | 2 |
5 files changed, 18 insertions, 5 deletions
diff --git a/configure.in b/configure.in index 1d6df1dd55e..f3840e6f1a8 100644 --- a/configure.in +++ b/configure.in @@ -2043,6 +2043,13 @@ AC_CACHE_CHECK([style of gethost* routines], mysql_cv_gethost_style, AC_LANG_SAVE AC_LANG_CPLUSPLUS +# Test whether madvise() is declared in C++ code -- it is not on some +# systems, such as Solaris +AC_CHECK_DECLS(madvise, [], [], [#if HAVE_SYS_MMAN_H +#include <sys/types.h> +#include <sys/mman.h> +#endif]) + # Do not treat warnings as errors if we are linking against other libc # this is to work around gcc not being permissive on non-system includes # with respect to ANSI C++ diff --git a/include/my_global.h b/include/my_global.h index be6e667057d..f3d42106458 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -310,6 +310,10 @@ C_MODE_END #undef setrlimit #define setrlimit cma_setrlimit64 #endif +/* Declare madvise where it is not declared for C++, like Solaris */ +#if HAVE_MADVISE && !HAVE_DECL_MADVISE && defined(__cplusplus) +extern "C" int madvise(void *addr, size_t len, int behav); +#endif #ifdef __QNXNTO__ /* This has to be after include limits.h */ diff --git a/isam/extra.c b/isam/extra.c index 421404311c8..0d15cd948bb 100644 --- a/isam/extra.c +++ b/isam/extra.c @@ -67,7 +67,7 @@ int nisam_extra(N_INFO *info, enum ha_extra_function function) break; } #endif -#if defined(HAVE_MMAP) && defined(HAVE_MADVICE) +#if defined(HAVE_MMAP) && defined(HAVE_MADVISE) if ((info->options & HA_OPTION_COMPRESS_RECORD)) { pthread_mutex_lock(&info->s->intern_lock); @@ -144,7 +144,7 @@ int nisam_extra(N_INFO *info, enum ha_extra_function function) info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED); error=end_io_cache(&info->rec_cache); } -#if defined(HAVE_MMAP) && defined(HAVE_MADVICE) +#if defined(HAVE_MMAP) && defined(HAVE_MADVISE) if (info->opt_flag & MEMMAP_USED) madvise(info->s->file_map,info->s->state.data_file_length,MADV_RANDOM); #endif diff --git a/myisam/mi_extra.c b/myisam/mi_extra.c index 4b011ca424f..1827aed98c3 100644 --- a/myisam/mi_extra.c +++ b/myisam/mi_extra.c @@ -62,7 +62,7 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) } if (share->base.blobs) mi_alloc_rec_buff(info, -1, &info->rec_buff); -#if defined(HAVE_MMAP) && defined(HAVE_MADVICE) +#if defined(HAVE_MMAP) && defined(HAVE_MADVISE) if (info->opt_flag & MEMMAP_USED) madvise(share->file_map,share->state.state.data_file_length,MADV_RANDOM); #endif @@ -93,7 +93,7 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) my_errno=EACCES; break; } -#if defined(HAVE_MMAP) && defined(HAVE_MADVICE) +#if defined(HAVE_MMAP) && defined(HAVE_MADVISE) if ((share->options & HA_OPTION_COMPRESS_RECORD)) { pthread_mutex_lock(&share->intern_lock); @@ -177,7 +177,7 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) error=end_io_cache(&info->rec_cache); /* Sergei will insert full text index caching here */ } -#if defined(HAVE_MMAP) && defined(HAVE_MADVICE) +#if defined(HAVE_MMAP) && defined(HAVE_MADVISE) if (info->opt_flag & MEMMAP_USED) madvise(share->file_map,share->state.state.data_file_length,MADV_RANDOM); #endif diff --git a/sql/examples/ha_tina.cc b/sql/examples/ha_tina.cc index 07e69bfac80..bbcdfb0dafb 100644 --- a/sql/examples/ha_tina.cc +++ b/sql/examples/ha_tina.cc @@ -608,7 +608,9 @@ int ha_tina::rnd_init(bool scan) current_position= next_position= 0; records= 0; chain_ptr= chain; +#ifdef HAVE_MADVISE (void)madvise(share->mapped_file,share->file_stat.st_size,MADV_SEQUENTIAL); +#endif DBUG_RETURN(0); } |