Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frama-c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
frama-c
Commits
020dd28a
Commit
020dd28a
authored
2 years ago
by
Virgile Prevosto
Committed by
Andre Maroneze
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
[machdep] __fc_machdep.h generation: fixed-size integer types
parent
ba1189fd
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
share/libc/stdint.h
+2
-2
2 additions, 2 deletions
share/libc/stdint.h
src/kernel_internals/runtime/machdep.ml
+78
-0
78 additions, 0 deletions
src/kernel_internals/runtime/machdep.ml
with
80 additions
and
2 deletions
share/libc/stdint.h
+
2
−
2
View file @
020dd28a
...
@@ -96,8 +96,8 @@ typedef __UINTPTR_T uintptr_t;
...
@@ -96,8 +96,8 @@ typedef __UINTPTR_T uintptr_t;
#endif
#endif
/* ISO C: 7.18.1.5 */
/* ISO C: 7.18.1.5 */
typedef
__INT
_
MAX_T
intmax_t
;
typedef
__INTMAX_T
intmax_t
;
typedef
__UINT
_
MAX_T
uintmax_t
;
typedef
__UINTMAX_T
uintmax_t
;
/* ISO C: 7.18.2.1 */
/* ISO C: 7.18.2.1 */
#define INT8_MIN (-128)
#define INT8_MIN (-128)
...
...
This diff is collapsed.
Click to expand it.
src/kernel_internals/runtime/machdep.ml
+
78
−
0
View file @
020dd28a
...
@@ -10,10 +10,88 @@ let gen_byte_order fmt mach =
...
@@ -10,10 +10,88 @@ let gen_byte_order fmt mach =
gen_define_string
fmt
"__FC_BYTE_ORDER"
gen_define_string
fmt
"__FC_BYTE_ORDER"
(
if
mach
.
little_endian
then
"__LITTLE_ENDIAN"
else
"__BIG_ENDIAN"
)
(
if
mach
.
little_endian
then
"__LITTLE_ENDIAN"
else
"__BIG_ENDIAN"
)
let
suff_of_kind
=
[
"char"
,
""
;
"short"
,
""
;
"int"
,
""
;
"long"
,
"L"
;
"long long"
,
"LL"
]
let
pp_of_kind
=
[
"char"
,
"hh"
;
"short"
,
"h"
;
"int"
,
""
;
"long"
,
"l"
;
"long long"
,
"ll"
;
]
let
max_val
bitsize
is_signed
kind
=
let
suff
=
List
.
assoc
kind
suff_of_kind
in
let
suff
=
if
is_signed
then
suff
else
"U"
^
suff
in
let
to_shift
=
if
is_signed
then
bitsize
-
1
else
bitsize
in
let
v
=
Z
.(
to_string
(
sub
(
shift_left
one
to_shift
)
one
))
in
v
^
suff
let
min_val
bitsize
kind
=
"-"
^
(
max_val
bitsize
true
kind
)
^
" - 1"
let
gen_define_stype
fmt
name
kind
=
gen_define_string
fmt
(
"__INT"
^
name
^
"_T"
)
(
"signed "
^
kind
)
let
gen_define_utype
fmt
name
kind
=
gen_define_string
fmt
(
"__UINT"
^
name
^
"_T"
)
(
"unsigned "
^
kind
)
let
gen_define_min_stype
fmt
name
bitsize
kind
=
gen_define_string
fmt
(
"__INT"
^
name
^
"_MIN"
)
(
min_val
bitsize
kind
)
let
gen_define_max_stype
fmt
name
bitsize
kind
=
gen_define_string
fmt
(
"__INT"
^
name
^
"_MAX"
)
(
max_val
bitsize
true
kind
)
let
gen_define_max_utype
fmt
name
bitsize
kind
=
gen_define_string
fmt
(
"__UINT"
^
name
^
"_MAX"
)
(
max_val
bitsize
false
kind
)
let
gen_define_printing_prefix
fmt
name
kind
=
gen_define_string
fmt
(
"__PRI"
^
name
^
"_PREFIX"
)
(
List
.
assoc
kind
pp_of_kind
)
let
existing_int_size
mach
=
[
1
,
"char"
;
mach
.
sizeof_short
,
"short"
;
mach
.
sizeof_int
,
"int"
;
mach
.
sizeof_long
,
"long"
;
mach
.
sizeof_longlong
,
"long long"
]
let
gen_int_type_family
fmt
name
bitsize
kind
=
gen_define_stype
fmt
name
kind
;
gen_define_utype
fmt
name
kind
;
gen_define_min_stype
fmt
name
bitsize
kind
;
gen_define_max_stype
fmt
name
bitsize
kind
;
gen_define_max_utype
fmt
name
bitsize
kind
;
gen_define_printing_prefix
fmt
name
kind
let
gen_fixed_size_family
fmt
bitsize
mach
=
let
size
=
bitsize
/
8
in
match
List
.
find_opt
(
fun
(
s
,_
)
->
s
>=
size
)
(
existing_int_size
mach
)
with
|
None
->
()
(* No corresponding type. *)
|
Some
(
exact_size
,
kind
)
->
if
size
=
exact_size
then
gen_int_type_family
fmt
(
string_of_int
bitsize
)
bitsize
kind
;
gen_int_type_family
fmt
(
"_LEAST"
^
string_of_int
bitsize
)
bitsize
kind
;
gen_int_type_family
fmt
(
"_FAST"
^
string_of_int
bitsize
)
bitsize
kind
let
gen_max_size_int
fmt
mach
=
gen_int_type_family
fmt
"MAX"
(
8
*
mach
.
sizeof_longlong
)
"long long"
let
gen_all_defines
fmt
mach
=
let
gen_all_defines
fmt
mach
=
Format
.
fprintf
fmt
"/* Machdep-specific info for Frama-C's libc */@
\n
"
;
Format
.
fprintf
fmt
"/* Machdep-specific info for Frama-C's libc */@
\n
"
;
Format
.
fprintf
fmt
"#ifndef __FC_MACHDEP@
\n
#define __FC_MACHDEP@
\n
"
;
Format
.
fprintf
fmt
"#ifndef __FC_MACHDEP@
\n
#define __FC_MACHDEP@
\n
"
;
gen_byte_order
fmt
mach
;
gen_byte_order
fmt
mach
;
(* TODO: __FC_POSIX_VERSION *)
gen_fixed_size_family
fmt
8
mach
;
gen_fixed_size_family
fmt
16
mach
;
gen_fixed_size_family
fmt
32
mach
;
gen_fixed_size_family
fmt
64
mach
;
gen_max_size_int
fmt
mach
;
Format
.
fprintf
fmt
"#endif // __FC_MACHDEP@
\n
"
Format
.
fprintf
fmt
"#endif // __FC_MACHDEP@
\n
"
let
generate_machdep_header
mach
=
let
generate_machdep_header
mach
=
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment