src/java.base/solaris/native/libjsig/jsig.c
branchihse-remove-mapfiles-branch
changeset 56112 39286667d14e
parent 47765 b7c7428eaab9
child 56114 0d38468d211c
equal deleted inserted replaced
56111:71934e9574d7 56112:39286667d14e
     1 /*
     1 /*
     2  * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    35 #include <string.h>
    35 #include <string.h>
    36 #include <signal.h>
    36 #include <signal.h>
    37 #include <dlfcn.h>
    37 #include <dlfcn.h>
    38 #include <thread.h>
    38 #include <thread.h>
    39 #include <synch.h>
    39 #include <synch.h>
       
    40 #incldue "jni.h"
    40 #include "jvm_md.h"
    41 #include "jvm_md.h"
    41 
    42 
    42 #define bool int
    43 #define bool int
    43 #define true 1
    44 #define true 1
    44 #define false 0
    45 #define false 0
   174     signal_unlock();
   175     signal_unlock();
   175     return oldhandler;
   176     return oldhandler;
   176   }
   177   }
   177 }
   178 }
   178 
   179 
   179 sa_handler_t signal(int sig, sa_handler_t disp) {
   180 JNIEXPORT sa_handler_t signal(int sig, sa_handler_t disp) {
   180   return set_signal(sig, disp, false);
   181   return set_signal(sig, disp, false);
   181 }
   182 }
   182 
   183 
   183 sa_handler_t sigset(int sig, sa_handler_t disp) {
   184 JNIEXPORT sa_handler_t sigset(int sig, sa_handler_t disp) {
   184   return set_signal(sig, disp, true);
   185   return set_signal(sig, disp, true);
   185 }
   186 }
   186 
   187 
   187 static int call_os_sigaction(int sig, const struct sigaction  *act,
   188 static int call_os_sigaction(int sig, const struct sigaction  *act,
   188                              struct sigaction *oact) {
   189                              struct sigaction *oact) {
   194     }
   195     }
   195   }
   196   }
   196   return (*os_sigaction)(sig, act, oact);
   197   return (*os_sigaction)(sig, act, oact);
   197 }
   198 }
   198 
   199 
   199 int sigaction(int sig, const struct sigaction *act, struct sigaction *oact) {
   200 JNIEXPORT int sigaction(int sig, const struct sigaction *act, struct sigaction *oact) {
   200   int res;
   201   int res;
   201   struct sigaction oldAct;
   202   struct sigaction oldAct;
   202 
   203 
   203   signal_lock();
   204   signal_lock();
   204 
   205 
   240     return res;
   241     return res;
   241   }
   242   }
   242 }
   243 }
   243 
   244 
   244 /* The four functions for the jvm to call into */
   245 /* The four functions for the jvm to call into */
   245 void JVM_begin_signal_setting() {
   246 JNIEXPORT void JVM_begin_signal_setting() {
   246   signal_lock();
   247   signal_lock();
   247   jvm_signal_installing = true;
   248   jvm_signal_installing = true;
   248   tid = thr_self();
   249   tid = thr_self();
   249   signal_unlock();
   250   signal_unlock();
   250 }
   251 }
   251 
   252 
   252 void JVM_end_signal_setting() {
   253 JNIEXPORT void JVM_end_signal_setting() {
   253   signal_lock();
   254   signal_lock();
   254   jvm_signal_installed = true;
   255   jvm_signal_installed = true;
   255   jvm_signal_installing = false;
   256   jvm_signal_installing = false;
   256   cond_broadcast(&cond);
   257   cond_broadcast(&cond);
   257   signal_unlock();
   258   signal_unlock();
   258 }
   259 }
   259 
   260 
   260 struct sigaction *JVM_get_signal_action(int sig) {
   261 JNIEXPORT struct sigaction *JVM_get_signal_action(int sig) {
   261   if (sact == NULL) {
   262   if (sact == NULL) {
   262     allocate_sact();
   263     allocate_sact();
   263   }
   264   }
   264   /* Does race condition make sense here? */
   265   /* Does race condition make sense here? */
   265   if (sigismember(&jvmsigs, sig)) {
   266   if (sigismember(&jvmsigs, sig)) {
   266     return &sact[sig];
   267     return &sact[sig];
   267   }
   268   }
   268   return NULL;
   269   return NULL;
   269 }
   270 }
   270 
   271 
   271 int JVM_get_libjsig_version() {
   272 JNIEXPORT int JVM_get_libjsig_version() {
   272   return JSIG_VERSION_1_4_1;
   273   return JSIG_VERSION_1_4_1;
   273 }
   274 }