diff options
| author | green <green@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-09-06 22:32:54 +0000 |
|---|---|---|
| committer | green <green@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-09-06 22:32:54 +0000 |
| commit | df1f11433357c40c4ccbbcea5fa119a441f14ca6 (patch) | |
| tree | ce727c113b87b1cdaa86ced6af1018bb91186e15 /libjava/gnu/gcj/natCore.cc | |
| parent | 862c1e2e1e04da36385052f1857661456657ad0d (diff) | |
| download | ppe42-gcc-df1f11433357c40c4ccbbcea5fa119a441f14ca6.tar.gz ppe42-gcc-df1f11433357c40c4ccbbcea5fa119a441f14ca6.zip | |
* 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
Diffstat (limited to 'libjava/gnu/gcj/natCore.cc')
| -rw-r--r-- | libjava/gnu/gcj/natCore.cc | 82 |
1 files changed, 82 insertions, 0 deletions
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 <green@redhat.com>. */ + +#include <config.h> + +#include <gcj/cni.h> +#include <jvm.h> +#include <string.h> +#include <stdlib.h> + +#include <java/lang/NullPointerException.h> +#include <java/io/IOException.h> +#include <gnu/gcj/Core.h> + +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")); +} |

