forked from tvrusso/SPICE-2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunix.c
More file actions
103 lines (83 loc) · 1.96 KB
/
unix.c
File metadata and controls
103 lines (83 loc) · 1.96 KB
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
/*
* SCCSID=unix.c 3/15/83
*/
#include <stdlib.h>
/* declarations to avoid warnings */
void mcopy(char*, char*, int);
void mclear(char*,int);
/*
* Zero, copy and move for vax unix.
*/
void move_( char * array1, int *index1, char *array2, int *index2, int *length )
{
array1 += *index1 - 1;
array2 += *index2 - 1;
mcopy( array2, array1, *length );
}
/*
Super obnoxious: they are assuming that ints are 4 bytes, doubles 8,
complex 16, even though there are supposedly pains taken to handle when
they aren't. Then they call "zero4" and friends on all ints.
On a modern 64 bit system we have 8 byte pointers, and for a variety of
reasons this makes us need to so 8 byte ints as well (because spice
is hamfistedly accessing pointer and then storing them in integers).
So let's fake this out and make "zero4" and the other "4" functions
actually copy 8, because that's what integers will be
These should really be named for the data types they zero instead of
the sizes!
*/
void zero4_( char *array, unsigned *length )
{
mclear( array, *length * 8 );
}
void zero8_( char *array, unsigned *length )
{
mclear( array, *length * 8 );
}
void zero16_( char *array, unsigned *length )
{
mclear( array, *length * 8 );
}
void copy4_( char *from, char *to, int *length )
{
mcopy( from, to, *length * 8 );
}
void copy8_( char *from, char *to, int *length )
{
mcopy( from, to, *length * 8 );
}
void copy16_( char *from, char *to, int *length )
{
mcopy( from, to, *length * 8 );
}
/*
* misc.c - miscellaneous utility routines.
* sccsid @(#)unix.c 6.1 (Splice2/Berkeley) 3/15/83
*/
/*
* mclear - clear memory.
*/
void mclear( char *data, int size )
{
for ( ; size > 0; size--, data++ ) {
*data = '\0';
}
}
/*
* mcopy - copy memory.
*/
void mcopy( char *from, char *to, int size )
{
if ( from >= to ) {
for ( ; size > 0; size-- ) {
*to++ = *from++;
}
}
else {
to += size;
from += size;
for ( ; size > 0; size-- ) {
*--to = *--from;
}
}
}