GNU Octave 10.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
xerbla.cc
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 1996-2025 The Octave Project Developers
4//
5// See the file COPYRIGHT.md in the top-level directory of this
6// distribution or <https://octave.org/copyright/>.
7//
8// This file is part of Octave.
9//
10// Octave is free software: you can redistribute it and/or modify it
11// under the terms of the GNU General Public License as published by
12// the Free Software Foundation, either version 3 of the License, or
13// (at your option) any later version.
14//
15// Octave is distributed in the hope that it will be useful, but
16// WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18// GNU General Public License for more details.
19//
20// You should have received a copy of the GNU General Public License
21// along with Octave; see the file COPYING. If not, see
22// <https://www.gnu.org/licenses/>.
23//
24////////////////////////////////////////////////////////////////////////
25
26#if defined (HAVE_CONFIG_H)
27# include "config.h"
28#endif
29
30#include <iostream>
31
32#include "f77-fcn.h"
33#include "lo-blas-proto.h"
34
35typedef void (*xerbla_handler_fptr) (void);
36
37/* Pointer to function to call to handle error. In the Octave
38 interpreter we set this to a function that throws an exception and
39 transfers control to the enclosing try/catch block. That is
40 typically at the top-level REPL.
41
42 We must use a function pointer instead of simply calling error
43 directly here because this function is called by LAPACK and BLAS
44 subroutines. To build shared libraries of those packages on Windows
45 requires that all symbols be known when the shared library is
46 constructed. If we call error directly, that would mean that the
47 BLAS and LAPACK libraries would have to depend on Octave... */
48
49static xerbla_handler_fptr xerbla_handler = nullptr;
50
51extern "C" void
53{
54 xerbla_handler = fcn;
55}
56
57/* Replacement for BLAS and LAPACK XERBLA subroutine that calls an
58 optionally installed handler function. */
59
61F77_FUNC (xerbla, XERBLA) (F77_CONST_CHAR_ARG_DEF (s_arg, len),
62 const F77_INT& info
64{
65 const char *s = F77_CHAR_ARG_USE (s_arg);
66 int slen = F77_CHAR_ARG_LEN_USE (s_arg, len);
67
68 std::cerr << std::string (s, slen) << ": parameter number " << info
69 << " is invalid" << std::endl;
70
71 if (xerbla_handler)
72 (*xerbla_handler) ();
73
74 F77_RETURN (0)
75}
octave_f77_int_type F77_INT
Definition f77-fcn.h:306
F77_RET_T(F77_CONST_CHAR_ARG_DECL, F77_CONST_CHAR_ARG_DECL, F77_CONST_CHAR_ARG_DECL, const F77_INT &, const F77_INT &, const F77_INT &, F77_INT &, F77_INT &, F77_DBLE *, const F77_INT &, F77_DBLE *, const F77_INT &, F77_DBLE *, F77_DBLE *, F77_DBLE *, const F77_INT &, F77_DBLE *, const F77_INT &, F77_DBLE *, const F77_INT &, F77_DBLE *, F77_INT *, F77_INT &F77_CHAR_ARG_LEN_DECL F77_CHAR_ARG_LEN_DECL F77_CHAR_ARG_LEN_DECL)
F77_RET_T F77_FUNC(xerbla, XERBLA)(F77_CONST_CHAR_ARG_DEF(s_arg
void(* xerbla_handler_fptr)(void)
Definition xerbla.cc:35
void octave_set_xerbla_handler(xerbla_handler_fptr fcn)
Definition xerbla.cc:52
F77_RET_T len
Definition xerbla.cc:61
F77_RET_T const F77_INT &info F77_CHAR_ARG_LEN_DEF(len))
Definition xerbla.cc:63