Skip to content

Commit

Permalink
InnoDB cleanup: Replace UNIV_LINUX, UNIV_SOLARIS, UNIV_AIX
Browse files Browse the repository at this point in the history
Let us use the normal platform-specific preprocessor symbols
__linux__, __sun__, _AIX instead of some homebrew ones.

The preprocessor symbol UNIV_HPUX must have lost its meaning
by f6deb00 (note: the symbol
UNIV_HPUX10 is being checked for, but only UNIV_HPUX is defined).
  • Loading branch information
dr-m committed Sep 19, 2022
1 parent bbf81b5 commit c22dff2
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 45 deletions.
2 changes: 1 addition & 1 deletion extra/mariabackup/changed_page_bitmap.cc
Expand Up @@ -459,7 +459,7 @@ log_online_open_bitmap_file_read_only(
bitmap_file->size = os_file_get_size(bitmap_file->file);
bitmap_file->offset = 0;

#ifdef UNIV_LINUX
#ifdef __linux__
posix_fadvise(bitmap_file->file, 0, 0, POSIX_FADV_SEQUENTIAL);
posix_fadvise(bitmap_file->file, 0, 0, POSIX_FADV_NOREUSE);
#endif
Expand Down
2 changes: 1 addition & 1 deletion storage/innobase/buf/buf0buf.cc
Expand Up @@ -76,7 +76,7 @@ Created 11/5/1995 Heikki Tuuri
#include "ut0byte.h"
#include <new>

#ifdef UNIV_LINUX
#ifdef __linux__
#include <stdlib.h>
#endif

Expand Down
16 changes: 8 additions & 8 deletions storage/innobase/buf/buf0flu.cc
Expand Up @@ -47,14 +47,14 @@ Created 11/11/1995 Heikki Tuuri
#include "srv0mon.h"
#include "ut0stage.h"
#include "fil0pagecompress.h"
#ifdef UNIV_LINUX
#ifdef __linux__
/* include defs for CPU time priority settings */
#include <unistd.h>
#include <sys/syscall.h>
#include <sys/time.h>
#include <sys/resource.h>
static const int buf_flush_page_cleaner_priority = -20;
#endif /* UNIV_LINUX */
#endif /* __linux__ */

/** Sleep time in microseconds for loop waiting for the oldest
modification lsn */
Expand Down Expand Up @@ -2875,7 +2875,7 @@ pc_wait_finished(
return(all_succeeded);
}

#ifdef UNIV_LINUX
#ifdef __linux__
/**
Set priority for page_cleaner threads.
@param[in] priority priority intended to set
Expand All @@ -2890,7 +2890,7 @@ buf_flush_page_cleaner_set_priority(
return(getpriority(PRIO_PROCESS, (pid_t)syscall(SYS_gettid))
== priority);
}
#endif /* UNIV_LINUX */
#endif /* __linux__ */

#ifdef UNIV_DEBUG
/** Loop used to disable page cleaner threads. */
Expand Down Expand Up @@ -3017,7 +3017,7 @@ DECLARE_THREAD(buf_flush_page_cleaner_coordinator)(void*)
ib::info() << "page_cleaner thread running, id "
<< os_thread_pf(os_thread_get_curr_id());
#endif /* UNIV_DEBUG_THREAD_CREATION */
#ifdef UNIV_LINUX
#ifdef __linux__
/* linux might be able to set different setting for each thread.
worth to try to set high priority for page cleaner threads */
if (buf_flush_page_cleaner_set_priority(
Expand All @@ -3032,7 +3032,7 @@ DECLARE_THREAD(buf_flush_page_cleaner_coordinator)(void*)
}
/* Signal that setpriority() has been attempted. */
os_event_set(recv_sys->flush_end);
#endif /* UNIV_LINUX */
#endif /* __linux__ */

do {
/* treat flushing requests during recovery. */
Expand Down Expand Up @@ -3433,7 +3433,7 @@ DECLARE_THREAD(buf_flush_page_cleaner_worker)(
os_event_set(page_cleaner.is_started);
mutex_exit(&page_cleaner.mutex);

#ifdef UNIV_LINUX
#ifdef __linux__
/* linux might be able to set different setting for each thread
worth to try to set high priority for page cleaner threads */
if (buf_flush_page_cleaner_set_priority(
Expand All @@ -3442,7 +3442,7 @@ DECLARE_THREAD(buf_flush_page_cleaner_worker)(
ib::info() << "page_cleaner worker priority: "
<< buf_flush_page_cleaner_priority;
}
#endif /* UNIV_LINUX */
#endif /* __linux__ */

while (true) {
os_event_wait(page_cleaner.is_requested);
Expand Down
4 changes: 2 additions & 2 deletions storage/innobase/include/os0proc.h
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, 2019, MariaDB Corporation.
Copyright (c) 2017, 2022, MariaDB Corporation.
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 the Free Software
Expand Down Expand Up @@ -30,7 +30,7 @@ Created 9/30/1995 Heikki Tuuri

#include "univ.i"

#ifdef UNIV_LINUX
#ifdef __linux__
#include <sys/ipc.h>
#include <sys/shm.h>
#endif
Expand Down
8 changes: 1 addition & 7 deletions storage/innobase/innodb.cmake
Expand Up @@ -55,7 +55,7 @@ ENDIF()
IF(UNIX)
IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")

ADD_DEFINITIONS("-DUNIV_LINUX -D_GNU_SOURCE=1")
ADD_DEFINITIONS("-D_GNU_SOURCE=1")

CHECK_INCLUDE_FILES (libaio.h HAVE_LIBAIO_H)
CHECK_LIBRARY_EXISTS(aio io_queue_init "" HAVE_LIBAIO)
Expand All @@ -67,12 +67,6 @@ IF(UNIX)
IF(HAVE_LIBNUMA)
LINK_LIBRARIES(numa)
ENDIF()
ELSEIF(CMAKE_SYSTEM_NAME MATCHES "HP*")
ADD_DEFINITIONS("-DUNIV_HPUX")
ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "AIX")
ADD_DEFINITIONS("-DUNIV_AIX")
ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
ADD_DEFINITIONS("-DUNIV_SOLARIS")
ENDIF()
ENDIF()

Expand Down
26 changes: 13 additions & 13 deletions storage/innobase/os/os0file.cc
Expand Up @@ -37,7 +37,7 @@ Created 10/21/1995 Heikki Tuuri
#include "os0file.h"
#include "sql_const.h"

#ifdef UNIV_LINUX
#ifdef __linux__
#include <sys/types.h>
#include <sys/stat.h>
#endif
Expand All @@ -63,18 +63,18 @@ Created 10/21/1995 Heikki Tuuri
# include <linux/falloc.h>
#endif /* HAVE_FALLOC_PUNCH_HOLE_AND_KEEP_SIZE */

#if defined(UNIV_LINUX) && defined(HAVE_SYS_IOCTL_H)
#if defined(__linux__) && defined(HAVE_SYS_IOCTL_H)
# include <sys/ioctl.h>
# ifndef DFS_IOCTL_ATOMIC_WRITE_SET
# define DFS_IOCTL_ATOMIC_WRITE_SET _IOW(0x95, 2, uint)
# endif
#endif

#if defined(UNIV_LINUX) && defined(HAVE_SYS_STATVFS_H)
#if defined(__linux__) && defined(HAVE_SYS_STATVFS_H)
#include <sys/statvfs.h>
#endif

#if defined(UNIV_LINUX) && defined(HAVE_LINUX_FALLOC_H)
#if defined(__linux__) && defined(HAVE_LINUX_FALLOC_H)
#include <linux/falloc.h>
#endif

Expand Down Expand Up @@ -827,7 +827,7 @@ os_file_get_block_size(
{
ulint fblock_size = 512;

#if defined(UNIV_LINUX)
#if defined(__linux__)
struct stat local_stat;
int err;

Expand All @@ -838,7 +838,7 @@ os_file_get_block_size(
} else {
fblock_size = local_stat.st_blksize;
}
#endif /* UNIV_LINUX */
#endif /* __linux__ */
#ifdef _WIN32

fblock_size = 0;
Expand Down Expand Up @@ -1629,7 +1629,7 @@ os_file_punch_hole_posix(

return(DB_IO_ERROR);

#elif defined(UNIV_SOLARIS)
#elif defined __sun__

// Use F_FREESP

Expand Down Expand Up @@ -5206,7 +5206,7 @@ os_file_set_nocache(
const char* operation_name MY_ATTRIBUTE((unused)))
{
/* some versions of Solaris may not have DIRECTIO_ON */
#if defined(UNIV_SOLARIS) && defined(DIRECTIO_ON)
#if defined(__sun__) && defined(DIRECTIO_ON)
if (directio(fd, DIRECTIO_ON) == -1) {
int errno_save = errno;

Expand All @@ -5223,7 +5223,7 @@ os_file_set_nocache(
if (errno_save == EINVAL) {
if (!warning_message_printed) {
warning_message_printed = true;
# ifdef UNIV_LINUX
# ifdef __linux__
ib::warn()
<< "Failed to set O_DIRECT on file"
<< file_name << "; " << operation_name
Expand All @@ -5232,12 +5232,12 @@ os_file_set_nocache(
"known to result in 'Invalid argument' "
"on Linux on tmpfs, "
"see MySQL Bug#26662.";
# else /* UNIV_LINUX */
# else /* __linux__ */
goto short_warning;
# endif /* UNIV_LINUX */
# endif /* __linux__ */
}
} else {
# ifndef UNIV_LINUX
# ifndef __linux__
short_warning:
# endif
ib::warn()
Expand All @@ -5247,7 +5247,7 @@ os_file_set_nocache(
<< ", continuing anyway.";
}
}
#endif /* defined(UNIV_SOLARIS) && defined(DIRECTIO_ON) */
#endif /* defined(__sun__) && defined(DIRECTIO_ON) */
}

#endif /* _WIN32 */
Expand Down
6 changes: 3 additions & 3 deletions storage/innobase/os/os0proc.cc
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2019, MariaDB Corporation.
Copyright (c) 2019, 2022, MariaDB Corporation.
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 the Free Software
Expand Down Expand Up @@ -186,11 +186,11 @@ os_mem_free_large(
#elif !defined OS_MAP_ANON
ut_free(ptr);
#else
# if defined(UNIV_SOLARIS)
# if defined(__sun__)
if (munmap(static_cast<caddr_t>(ptr), size)) {
# else
if (munmap(ptr, size)) {
# endif /* UNIV_SOLARIS */
# endif /* __sun__ */
ib::error() << "munmap(" << ptr << ", " << size << ") failed;"
" errno " << errno;
} else {
Expand Down
12 changes: 6 additions & 6 deletions storage/innobase/row/row0merge.cc
Expand Up @@ -3364,12 +3364,12 @@ row_merge_sort(
is used. MDEV-9356: innodb.innodb_bug53290 fails (crashes) on
sol10-64 in buildbot.
*/
#ifndef UNIV_SOLARIS
#ifndef __sun__
/* Progress report only for "normal" indexes. */
if (!(dup->index->type & DICT_FTS)) {
thd_progress_init(trx->mysql_thd, 1);
}
#endif /* UNIV_SOLARIS */
#endif /* __sun__ */

if (global_system_variables.log_warnings > 2) {
sql_print_information("InnoDB: Online DDL : merge-sorting"
Expand All @@ -3382,11 +3382,11 @@ row_merge_sort(
/* Report progress of merge sort to MySQL for
show processlist progress field */
/* Progress report only for "normal" indexes. */
#ifndef UNIV_SOLARIS
#ifndef __sun__
if (!(dup->index->type & DICT_FTS)) {
thd_progress_report(trx->mysql_thd, file->offset - num_runs, file->offset);
}
#endif /* UNIV_SOLARIS */
#endif /* __sun__ */

error = row_merge(trx, dup, file, block, tmpfd,
&num_runs, run_offset, stage,
Expand All @@ -3411,11 +3411,11 @@ row_merge_sort(
ut_free(run_offset);

/* Progress report only for "normal" indexes. */
#ifndef UNIV_SOLARIS
#ifndef __sun__
if (!(dup->index->type & DICT_FTS)) {
thd_progress_end(trx->mysql_thd);
}
#endif /* UNIV_SOLARIS */
#endif /* __sun__ */

DBUG_RETURN(error);
}
Expand Down
8 changes: 4 additions & 4 deletions storage/innobase/srv/srv0start.cc
Expand Up @@ -606,12 +606,12 @@ srv_undo_tablespace_create(

} else if (ret == FALSE) {
if (os_file_get_last_error(false) != OS_FILE_ALREADY_EXISTS
#ifdef UNIV_AIX
#ifdef _AIX
/* AIX 5.1 after security patch ML7 may have
errno set to 0 here, which causes our function
to return 100; work around that AIX problem */
&& os_file_get_last_error(false) != 100
#endif /* UNIV_AIX */
#endif
) {
ib::error() << "Can't create UNDO tablespace "
<< name;
Expand Down Expand Up @@ -1666,10 +1666,10 @@ dberr_t srv_start(bool create_new_db)
buf_flush_set_page_cleaner_thread_cnt(srv_n_page_cleaners);
}

#ifdef UNIV_LINUX
#ifdef __linux__
/* Wait for the setpriority() call to finish. */
os_event_wait(recv_sys->flush_end);
#endif /* UNIV_LINUX */
#endif /* __linux__ */
srv_start_state_set(SRV_START_STATE_IO);
}

Expand Down

0 comments on commit c22dff2

Please sign in to comment.