compare.c hash.c mlvalues.h: redefinition de Is_atom a l'aide de &end
pour que les constantes structurees produites par le compilo natif apparaissent comme des atomes et qu'on descende dedans dans equal et hash. ints.c: rectification de format_int pour qu'il formatte des long, pas des int. git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@101 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02master
parent
997d43903b
commit
0c8b586da0
|
@ -17,11 +17,9 @@ static long compare_val(v1, v2)
|
|||
if (Is_long(v1) || Is_long(v2)) return Long_val(v1) - Long_val(v2);
|
||||
/* If one of the objects is outside the heap (but is not an atom),
|
||||
use address comparison. */
|
||||
/* Does not work with the native-code generator !
|
||||
Removed, but need to find something */
|
||||
/* if ((!Is_atom(v1) && !Is_young(v1) && !Is_in_heap(v1)) ||
|
||||
(!Is_atom(v2) && !Is_young(v2) && !Is_in_heap(v2)))
|
||||
return v1 - v2; */
|
||||
if ((!Is_atom(v1) && !Is_young(v1) && !Is_in_heap(v1)) ||
|
||||
(!Is_atom(v2) && !Is_young(v2) && !Is_in_heap(v2)))
|
||||
return v1 - v2;
|
||||
t1 = Tag_val(v1);
|
||||
t2 = Tag_val(v2);
|
||||
if (t1 != t2) return (long)t1 - (long)t2;
|
||||
|
|
|
@ -42,10 +42,10 @@ static void hash_aux(obj)
|
|||
return;
|
||||
}
|
||||
|
||||
/* Pointers into the heap are well-structured blocks.
|
||||
/* Pointers into the heap are well-structured blocks. So are atoms.
|
||||
We can inspect the block contents. */
|
||||
|
||||
if (Is_in_heap(obj) || Is_young(obj)) {
|
||||
if (Is_atom(obj) || Is_young(obj) || Is_in_heap(obj)) {
|
||||
tag = Tag_val(obj);
|
||||
switch (tag) {
|
||||
case String_tag:
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
#include "alloc.h"
|
||||
#include "fail.h"
|
||||
#include "memory.h"
|
||||
#include "misc.h"
|
||||
#include "mlvalues.h"
|
||||
#include "str.h"
|
||||
|
||||
value int_of_string(s) /* ML */
|
||||
value s;
|
||||
|
@ -54,10 +56,11 @@ value int_of_string(s) /* ML */
|
|||
value format_int(fmt, arg) /* ML */
|
||||
value fmt, arg;
|
||||
{
|
||||
char format_buffer[32];
|
||||
char format_string[32], format_buffer[32];
|
||||
int prec;
|
||||
char * p;
|
||||
char * dest;
|
||||
mlsize_t len;
|
||||
value res;
|
||||
|
||||
prec = 32;
|
||||
|
@ -72,7 +75,14 @@ value format_int(fmt, arg) /* ML */
|
|||
} else {
|
||||
dest = stat_alloc(prec);
|
||||
}
|
||||
sprintf(dest, String_val(fmt), Long_val(arg));
|
||||
len = string_length(fmt);
|
||||
if (len >= sizeof(format_string) - 1)
|
||||
invalid_argument("format_int: format too long");
|
||||
bcopy(String_val(fmt), format_string, len);
|
||||
format_string[len + 1] = 0;
|
||||
format_string[len] = format_string[len - 1];
|
||||
format_string[len - 1] = 'l';
|
||||
sprintf(dest, format_string, Long_val(arg));
|
||||
res = copy_string(dest);
|
||||
if (dest != format_buffer) {
|
||||
stat_free(dest);
|
||||
|
|
|
@ -196,7 +196,13 @@ typedef void (*final_fun) P((value));
|
|||
|
||||
extern header_t first_atoms[];
|
||||
#define Atom(tag) (Val_hp (&(first_atoms [tag])))
|
||||
#define Is_atom(v) (v >= Atom(0) && v <= Atom(255))
|
||||
|
||||
/* For the benefits of the native-code generator, we define as atoms
|
||||
all data in the statically initialized or statically uninitialized (BSS)
|
||||
zones. */
|
||||
|
||||
extern int end;
|
||||
#define Is_atom(v) ((int *)(v) < &end)
|
||||
|
||||
/* Booleans are integers 0 or 1 */
|
||||
|
||||
|
|
Loading…
Reference in New Issue