aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/compute/skc/assert_skc.c
blob: 4902f980f2f636d0987a5e0d8d9cc1fd6ff29bb5 (plain)
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
/*
 * Copyright 2016 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 *
 */

//
//
//

#include <stdlib.h>
#include <stdio.h>

//
//
//

#include "assert_skc.h"

//
//
//

#define SKC_ERR_TO_STR(err) case err: return #err

//
//
//

char const *
skc_get_error_string(skc_err const err)
{
  switch(err)
    {
      SKC_ERR_TO_STR(SKC_ERR_SUCCESS);
      SKC_ERR_TO_STR(SKC_ERR_NOT_IMPLEMENTED);
      SKC_ERR_TO_STR(SKC_ERR_POOL_EMPTY);
      SKC_ERR_TO_STR(SKC_ERR_CONDVAR_WAIT);
      SKC_ERR_TO_STR(SKC_ERR_LAYER_ID_INVALID);
      SKC_ERR_TO_STR(SKC_ERR_LAYER_NOT_EMPTY);
      SKC_ERR_TO_STR(SKC_ERR_TRANSFORM_WEAKREF_INVALID);
      SKC_ERR_TO_STR(SKC_ERR_STROKE_STYLE_WEAKREF_INVALID);
      SKC_ERR_TO_STR(SKC_ERR_COMMAND_NOT_READY);
      SKC_ERR_TO_STR(SKC_ERR_COMMAND_NOT_COMPLETED);
      SKC_ERR_TO_STR(SKC_ERR_COMMAND_NOT_STARTED);
      SKC_ERR_TO_STR(SKC_ERR_COMMAND_NOT_READY_OR_COMPLETED);
      SKC_ERR_TO_STR(SKC_ERR_COMPOSITION_SEALED);
      SKC_ERR_TO_STR(SKC_ERR_STYLING_SEALED);
      SKC_ERR_TO_STR(SKC_ERR_HANDLE_INVALID);
      SKC_ERR_TO_STR(SKC_ERR_HANDLE_OVERFLOW);

    default:
      return "UNKNOWN SKC ERROR CODE";
    }
}

//
//
//

skc_err
assert_skc(skc_err const err, char const * const file, int const line, bool const abort)
{
  if (err != SKC_ERR_SUCCESS)
    {
      char const * const skc_err_str = skc_get_error_string(err);

      fprintf(stderr,
              "\"%s\", line %d: skc_assert (%d) = \"%s\"",
              file,line,err,skc_err_str);

      if (abort)
        {
          // stop profiling and reset device here if necessary
          exit(err);
        }
    }

  return err;
}

//
//
//