File: binit.c

package info (click to toggle)
yorick 1.4-14
  • links: PTS
  • area: main
  • in suites: potato
  • size: 5,948 kB
  • ctags: 6,609
  • sloc: ansic: 63,898; yacc: 889; makefile: 605; sh: 65; lisp: 60; fortran: 19
file content (136 lines) | stat: -rw-r--r-- 4,319 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/*
    BINIT.C

    Initialization routines for stand alone binary file package.

    $Id: binit.c,v 1.1 1993/08/27 18:32:09 munro Exp $
 */
/*    Copyright (c) 1994.  The Regents of the University of California.
                    All rights reserved.  */

#define NOT_YORICK

#include "binio.h"
#include "defmem.h"

/* Include file automatically generated by the FMCALC program.  */
#include "prmtyp.h"

/* ------------------------------------------------------------------------ */

extern void InitStructDefs(void);   /* defined below */

Operations charOps, shortOps, intOps, longOps, floatOps, doubleOps,
  complexOps, stringOps, pointerOps, structOps, structDefOps, streamOps;

Operations *yOpsStruct= &structOps;
Operations *yOpsStream= &streamOps;
Operations *yOpsStructDef= &structDefOps;

Operations charOps= { &FreeArray };
Operations shortOps= { &FreeArray };
Operations intOps= { &FreeArray };
Operations longOps= { &FreeArray };
Operations floatOps= { &FreeArray };
Operations doubleOps= { &FreeArray };
Operations complexOps= { &FreeArray };
Operations stringOps= { &FreeArray };
Operations pointerOps= { &FreeArray };
Operations structOps= { &FreeArray };
Operations structDefOps= { &FreeStructDef };
Operations streamOps= { &FreeIOStream };

/* ------------------------------------------------------------------------ */

/* Floating point layouts for floats and doubles on this machine */
static FPLayout fltSLayout= FLOAT_LAYOUT;
static FPLayout dblSLayout= DOUBLE_LAYOUT;
FPLayout *fltLayout= &fltSLayout;
FPLayout *dblLayout= &dblSLayout;

StructDef charStruct = {
  0, &structDefOps, &charOps, sizeof(char),
  CHAR_ALIGN, {0, 0, 0, 0, 0}, 0, 0,
  &CopyX, 0, 0, 0, 0, 0, 0, 0 };

StructDef shortStruct = {
  0, &structDefOps, &shortOps, sizeof(short),
  SHORT_ALIGN, {0, 0, 0, 0, 0}, 0, 0,
  &CopyX, 0, 1, 0, 0, 0, SHORT_ORDER, 0 };

StructDef intStruct = {
  0, &structDefOps, &intOps, sizeof(int),
  INT_ALIGN, {0, 0, 0, 0, 0}, 0, 0,
  &CopyX, 0, 2, 0, 0, 0, INT_ORDER, 0 };

StructDef longStruct = {
  0, &structDefOps, &longOps, sizeof(long),
  LONG_ALIGN, {0, 0, 0, 0, 0}, 0, 0,
  &CopyX, 0, 3, 0, 0, 0, LONG_ORDER, 0 };

StructDef floatStruct = {
  0, &structDefOps, &floatOps, sizeof(float),
  FLOAT_ALIGN, {0, 0, 0, 0, 0}, 0, 0,
  &CopyX, 0, 4, 0, 0, 0, FLOAT_ORDER, &fltSLayout };

StructDef doubleStruct = {
  0, &structDefOps, &doubleOps, sizeof(double),
  DOUBLE_ALIGN, {0, 0, 0, 0, 0}, 0, 0,
  &CopyX, 0, 5, 0, 0, 0, DOUBLE_ORDER, &dblSLayout };

StructDef stringStruct = {
  0, &structDefOps, &stringOps, sizeof(char *),
  POINTER_ALIGN, {0, 0, 0, 0, 0}, 0, 0,
  &CopyQ, 0, 6, 0, 0, 0, 0, 0 };

StructDef pointerStruct = {
  0, &structDefOps, &pointerOps, sizeof(void *),
  POINTER_ALIGN, {0, 0, 0, 0, 0}, 0, 0,
  &CopyP, 0, 7, 0, 0, 0, 0, 0 };

StructDef complexStruct = {
  0, &structDefOps, 0 /* &complexOps */, 0 /* 2*sizeof(double) */,
  0 /* DOUBLE_ALIGN */, {0, 0, 0, 0, 0}, 0, 0,
  &CopyX, 0, 8, 0, 0, 0, 0, 0 };

int yStructAlign= STRUCT_ALIGN;

HashTable yStructTable;
StructDef **yStructList= 0;

static void PrimInstall(char *name, StructDef *base);

void (*DefInstallHook)(const char *name, StructDef *base)= 0;

static void PrimInstall(char *name, StructDef *base)
{
  HashAdd(&yStructTable, name, 0L);
  HASH_MANAGE(yStructTable, StructDef *, yStructList);
  yStructList[hashIndex]= base;
  if (DefInstallHook) DefInstallHook(name, base);
}

void InitStructDefs(void)
{
  /* install the basic StructDefs into the global symbol table --
     this order is critical */
  PrimInstall("char", &charStruct);
  PrimInstall("short", &shortStruct);
  PrimInstall("int", &intStruct);
  PrimInstall("long", &longStruct);
  PrimInstall("float", &floatStruct);
  PrimInstall("double", &doubleStruct);
  PrimInstall("string", &stringStruct);
  PrimInstall("pointer", &pointerStruct);

  /* define the re and im parts of complex */
  HashAdd(&yStructTable, "complex", 0L);
  HASH_MANAGE(yStructTable, StructDef *, yStructList);
  yStructList[hashIndex]= &complexStruct;
  AddMember(&complexStruct, -1L, "re", &doubleStruct, (Dimension *)0);
  AddMember(&complexStruct, -1L, "im", &doubleStruct, (Dimension *)0);
  InstallStruct(&complexStruct, (StructDef *)0);
  complexStruct.dataOps= &complexOps;
}

/* ------------------------------------------------------------------------ */