src/hotspot/share/prims/jvm.cpp
branchihse-cflags-rewrite-branch
changeset 56312 a52bcf4118eb
parent 56221 bdf8f77aad3a
parent 49192 6734eeef4283
child 56726 3a9b7a1f9197
equal deleted inserted replaced
56285:9bc8db601fe2 56312:a52bcf4118eb
    59 #include "runtime/init.hpp"
    59 #include "runtime/init.hpp"
    60 #include "runtime/interfaceSupport.hpp"
    60 #include "runtime/interfaceSupport.hpp"
    61 #include "runtime/java.hpp"
    61 #include "runtime/java.hpp"
    62 #include "runtime/javaCalls.hpp"
    62 #include "runtime/javaCalls.hpp"
    63 #include "runtime/jfieldIDWorkaround.hpp"
    63 #include "runtime/jfieldIDWorkaround.hpp"
       
    64 #include "runtime/jniHandles.inline.hpp"
    64 #include "runtime/orderAccess.inline.hpp"
    65 #include "runtime/orderAccess.inline.hpp"
    65 #include "runtime/os.inline.hpp"
    66 #include "runtime/os.inline.hpp"
    66 #include "runtime/perfData.hpp"
    67 #include "runtime/perfData.hpp"
    67 #include "runtime/reflection.hpp"
    68 #include "runtime/reflection.hpp"
    68 #include "runtime/thread.inline.hpp"
    69 #include "runtime/thread.inline.hpp"
   431 
   432 
   432 
   433 
   433 // java.lang.Runtime /////////////////////////////////////////////////////////////////////////
   434 // java.lang.Runtime /////////////////////////////////////////////////////////////////////////
   434 
   435 
   435 extern volatile jint vm_created;
   436 extern volatile jint vm_created;
       
   437 
       
   438 JVM_ENTRY_NO_ENV(void, JVM_BeforeHalt())
       
   439   JVMWrapper("JVM_BeforeHalt");
       
   440   EventShutdown event;
       
   441   if (event.should_commit()) {
       
   442     event.set_reason("Shutdown requested from Java");
       
   443     event.commit();
       
   444   }
       
   445 JVM_END
       
   446 
   436 
   447 
   437 JVM_ENTRY_NO_ENV(void, JVM_Halt(jint code))
   448 JVM_ENTRY_NO_ENV(void, JVM_Halt(jint code))
   438   before_exit(thread);
   449   before_exit(thread);
   439   vm_exit(code);
   450   vm_exit(code);
   440 JVM_END
   451 JVM_END
  2658 // Printing support //////////////////////////////////////////////////
  2669 // Printing support //////////////////////////////////////////////////
  2659 extern "C" {
  2670 extern "C" {
  2660 
  2671 
  2661 ATTRIBUTE_PRINTF(3, 0)
  2672 ATTRIBUTE_PRINTF(3, 0)
  2662 int jio_vsnprintf(char *str, size_t count, const char *fmt, va_list args) {
  2673 int jio_vsnprintf(char *str, size_t count, const char *fmt, va_list args) {
  2663   // see bug 4399518, 4417214
  2674   // Reject count values that are negative signed values converted to
       
  2675   // unsigned; see bug 4399518, 4417214
  2664   if ((intptr_t)count <= 0) return -1;
  2676   if ((intptr_t)count <= 0) return -1;
  2665 
  2677 
  2666   int result = vsnprintf(str, count, fmt, args);
  2678   int result = os::vsnprintf(str, count, fmt, args);
  2667   // Note: on truncation vsnprintf(3) on Unix returns numbers of
  2679   if (result > 0 && (size_t)result >= count) {
  2668   // characters which would have been written had the buffer been large
       
  2669   // enough; on Windows, it returns -1. We handle both cases here and
       
  2670   // always return -1, and perform null termination.
       
  2671   if ((result > 0 && (size_t)result >= count) || result == -1) {
       
  2672     str[count - 1] = '\0';
       
  2673     result = -1;
  2680     result = -1;
  2674   }
  2681   }
  2675 
  2682 
  2676   return result;
  2683   return result;
  2677 }
  2684 }
  2678 
  2685 
  2679 ATTRIBUTE_PRINTF(3, 0)
  2686 ATTRIBUTE_PRINTF(3, 4)
  2680 int jio_snprintf(char *str, size_t count, const char *fmt, ...) {
  2687 int jio_snprintf(char *str, size_t count, const char *fmt, ...) {
  2681   va_list args;
  2688   va_list args;
  2682   int len;
  2689   int len;
  2683   va_start(args, fmt);
  2690   va_start(args, fmt);
  2684   len = jio_vsnprintf(str, count, fmt, args);
  2691   len = jio_vsnprintf(str, count, fmt, args);
  2685   va_end(args);
  2692   va_end(args);
  2686   return len;
  2693   return len;
  2687 }
  2694 }
  2688 
  2695 
  2689 ATTRIBUTE_PRINTF(2,3)
  2696 ATTRIBUTE_PRINTF(2, 3)
  2690 int jio_fprintf(FILE* f, const char *fmt, ...) {
  2697 int jio_fprintf(FILE* f, const char *fmt, ...) {
  2691   int len;
  2698   int len;
  2692   va_list args;
  2699   va_list args;
  2693   va_start(args, fmt);
  2700   va_start(args, fmt);
  2694   len = jio_vfprintf(f, fmt, args);
  2701   len = jio_vfprintf(f, fmt, args);