2705
2706 ATTRIBUTE_PRINTF(2, 0)
2707 int jio_vfprintf(FILE* f, const char *fmt, va_list args) {
2708 if (Arguments::vfprintf_hook() != NULL) {
2709 return Arguments::vfprintf_hook()(f, fmt, args);
2710 } else {
2711 return vfprintf(f, fmt, args);
2712 }
2713 }
2714
2715 ATTRIBUTE_PRINTF(1, 2)
2716 JNIEXPORT int jio_printf(const char *fmt, ...) {
2717 int len;
2718 va_list args;
2719 va_start(args, fmt);
2720 len = jio_vfprintf(defaultStream::output_stream(), fmt, args);
2721 va_end(args);
2722 return len;
2723 }
2724
2725
2726 // HotSpot specific jio method
2727 void jio_print(const char* s) {
2728 // Try to make this function as atomic as possible.
2729 if (Arguments::vfprintf_hook() != NULL) {
2730 jio_fprintf(defaultStream::output_stream(), "%s", s);
2731 } else {
2732 // Make an unused local variable to avoid warning from gcc 4.x compiler.
2733 size_t count = ::write(defaultStream::output_fd(), s, (int)strlen(s));
2734 }
2735 }
2736
2737 } // Extern C
2738
2739 // java.lang.Thread //////////////////////////////////////////////////////////////////////////////
2740
2741 // In most of the JVM thread support functions we need to access the
2742 // thread through a ThreadsListHandle to prevent it from exiting and
2743 // being reclaimed while we try to operate on it. The exceptions to this
2744 // rule are when operating on the current thread, or if the monitor of
2745 // the target java.lang.Thread is locked at the Java level - in both
2746 // cases the target cannot exit.
2747
2748 static void thread_entry(JavaThread* thread, TRAPS) {
2749 HandleMark hm(THREAD);
2750 Handle obj(THREAD, thread->threadObj());
2751 JavaValue result(T_VOID);
2752 JavaCalls::call_virtual(&result,
2753 obj,
|
2705
2706 ATTRIBUTE_PRINTF(2, 0)
2707 int jio_vfprintf(FILE* f, const char *fmt, va_list args) {
2708 if (Arguments::vfprintf_hook() != NULL) {
2709 return Arguments::vfprintf_hook()(f, fmt, args);
2710 } else {
2711 return vfprintf(f, fmt, args);
2712 }
2713 }
2714
2715 ATTRIBUTE_PRINTF(1, 2)
2716 JNIEXPORT int jio_printf(const char *fmt, ...) {
2717 int len;
2718 va_list args;
2719 va_start(args, fmt);
2720 len = jio_vfprintf(defaultStream::output_stream(), fmt, args);
2721 va_end(args);
2722 return len;
2723 }
2724
2725 // HotSpot specific jio method
2726 void jio_print(const char* s, size_t len) {
2727 // Try to make this function as atomic as possible.
2728 if (Arguments::vfprintf_hook() != NULL) {
2729 jio_fprintf(defaultStream::output_stream(), "%.*s", len, s);
2730 } else {
2731 // Make an unused local variable to avoid warning from gcc 4.x compiler.
2732 size_t count = ::write(defaultStream::output_fd(), s, (int)len);
2733 }
2734 }
2735
2736 } // Extern C
2737
2738 // java.lang.Thread //////////////////////////////////////////////////////////////////////////////
2739
2740 // In most of the JVM thread support functions we need to access the
2741 // thread through a ThreadsListHandle to prevent it from exiting and
2742 // being reclaimed while we try to operate on it. The exceptions to this
2743 // rule are when operating on the current thread, or if the monitor of
2744 // the target java.lang.Thread is locked at the Java level - in both
2745 // cases the target cannot exit.
2746
2747 static void thread_entry(JavaThread* thread, TRAPS) {
2748 HandleMark hm(THREAD);
2749 Handle obj(THREAD, thread->threadObj());
2750 JavaValue result(T_VOID);
2751 JavaCalls::call_virtual(&result,
2752 obj,
|