File: dwarf_default_lower_bound.c

package info (click to toggle)
elfutils 0.194-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 27,680 kB
  • sloc: ansic: 114,970; sh: 35,537; cpp: 4,998; makefile: 1,986; yacc: 1,388; lex: 130; asm: 77; sed: 39; awk: 35
file content (195 lines) | stat: -rw-r--r-- 5,052 bytes parent folder | download | duplicates (2)
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
/* Get the default subrange lower bound for a given language.
   Copyright (C) 2016 Red Hat, Inc.
   Copyright (C) 2024, 2025 Mark J. Wielaard <mark@klomp.org>
   This file is part of elfutils.

   This file is free software; you can redistribute it and/or modify
   it under the terms of either

     * the GNU Lesser General Public License as published by the Free
       Software Foundation; either version 3 of the License, or (at
       your option) any later version

   or

     * 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

   or both in parallel, as here.

   elfutils 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 copies of the GNU General Public License and
   the GNU Lesser General Public License along with this program.  If
   not, see <http://www.gnu.org/licenses/>.  */

#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

#include <dwarf.h>
#include "libdwP.h"

/* Determine default lower bound from language, as per the DWARF5
   "Subrange Type Entries" table.  */
int
dwarf_default_lower_bound (int lang, Dwarf_Sword *result)
{
  switch (lang)
    {
    case DW_LANG_C:
    case DW_LANG_C89:
    case DW_LANG_C99:
    case DW_LANG_C11:
    case DW_LANG_C_plus_plus:
    case DW_LANG_C_plus_plus_03:
    case DW_LANG_C_plus_plus_11:
    case DW_LANG_C_plus_plus_14:
    case DW_LANG_ObjC:
    case DW_LANG_ObjC_plus_plus:
    case DW_LANG_Java:
    case DW_LANG_D:
    case DW_LANG_Python:
    case DW_LANG_UPC:
    case DW_LANG_OpenCL:
    case DW_LANG_Go:
    case DW_LANG_Haskell:
    case DW_LANG_OCaml:
    case DW_LANG_Rust:
    case DW_LANG_Swift:
    case DW_LANG_Dylan:
    case DW_LANG_RenderScript:
    case DW_LANG_BLISS:
    case DW_LANG_Kotlin:
    case DW_LANG_Zig:
    case DW_LANG_Crystal:
    case DW_LANG_C_plus_plus_17:
    case DW_LANG_C_plus_plus_20:
    case DW_LANG_C17:
    case DW_LANG_HIP:
    case DW_LANG_Assembly:
    case DW_LANG_C_sharp:
    case DW_LANG_Mojo:
    case DW_LANG_GLSL:
    case DW_LANG_GLSL_ES:
    case DW_LANG_HLSL:
    case DW_LANG_OpenCL_CPP:
    case DW_LANG_CPP_for_OpenCL:
    case DW_LANG_SYCL:
    case DW_LANG_C_plus_plus_23:
    case DW_LANG_Odin:
    case DW_LANG_P4:
    case DW_LANG_Metal:
    case DW_LANG_C23:
    case DW_LANG_Ruby:
    case DW_LANG_Move:
    case DW_LANG_Hylo:
    case DW_LANG_V:
    case DW_LANG_Nim:
      *result = 0;
      return 0;

    case DW_LANG_Ada83:
    case DW_LANG_Ada95:
    case DW_LANG_Cobol74:
    case DW_LANG_Cobol85:
    case DW_LANG_Fortran77:
    case DW_LANG_Fortran90:
    case DW_LANG_Fortran95:
    case DW_LANG_Fortran03:
    case DW_LANG_Fortran08:
    case DW_LANG_Pascal83:
    case DW_LANG_Modula2:
    case DW_LANG_Modula3:
    case DW_LANG_PLI:
    case DW_LANG_Julia:
    case DW_LANG_Fortran18:
    case DW_LANG_Ada2005:
    case DW_LANG_Ada2012:
    case DW_LANG_Fortran23:
    case DW_LANG_Algol68:
      *result = 1;
      return 0;

    /* Special case vendor Assembly variant.  */
    case DW_LANG_Mips_Assembler:
      *result = 0;
      return 0;

    default:
      __libdw_seterrno (DWARF_E_UNKNOWN_LANGUAGE);
      return -1;
    }
}
INTDEF (dwarf_default_lower_bound)

/* Determine default lower bound from language, as per the DWARF6
   https://dwarfstd.org/languages-v6.html table.  */
int
dwarf_language_lower_bound (Dwarf_Word lang, Dwarf_Sword *result)
{
  switch (lang)
    {
    case DW_LNAME_BLISS:
    case DW_LNAME_C:
    case DW_LNAME_C_plus_plus:
    case DW_LNAME_Crystal:
    case DW_LNAME_D:
    case DW_LNAME_Dylan:
    case DW_LNAME_Go:
    case DW_LNAME_Haskell:
    case DW_LNAME_Java:
    case DW_LNAME_Kotlin:
    case DW_LNAME_ObjC:
    case DW_LNAME_ObjC_plus_plus:
    case DW_LNAME_OCaml:
    case DW_LNAME_OpenCL_C:
    case DW_LNAME_Python:
    case DW_LNAME_RenderScript:
    case DW_LNAME_Rust:
    case DW_LNAME_Swift:
    case DW_LNAME_UPC:
    case DW_LNAME_Zig:
    case DW_LNAME_Assembly:
    case DW_LNAME_C_sharp:
    case DW_LNAME_Mojo:
    case DW_LNAME_GLSL:
    case DW_LNAME_GLSL_ES:
    case DW_LNAME_HLSL:
    case DW_LNAME_OpenCL_CPP:
    case DW_LNAME_CPP_for_OpenCL:
    case DW_LNAME_SYCL:
    case DW_LNAME_Ruby:
    case DW_LNAME_Move:
    case DW_LNAME_Hylo:
    case DW_LNAME_HIP:
    case DW_LNAME_Odin:
    case DW_LNAME_P4:
    case DW_LNAME_Metal:
    case DW_LNAME_V:
    case DW_LNAME_Nim:
      *result = 0;
      return 0;

    case DW_LNAME_Ada:
    case DW_LNAME_Cobol:
    case DW_LNAME_Fortran:
    case DW_LNAME_Julia:
    case DW_LNAME_Modula2:
    case DW_LNAME_Modula3:
    case DW_LNAME_Pascal:
    case DW_LNAME_PLI:
    case DW_LNAME_Algol68:
      *result = 1;
      return 0;

    default:
      __libdw_seterrno (DWARF_E_UNKNOWN_LANGUAGE);
      return -1;
    }
}
INTDEF (dwarf_language_lower_bound)