OSDN Git Service

Ignore spin wait requests with no designated referrer.
[mingw/mingw-get.git] / src / dmh.h
1 #ifndef DMH_H
2 /*
3  * dmh.h
4  *
5  * $Id$
6  *
7  * Written by Keith Marshall <keithmarshall@users.sourceforge.net>
8  * Copyright (C) 2009, 2010, 2011, 2012 MinGW.org Project
9  *
10  *
11  * This header file provides the public API declarations for the
12  * diagnostic message handling subsystem.
13  *
14  *
15  * This is free software.  Permission is granted to copy, modify and
16  * redistribute this software, under the provisions of the GNU General
17  * Public License, Version 3, (or, at your option, any later version),
18  * as published by the Free Software Foundation; see the file COPYING
19  * for licensing details.
20  *
21  * Note, in particular, that this software is provided "as is", in the
22  * hope that it may prove useful, but WITHOUT WARRANTY OF ANY KIND; not
23  * even an implied WARRANTY OF MERCHANTABILITY, nor of FITNESS FOR ANY
24  * PARTICULAR PURPOSE.  Under no circumstances will the author, or the
25  * MinGW Project, accept liability for any damages, however caused,
26  * arising from the use of this software.
27  *
28  */
29 #define DMH_H  1
30
31 #include <stdint.h>
32 #ifdef __cplusplus
33 #include <exception>
34 #endif
35
36 #undef EXTERN_C
37 #ifdef __cplusplus
38 # define EXTERN_C  extern "C"
39 #else
40 # define EXTERN_C
41 #endif
42
43 typedef
44 enum dmh_class
45 {
46   DMH_SUBSYSTEM_TTY = 0,
47   DMH_SUBSYSTEM_GUI
48 } dmh_class;
49
50 typedef
51 enum dmh_severity
52 {
53   DMH_INFO = 0,
54   DMH_WARNING,
55   DMH_ERROR,
56   DMH_FATAL
57 } dmh_severity;
58
59 EXTERN_C void dmh_init( const dmh_class, const char* );
60 EXTERN_C int dmh_notify( const dmh_severity, const char *fmt, ... );
61 EXTERN_C int dmh_printf( const char *fmt, ... );
62
63 #define DMH_COMPILE_DIGEST      (uint16_t)(0x0100U)
64 #define DMH_DISPATCH_DIGEST     (uint16_t)(0x0200U)
65
66 #define DMH_DIGEST_MASK         (DMH_COMPILE_DIGEST | DMH_DISPATCH_DIGEST)
67 #define DMH_BEGIN_DIGEST        (DMH_COMPILE_DIGEST),  ~(DMH_DIGEST_MASK)
68 #define DMH_END_DIGEST          (DMH_DISPATCH_DIGEST), ~(DMH_DIGEST_MASK)
69
70 #define DMH_GET_CONTROL_STATE   (uint16_t)(0x0000U), (uint16_t)(0xFFFFU)
71
72 #define DMH_SEVERITY_MASK       (DMH_INFO | DMH_WARNING | DMH_ERROR | DMH_FATAL)
73
74 EXTERN_C uint16_t dmh_control( const uint16_t, const uint16_t );
75
76 #ifdef __cplusplus
77 class dmh_exception : public std::exception
78 {
79   /* Limited purpose exception class; can only accept messages
80    * that are const char, because lifetime is assumed infinite,
81    * and storage is not freed. Used to handle fatal errors,
82    * which otherwise would force a direct call to exit().  By
83    * using this class, we can ensure that last rites are
84    * performed before exiting.
85    */
86   public:
87     dmh_exception() throw();
88     dmh_exception( const char* ) throw();
89     virtual ~dmh_exception() throw();
90     virtual const char* what() const throw();
91
92   protected:
93     const char *message;
94 };
95 #endif /* __cplusplus */
96
97 #endif /* DMH_H: $RCSfile$: end of file */