1 // Copyright 2000-2005 the Contributors, as shown in the revision logs.
2 // Licensed under the GNU General Public License version 2 ("the License").
3 // You may not use this file except in compliance with the License.
7 import org.ibex.util.*;
9 import java.security.*;
10 import java.security.cert.*;
11 import org.ibex.graphics.*;
12 import org.ibex.core.*;
13 import org.ibex.net.*;
15 /** common superclass for all platforms that use GCJ to compile a native binary */
16 public abstract class GCJ extends Platform {
18 protected native InputStream _getBuiltinInputStream();
20 protected native void _decodeJPEG(InputStream is, Picture p);
22 // FEATURE: This could be optimized (a lot) by using a custom hashtable
23 public final static class Retainer {
24 private static Hash table = new Hash();
25 private final static class Key {
27 public Key(Object o) { this.o = o; }
28 public int hashCode() { return o == null ? 0 : o.hashCode(); }
29 public boolean equals(Object o2) { return (o2 instanceof Key) && ((Key)o2).o == o; }
31 private final static class Entry {
33 public Entry() { inc(); }
34 public void inc() { refCount++; }
35 public boolean dec() { return --refCount == 0; }
37 public static synchronized void retain(Object o) {
39 Entry r = (Entry) table.get(k);
40 if(r == null) table.put(k,new Entry());
43 public static synchronized void release(Object o) {
45 Entry e = (Entry) table.get(k);
46 if(e == null) throw new Error("Retainer::Release on unknown object");
47 if(e.dec()) { table.remove(k); }