source: trunk/minix/lib/ack/libm2/confarray.c@ 12

Last change on this file since 12 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 1.5 KB
Line 
1/*
2 (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
3 See the copyright notice in the ACK home directory, in the file "Copyright".
4*/
5
6/*
7 Module: runtime support for conformant arrays
8 Author: Ceriel J.H. Jacobs
9 Version: $Header: /cvsup/minix/src/lib/ack/libm2/confarray.c,v 1.1 2005/10/10 15:27:46 beng Exp $
10*/
11#include <m2_traps.h>
12
13#ifndef EM_WSIZE
14#define EM_WSIZE _EM_WSIZE
15#define EM_PSIZE _EM_PSIZE
16#endif
17
18#if EM_WSIZE==EM_PSIZE
19typedef unsigned pcnt;
20#else
21typedef unsigned long pcnt;
22#endif
23
24struct descr {
25 char *addr;
26 int low;
27 unsigned int highminlow;
28 unsigned int size;
29};
30
31static struct descr *descrs[10];
32static struct descr **ppdescr = descrs;
33
34pcnt
35new_stackptr(pdscr, a)
36 struct descr *pdscr;
37{
38 register struct descr *pdescr = pdscr;
39 pcnt size = (((pdescr->highminlow + 1) * pdescr->size +
40 (EM_WSIZE - 1)) & ~(EM_WSIZE - 1));
41
42 if (ppdescr >= &descrs[10]) {
43 /* to many nested traps + handlers ! */
44 TRP(M2_TOOMANY);
45 }
46 *ppdescr++ = pdescr;
47 if ((char *) &a - (char *) &pdscr > 0) {
48 /* stack grows downwards */
49 return - size;
50 }
51 return size;
52}
53
54copy_array(pp, a)
55 char *pp;
56{
57 register char *p = pp;
58 register char *q;
59 register pcnt sz;
60 char dummy;
61
62 ppdescr--;
63 sz = ((*ppdescr)->highminlow + 1) * (*ppdescr)->size;
64
65 if ((char *) &a - (char *) &pp > 0) {
66 (*ppdescr)->addr = q = (char *) &a;
67 }
68 else (*ppdescr)->addr = q = (char *) &a -
69 ((sz + (EM_WSIZE - 1)) & ~ (EM_WSIZE - 1));
70
71 while (sz--) *q++ = *p++;
72}
Note: See TracBrowser for help on using the repository browser.