1 /* src/vm/suck.hpp - functions to read LE ordered types from a buffer
3 Copyright (C) 1996-2005, 2006, 2007, 2008
4 CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
6 This file is part of CACAO.
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2, or (at
11 your option) any later version.
13 This program is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
37 #include "threads/mutex.hpp"
39 #include "toolbox/hashtable.h"
41 #include "vm/class.hpp"
42 #include "vm/global.h"
43 #include "vm/loader.hpp"
46 /* list_classpath_entry *******************************************************/
53 typedef struct list_classpath_entry {
54 #if defined(ENABLE_THREADS)
55 Mutex *mutex; /* mutex locking on zip/jar files */
60 #if defined(ENABLE_ZLIB)
63 } list_classpath_entry;
69 * Classpath entries list.
71 class SuckClasspath : protected std::list<list_classpath_entry*> {
73 void add(char *classpath);
74 void add_from_property(const char *key);
76 // make iterator of std::list visible
77 using std::list<list_classpath_entry*>::iterator;
79 // make functions of std::list visible
80 using std::list<list_classpath_entry*>::begin;
81 using std::list<list_classpath_entry*>::end;
86 /* macros to read LE and BE types from a buffer ********************************
88 BE macros are for Java class file loading.
89 LE macros are for ZIP file loading.
91 *******************************************************************************/
93 /* LE macros (for ZIP files ) *************************************************/
95 #if defined(__I386__) || defined(__X86_64__)
97 /* we can optimize the LE access on little endian machines without alignment */
99 #define SUCK_LE_U1(p) *((u1 *) (p))
100 #define SUCK_LE_U2(p) *((u2 *) (p))
101 #define SUCK_LE_U4(p) *((u4 *) (p))
102 #define SUCK_LE_U8(p) *((u8 *) (p))
104 #else /* defined(__I386__) || defined(__X86_64__) */
106 #define SUCK_LE_U1(p) \
109 #define SUCK_LE_U2(p) \
110 ((((u2) (p)[1]) << 8) + \
113 #define SUCK_LE_U4(p) \
114 ((((u4) (p)[3]) << 24) + \
115 (((u4) (p)[2]) << 16) + \
116 (((u4) (p)[1]) << 8) + \
119 #define SUCK_LE_U8(p) \
120 ((((u8) (p)[7]) << 56) + \
121 (((u8) (p)[6]) << 48) + \
122 (((u8) (p)[5]) << 40) + \
123 (((u8) (p)[4]) << 32) + \
124 (((u8) (p)[3]) << 24) + \
125 (((u8) (p)[2]) << 16) + \
126 (((u8) (p)[1]) << 8) + \
129 #endif /* defined(__I386__) || defined(__X86_64__) */
132 /* BE macros (for Java class files ) ******************************************/
134 #define SUCK_BE_U1(p) \
137 #define SUCK_BE_U2(p) \
138 ((((u2) (p)[0]) << 8) + \
141 #define SUCK_BE_U4(p) \
142 ((((u4) (p)[0]) << 24) + \
143 (((u4) (p)[1]) << 16) + \
144 (((u4) (p)[2]) << 8) + \
147 #define SUCK_BE_U8(p) \
148 ((((u8) (p)[0]) << 56) + \
149 (((u8) (p)[1]) << 48) + \
150 (((u8) (p)[2]) << 40) + \
151 (((u8) (p)[3]) << 32) + \
152 (((u8) (p)[4]) << 24) + \
153 (((u8) (p)[5]) << 16) + \
154 (((u8) (p)[6]) << 8) + \
158 #define SUCK_BE_S1(p) (s1) SUCK_BE_U1(p)
159 #define SUCK_BE_S2(p) (s2) SUCK_BE_U2(p)
160 #define SUCK_BE_S4(p) (s4) SUCK_BE_U4(p)
161 #define SUCK_BE_S8(p) (s8) SUCK_BE_U8(p)
164 /* signed suck defines ********************************************************/
166 #define suck_s1(a) (s1) suck_u1((a))
167 #define suck_s2(a) (s2) suck_u2((a))
168 #define suck_s4(a) (s4) suck_u4((a))
169 #define suck_s8(a) (s8) suck_u8((a))
172 /* function prototypes ********************************************************/
178 bool suck_check_classbuffer_size(classbuffer *cb, s4 len);
180 u1 suck_u1(classbuffer *cb);
181 u2 suck_u2(classbuffer *cb);
182 u4 suck_u4(classbuffer *cb);
183 u8 suck_u8(classbuffer *cb);
185 float suck_float(classbuffer *cb);
186 double suck_double(classbuffer *cb);
188 void suck_nbytes(u1 *buffer, classbuffer *cb, s4 len);
189 void suck_skip_nbytes(classbuffer *cb, s4 len);
191 classbuffer *suck_start(classinfo *c);
193 void suck_stop(classbuffer *cb);
203 * These are local overrides for various environment variables in Emacs.
204 * Please do not remove this and leave it at the end of the file, where
205 * Emacs will automagically detect them.
206 * ---------------------------------------------------------------------
209 * indent-tabs-mode: t
213 * vim:noexpandtab:sw=4:ts=4: