jvm_windows.cpp revision 0
0N/A/*
0N/A * Copyright 1998-2007 Sun Microsystems, Inc. All Rights Reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
0N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
0N/A * CA 95054 USA or visit www.sun.com if you need additional information or
0N/A * have any questions.
0N/A *
0N/A */
0N/A
0N/A#include "incls/_precompiled.incl"
0N/A#include "incls/_jvm_windows.cpp.incl"
0N/A
0N/A#include <signal.h>
0N/A
0N/AJVM_LEAF(void*, JVM_GetThreadInterruptEvent())
0N/A return Thread::current()->osthread()->interrupt_event();
0N/AJVM_END
0N/A
0N/A// sun.misc.Signal ///////////////////////////////////////////////////////////
0N/A// Signal code is mostly copied from classic vm, signals_md.c 1.4 98/08/23
0N/A/*
0N/A * This function is included primarily as a debugging aid. If Java is
0N/A * running in a console window, then pressing <CTRL-BREAK> will cause
0N/A * the current state of all active threads and monitors to be written
0N/A * to the console window.
0N/A */
0N/A
0N/AJVM_ENTRY_NO_ENV(void*, JVM_RegisterSignal(jint sig, void* handler))
0N/A // Copied from classic vm
0N/A // signals_md.c 1.4 98/08/23
0N/A void* newHandler = handler == (void *)2
0N/A ? os::user_handler()
0N/A : handler;
0N/A switch (sig) {
0N/A case SIGFPE:
0N/A return (void *)-1; /* already used by VM */
0N/A case SIGBREAK:
0N/A if (!ReduceSignalUsage) return (void *)-1;
0N/A
0N/A /* The following signals are used for Shutdown Hooks support. However, if
0N/A ReduceSignalUsage (-Xrs) is set, Shutdown Hooks must be invoked via
0N/A System.exit(), Java is not allowed to use these signals, and the the
0N/A user is allowed to set his own _native_ handler for these signals and
0N/A invoke System.exit() as needed. Terminator.setup() is avoiding
0N/A registration of these signals when -Xrs is present. */
0N/A case SHUTDOWN1_SIGNAL:
0N/A case SHUTDOWN2_SIGNAL:
0N/A if (ReduceSignalUsage) return (void*)-1;
0N/A }
0N/A
0N/A void* oldHandler = os::signal(sig, newHandler);
0N/A if (oldHandler == os::user_handler()) {
0N/A return (void *)2;
0N/A } else {
0N/A return oldHandler;
0N/A }
0N/AJVM_END
0N/A
0N/A
0N/AJVM_ENTRY_NO_ENV(jboolean, JVM_RaiseSignal(jint sig))
0N/A if (ReduceSignalUsage) {
0N/A // do not allow SHUTDOWN1_SIGNAL,SHUTDOWN2_SIGNAL,BREAK_SIGNAL
0N/A // to be raised when ReduceSignalUsage is set, since no handler
0N/A // for them is actually registered in JVM or via JVM_RegisterSignal.
0N/A if (sig == SHUTDOWN1_SIGNAL || sig == SHUTDOWN2_SIGNAL ||
0N/A sig == SIGBREAK) {
0N/A return JNI_FALSE;
0N/A }
0N/A }
0N/A os::signal_raise(sig);
0N/A return JNI_TRUE;
0N/AJVM_END
0N/A
0N/A
0N/A/*
0N/A All the defined signal names for Windows.
0N/A
0N/A NOTE that not all of these names are accepted by FindSignal!
0N/A
0N/A For various reasons some of these may be rejected at runtime.
0N/A
0N/A Here are the names currently accepted by a user of sun.misc.Signal with
0N/A 1.4.1 (ignoring potential interaction with use of chaining, etc):
0N/A
0N/A (LIST TBD)
0N/A
0N/A*/
0N/Astruct siglabel {
0N/A char *name;
0N/A int number;
0N/A};
0N/A
0N/Astruct siglabel siglabels[] =
0N/A /* derived from version 6.0 VC98/include/signal.h */
0N/A {"ABRT", SIGABRT, /* abnormal termination triggered by abort cl */
0N/A "FPE", SIGFPE, /* floating point exception */
0N/A "SEGV", SIGSEGV, /* segment violation */
0N/A "INT", SIGINT, /* interrupt */
0N/A "TERM", SIGTERM, /* software term signal from kill */
0N/A "BREAK", SIGBREAK, /* Ctrl-Break sequence */
0N/A "ILL", SIGILL}; /* illegal instruction */
0N/A
0N/AJVM_ENTRY_NO_ENV(jint, JVM_FindSignal(const char *name))
0N/A /* find and return the named signal's number */
0N/A
0N/A for(int i=0;i<sizeof(siglabels)/sizeof(struct siglabel);i++)
0N/A if(!strcmp(name, siglabels[i].name))
0N/A return siglabels[i].number;
0N/A return -1;
0N/AJVM_END