YAP 7.1.0
arrays.h
1/*************************************************************************
2* *
3* YAP Prolog *
4* *
5* Yap Prolog was developed at NCCUP - Universidade do Porto *
6* *
7* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
8* *
9**************************************************************************
10* *
11* File: corout.c *
12* Last rev: *
13* mods: *
14* comments: Support to YAP arrays *
15* *
16*************************************************************************/
17#ifdef SCCS
18static char SccsId[]="%W% %G%";
19#endif
20
21#ifndef ARRAYS_H
22#define ARRAYS_H 1
23
24#include "arrays.h"
25
26/* second case is for static arrays */
27
28typedef struct {
29 Term tlive;
30 Term tstore;
31} live_term;
32
33typedef union {
34 Int *ints;
35 char *chars;
36 unsigned char *uchars;
37 Float *floats;
38 AtomEntry **ptrs;
39 Term *atoms;
40 Term *dbrefs;
41 struct DB_TERM **terms;
42 live_term *lterms;
44
45/* first, the valid types */
46typedef enum static_array_type
47{
48 array_of_ints,
49 array_of_chars,
50 array_of_uchars,
51 array_of_doubles,
52 array_of_ptrs,
53 array_of_atoms,
54 array_of_dbrefs,
55 array_of_nb_terms,
56 array_of_terms
57} static_array_types;
58
59/* This should never be followed by GC */
60typedef struct array_access_struct {
61 Functor array_access_func; /* identifier of array access */
62 Term ArrayT; /* term that references the array */
63 Term indx; /* index in array, for now
64 keep it as an integer! */
66
67typedef enum {
68 STATIC_ARRAY = 1,
69 DYNAMIC_ARRAY = 2,
70 MMAP_ARRAY = 4,
71 FIXED_ARRAY = 8
72} array_type;
73
74
75/* next, the actual data structure */
76typedef struct static_array_entry {
77 Prop NextOfPE; /* used to chain properties */
78 PropFlags KindOfPE; /* kind of property */
79 Int ArrayEArity; /* Arity of Array (negative) */
80 array_type TypeOfAE;
81#if defined(YAPOR) || defined(THREADS)
82 rwlock_t ArRWLock; /* a read-write lock to protect the entry */
83#endif
84 struct static_array_entry *NextAE;
85 static_array_types ArrayType; /* Type of Array Elements. */
86 statarray_elements ValueOfVE; /* Pointer to the Array itself */
88
89
90/* array property entry structure */
91/* first case is for dynamic arrays */
92typedef struct array_entry {
93 Prop NextOfPE; /* used to chain properties */
94 PropFlags KindOfPE; /* kind of property */
95 Int ArrayEArity; /* Arity of Array (positive) */
96 array_type TypeOfAE;
97#if defined(YAPOR) || defined(THREADS)
98 rwlock_t ArRWLock; /* a read-write lock to protect the entry */
99#if THREADS
100 unsigned int owner_id;
101#endif
102#endif
103 struct array_entry *NextAE;
104 Term ValueOfVE; /* Pointer to the actual array */
105} ArrayEntry;
106
107
108struct static_array_entry *
109Yap_StaticVector( Atom Name, size_t size, static_array_types props );
110
111struct static_array_entry *
112Yap_StaticArray(Atom na, size_t dim, static_array_types type, CODEADDR start_addr, struct static_array_entry *p);
113
114#endif
struct static_array_entry * Yap_StaticVector(Atom Name, size_t size, static_array_types props)
create a new vectir in a given name Name
Definition: arrays.c:1301
Definition: Yatom.h:689
Definition: arrays.h:92
Definition: arrays.h:76