Skip to content

Commit

Permalink
fix(engine/tests): gettimeofday changed its signature since alma9
Browse files Browse the repository at this point in the history
  • Loading branch information
bouda1 committed Jul 19, 2024
1 parent d7968a1 commit 647288c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 19 deletions.
11 changes: 10 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ set(BUILD_ARGS "-w" "dupbuild=warn")
# Get distributions name
#
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
file(STRINGS "/etc/os-release" release REGEX "^ID")
file(STRINGS "/etc/os-release" release REGEX "ID")

foreach(line ${release})
if(${line} MATCHES "ID_LIKE=.*")
Expand All @@ -115,6 +115,10 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
if(${line} MATCHES "ID=.*")
string(REGEX REPLACE "ID=\"(.*)\"" "\\1" id ${line})
endif()

if(${line} MATCHES "VERSION_ID=.*")
string(REGEX REPLACE "VERSION_ID=\"([0-9]+)\..*" "\\1" os_version ${line})
endif()
endforeach()

string(TOLOWER "${like}" like)
Expand All @@ -135,6 +139,11 @@ else()
set(OS_DISTRIBUTOR "${CMAKE_SYSTEM_NAME}")
endif()

if(OS_DISTRIBUTOR STREQUAL "CentOS" AND os_version STREQUAL "8")
message(STATUS "Legacy gettimeofday")
add_definitions("-DLEGACY_GETTIMEOFDAY")
endif()

message(STATUS "${id} detected (compatible with ${OS_DISTRIBUTOR})")

# set -latomic if OS is Raspbian.
Expand Down
4 changes: 4 additions & 0 deletions engine/tests/timeperiod/utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,11 @@ extern "C" time_t time(time_t* t) __THROW {
return (gl_now);
}

#ifdef LEGACY_GETTIMEOFDAY
extern "C" int gettimeofday(struct timeval* tv, struct timezone*) __THROW {
#else
extern "C" int gettimeofday(struct timeval* tv, void*) __THROW {
#endif
// extern "C" int gettimeofday(struct timeval* tv, struct timezone*) __THROW {
if (tv) {
tv->tv_sec = gl_now;
Expand Down
36 changes: 18 additions & 18 deletions engine/tests/timeperiod/utils.hh
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
/*
** Copyright 2016 Centreon
**
** This file is part of Centreon Engine.
**
** Centreon Engine is free software: you can redistribute it and/or
** modify it under the terms of the GNU General Public License version 2
** as published by the Free Software Foundation.
**
** Centreon Engine 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 GNU
** General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Centreon Engine. If not, see
** <http://www.gnu.org/licenses/>.
*/
/**
* Copyright 2016-2024 Centreon
*
* This file is part of Centreon Engine.
*
* Centreon Engine is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* Centreon Engine 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 GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Centreon Engine. If not, see
* <http://www.gnu.org/licenses/>.
*/

#ifndef TESTS_TIMEPERIOD_UTILS_HH
#define TESTS_TIMEPERIOD_UTILS_HH
Expand Down

0 comments on commit 647288c

Please sign in to comment.