src/os/windows/vm/jvm_windows.cpp

changeset 435
a61af66fc99e
child 1907
c18cbe5936b8
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/os/windows/vm/jvm_windows.cpp	Sat Dec 01 00:00:00 2007 +0000
     1.3 @@ -0,0 +1,125 @@
     1.4 +/*
     1.5 + * Copyright 1998-2007 Sun Microsystems, Inc.  All Rights Reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
    1.24 + * have any questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +#include "incls/_precompiled.incl"
    1.29 +#include "incls/_jvm_windows.cpp.incl"
    1.30 +
    1.31 +#include <signal.h>
    1.32 +
    1.33 +JVM_LEAF(void*, JVM_GetThreadInterruptEvent())
    1.34 +  return Thread::current()->osthread()->interrupt_event();
    1.35 +JVM_END
    1.36 +
    1.37 +// sun.misc.Signal ///////////////////////////////////////////////////////////
    1.38 +// Signal code is mostly copied from classic vm, signals_md.c   1.4 98/08/23
    1.39 +/*
    1.40 + * This function is included primarily as a debugging aid. If Java is
    1.41 + * running in a console window, then pressing <CTRL-BREAK> will cause
    1.42 + * the current state of all active threads and monitors to be written
    1.43 + * to the console window.
    1.44 + */
    1.45 +
    1.46 +JVM_ENTRY_NO_ENV(void*, JVM_RegisterSignal(jint sig, void* handler))
    1.47 +  // Copied from classic vm
    1.48 +  // signals_md.c       1.4 98/08/23
    1.49 +  void* newHandler = handler == (void *)2
    1.50 +                   ? os::user_handler()
    1.51 +                   : handler;
    1.52 +  switch (sig) {
    1.53 +   case SIGFPE:
    1.54 +     return (void *)-1; /* already used by VM */
    1.55 +   case SIGBREAK:
    1.56 +     if (!ReduceSignalUsage) return (void *)-1;
    1.57 +
    1.58 +    /* The following signals are used for Shutdown Hooks support. However, if
    1.59 +       ReduceSignalUsage (-Xrs) is set, Shutdown Hooks must be invoked via
    1.60 +       System.exit(), Java is not allowed to use these signals, and the the
    1.61 +       user is allowed to set his own _native_ handler for these signals and
    1.62 +       invoke System.exit() as needed. Terminator.setup() is avoiding
    1.63 +       registration of these signals when -Xrs is present. */
    1.64 +   case SHUTDOWN1_SIGNAL:
    1.65 +   case SHUTDOWN2_SIGNAL:
    1.66 +     if (ReduceSignalUsage) return (void*)-1;
    1.67 +  }
    1.68 +
    1.69 +  void* oldHandler = os::signal(sig, newHandler);
    1.70 +  if (oldHandler == os::user_handler()) {
    1.71 +      return (void *)2;
    1.72 +  } else {
    1.73 +      return oldHandler;
    1.74 +  }
    1.75 +JVM_END
    1.76 +
    1.77 +
    1.78 +JVM_ENTRY_NO_ENV(jboolean, JVM_RaiseSignal(jint sig))
    1.79 +  if (ReduceSignalUsage) {
    1.80 +    // do not allow SHUTDOWN1_SIGNAL,SHUTDOWN2_SIGNAL,BREAK_SIGNAL
    1.81 +    // to be raised when ReduceSignalUsage is set, since no handler
    1.82 +    // for them is actually registered in JVM or via JVM_RegisterSignal.
    1.83 +    if (sig == SHUTDOWN1_SIGNAL || sig == SHUTDOWN2_SIGNAL ||
    1.84 +        sig == SIGBREAK) {
    1.85 +      return JNI_FALSE;
    1.86 +    }
    1.87 +  }
    1.88 +  os::signal_raise(sig);
    1.89 +  return JNI_TRUE;
    1.90 +JVM_END
    1.91 +
    1.92 +
    1.93 +/*
    1.94 +  All the defined signal names for Windows.
    1.95 +
    1.96 +  NOTE that not all of these names are accepted by FindSignal!
    1.97 +
    1.98 +  For various reasons some of these may be rejected at runtime.
    1.99 +
   1.100 +  Here are the names currently accepted by a user of sun.misc.Signal with
   1.101 +  1.4.1 (ignoring potential interaction with use of chaining, etc):
   1.102 +
   1.103 +     (LIST TBD)
   1.104 +
   1.105 +*/
   1.106 +struct siglabel {
   1.107 +  char *name;
   1.108 +  int   number;
   1.109 +};
   1.110 +
   1.111 +struct siglabel siglabels[] =
   1.112 +  /* derived from version 6.0 VC98/include/signal.h */
   1.113 +  {"ABRT",      SIGABRT,        /* abnormal termination triggered by abort cl */
   1.114 +  "FPE",        SIGFPE,         /* floating point exception */
   1.115 +  "SEGV",       SIGSEGV,        /* segment violation */
   1.116 +  "INT",        SIGINT,         /* interrupt */
   1.117 +  "TERM",       SIGTERM,        /* software term signal from kill */
   1.118 +  "BREAK",      SIGBREAK,       /* Ctrl-Break sequence */
   1.119 +  "ILL",        SIGILL};        /* illegal instruction */
   1.120 +
   1.121 +JVM_ENTRY_NO_ENV(jint, JVM_FindSignal(const char *name))
   1.122 +  /* find and return the named signal's number */
   1.123 +
   1.124 +  for(int i=0;i<sizeof(siglabels)/sizeof(struct siglabel);i++)
   1.125 +    if(!strcmp(name, siglabels[i].name))
   1.126 +      return siglabels[i].number;
   1.127 +  return -1;
   1.128 +JVM_END

mercurial