1 /****************************************************************
2 Copyright (C) 1997 Lucent Technologies
3 All Rights Reserved
4 
5 Permission to use, copy, modify, and distribute this software and
6 its documentation for any purpose and without fee is hereby
7 granted, provided that the above copyright notice appear in all
8 copies and that both that the copyright notice and this
9 permission notice and warranty disclaimer appear in supporting
10 documentation, and that the name of Lucent or any of its entities
11 not be used in advertising or publicity pertaining to
12 distribution of the software without specific, written prior
13 permission.
14 
15 LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16 INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
17 IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
18 SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
20 IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
21 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
22 THIS SOFTWARE.
23 ****************************************************************/
24 
25 #include "asl_pfgh.h"
26 
27  int
28 #ifdef KR_headers
htcl_ASL(x)29 htcl_ASL(x) register unsigned int x;
30 #else
31 htcl_ASL(register unsigned int x)
32 #endif
33 {
34 	register int k = 0;
35 	register unsigned int L = sizeof(char *);
36 
37 	while(L < x) {
38 		k++;
39 		if (!(L <<= 1))
40 			break;
41 		}
42 	return k;
43 	}
44 
45  Char *
46 #ifdef KR_headers
new_mblk_ASL(a,k)47 new_mblk_ASL(a, k) ASL *a; int k;
48 #else
49 new_mblk_ASL(ASL *a, int k)
50 #endif
51 {
52 	Char *rv, **t;
53 	switch(a->i.ASLtype) {
54 	  case ASL_read_pfg:
55 	  case ASL_read_pfgh:
56 		break;
57 	  default:
58 		badasl_ASL(a, ASL_read_pfgh, "new_mblk");
59 	  }
60 	ACQUIRE_DTOA_LOCK(MBLK_LOCK);
61 	t = ((ASL_pfgh*)a)->mblk_free + k;
62 	if (rv = *t) {
63 		*t = *(Char**)rv;
64 		FREE_DTOA_LOCK(MBLK_LOCK);
65 		}
66 	else {
67 		FREE_DTOA_LOCK(NEW_MBLK_LOCK);
68 		rv = mem_ASL(a, sizeof(char*)<<k);
69 		}
70 	return rv;
71 	}
72 
73 #ifndef PSHVREAD
74  static
75 #endif
76  void
77 #ifdef KR_headers
Del_mblk_ASL(a,k,x)78 Del_mblk_ASL(a, k, x) ASL *a; int k; Char *x;
79 #else
80 Del_mblk_ASL(ASL *a, int k, Char *x)
81 #endif
82 {
83 	Char **t;
84 	switch(a->i.ASLtype) {
85 	  case ASL_read_pfg:
86 	  case ASL_read_pfgh:
87 		break;
88 	  default:
89 		badasl_ASL(a, ASL_read_pfgh, "del_mblk");
90 	  }
91 	t = ((ASL_pfgh*)a)->mblk_free + k;
92 	*(Char**)x = *t;
93 	*t = x;
94 	}
95