OSDN Git Service

* tree-vrp.c (has_assert_expr, maybe_add_assert_expr): Remove.
[pf3gnuchains/gcc-fork.git] / libjava / gcj / javaprims.h
1 // javaprims.h - Main external header file for libgcj.  -*- c++ -*-
2
3
4 /* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
5    Free Software Foundation
6
7    This file is part of libgcj.
8
9 This software is copyrighted work licensed under the terms of the
10 Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
11 details.  */
12
13 #ifndef __JAVAPRIMS_H__
14 #define __JAVAPRIMS_H__
15
16 // Force C++ compiler to use Java-style exceptions.
17 #pragma GCC java_exceptions
18
19 #include <gcj/libgcj-config.h>
20
21 // FIXME: this is a hack until we get a proper gcjh.
22 // It is needed to work around system header files that define TRUE
23 // and FALSE.
24 #undef TRUE
25 #define TRUE TRUE
26 #undef FALSE
27 #define FALSE FALSE
28
29 // To force selection of correct types that will mangle consistently
30 // across platforms.
31 extern "Java"
32 {
33   typedef __java_byte jbyte;
34   typedef __java_short jshort;
35   typedef __java_int jint;
36   typedef __java_long jlong;
37   typedef __java_float jfloat;
38   typedef __java_double jdouble;
39   typedef __java_char jchar;
40   typedef __java_boolean jboolean;
41   typedef jint jsize;
42
43   // The following class declarations are automatically generated by
44   // the `classes.pl' script.
45   namespace java
46   {
47     namespace io
48     {
49       class BufferedInputStream;
50       class BufferedOutputStream;
51       class BufferedReader;
52       class BufferedWriter;
53       class ByteArrayInputStream;
54       class ByteArrayOutputStream;
55       class CharArrayReader;
56       class CharArrayWriter;
57       class CharConversionException;
58       class DataInput;
59       class DataInputStream;
60       class DataOutput;
61       class DataOutputStream;
62       class EOFException;
63       class Externalizable;
64       class File;
65       class FileDescriptor;
66       class FileFilter;
67       class FileInputStream;
68       class FileNotFoundException;
69       class FileOutputStream;
70       class FilePermission;
71       class FileReader;
72       class FileWriter;
73       class FilenameFilter;
74       class FilterInputStream;
75       class FilterOutputStream;
76       class FilterReader;
77       class FilterWriter;
78       class IOException;
79       class InputStream;
80       class InputStreamReader;
81       class InterruptedIOException;
82       class InvalidClassException;
83       class InvalidObjectException;
84       class LineNumberInputStream;
85       class LineNumberReader;
86       class NotActiveException;
87       class NotSerializableException;
88       class ObjectInput;
89       class ObjectInputStream;
90       class ObjectInputStream$GetField;
91       class ObjectInputStream$ValidatorAndPriority;
92       class ObjectInputValidation;
93       class ObjectOutput;
94       class ObjectOutputStream;
95       class ObjectOutputStream$PutField;
96       class ObjectStreamClass;
97       class ObjectStreamClass$InterfaceComparator;
98       class ObjectStreamClass$MemberComparator;
99       class ObjectStreamConstants;
100       class ObjectStreamException;
101       class ObjectStreamField;
102       class OptionalDataException;
103       class OutputStream;
104       class OutputStreamWriter;
105       class PipedInputStream;
106       class PipedOutputStream;
107       class PipedReader;
108       class PipedWriter;
109       class PrintStream;
110       class PrintWriter;
111       class PushbackInputStream;
112       class PushbackReader;
113       class RandomAccessFile;
114       class Reader;
115       class SequenceInputStream;
116       class Serializable;
117       class SerializablePermission;
118       class StreamCorruptedException;
119       class StreamTokenizer;
120       class StringBufferInputStream;
121       class StringReader;
122       class StringWriter;
123       class SyncFailedException;
124       class UTFDataFormatException;
125       class UnsupportedEncodingException;
126       class VMObjectStreamClass;
127       class WriteAbortedException;
128       class Writer;
129     }
130
131     namespace lang
132     {
133       class AbstractMethodError;
134       class ArithmeticException;
135       class ArrayIndexOutOfBoundsException;
136       class ArrayStoreException;
137       class AssertionError;
138       class Boolean;
139       class Byte;
140       class CharSequence;
141       class Character;
142       class Character$Subset;
143       class Character$UnicodeBlock;
144       class Class;
145       class ClassCastException;
146       class ClassCircularityError;
147       class ClassFormatError;
148       class ClassLoader;
149       class ClassNotFoundException;
150       class CloneNotSupportedException;
151       class Cloneable;
152       class Comparable;
153       class Compiler;
154       class ConcreteProcess;
155       class ConcreteProcess$EOFInputStream;
156       class ConcreteProcess$ProcessManager;
157       class Double;
158       class Error;
159       class Exception;
160       class ExceptionInInitializerError;
161       class Float;
162       class IllegalAccessError;
163       class IllegalAccessException;
164       class IllegalArgumentException;
165       class IllegalMonitorStateException;
166       class IllegalStateException;
167       class IllegalThreadStateException;
168       class IncompatibleClassChangeError;
169       class IndexOutOfBoundsException;
170       class InheritableThreadLocal;
171       class InstantiationError;
172       class InstantiationException;
173       class Integer;
174       class InternalError;
175       class InterruptedException;
176       class LinkageError;
177       class Long;
178       class Math;
179       class NegativeArraySizeException;
180       class NoClassDefFoundError;
181       class NoSuchFieldError;
182       class NoSuchFieldException;
183       class NoSuchMethodError;
184       class NoSuchMethodException;
185       class NullPointerException;
186       class Number;
187       class NumberFormatException;
188       class Object;
189       class OutOfMemoryError;
190       class Package;
191       class Process;
192       class Runnable;
193       class Runtime;
194       class RuntimeException;
195       class RuntimePermission;
196       class SecurityContext;
197       class SecurityException;
198       class SecurityManager;
199       class Short;
200       class StackOverflowError;
201       class StackTraceElement;
202       class StrictMath;
203       class String;
204       class String$CaseInsensitiveComparator;
205       class StringBuffer;
206       class StringBuilder;
207       class StringIndexOutOfBoundsException;
208       class System;
209       class Thread;
210       class ThreadDeath;
211       class ThreadGroup;
212       class ThreadLocal;
213       class Throwable;
214       class Throwable$StaticData;
215       class UnknownError;
216       class UnsatisfiedLinkError;
217       class UnsupportedClassVersionError;
218       class UnsupportedOperationException;
219       class VMClassLoader;
220       class VMCompiler;
221       class VMSecurityManager;
222       class VMThrowable;
223       class VerifyError;
224       class VirtualMachineError;
225       class Void;
226       namespace ref
227       {
228         class PhantomReference;
229         class Reference;
230         class ReferenceQueue;
231         class SoftReference;
232         class WeakReference;
233       }
234
235       namespace reflect
236       {
237         class AccessibleObject;
238         class Array;
239         class Constructor;
240         class Field;
241         class InvocationHandler;
242         class InvocationTargetException;
243         class Member;
244         class Method;
245         class Modifier;
246         class Proxy;
247         class Proxy$ClassFactory;
248         class Proxy$ProxyData;
249         class Proxy$ProxySignature;
250         class Proxy$ProxyType;
251         class ReflectPermission;
252         class UndeclaredThrowableException;
253       }
254     }
255
256     namespace util
257     {
258       class AbstractCollection;
259       class AbstractList;
260       class AbstractList$RandomAccessSubList;
261       class AbstractList$SubList;
262       class AbstractMap;
263       class AbstractMap$BasicMapEntry;
264       class AbstractSequentialList;
265       class AbstractSet;
266       class ArrayList;
267       class Arrays;
268       class Arrays$ArrayList;
269       class BitSet;
270       class Calendar;
271       class Collection;
272       class Collections;
273       class Collections$CopiesList;
274       class Collections$EmptyList;
275       class Collections$EmptyMap;
276       class Collections$EmptySet;
277       class Collections$ReverseComparator;
278       class Collections$SingletonList;
279       class Collections$SingletonMap;
280       class Collections$SingletonSet;
281       class Collections$SynchronizedCollection;
282       class Collections$SynchronizedIterator;
283       class Collections$SynchronizedList;
284       class Collections$SynchronizedListIterator;
285       class Collections$SynchronizedMap;
286       class Collections$SynchronizedMapEntry;
287       class Collections$SynchronizedRandomAccessList;
288       class Collections$SynchronizedSet;
289       class Collections$SynchronizedSortedMap;
290       class Collections$SynchronizedSortedSet;
291       class Collections$UnmodifiableCollection;
292       class Collections$UnmodifiableEntrySet;
293       class Collections$UnmodifiableIterator;
294       class Collections$UnmodifiableList;
295       class Collections$UnmodifiableListIterator;
296       class Collections$UnmodifiableMap;
297       class Collections$UnmodifiableRandomAccessList;
298       class Collections$UnmodifiableSet;
299       class Collections$UnmodifiableSortedMap;
300       class Collections$UnmodifiableSortedSet;
301       class Comparator;
302       class ConcurrentModificationException;
303       class Currency;
304       class Date;
305       class Dictionary;
306       class EmptyStackException;
307       class Enumeration;
308       class EventListener;
309       class EventListenerProxy;
310       class EventObject;
311       class GregorianCalendar;
312       class HashMap;
313       class HashMap$HashEntry;
314       class HashMap$HashIterator;
315       class HashSet;
316       class Hashtable;
317       class Hashtable$Enumerator;
318       class Hashtable$HashEntry;
319       class Hashtable$HashIterator;
320       class IdentityHashMap;
321       class IdentityHashMap$IdentityEntry;
322       class IdentityHashMap$IdentityIterator;
323       class Iterator;
324       class LinkedHashMap;
325       class LinkedHashMap$LinkedHashEntry;
326       class LinkedHashSet;
327       class LinkedList;
328       class LinkedList$Entry;
329       class LinkedList$LinkedListItr;
330       class List;
331       class ListIterator;
332       class ListResourceBundle;
333       class Locale;
334       class Map;
335       class Map$Entry;
336       class Map$Map;
337       class MissingResourceException;
338       class MyResources;
339       class NoSuchElementException;
340       class Observable;
341       class Observer;
342       class Properties;
343       class PropertyPermission;
344       class PropertyPermissionCollection;
345       class PropertyResourceBundle;
346       class Random;
347       class RandomAccess;
348       class ResourceBundle;
349       class ResourceBundle$BundleKey;
350       class Set;
351       class SimpleTimeZone;
352       class SortedMap;
353       class SortedSet;
354       class Stack;
355       class StringTokenizer;
356       class TimeZone;
357       class Timer;
358       class Timer$Scheduler;
359       class Timer$TaskQueue;
360       class TimerTask;
361       class TooManyListenersException;
362       class TreeMap;
363       class TreeMap$Node;
364       class TreeMap$SubMap;
365       class TreeMap$TreeIterator;
366       class TreeSet;
367       class VMTimeZone;
368       class Vector;
369       class WeakHashMap;
370       class WeakHashMap$WeakBucket;
371       class WeakHashMap$WeakEntry;
372       class WeakHashMap$WeakEntrySet;
373       namespace jar
374       {
375         class Attributes;
376         class Attributes$Name;
377         class JarEntry;
378         class JarException;
379         class JarFile;
380         class JarFile$EntryInputStream;
381         class JarFile$JarEnumeration;
382         class JarInputStream;
383         class JarOutputStream;
384         class Manifest;
385       }
386
387       namespace logging
388       {
389         class ConsoleHandler;
390         class ErrorManager;
391         class FileHandler;
392         class Filter;
393         class Formatter;
394         class Handler;
395         class Level;
396         class LogManager;
397         class LogRecord;
398         class Logger;
399         class LoggingPermission;
400         class MemoryHandler;
401         class SimpleFormatter;
402         class SocketHandler;
403         class StreamHandler;
404         class XMLFormatter;
405       }
406
407       namespace prefs
408       {
409         class AbstractPreferences;
410         class BackingStoreException;
411         class InvalidPreferencesFormatException;
412         class NodeChangeEvent;
413         class NodeChangeListener;
414         class PreferenceChangeEvent;
415         class PreferenceChangeListener;
416         class Preferences;
417         class PreferencesFactory;
418       }
419
420       namespace regex
421       {
422         class Matcher;
423         class Pattern;
424         class PatternSyntaxException;
425       }
426
427       namespace zip
428       {
429         class Adler32;
430         class CRC32;
431         class CheckedInputStream;
432         class CheckedOutputStream;
433         class Checksum;
434         class DataFormatException;
435         class Deflater;
436         class DeflaterOutputStream;
437         class GZIPInputStream;
438         class GZIPOutputStream;
439         class Inflater;
440         class InflaterInputStream;
441         class ZipConstants;
442         class ZipEntry;
443         class ZipException;
444         class ZipFile;
445         class ZipFile$PartialInputStream;
446         class ZipFile$ZipEntryEnumeration;
447         class ZipInputStream;
448         class ZipOutputStream;
449       }
450     }
451   }
452 }
453   
454 typedef struct java::lang::Object* jobject;
455 typedef class java::lang::Class* jclass;
456 typedef class java::lang::Throwable* jthrowable;
457 typedef class java::lang::String* jstring;
458 struct _Jv_JNIEnv;
459
460 typedef struct _Jv_Field *jfieldID;
461 typedef struct _Jv_Method *jmethodID;
462
463 extern "C" jobject _Jv_AllocObject (jclass) __attribute__((__malloc__));
464 extern "C" jobject _Jv_AllocObjectNoFinalizer (jclass) __attribute__((__malloc__));
465 extern "C" jobject _Jv_AllocObjectNoInitNoFinalizer (jclass) __attribute__((__malloc__));
466 #ifdef JV_HASH_SYNCHRONIZATION
467   extern "C" jobject _Jv_AllocPtrFreeObject (jclass)
468                             __attribute__((__malloc__));
469 #else
470   // Collector still needs to scan sync_info
471   static inline jobject _Jv_AllocPtrFreeObject (jclass klass)
472   {
473     return _Jv_AllocObject(klass);
474   }
475 #endif
476 extern "C" jboolean _Jv_IsInstanceOf(jobject, jclass);
477 extern "C" jstring _Jv_AllocString(jsize) __attribute__((__malloc__));
478 extern "C" jstring _Jv_NewString (const jchar*, jsize)
479   __attribute__((__malloc__));
480 extern jint _Jv_FormatInt (jchar* bufend, jint num);
481 extern "C" jchar* _Jv_GetStringChars (jstring str);
482 extern "C" void _Jv_MonitorEnter (jobject);
483 extern "C" void _Jv_MonitorExit (jobject);
484 extern "C" jstring _Jv_NewStringUTF (const char *bytes)
485   __attribute__((__malloc__));
486 extern "C" jstring _Jv_NewStringLatin1(const char*, jsize)
487   __attribute__((__malloc__));
488 extern "C" jsize _Jv_GetStringUTFLength (jstring);
489 extern "C" jsize _Jv_GetStringUTFRegion (jstring, jsize, jsize, char *);
490 extern "C" jint _Jv_hashUtf8String (char*, int);
491
492 struct _Jv_VMOption
493 {
494   // a VM initialization option
495   char* optionString;
496   // extra information associated with this option
497   void* extraInfo;
498 };
499
500 struct _Jv_VMInitArgs
501 {
502   // for compatibility with JavaVMInitArgs
503   jint version;
504
505   // number of VM initialization options
506   jint nOptions;
507
508   // an array of VM initialization options
509   struct _Jv_VMOption* options;
510
511   // true if the option parser should ignore unrecognized options
512   jboolean ignoreUnrecognized;
513 };
514
515 extern jint _Jv_CreateJavaVM (struct _Jv_VMInitArgs*);
516
517 void
518 _Jv_ThreadRun (java::lang::Thread* thread);
519 jint
520 _Jv_AttachCurrentThread(java::lang::Thread* thread);
521 extern "C" java::lang::Thread*
522 _Jv_AttachCurrentThread(jstring name, java::lang::ThreadGroup* group);
523 extern "C" java::lang::Thread*
524 _Jv_AttachCurrentThreadAsDaemon(jstring name, java::lang::ThreadGroup* group);
525 extern "C" jint _Jv_DetachCurrentThread (void);
526
527 extern "C" void _Jv_Throw (jthrowable) __attribute__ ((__noreturn__));
528 extern "C" void* _Jv_Malloc (jsize) __attribute__((__malloc__));
529 extern "C" void* _Jv_Realloc (void *, jsize);
530 extern "C" void _Jv_Free (void*);
531 extern void (*_Jv_RegisterClassHook) (jclass cl);
532 extern "C" void _Jv_RegisterClassHookDefault (jclass);
533
534 typedef unsigned short _Jv_ushort __attribute__((__mode__(__HI__)));
535 typedef unsigned int _Jv_uint __attribute__((__mode__(__SI__)));
536 typedef unsigned int _Jv_ulong __attribute__((__mode__(__DI__)));
537
538 class _Jv_Utf8Const
539 {
540   _Jv_ushort hash;
541   _Jv_ushort length;    /* In bytes, of data portion, without final '\0'. */
542   char data[1];         /* In Utf8 format, with final '\0'. */
543  public:
544   /** Return same value of java.lang.String's hashCode. */
545   jint hash32() { return _Jv_hashUtf8String(data, length); }
546   /** Return a hash code that has at least 16 bits of information. */
547   _Jv_ushort hash16 () { return hash; }
548   /** Return a hash code that has at least 8 bits of information. */
549   _Jv_ushort hash8 () { return hash; }
550   /** Length in bytes of the UTF8-encoding. */
551   _Jv_ushort len () const { return length; }
552   /** Pointer to the first byte in the NUL-terminated UTF8-encoding. */
553   char* chars() { return data; }
554   /** Pointer to the NUL byte that terminated the UTF8-encoding. */
555   char* limit() { return data+length; }
556   /** Return the first byte in the UTF8-encoding. */
557   char first() const { return data[0]; }
558   /** Create a (non-interned) java.lang.String from this UTF8Const. */
559   jstring toString() { return _Jv_NewStringUTF(data); }
560   /** Given an UTF8 string, how many bytes needed for a UTF8Const,
561       including struct header, and final NUL.  I.e. what to pas to malloc. */
562   static int space_needed (char *, int len)
563   { return sizeof (_Jv_Utf8Const) + len + 1; }
564   /** Given an allocated _Jv_Utf8Const, copy / fill it in. */
565   void init (char *s, int len);
566   friend jboolean _Jv_equalUtf8Consts (const _Jv_Utf8Const*, const _Jv_Utf8Const *);
567   friend jboolean _Jv_equal (_Jv_Utf8Const*, jstring, jint);
568   friend jboolean _Jv_equaln (_Jv_Utf8Const*, jstring, jint);
569   friend _Jv_Utf8Const *_Jv_makeUtf8Const (char*, int);
570   friend _Jv_Utf8Const *_Jv_makeUtf8Const (jstring);
571   friend jstring _Jv_NewStringUtf8Const (_Jv_Utf8Const*);
572 };
573
574
575 #endif /* __JAVAPRIMS_H__ */