1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
|
/*PGR-GNU*****************************************************************
File: interruption.hpp
Copyright (c) 2015-2026 pgRouting developers
Mail: project@pgrouting.org
Copyright (c) 2020 Mohamed Bakli, Esteban Zimányi, Mahmoud Sakr
mohamed_bakli@ulb.ac.be, estebanzimanyi@gmail.com, m_attia_sakr@yahoo.com
------
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 Foundation; either version 2 of the License, or
(at your option) any later version.
This program 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 this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
********************************************************************PGR-GNU*/
#ifndef INCLUDE_CPP_COMMON_INTERRUPTION_HPP_
#define INCLUDE_CPP_COMMON_INTERRUPTION_HPP_
#ifdef _MSC_VER
#define __PGR_PRETTY_FUNCTION__ __FUNCSIG__
#else
#define __PGR_PRETTY_FUNCTION__ __PRETTY_FUNCTION__
#endif
extern "C" {
#ifdef _MSC_VER
#include <postgres.h>
#include <miscadmin.h>
#else
/*
* Instead of including all the files
* copy/paste what is used
* IMPORTANT: this copy/paste might depend on the postgreSQL version
*/
#include <signal.h>
/*
* https://doxygen.postgresql.org/c_8h.html#a166c1d950e659804f0e3247aad99a81f
*/
#ifndef PGDLLIMPORT
#define PGDLLIMPORT
#endif
/*
* https://doxygen.postgresql.org/miscadmin_8h_source.html
*/
extern PGDLLIMPORT volatile sig_atomic_t InterruptPending;
extern void ProcessInterrupts(void);
#if __GNUC__ >= 3
#define unlikely(x) __builtin_expect((x) != 0, 0)
#else
#define unlikely(x) ((x) != 0)
#endif
/* Test whether an interrupt is pending */
#if !defined(WIN32) || defined(__MINGW64_VERSION_MAJOR)
#define INTERRUPTS_PENDING_CONDITION() \
(unlikely(InterruptPending))
#else
extern void pgwin32_dispatch_queued_signals(void);
#define INTERRUPTS_PENDING_CONDITION() \
(unlikely(UNBLOCKED_SIGNAL_QUEUE()) ? pgwin32_dispatch_queued_signals() : 0, \
unlikely(InterruptPending))
#endif
/* Service interrupt, if one is pending and it's safe to service it now */
#define CHECK_FOR_INTERRUPTS() \
do { \
if (INTERRUPTS_PENDING_CONDITION()) \
ProcessInterrupts(); \
} while (0)
#endif
}
#include "cpp_common/undefPostgresDefine.hpp"
#endif // INCLUDE_CPP_COMMON_INTERRUPTION_HPP_
|