Skip to content

Commit be3627b

Browse files
gretay-jsstedolan
authored andcommitted
Change prefix of all magic numbers to avoid clashes with upstream.
1 parent f00aed7 commit be3627b

File tree

3 files changed

+27
-34
lines changed

3 files changed

+27
-34
lines changed

ocaml/runtime/caml/exec.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ struct exec_trailer {
6060

6161
/* Magic number for this release */
6262

63-
#define EXEC_MAGIC "Caml1999X029"
63+
#define EXEC_MAGIC "Caml2021X029"
6464

6565
#endif /* CAML_INTERNALS */
6666

ocaml/utils/config.mlp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,11 @@ let function_sections = %%FUNCTION_SECTIONS%%
9191
let probes = %%PROBES%%
9292
let afl_instrument = %%AFL_INSTRUMENT%%
9393

94-
let exec_magic_number = "Caml1999X029"
94+
let exec_magic_number = "Caml2021X029"
9595
(* exec_magic_number is duplicated in runtime/caml/exec.h *)
96-
and cmi_magic_number = "Caml1999I029"
97-
and cmo_magic_number = "Caml1999O029"
98-
and cma_magic_number = "Caml1999A029"
96+
and cmi_magic_number = "Caml2021I029"
97+
and cmo_magic_number = "Caml2021O029"
98+
and cma_magic_number = "Caml2021A029"
9999
and cmx_magic_number =
100100
if flambda || flambda2 then
101101
"Caml2021y029"
@@ -106,11 +106,11 @@ and cmxa_magic_number =
106106
"Caml2021z029"
107107
else
108108
"Caml2021Z029"
109-
and ast_impl_magic_number = "Caml1999M029"
110-
and ast_intf_magic_number = "Caml1999N029"
111-
and cmxs_magic_number = "Caml1999D029"
112-
and cmt_magic_number = "Caml1999T029"
113-
and linear_magic_number = "Caml1999L029"
109+
and ast_impl_magic_number = "Caml2021M029"
110+
and ast_intf_magic_number = "Caml2021N029"
111+
and cmxs_magic_number = "Caml2021D029"
112+
and cmt_magic_number = "Caml2021T029"
113+
and linear_magic_number = "Caml2021L029"
114114
and cfg_magic_number = "Caml2021G029"
115115

116116
let interface_suffix = ref ".mli"

ocaml/utils/misc.ml

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -982,37 +982,30 @@ module Magic_number = struct
982982

983983
type raw_kind = string
984984

985+
(* We do not accept Caml1999 prefixes. *)
985986
let parse_kind : raw_kind -> kind option = function
986-
| "Caml1999X" -> Some Exec
987-
| "Caml1999I" -> Some Cmi
988-
| "Caml1999O" -> Some Cmo
989-
| "Caml1999A" -> Some Cma
987+
| "Caml2021X" -> Some Exec
988+
| "Caml2021I" -> Some Cmi
989+
| "Caml2021O" -> Some Cmo
990+
| "Caml2021A" -> Some Cma
990991
| "Caml2021y" -> Some (Cmx {flambda = true})
991992
| "Caml2021Y" -> Some (Cmx {flambda = false})
992993
| "Caml2021z" -> Some (Cmxa {flambda = true})
993994
| "Caml2021Z" -> Some (Cmxa {flambda = false})
994-
995-
(* Caml2007D and Caml2012T were used instead of the common Caml1999 prefix
996-
between the introduction of those magic numbers and October 2017
997-
(8ba70ff194b66c0a50ffb97d41fe9c4bdf9362d6).
998-
999-
We accept them here, but will always produce/show kind prefixes
1000-
that follow the current convention, Caml1999{D,T}. *)
1001-
| "Caml2007D" | "Caml1999D" -> Some Cmxs
1002-
| "Caml2012T" | "Caml1999T" -> Some Cmt
1003-
1004-
| "Caml1999M" -> Some Ast_impl
1005-
| "Caml1999N" -> Some Ast_intf
995+
| "Caml2021D" -> Some Cmxs
996+
| "Caml2021T" -> Some Cmt
997+
| "Caml2021M" -> Some Ast_impl
998+
| "Caml2021N" -> Some Ast_intf
1006999
| _ -> None
10071000

10081001
(* note: over time the magic kind number has changed for certain kinds;
10091002
this function returns them as they are produced by the current compiler,
10101003
but [parse_kind] accepts older formats as well. *)
10111004
let raw_kind : kind -> raw = function
1012-
| Exec -> "Caml1999X"
1013-
| Cmi -> "Caml1999I"
1014-
| Cmo -> "Caml1999O"
1015-
| Cma -> "Caml1999A"
1005+
| Exec -> "Caml2021X"
1006+
| Cmi -> "Caml2021I"
1007+
| Cmo -> "Caml2021O"
1008+
| Cma -> "Caml2021A"
10161009
| Cmx config ->
10171010
if config.flambda
10181011
then "Caml2021y"
@@ -1021,10 +1014,10 @@ module Magic_number = struct
10211014
if config.flambda
10221015
then "Caml2021z"
10231016
else "Caml2021Z"
1024-
| Cmxs -> "Caml1999D"
1025-
| Cmt -> "Caml1999T"
1026-
| Ast_impl -> "Caml1999M"
1027-
| Ast_intf -> "Caml1999N"
1017+
| Cmxs -> "Caml2021D"
1018+
| Cmt -> "Caml2021T"
1019+
| Ast_impl -> "Caml2021M"
1020+
| Ast_intf -> "Caml2021N"
10281021

10291022
let string_of_kind : kind -> string = function
10301023
| Exec -> "exec"

0 commit comments

Comments
 (0)