summaryrefslogtreecommitdiff
path: root/byterun/alloc.c
diff options
context:
space:
mode:
authorNo author <no_author@ocaml.org>1995-06-15 16:08:54 +0000
committerNo author <no_author@ocaml.org>1995-06-15 16:08:54 +0000
commit77b1c8b89fd8940a63b17c41eb37161e5d159831 (patch)
tree43dbfb3982d9166b717199cb8faa97bdce30add7 /byterun/alloc.c
parentba79d4bd1f01a70b892c69f6a5e6e86714a023d6 (diff)
downloadocaml-unlabeled-1.2.2.tar.gz
This commit was manufactured by cvs2svn to create branchunlabeled-1.2.2
'unlabeled-1.2.2'. git-svn-id: http://caml.inria.fr/svn/ocaml/branches/unlabeled-1.2.2@37 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'byterun/alloc.c')
-rw-r--r--byterun/alloc.c131
1 files changed, 0 insertions, 131 deletions
diff --git a/byterun/alloc.c b/byterun/alloc.c
deleted file mode 100644
index afe0892cee..0000000000
--- a/byterun/alloc.c
+++ /dev/null
@@ -1,131 +0,0 @@
-/* 1. Allocation functions doing the same work as the macros in the
- case where [Setup_for_gc] and [Restore_after_gc] are no-ops.
- 2. Convenience functions related to allocation.
-*/
-
-#include <string.h>
-#include "alloc.h"
-#include "major_gc.h"
-#include "memory.h"
-#include "mlvalues.h"
-#include "stacks.h"
-
-#define Setup_for_gc
-#define Restore_after_gc
-
-value alloc (wosize, tag)
- mlsize_t wosize;
- tag_t tag;
-{
- value result;
-
- Assert (wosize > 0 && wosize <= Max_young_wosize);
- Alloc_small (result, wosize, tag);
- return result;
-}
-
-value alloc_tuple(n)
- mlsize_t n;
-{
- return alloc(n, 0);
-}
-
-value alloc_string (len)
- mlsize_t len;
-{
- value result;
- mlsize_t offset_index;
- mlsize_t wosize = (len + sizeof (value)) / sizeof (value);
-
- if (wosize <= Max_young_wosize) {
- Alloc_small (result, wosize, String_tag);
- }else{
- result = alloc_shr (wosize, String_tag);
- }
- Field (result, wosize - 1) = 0;
- offset_index = Bsize_wsize (wosize) - 1;
- Byte (result, offset_index) = offset_index - len;
- return result;
-}
-
-value alloc_final (len, fun, mem, max)
- mlsize_t len;
- final_fun fun;
- mlsize_t mem, max;
-{
- value result = alloc_shr (len, Final_tag);
-
- Field (result, 0) = (value) fun;
- adjust_gc_speed (mem, max);
- return result;
-}
-
-value copy_double(d)
- double d;
-{
- value res;
-
- Alloc_small(res, Double_wosize, Double_tag);
- Store_double_val(res, d);
- return res;
-}
-
-value copy_string(s)
- char * s;
-{
- int len;
- value res;
-
- len = strlen(s);
- res = alloc_string(len);
- bcopy(s, String_val(res), len);
- return res;
-}
-
-value alloc_array(funct, arr)
- value (*funct) P((char *));
- char ** arr;
-{
- mlsize_t nbr, n;
- value v;
-
- nbr = 0;
- while (arr[nbr] != 0) nbr++;
- if (nbr == 0) {
- v = Atom(0);
- } else {
- while (extern_sp - nbr <= stack_low)
- realloc_stack();
- for (n = 0; n < nbr; n++)
- *--extern_sp = funct(arr[n]);
- if (nbr < Max_young_wosize) {
- v = alloc(nbr, 0);
- n = nbr;
- while (n-- > 0) Field (v, n) = *extern_sp++;
- } else {
- v = alloc_shr(nbr, 0);
- n = nbr;
- while (n-- > 0) initialize (&Field(v, n), *extern_sp++);
- }
- }
- return v;
-}
-
-value copy_string_array(arr)
- char ** arr;
-{
- return alloc_array(copy_string, arr);
-}
-
-int convert_flag_list(list, flags)
- value list;
- int * flags;
-{
- int res;
- res = 0;
- while (Tag_val(list) == 1) {
- res |= flags[Tag_val(Field(list, 0))];
- list = Field(list, 1);
- }
- return res;
-}