1 /* src/vm/suck.h - functions to read LE ordered types from a buffer
3 Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
4 R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
5 C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
6 Institut f. Computersprachen - TU Wien
8 This file is part of CACAO.
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2, or (at
13 your option) any later version.
15 This program is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
25 Contact: cacao@complang.tuwien.ac.at
27 Authors: Christian Thalinger
31 $Id: suck.h 4099 2006-01-08 22:38:03Z twisti $
43 #include "vm/hashtable.h"
44 #include "vm/loader.h"
47 /* list_classpath_entry *******************************************************/
54 typedef struct list_classpath_entry list_classpath_entry;
56 struct list_classpath_entry {
57 #if defined(USE_THREADS)
58 /* Required for monitor locking on zip/jar files. */
59 java_objectheader header;
64 #if defined(ENABLE_ZLIB)
71 /* macros to read LE and BE types from a buffer ********************************
73 BE macros are for Java class file loading.
74 LE macros are for ZIP file loading.
76 *******************************************************************************/
78 /* LE macros (for ZIP files ) *************************************************/
80 #if defined(__I386__) || defined(__X86_64__)
82 /* we can optimize the LE access on little endian machines without alignment */
84 #define SUCK_LE_U1(p) *((u1 *) (p))
85 #define SUCK_LE_U2(p) *((u2 *) (p))
86 #define SUCK_LE_U4(p) *((u4 *) (p))
89 #define SUCK_LE_U8(p) *((u8 *) (p))
92 #else /* defined(__I386__) || defined(__X86_64__) */
94 #define SUCK_LE_U1(p) \
97 #define SUCK_LE_U2(p) \
98 ((((u2) (p)[1]) << 8) + \
101 #define SUCK_LE_U4(p) \
102 ((((u4) (p)[3]) << 24) + \
103 (((u4) (p)[2]) << 16) + \
104 (((u4) (p)[1]) << 8) + \
107 #if U8_AVAILABLE == 1
108 #define SUCK_LE_U8(p) \
109 ((((u8) (p)[7]) << 56) + \
110 (((u8) (p)[6]) << 48) + \
111 (((u8) (p)[5]) << 40) + \
112 (((u8) (p)[4]) << 32) + \
113 (((u8) (p)[3]) << 24) + \
114 (((u8) (p)[2]) << 16) + \
115 (((u8) (p)[1]) << 8) + \
119 #endif /* defined(__I386__) || defined(__X86_64__) */
122 /* BE macros (for Java class files ) ******************************************/
124 #define SUCK_BE_U1(p) \
127 #define SUCK_BE_U2(p) \
128 ((((u2) (p)[0]) << 8) + \
131 #define SUCK_BE_U4(p) \
132 ((((u4) (p)[0]) << 24) + \
133 (((u4) (p)[1]) << 16) + \
134 (((u4) (p)[2]) << 8) + \
137 #if U8_AVAILABLE == 1
138 #define SUCK_BE_U8(p) \
139 ((((u8) (p)[0]) << 56) + \
140 (((u8) (p)[1]) << 48) + \
141 (((u8) (p)[2]) << 40) + \
142 (((u8) (p)[3]) << 32) + \
143 (((u8) (p)[4]) << 24) + \
144 (((u8) (p)[5]) << 16) + \
145 (((u8) (p)[6]) << 8) + \
150 /* signed suck defines ********************************************************/
152 #define suck_s1(a) (s1) suck_u1((a))
153 #define suck_s2(a) (s2) suck_u2((a))
154 #define suck_s4(a) (s4) suck_u4((a))
155 #define suck_s8(a) (s8) suck_u8((a))
158 /* export variables ***********************************************************/
160 extern char *bootclasspath;
161 extern char *classpath;
163 extern list *list_classpath_entries;
166 /* function prototypes ********************************************************/
168 bool suck_init(void);
170 void suck_add(char *classpath);
171 void suck_add_from_property(char *key);
173 bool suck_check_classbuffer_size(classbuffer *cb, s4 len);
175 u1 suck_u1(classbuffer *cb);
176 u2 suck_u2(classbuffer *cb);
177 u4 suck_u4(classbuffer *cb);
178 u8 suck_u8(classbuffer *cb);
180 float suck_float(classbuffer *cb);
181 double suck_double(classbuffer *cb);
183 void suck_nbytes(u1 *buffer, classbuffer *cb, s4 len);
184 void suck_skip_nbytes(classbuffer *cb, s4 len);
186 classbuffer *suck_start(classinfo *c);
188 void suck_stop(classbuffer *cb);
193 * These are local overrides for various environment variables in Emacs.
194 * Please do not remove this and leave it at the end of the file, where
195 * Emacs will automagically detect them.
196 * ---------------------------------------------------------------------
199 * indent-tabs-mode: t