| @@ -16,8 +16,7 @@ · 15 unmodified lines |
| 16 | 16 | #define SIZE_FLOAT sizeof(float) |
| 17 | 17 | #define SIZE_DOUBLE sizeof(double) |
| 18 | 18 | |
| 19 | | −extern void invalid_argument (char *) Noreturn; |
| 20 | | −extern void raise_out_of_memory (void) Noreturn; |
| 19 | +extern void caml_invalid_argument (char *) Noreturn; |
| 21 | 20 | |
| 22 | 21 | static int raw_sizeof (value kind) |
| 23 | 22 | { |
| @@ -52,7 +51,7 @@ static void check_size (value raw, long pos, char *msg) · 28 unmodified lines |
| 52 | 51 | { |
| 53 | 52 | if (pos < 0 || |
| 54 | 53 | (pos+1) * raw_sizeof(Kind_raw(raw)) > Int_val(Size_raw(raw))) |
| 55 | | − invalid_argument (msg); |
| 54 | + caml_invalid_argument (msg); |
| 56 | 55 | } |
| 57 | 56 | |
| 58 | 57 | CAMLprim value ml_raw_get (value raw, value pos) /* ML */ |
| @@ -89,8 +88,8 @@ CAMLprim value ml_raw_read (value raw, value pos, value len) /* ML */ · 30 unmodified lines |
| 89 | 88 | value ret; |
| 90 | 89 | |
| 91 | 90 | check_size (raw,s+l-1,"Raw.read"); |
| 92 | | − if (l<0 || s<0) invalid_argument("Raw.read"); |
| 93 | | − ret = alloc_shr (l, 0); |
| 91 | + if (l<0 || s<0) caml_invalid_argument("Raw.read"); |
| 92 | + ret = caml_alloc_shr (l, 0); |
| 94 | 93 | switch (Kind_raw(raw)) { |
| 95 | 94 | case MLTAG_bitmap: |
| 96 | 95 | case MLTAG_ubyte: |
| @@ -161,8 +160,8 @@ CAMLprim value ml_raw_read_string (value raw, value pos, value len) /* ML */ · 64 unmodified lines |
| 161 | 160 | value ret; |
| 162 | 161 | |
| 163 | 162 | if (l<0 || s<0 || s+l > Int_val(Size_raw(raw))) |
| 164 | | − invalid_argument("Raw.read_string"); |
| 165 | | − ret = alloc_string (l); |
| 163 | + caml_invalid_argument("Raw.read_string"); |
| 164 | + ret = caml_alloc_string (l); |
| 166 | 165 | memcpy (Bp_val(ret), Bp_val(Addr_raw(raw))+s, l); |
| 167 | 166 | CAMLreturn(ret); |
| 168 | 167 | } |
| @@ -170,10 +169,10 @@ CAMLprim value ml_raw_read_string (value raw, value pos, value len) /* ML */ · 1 unmodified line |
| 170 | 169 | CAMLprim value ml_raw_write_string (value raw, value pos, value data) /* ML */ |
| 171 | 170 | { |
| 172 | 171 | int s = Int_val(pos); |
| 173 | | − int l = string_length(data); |
| 172 | + int l = caml_string_length(data); |
| 174 | 173 | |
| 175 | 174 | if (s<0 || s+l > Int_val(Size_raw(raw))) |
| 176 | | − invalid_argument("Raw.write_string"); |
| 175 | + caml_invalid_argument("Raw.write_string"); |
| 177 | 176 | memcpy (Bp_val(Addr_raw(raw))+s, String_val(data), l); |
| 178 | 177 | return Val_unit; |
| 179 | 178 | } |
| @@ -215,7 +214,7 @@ CAMLprim value ml_raw_write (value raw, value pos, value data) /* ML */ · 35 unmodified lines |
| 215 | 214 | int i, l = Wosize_val(data); |
| 216 | 215 | |
| 217 | 216 | check_size (raw,s+l-1,"Raw.write"); |
| 218 | | − if (s<0) invalid_argument("Raw.write"); |
| 217 | + if (s<0) caml_invalid_argument("Raw.write"); |
| 219 | 218 | |
| 220 | 219 | switch (Kind_raw(raw)) { |
| 221 | 220 | case MLTAG_bitmap: |
| @@ -273,9 +272,9 @@ CAMLprim value ml_raw_get_float (value raw, value pos) /* ML */ · 51 unmodified lines |
| 273 | 272 | |
| 274 | 273 | check_size (raw,i,"Raw.get_float"); |
| 275 | 274 | if (Kind_raw(raw) == MLTAG_float) |
| 276 | | − return copy_double ((double) Float_raw(raw)[i]); |
| 275 | + return caml_copy_double ((double) Float_raw(raw)[i]); |
| 277 | 276 | else |
| 278 | | − return copy_double (Double_raw(raw)[i]); |
| 277 | + return caml_copy_double (Double_raw(raw)[i]); |
| 279 | 278 | } |
| 280 | 279 | |
| 281 | 280 | CAMLprim value ml_raw_read_float (value raw, value pos, value len) /* ML */ |
| @@ -285,8 +284,8 @@ CAMLprim value ml_raw_read_float (value raw, value pos, value len) /* ML */ · 3 unmodified lines |
| 285 | 284 | value ret = Val_unit; |
| 286 | 285 | |
| 287 | 286 | check_size (raw,s+l-1,"Raw.read_float"); |
| 288 | | − if (l<0 || s<0) invalid_argument("Raw.read_float"); |
| 289 | | − ret = alloc_shr (l*sizeof(double)/sizeof(value), Double_array_tag); |
| 287 | + if (l<0 || s<0) caml_invalid_argument("Raw.read_float"); |
| 288 | + ret = caml_alloc_shr (l*sizeof(double)/sizeof(value), Double_array_tag); |
| 290 | 289 | if (Kind_raw(raw) == MLTAG_float) { |
| 291 | 290 | float *float_raw = Float_raw(raw)+s; |
| 292 | 291 | for (i = 0; i < l; i++) |
| @@ -317,7 +316,7 @@ CAMLprim value ml_raw_write_float (value raw, value pos, value data) /* ML */ · 24 unmodified lines |
| 317 | 316 | int i, l = Wosize_val(data)*sizeof(value)/sizeof(double); |
| 318 | 317 | |
| 319 | 318 | check_size (raw,s+l-1,"Raw.write_float"); |
| 320 | | − if (s<0) invalid_argument("Raw.write_float"); |
| 319 | + if (s<0) caml_invalid_argument("Raw.write_float"); |
| 321 | 320 | if (Kind_raw(raw) == MLTAG_float) { |
| 322 | 321 | float *float_raw = Float_raw(raw)+s; |
| 323 | 322 | for (i = 0; i < l; i++) |
| @@ -428,10 +427,10 @@ CAMLprim value ml_raw_get_long (value raw, value pos) /* ML */ · 104 unmodified lines |
| 428 | 427 | switch (Kind_raw(raw)) { |
| 429 | 428 | case MLTAG_int: |
| 430 | 429 | case MLTAG_uint: |
| 431 | | − return copy_nativeint (Int_raw(raw)[i]); |
| 430 | + return caml_copy_nativeint (Int_raw(raw)[i]); |
| 432 | 431 | case MLTAG_long: |
| 433 | 432 | case MLTAG_ulong: |
| 434 | | − return copy_nativeint (Long_raw(raw)[i]); |
| 433 | + return caml_copy_nativeint (Long_raw(raw)[i]); |
| 435 | 434 | } |
| 436 | 435 | return Val_unit; |
| 437 | 436 | } |
| @@ -463,10 +462,10 @@ CAMLprim value ml_raw_alloc (value kind, value len) /* ML */ · 25 unmodified lines |
| 463 | 462 | int offset = 0; |
| 464 | 463 | |
| 465 | 464 | if (kind == MLTAG_double && sizeof(double) > sizeof(value)) { |
| 466 | | − data = alloc_shr ((size-1)/sizeof(value)+2, Abstract_tag); |
| 465 | + data = caml_alloc_shr ((size-1)/sizeof(value)+2, Abstract_tag); |
| 467 | 466 | offset = (data % sizeof(double) ? sizeof(value) : 0); |
| 468 | | − } else data = alloc_shr ((size-1)/sizeof(value)+1, Abstract_tag); |
| 469 | | − raw = alloc_small (SIZE_RAW,0); |
| 467 | + } else data = caml_alloc_shr ((size-1)/sizeof(value)+1, Abstract_tag); |
| 468 | + raw = caml_alloc_small (SIZE_RAW,0); |
| 470 | 469 | Kind_raw(raw) = kind; |
| 471 | 470 | Size_raw(raw) = Val_int(size); |
| 472 | 471 | Base_raw(raw) = data; |
| @@ -483,10 +482,10 @@ CAMLprim value ml_raw_alloc_static (value kind, value len) /* ML */ · 10 unmodified lines |
| 483 | 482 | int offset = 0; |
| 484 | 483 | |
| 485 | 484 | if (kind == MLTAG_double && sizeof(double) > sizeof(long)) { |
| 486 | | − data = stat_alloc (size+sizeof(long)); |
| 485 | + data = caml_stat_alloc (size+sizeof(long)); |
| 487 | 486 | offset = ((long)data % sizeof(double) ? sizeof(value) : 0); |
| 488 | | − } else data = stat_alloc (size); |
| 489 | | − raw = alloc_small (SIZE_RAW, 0); |
| 487 | + } else data = caml_stat_alloc (size); |
| 488 | + raw = caml_alloc_small (SIZE_RAW, 0); |
| 490 | 489 | Kind_raw(raw) = kind; |
| 491 | 490 | Size_raw(raw) = Val_int(size); |
| 492 | 491 | Base_raw(raw) = (value) data; |
| @@ -497,8 +496,8 @@ CAMLprim value ml_raw_alloc_static (value kind, value len) /* ML */ · 4 unmodified lines |
| 497 | 496 | |
| 498 | 497 | CAMLprim value ml_raw_free_static (value raw) /* ML */ |
| 499 | 498 | { |
| 500 | | − if (Static_raw(raw) != Val_int(1)) invalid_argument ("Raw.free_static"); |
| 501 | | − stat_free (Void_raw(raw)); |
| 499 | + if (Static_raw(raw) != Val_int(1)) caml_invalid_argument ("Raw.free_static"); |
| 500 | + caml_stat_free (Void_raw(raw)); |
| 502 | 501 | Base_raw(raw) = Val_unit; |
| 503 | 502 | Size_raw(raw) = Val_unit; |
| 504 | 503 | Offset_raw(raw) = Val_unit; |