FLANG
stop.h
1//===-- include/flang/Runtime/stop.h ----------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef FORTRAN_RUNTIME_STOP_H_
10#define FORTRAN_RUNTIME_STOP_H_
11
12#include "flang/Runtime/c-or-cpp.h"
13#include "flang/Runtime/entry-names.h"
14#include "flang/Runtime/extensions.h"
15#include <stdlib.h>
16
17FORTRAN_EXTERN_C_BEGIN
18
19// Program-initiated image stop
20NORETURN RT_API_ATTRS void RTNAME(StopStatement)(
21 int code DEFAULT_VALUE(EXIT_SUCCESS), bool isErrorStop DEFAULT_VALUE(false),
22 bool quiet DEFAULT_VALUE(false));
23NORETURN RT_API_ATTRS void RTNAME(StopStatementText)(const char *, size_t,
24 bool isErrorStop DEFAULT_VALUE(false), bool quiet DEFAULT_VALUE(false));
25void RTNAME(PauseStatement)(NO_ARGUMENTS);
26void RTNAME(PauseStatementInt)(int);
27void RTNAME(PauseStatementText)(const char *, size_t);
28NORETURN void RTNAME(FailImageStatement)(NO_ARGUMENTS);
29NORETURN void RTNAME(ProgramEndStatement)(NO_ARGUMENTS);
30
31void RTNAME(RegisterImagesNormalEndCallback)(void (*)(int));
32void RTNAME(RegisterImagesErrorCallback)(void (*)(int));
33void RTNAME(RegisterFailImageCallback)(void (*)(void));
34
35// Extensions
36NORETURN void RTNAME(Exit)(int status DEFAULT_VALUE(EXIT_SUCCESS));
37RT_OFFLOAD_API_GROUP_BEGIN
38NORETURN void RTNAME(Abort)(NO_ARGUMENTS);
39RT_OFFLOAD_API_GROUP_END
40void FORTRAN_PROCEDURE_NAME(backtrace)(NO_ARGUMENTS);
41
42// Crash with an error message when the program dynamically violates a Fortran
43// constraint.
44RT_EXT_API_GROUP_BEGIN
45NORETURN RT_API_ATTRS void RTNAME(ReportFatalUserError)(
46 const char *message, const char *source, int line);
47
48// The caller must provide a NUL-terminated message containing at most four
49// %lld conversions, with any other percent signs escaped as %%. This contract
50// is not checked. A fixed argument list also permits calls from device code;
51// unused values are ignored.
52NORETURN RT_API_ATTRS void RTNAME(ReportFatalUserErrorValues)(
53 const char *message, const char *source, int line, long long v0,
54 long long v1, long long v2, long long v3);
55
56// The same NUL-terminated restricted format with an arbitrary number of values.
57// The number of %lld conversions must equal count; values may be null when
58// count is zero. The diagnostic is printed in pieces without allocating a
59// formatted message, so concurrent failures may interleave their output.
60NORETURN RT_API_ATTRS void RTNAME(ReportFatalUserErrorValueArray)(
61 const char *message, const char *source, int line, size_t count,
62 const long long *values);
63RT_EXT_API_GROUP_END
64
65FORTRAN_EXTERN_C_END
66
67#endif // FORTRAN_RUNTIME_STOP_H_