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
33 #include "threads/mutex.hpp"
35 #include "toolbox/hashtable.h"
36 #include "toolbox/list.hpp"
39 #include "vm/global.h"
40 #include "vm/loader.hpp"
43 /* list_classpath_entry *******************************************************/
50 typedef struct list_classpath_entry list_classpath_entry;
52 struct list_classpath_entry {
53 #if defined(ENABLE_THREADS)
54 Mutex *mutex; /* mutex locking on zip/jar files */
59 #if defined(ENABLE_ZLIB)
65 /* macros to read LE and BE types from a buffer ********************************
67 BE macros are for Java class file loading.
68 LE macros are for ZIP file loading.
70 *******************************************************************************/
72 /* LE macros (for ZIP files ) *************************************************/
74 #if defined(__I386__) || defined(__X86_64__)
76 /* we can optimize the LE access on little endian machines without alignment */
78 #define SUCK_LE_U1(p) *((u1 *) (p))
79 #define SUCK_LE_U2(p) *((u2 *) (p))
80 #define SUCK_LE_U4(p) *((u4 *) (p))
83 #define SUCK_LE_U8(p) *((u8 *) (p))
86 #else /* defined(__I386__) || defined(__X86_64__) */
88 #define SUCK_LE_U1(p) \
91 #define SUCK_LE_U2(p) \
92 ((((u2) (p)[1]) << 8) + \
95 #define SUCK_LE_U4(p) \
96 ((((u4) (p)[3]) << 24) + \
97 (((u4) (p)[2]) << 16) + \
98 (((u4) (p)[1]) << 8) + \
101 #if U8_AVAILABLE == 1
102 #define SUCK_LE_U8(p) \
103 ((((u8) (p)[7]) << 56) + \
104 (((u8) (p)[6]) << 48) + \
105 (((u8) (p)[5]) << 40) + \
106 (((u8) (p)[4]) << 32) + \
107 (((u8) (p)[3]) << 24) + \
108 (((u8) (p)[2]) << 16) + \
109 (((u8) (p)[1]) << 8) + \
113 #endif /* defined(__I386__) || defined(__X86_64__) */
116 /* BE macros (for Java class files ) ******************************************/
118 #define SUCK_BE_U1(p) \
121 #define SUCK_BE_U2(p) \
122 ((((u2) (p)[0]) << 8) + \
125 #define SUCK_BE_U4(p) \
126 ((((u4) (p)[0]) << 24) + \
127 (((u4) (p)[1]) << 16) + \
128 (((u4) (p)[2]) << 8) + \
131 #if U8_AVAILABLE == 1
132 #define SUCK_BE_U8(p) \
133 ((((u8) (p)[0]) << 56) + \
134 (((u8) (p)[1]) << 48) + \
135 (((u8) (p)[2]) << 40) + \
136 (((u8) (p)[3]) << 32) + \
137 (((u8) (p)[4]) << 24) + \
138 (((u8) (p)[5]) << 16) + \
139 (((u8) (p)[6]) << 8) + \
144 #define SUCK_BE_S1(p) (s1) SUCK_BE_U1(p)
145 #define SUCK_BE_S2(p) (s2) SUCK_BE_U2(p)
146 #define SUCK_BE_S4(p) (s4) SUCK_BE_U4(p)
147 #define SUCK_BE_S8(p) (s8) SUCK_BE_U8(p)
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 ***********************************************************/
161 extern List<list_classpath_entry*>* list_classpath_entries;
163 extern List* list_classpath_entries;
166 /* function prototypes ********************************************************/
172 bool suck_init(void);
174 void suck_add(char *classpath);
175 void suck_add_from_property(const char *key);
177 bool suck_check_classbuffer_size(classbuffer *cb, s4 len);
179 u1 suck_u1(classbuffer *cb);
180 u2 suck_u2(classbuffer *cb);
181 u4 suck_u4(classbuffer *cb);
182 u8 suck_u8(classbuffer *cb);
184 float suck_float(classbuffer *cb);
185 double suck_double(classbuffer *cb);
187 void suck_nbytes(u1 *buffer, classbuffer *cb, s4 len);
188 void suck_skip_nbytes(classbuffer *cb, s4 len);
190 classbuffer *suck_start(classinfo *c);
192 void suck_stop(classbuffer *cb);
202 * These are local overrides for various environment variables in Emacs.
203 * Please do not remove this and leave it at the end of the file, where
204 * Emacs will automagically detect them.
205 * ---------------------------------------------------------------------
208 * indent-tabs-mode: t
212 * vim:noexpandtab:sw=4:ts=4: