From df1f11433357c40c4ccbbcea5fa119a441f14ca6 Mon Sep 17 00:00:00 2001 From: green Date: Thu, 6 Sep 2001 22:32:54 +0000 Subject: * include/jvm.h: Declare _Jv_RegisterResource. * gnu/gcj/Core.java, gnu/gcj/natCore.cc, gnu/gcj/protocol/core/Connection.java, gnu/gcj/protocol/core/Handler.java, gnu/gcj/protocol/core/CoreInputStream.java, gnu/gcj/protocol/core/natCoreInputStream.cc: New files. * java/net/URL.java (setURLStreamHandler): Use gnu.gcj.protocol.core.Handler for the core protocol. * gnu/gcj/runtime/VMClassLoader.java (init): Add "core:/" to the end of java.class.path. * Makefile.am (ordinary_java_source_files): Add new java files. (nat_source_files): Add new native code files. * Makefile.in: Rebuilt. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@45450 138bc75d-0d04-0410-961f-82ee72b054a4 --- libjava/gnu/gcj/natCore.cc | 82 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 libjava/gnu/gcj/natCore.cc (limited to 'libjava/gnu/gcj/natCore.cc') diff --git a/libjava/gnu/gcj/natCore.cc b/libjava/gnu/gcj/natCore.cc new file mode 100644 index 00000000000..8e7a0240527 --- /dev/null +++ b/libjava/gnu/gcj/natCore.cc @@ -0,0 +1,82 @@ +// natCore -- C++ side of Core + +/* Copyright (C) 2001 Free Software Foundation + + This file is part of libgcj. + +This software is copyrighted work licensed under the terms of the +Libgcj License. Please consult the file "LIBGCJ_LICENSE" for +details. */ + +/* Author: Anthony Green . */ + +#include + +#include +#include +#include +#include + +#include +#include +#include + +typedef struct core_chain_struct +{ + int name_length; + const char *name; + int data_length; + const void *data; + + struct core_chain_struct *next; +} core_chain; + +static core_chain *root; + +void _Jv_RegisterResource (void *vptr) +{ + char *rptr = (char *)vptr; + + // These are permanent data structures for now. This routine is + // called from a static constructor, so we shouldn't depend on too + // much existing infrastructure. + core_chain *cc = (core_chain *) malloc (sizeof (core_chain)); + + cc->name_length = ((int *)rptr)[0]; + cc->data_length = ((int *)rptr)[1]; + cc->name = rptr + 2*sizeof(int); + cc->data = cc->name + cc->name_length; + + // Add this new item to the chain... + core_chain *old_root = root; + cc->next = old_root; + root = cc; +} + +gnu::gcj::Core * +gnu::gcj::Core::create (jstring name) +{ + char buf[name->length() + 1]; + jsize total = JvGetStringUTFRegion (name, 0, name->length(), buf); + buf[total] = '\0'; + + core_chain *node = root; + + while (node) + { + if (total == node->name_length + && strncmp (buf, node->name, total) == 0) + { + gnu::gcj::Core *core = + (gnu::gcj::Core *) _Jv_AllocObject(&gnu::gcj::Core::class$, + sizeof (gnu::gcj::Core)); + core->ptr = (gnu::gcj::RawData *) node->data; + core->length = node->data_length; + return core; + } + else + node = node->next; + } + + throw new java::io::IOException (JvNewStringLatin1 ("can't open core")); +} -- cgit v1.2.3