1 /*
2 * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
868 void SplashFreeLibrary() {
869 if (hSplashLib) {
870 dlclose(hSplashLib);
871 hSplashLib = NULL;
872 }
873 }
874
875 /*
876 * Block current thread and continue execution in a new thread
877 */
878 int
879 ContinueInNewThread0(int (JNICALL *continuation)(void *), jlong stack_size, void * args) {
880 int rslt;
881 pthread_t tid;
882 pthread_attr_t attr;
883 pthread_attr_init(&attr);
884 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
885
886 if (stack_size > 0) {
887 pthread_attr_setstacksize(&attr, stack_size);
888 }
889
890 if (pthread_create(&tid, &attr, (void *(*)(void*))continuation, (void*)args) == 0) {
891 void * tmp;
892 pthread_join(tid, &tmp);
893 rslt = (int)(intptr_t)tmp;
894 } else {
895 /*
896 * Continue execution in current thread if for some reason (e.g. out of
897 * memory/LWP) a new thread can't be created. This will likely fail
898 * later in continuation as JNI_CreateJavaVM needs to create quite a
899 * few new threads, anyway, just give it a try..
900 */
901 rslt = continuation(args);
902 }
903
904 pthread_attr_destroy(&attr);
905 return rslt;
906 }
907
| 1 /*
2 * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
868 void SplashFreeLibrary() {
869 if (hSplashLib) {
870 dlclose(hSplashLib);
871 hSplashLib = NULL;
872 }
873 }
874
875 /*
876 * Block current thread and continue execution in a new thread
877 */
878 int
879 ContinueInNewThread0(int (JNICALL *continuation)(void *), jlong stack_size, void * args) {
880 int rslt;
881 pthread_t tid;
882 pthread_attr_t attr;
883 pthread_attr_init(&attr);
884 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
885
886 if (stack_size > 0) {
887 pthread_attr_setstacksize(&attr, stack_size);
888 pthread_attr_setguardsize(&attr, 0); // no pthread guard page on java threads
889 }
890
891 if (pthread_create(&tid, &attr, (void *(*)(void*))continuation, (void*)args) == 0) {
892 void * tmp;
893 pthread_join(tid, &tmp);
894 rslt = (int)(intptr_t)tmp;
895 } else {
896 /*
897 * Continue execution in current thread if for some reason (e.g. out of
898 * memory/LWP) a new thread can't be created. This will likely fail
899 * later in continuation as JNI_CreateJavaVM needs to create quite a
900 * few new threads, anyway, just give it a try..
901 */
902 rslt = continuation(args);
903 }
904
905 pthread_attr_destroy(&attr);
906 return rslt;
907 }
908
|