~ubuntu-branches/debian/sid/ocaml/sid

« back to all changes in this revision

Viewing changes to byterun/compare.c

  • Committer: Bazaar Package Importer
  • Author(s): Stefano Zacchiroli
  • Date: 2009-02-22 08:49:13 UTC
  • mfrom: (12.1.1 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090222084913-3i0uw2bhd0lgw0ok
* Uploading to unstable
* debian/control: bump dh-ocaml to (>= 0.4) to avoid buggy ocamlinit.mk

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
/*                                                                     */
12
12
/***********************************************************************/
13
13
 
14
 
/* $Id: compare.c,v 1.36.4.1 2008/01/03 09:54:17 xleroy Exp $ */
 
14
/* $Id: compare.c,v 1.39 2008/01/11 16:13:16 doligez Exp $ */
15
15
 
16
16
#include <string.h>
17
17
#include <stdlib.h>
104
104
      if (Is_long(v2))
105
105
        return Long_val(v1) - Long_val(v2);
106
106
      /* Subtraction above cannot overflow and cannot result in UNORDERED */
107
 
      if ((Is_atom(v2) || Is_young(v2) || Is_in_heap(v2)) &&
 
107
      if (Is_in_value_area(v2) &&
108
108
          Tag_val(v2) == Forward_tag) {
109
109
        v2 = Forward_val(v2);
110
110
        continue;
112
112
      return LESS;                /* v1 long < v2 block */
113
113
    }
114
114
    if (Is_long(v2)) {
115
 
      if ((Is_atom(v1) || Is_young(v1) || Is_in_heap(v1)) &&
 
115
      if (Is_in_value_area(v1) &&
116
116
          Tag_val(v1) == Forward_tag) {
117
117
        v1 = Forward_val(v1);
118
118
        continue;
122
122
    /* If one of the objects is outside the heap (but is not an atom),
123
123
       use address comparison. Since both addresses are 2-aligned,
124
124
       shift lsb off to avoid overflow in subtraction. */
125
 
    if ((!Is_atom(v1) && !Is_young(v1) && !Is_in_heap(v1)) ||
126
 
        (!Is_atom(v2) && !Is_young(v2) && !Is_in_heap(v2))) {
 
125
    if (! Is_in_value_area(v1) || ! Is_in_value_area(v2)) {
127
126
      if (v1 == v2) goto next_item;
128
127
      return (v1 >> 1) - (v2 >> 1);
129
128
      /* Subtraction above cannot result in UNORDERED */