Ignore:
Timestamp:
Feb 13, 2012, 10:07:12 PM (14 years ago)
Author:
dmik
Message:

trunk: Merged in openjdk6 b24 from branches/vendor/oracle.

Location:
trunk/openjdk
Files:
6 deleted
24 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/openjdk

  • trunk/openjdk/hotspot/src/os/linux/vm/attachListener_linux.cpp

    r278 r309  
    11/*
    2  * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    2323 */
    2424
    25 # include "incls/_precompiled.incl"
    26 # include "incls/_attachListener_linux.cpp.incl"
     25#include "precompiled.hpp"
     26#include "runtime/interfaceSupport.hpp"
     27#include "runtime/os.hpp"
     28#include "services/attachListener.hpp"
     29#include "services/dtraceAttacher.hpp"
    2730
    2831#include <unistd.h>
     
    177180  int n = snprintf(path, UNIX_PATH_MAX, "%s/.java_pid%d",
    178181                   os::get_temp_directory(), os::current_process_id());
    179   if (n <= (int)UNIX_PATH_MAX) {
     182  if (n < (int)UNIX_PATH_MAX) {
    180183    n = snprintf(initial_path, UNIX_PATH_MAX, "%s.tmp", path);
    181184  }
    182   if (n > (int)UNIX_PATH_MAX) {
     185  if (n >= (int)UNIX_PATH_MAX) {
    183186    return -1;
    184187  }
  • trunk/openjdk/hotspot/src/os/linux/vm/c1_globals_linux.hpp

    r278 r309  
    11/*
    2  * Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    2323 */
    2424
     25#ifndef OS_LINUX_VM_C1_GLOBALS_LINUX_HPP
     26#define OS_LINUX_VM_C1_GLOBALS_LINUX_HPP
     27
     28#include "utilities/globalDefinitions.hpp"
     29#include "utilities/macros.hpp"
     30
    2531//
    2632// Sets the default values for operating system dependent flags used by the
    2733// client compiler. (see c1_globals.hpp)
    2834//
     35
     36#endif // OS_LINUX_VM_C1_GLOBALS_LINUX_HPP
  • trunk/openjdk/hotspot/src/os/linux/vm/c2_globals_linux.hpp

    r278 r309  
    11/*
    2  * Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    2323 */
    2424
     25#ifndef OS_LINUX_VM_C2_GLOBALS_LINUX_HPP
     26#define OS_LINUX_VM_C2_GLOBALS_LINUX_HPP
     27
     28#include "utilities/globalDefinitions.hpp"
     29#include "utilities/macros.hpp"
     30
    2531//
    2632// Sets the default values for operating system dependent flags used by the
    2733// server compiler. (see c2_globals.hpp)
    2834//
     35
     36#endif // OS_LINUX_VM_C2_GLOBALS_LINUX_HPP
  • trunk/openjdk/hotspot/src/os/linux/vm/chaitin_linux.cpp

    r278 r309  
    11/*
    2  * Copyright (c) 1999, 2001, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    2323 */
    2424
    25 #include "incls/_precompiled.incl"
    26 #include "incls/_chaitin_linux.cpp.incl"
     25#include "precompiled.hpp"
     26#include "opto/chaitin.hpp"
     27#include "opto/machnode.hpp"
    2728
    2829void PhaseRegAlloc::pd_preallocate_hook() {
  • trunk/openjdk/hotspot/src/os/linux/vm/dtraceJSDT_linux.cpp

    r278 r309  
    11/*
    2  * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    2323 */
    2424
    25 #include "incls/_precompiled.incl"
    26 #include "incls/_dtraceJSDT_linux.cpp.incl"
     25#include "precompiled.hpp"
     26#include "classfile/javaClasses.hpp"
     27#include "code/codeBlob.hpp"
     28#include "memory/allocation.hpp"
     29#include "prims/jvm.h"
     30#include "runtime/dtraceJSDT.hpp"
     31#include "runtime/jniHandles.hpp"
     32#include "runtime/os.hpp"
     33#include "runtime/signature.hpp"
     34#include "utilities/globalDefinitions.hpp"
    2735
    2836int DTraceJSDT::pd_activate(
  • trunk/openjdk/hotspot/src/os/linux/vm/globals_linux.hpp

    r278 r309  
    11/*
    2  * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    2323 */
    2424
     25#ifndef OS_LINUX_VM_GLOBALS_LINUX_HPP
     26#define OS_LINUX_VM_GLOBALS_LINUX_HPP
     27
    2528//
    2629// Defines Linux specific flags. They are not available on other platforms.
     
    4346define_pd_global(bool, UseOSErrorReporting, false);
    4447define_pd_global(bool, UseThreadPriorities, true) ;
     48
     49#endif // OS_LINUX_VM_GLOBALS_LINUX_HPP
  • trunk/openjdk/hotspot/src/os/linux/vm/interfaceSupport_linux.hpp

    r278 r309  
    11/*
    2  * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    2323 */
    2424
     25#ifndef OS_LINUX_VM_INTERFACESUPPORT_LINUX_HPP
     26#define OS_LINUX_VM_INTERFACESUPPORT_LINUX_HPP
     27
    2528// Contains inlined functions for class InterfaceSupport
    2629
     
    2831  os::write_memory_serialize_page(thread);
    2932}
     33
     34#endif // OS_LINUX_VM_INTERFACESUPPORT_LINUX_HPP
  • trunk/openjdk/hotspot/src/os/linux/vm/jsig.c

    r278 r309  
    11/*
    2  * Copyright (c) 2001, 2006, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
  • trunk/openjdk/hotspot/src/os/linux/vm/jvm_linux.cpp

    r278 r309  
    11/*
    2  * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    2323 */
    2424
    25 #include "incls/_precompiled.incl"
    26 #include "incls/_jvm_linux.cpp.incl"
     25#include "precompiled.hpp"
     26#include "prims/jvm.h"
     27#include "runtime/interfaceSupport.hpp"
     28#include "runtime/osThread.hpp"
    2729
    2830#include <signal.h>
  • trunk/openjdk/hotspot/src/os/linux/vm/jvm_linux.h

    r278 r309  
    11/*
    2  * Copyright (c) 1999, 2005, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    2222 *
    2323 */
     24
     25#ifndef OS_LINUX_VM_JVM_LINUX_H
     26#define OS_LINUX_VM_JVM_LINUX_H
    2427
    2528/*
     
    9699// jvm_solaris.h        1.6 99/06/22 16:38:47
    97100// End
     101
     102#endif // OS_LINUX_VM_JVM_LINUX_H
  • trunk/openjdk/hotspot/src/os/linux/vm/mutex_linux.cpp

    r278 r309  
    11/*
    2  * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    2323 */
    2424
    25 # include "incls/_precompiled.incl"
    26 # include "incls/_mutex_linux.cpp.incl"
     25#include "precompiled.hpp"
     26#include "mutex_linux.inline.hpp"
     27#include "runtime/interfaceSupport.hpp"
     28#include "runtime/mutex.hpp"
     29#include "thread_linux.inline.hpp"
     30#include "utilities/events.hpp"
    2731
    2832// put OS-includes here
  • trunk/openjdk/hotspot/src/os/linux/vm/mutex_linux.inline.hpp

    r278 r309  
    11/*
    2  * Copyright (c) 1999, 2002, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    2323 */
    2424
     25#ifndef OS_LINUX_VM_MUTEX_LINUX_INLINE_HPP
     26#define OS_LINUX_VM_MUTEX_LINUX_INLINE_HPP
     27
     28#include "os_linux.inline.hpp"
     29#include "runtime/interfaceSupport.hpp"
     30#include "thread_linux.inline.hpp"
     31
    2532
    2633// Reconciliation History
    2734// mutex_solaris.inline.hpp     1.5 99/06/22 16:38:49
    2835// End
     36
     37#endif // OS_LINUX_VM_MUTEX_LINUX_INLINE_HPP
  • trunk/openjdk/hotspot/src/os/linux/vm/osThread_linux.cpp

    r278 r309  
    11/*
    2  * Copyright (c) 1999, 2004, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    2323 */
    2424
    25 // do not include  precompiled  header file
    26 # include "incls/_osThread_linux.cpp.incl"
     25// no precompiled headers
     26#include "runtime/atomic.hpp"
     27#include "runtime/handles.inline.hpp"
     28#include "runtime/mutexLocker.hpp"
     29#include "runtime/os.hpp"
     30#include "runtime/osThread.hpp"
     31#include "runtime/safepoint.hpp"
     32#include "runtime/vmThread.hpp"
     33#ifdef TARGET_ARCH_x86
     34# include "assembler_x86.inline.hpp"
     35#endif
     36#ifdef TARGET_ARCH_sparc
     37# include "assembler_sparc.inline.hpp"
     38#endif
     39#ifdef TARGET_ARCH_zero
     40# include "assembler_zero.inline.hpp"
     41#endif
    2742
    2843
  • trunk/openjdk/hotspot/src/os/linux/vm/osThread_linux.hpp

    r278 r309  
    11/*
    2  * Copyright (c) 1999, 2004, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    2222 *
    2323 */
     24
     25#ifndef OS_LINUX_VM_OSTHREAD_LINUX_HPP
     26#define OS_LINUX_VM_OSTHREAD_LINUX_HPP
    2427
    2528 private:
     
    140143// osThread_solaris.hpp 1.24 99/08/27 13:11:54
    141144// End
     145
     146#endif // OS_LINUX_VM_OSTHREAD_LINUX_HPP
  • trunk/openjdk/hotspot/src/os/linux/vm/os_linux.cpp

    r278 r309  
    11/*
    2  * Copyright (c) 1999, 2009, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    2525# define __STDC_FORMAT_MACROS
    2626
    27 // do not include  precompiled  header file
    28 # include "incls/_os_linux.cpp.incl"
     27// no precompiled headers
     28#include "classfile/classLoader.hpp"
     29#include "classfile/systemDictionary.hpp"
     30#include "classfile/vmSymbols.hpp"
     31#include "code/icBuffer.hpp"
     32#include "code/vtableStubs.hpp"
     33#include "compiler/compileBroker.hpp"
     34#include "interpreter/interpreter.hpp"
     35#include "jvm_linux.h"
     36#include "memory/allocation.inline.hpp"
     37#include "memory/filemap.hpp"
     38#include "mutex_linux.inline.hpp"
     39#include "oops/oop.inline.hpp"
     40#include "os_share_linux.hpp"
     41#include "prims/jniFastGetField.hpp"
     42#include "prims/jvm.h"
     43#include "prims/jvm_misc.hpp"
     44#include "runtime/arguments.hpp"
     45#include "runtime/extendedPC.hpp"
     46#include "runtime/globals.hpp"
     47#include "runtime/interfaceSupport.hpp"
     48#include "runtime/java.hpp"
     49#include "runtime/javaCalls.hpp"
     50#include "runtime/mutexLocker.hpp"
     51#include "runtime/objectMonitor.hpp"
     52#include "runtime/osThread.hpp"
     53#include "runtime/perfMemory.hpp"
     54#include "runtime/sharedRuntime.hpp"
     55#include "runtime/statSampler.hpp"
     56#include "runtime/stubRoutines.hpp"
     57#include "runtime/threadCritical.hpp"
     58#include "runtime/timer.hpp"
     59#include "services/attachListener.hpp"
     60#include "services/runtimeService.hpp"
     61#include "thread_linux.inline.hpp"
     62#include "utilities/decoder.hpp"
     63#include "utilities/defaultStream.hpp"
     64#include "utilities/events.hpp"
     65#include "utilities/growableArray.hpp"
     66#include "utilities/vmError.hpp"
     67#ifdef TARGET_ARCH_x86
     68# include "assembler_x86.inline.hpp"
     69# include "nativeInst_x86.hpp"
     70#endif
     71#ifdef TARGET_ARCH_sparc
     72# include "assembler_sparc.inline.hpp"
     73# include "nativeInst_sparc.hpp"
     74#endif
     75#ifdef TARGET_ARCH_zero
     76# include "assembler_zero.inline.hpp"
     77# include "nativeInst_zero.hpp"
     78#endif
     79#ifdef COMPILER1
     80#include "c1/c1_Runtime1.hpp"
     81#endif
     82#ifdef COMPILER2
     83#include "opto/runtime.hpp"
     84#endif
    2985
    3086// put OS-includes here
     
    60116# include <stdint.h>
    61117# include <inttypes.h>
     118# include <sys/ioctl.h>
    62119
    63120#define MAX_PATH    (2 * K)
     
    828885      switch (thr_type) {
    829886      case os::java_thread:
    830         // Java threads use ThreadStackSize which default value can be changed with the flag -Xss
    831         if (JavaThread::stack_size_at_create() > 0) stack_size = JavaThread::stack_size_at_create();
     887        // Java threads use ThreadStackSize which default value can be
     888        // changed with the flag -Xss
     889        assert (JavaThread::stack_size_at_create() > 0, "this should be set");
     890        stack_size = JavaThread::stack_size_at_create();
    832891        break;
    833892      case os::compiler_thread:
     
    15081567void os::set_error_file(const char *logfile) {}
    15091568
     1569
     1570// This method is a copy of JDK's sysGetLastErrorString
     1571// from src/solaris/hpi/src/system_md.c
     1572
     1573size_t os::lasterror(char *buf, size_t len) {
     1574
     1575  if (errno == 0)  return 0;
     1576
     1577  const char *s = ::strerror(errno);
     1578  size_t n = ::strlen(s);
     1579  if (n >= len) {
     1580    n = len - 1;
     1581  }
     1582  ::strncpy(buf, s, n);
     1583  buf[n] = '\0';
     1584  return n;
     1585}
     1586
    15101587intx os::current_thread_id() { return (intx)pthread_self(); }
    15111588int os::current_process_id() {
     
    16131690
    16141691  if (dladdr((void*)addr, &dlinfo) && dlinfo.dli_sname != NULL) {
    1615     if (buf) jio_snprintf(buf, buflen, "%s", dlinfo.dli_sname);
    1616     if (offset) *offset = addr - (address)dlinfo.dli_saddr;
     1692    if (buf != NULL) {
     1693      if(!Decoder::demangle(dlinfo.dli_sname, buf, buflen)) {
     1694        jio_snprintf(buf, buflen, "%s", dlinfo.dli_sname);
     1695      }
     1696    }
     1697    if (offset != NULL) *offset = addr - (address)dlinfo.dli_saddr;
    16171698    return true;
    1618   } else {
    1619     if (buf) buf[0] = '\0';
    1620     if (offset) *offset = -1;
    1621     return false;
    1622   }
     1699  } else if (dlinfo.dli_fname != NULL && dlinfo.dli_fbase != 0) {
     1700    if (Decoder::decode((address)(addr - (address)dlinfo.dli_fbase),
     1701       dlinfo.dli_fname, buf, buflen, offset) == Decoder::no_error) {
     1702       return true;
     1703    }
     1704  }
     1705
     1706  if (buf != NULL) buf[0] = '\0';
     1707  if (offset != NULL) *offset = -1;
     1708  return false;
    16231709}
    16241710
     
    18711957
    18721958
    1873 bool _print_ascii_file(const char* filename, outputStream* st) {
    1874   int fd = open(filename, O_RDONLY);
     1959static bool _print_ascii_file(const char* filename, outputStream* st) {
     1960  int fd = ::open(filename, O_RDONLY);
    18751961  if (fd == -1) {
    18761962     return false;
     
    18791965  char buf[32];
    18801966  int bytes;
    1881   while ((bytes = read(fd, buf, sizeof(buf))) > 0) {
     1967  while ((bytes = ::read(fd, buf, sizeof(buf))) > 0) {
    18821968    st->print_raw(buf, bytes);
    18831969  }
    18841970
    1885   close(fd);
     1971  ::close(fd);
    18861972
    18871973  return true;
     
    21612247          // "libjvm"debug_only("_g")".so" since for fastdebug version
    21622248          // we should have "libjvm.so" but debug_only("_g") adds "_g"!
    2163           // It is used when we are choosing the HPI library's name
    2164           // "libhpi[_g].so" in hpi::initialize_get_interface().
    21652249          len = strlen(buf);
    21662250          snprintf(buf + len, buflen-len, "/hotspot/libjvm%s.so", p);
     
    23462430  unlink(buf);
    23472431
    2348   int fd = open(buf, O_CREAT | O_RDWR, S_IRWXU);
     2432  int fd = ::open(buf, O_CREAT | O_RDWR, S_IRWXU);
    23492433
    23502434  if (fd != -1) {
    2351     off_t rv = lseek(fd, size-2, SEEK_SET);
     2435    off_t rv = ::lseek(fd, size-2, SEEK_SET);
    23522436    if (rv != (off_t)-1) {
    2353       if (write(fd, "", 1) == 1) {
     2437      if (::write(fd, "", 1) == 1) {
    23542438        mmap(base, size,
    23552439             PROT_READ|PROT_WRITE|PROT_EXEC,
     
    23572441      }
    23582442    }
    2359     close(fd);
     2443    ::close(fd);
    23602444    unlink(buf);
    23612445  }
     
    39224006  Linux::install_signal_handlers();
    39234007
     4008  // Check minimum allowable stack size for thread creation and to initialize
     4009  // the java system classes, including StackOverflowError - depends on page
     4010  // size.  Add a page for compiler2 recursion in main thread.
     4011  // Add in 2*BytesPerWord times page size to account for VM stack during
     4012  // class initialization depending on 32 or 64 bit VM.
     4013  os::Linux::min_stack_allowed = MAX2(os::Linux::min_stack_allowed,
     4014            (size_t)(StackYellowPages+StackRedPages+StackShadowPages+
     4015                    2*BytesPerWord COMPILER2_PRESENT(+1)) * Linux::page_size());
     4016
    39244017  size_t threadStackSizeInBytes = ThreadStackSize * K;
    39254018  if (threadStackSizeInBytes != 0 &&
    3926       threadStackSizeInBytes < Linux::min_stack_allowed) {
     4019      threadStackSizeInBytes < os::Linux::min_stack_allowed) {
    39274020        tty->print_cr("\nThe stack size specified is too small, "
    39284021                      "Specify at least %dk",
    3929                       Linux::min_stack_allowed / K);
     4022                      os::Linux::min_stack_allowed/ K);
    39304023        return JNI_ERR;
    39314024  }
     
    39794072  // Initialize lock used to serialize thread creation (see os::create_thread)
    39804073  Linux::set_createThread_lock(new Mutex(Mutex::leaf, "createThread_lock", false));
    3981 
    3982   // Initialize HPI.
    3983   jint hpi_result = hpi::initialize();
    3984   if (hpi_result != JNI_OK) {
    3985     tty->print_cr("There was an error trying to initialize the HPI library.");
    3986     return hpi_result;
    3987   }
    39884074
    39894075  // at-exit methods are called in the reverse order of their registration.
     
    41844270    return -1;
    41854271  }
    4186   hpi::native_path(strcpy(pathbuf, path));
     4272  os::native_path(strcpy(pathbuf, path));
    41874273  return ::stat(pathbuf, sbuf);
    41884274}
     
    42164302}
    42174303
     4304// This code originates from JDK's sysOpen and open64_w
     4305// from src/solaris/hpi/src/system_md.c
     4306
     4307#ifndef O_DELETE
     4308#define O_DELETE 0x10000
     4309#endif
     4310
     4311// Open a file. Unlink the file immediately after open returns
     4312// if the specified oflag has the O_DELETE flag set.
     4313// O_DELETE is used only in j2se/src/share/native/java/util/zip/ZipFile.c
     4314
     4315int os::open(const char *path, int oflag, int mode) {
     4316
     4317  if (strlen(path) > MAX_PATH - 1) {
     4318    errno = ENAMETOOLONG;
     4319    return -1;
     4320  }
     4321  int fd;
     4322  int o_delete = (oflag & O_DELETE);
     4323  oflag = oflag & ~O_DELETE;
     4324
     4325  fd = ::open64(path, oflag, mode);
     4326  if (fd == -1) return -1;
     4327
     4328  //If the open succeeded, the file might still be a directory
     4329  {
     4330    struct stat64 buf64;
     4331    int ret = ::fstat64(fd, &buf64);
     4332    int st_mode = buf64.st_mode;
     4333
     4334    if (ret != -1) {
     4335      if ((st_mode & S_IFMT) == S_IFDIR) {
     4336        errno = EISDIR;
     4337        ::close(fd);
     4338        return -1;
     4339      }
     4340    } else {
     4341      ::close(fd);
     4342      return -1;
     4343    }
     4344  }
     4345
     4346    /*
     4347     * All file descriptors that are opened in the JVM and not
     4348     * specifically destined for a subprocess should have the
     4349     * close-on-exec flag set.  If we don't set it, then careless 3rd
     4350     * party native code might fork and exec without closing all
     4351     * appropriate file descriptors (e.g. as we do in closeDescriptors in
     4352     * UNIXProcess.c), and this in turn might:
     4353     *
     4354     * - cause end-of-file to fail to be detected on some file
     4355     *   descriptors, resulting in mysterious hangs, or
     4356     *
     4357     * - might cause an fopen in the subprocess to fail on a system
     4358     *   suffering from bug 1085341.
     4359     *
     4360     * (Yes, the default setting of the close-on-exec flag is a Unix
     4361     * design flaw)
     4362     *
     4363     * See:
     4364     * 1085341: 32-bit stdio routines should support file descriptors >255
     4365     * 4843136: (process) pipe file descriptor from Runtime.exec not being closed
     4366     * 6339493: (process) Runtime.exec does not close all file descriptors on Solaris 9
     4367     */
     4368#ifdef FD_CLOEXEC
     4369    {
     4370        int flags = ::fcntl(fd, F_GETFD);
     4371        if (flags != -1)
     4372            ::fcntl(fd, F_SETFD, flags | FD_CLOEXEC);
     4373    }
     4374#endif
     4375
     4376  if (o_delete != 0) {
     4377    ::unlink(path);
     4378  }
     4379  return fd;
     4380}
     4381
     4382
    42184383// create binary file, rewriting existing file if required
    42194384int os::create_binary_file(const char* path, bool rewrite_existing) {
     
    42334398jlong os::seek_to_file_offset(int fd, jlong offset) {
    42344399  return (jlong)::lseek64(fd, (off64_t)offset, SEEK_SET);
     4400}
     4401
     4402// This code originates from JDK's sysAvailable
     4403// from src/solaris/hpi/src/native_threads/src/sys_api_td.c
     4404
     4405int os::available(int fd, jlong *bytes) {
     4406  jlong cur, end;
     4407  int mode;
     4408  struct stat64 buf64;
     4409
     4410  if (::fstat64(fd, &buf64) >= 0) {
     4411    mode = buf64.st_mode;
     4412    if (S_ISCHR(mode) || S_ISFIFO(mode) || S_ISSOCK(mode)) {
     4413      /*
     4414      * XXX: is the following call interruptible? If so, this might
     4415      * need to go through the INTERRUPT_IO() wrapper as for other
     4416      * blocking, interruptible calls in this file.
     4417      */
     4418      int n;
     4419      if (::ioctl(fd, FIONREAD, &n) >= 0) {
     4420        *bytes = n;
     4421        return 1;
     4422      }
     4423    }
     4424  }
     4425  if ((cur = ::lseek64(fd, 0L, SEEK_CUR)) == -1) {
     4426    return 0;
     4427  } else if ((end = ::lseek64(fd, 0L, SEEK_END)) == -1) {
     4428    return 0;
     4429  } else if (::lseek64(fd, cur, SEEK_SET) == -1) {
     4430    return 0;
     4431  }
     4432  *bytes = end - cur;
     4433  return 1;
     4434}
     4435
     4436int os::socket_available(int fd, jint *pbytes) {
     4437  // Linux doc says EINTR not returned, unlike Solaris
     4438  int ret = ::ioctl(fd, FIONREAD, pbytes);
     4439
     4440  //%% note ioctl can return 0 when successful, JVM_SocketAvailable
     4441  // is expected to return 0 on failure and 1 on success to the jdk.
     4442  return (ret < 0) ? 0 : 1;
    42354443}
    42364444
     
    44614669  if (fd != -1) {
    44624670    struct stat buf;
    4463     close(fd);
     4671    ::close(fd);
    44644672    while (::stat(filename, &buf) == 0) {
    44654673      (void)::poll(NULL, 0, 100);
     
    48395047  // Next, demultiplex/decode time arguments
    48405048  timespec absTime;
    4841   if (time < 0) { // don't wait at all
     5049  if (time < 0 || (isAbsolute && time == 0) ) { // don't wait at all
    48425050    return;
    48435051  }
  • trunk/openjdk/hotspot/src/os/linux/vm/os_linux.hpp

    r278 r309  
    11/*
    2  * Copyright (c) 1999, 2009, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    2222 *
    2323 */
     24
     25#ifndef OS_LINUX_VM_OS_LINUX_HPP
     26#define OS_LINUX_VM_OS_LINUX_HPP
    2427
    2528// Linux_OS defines the interface to Linux operating systems
     
    329332    }
    330333} ;
     334
     335#endif // OS_LINUX_VM_OS_LINUX_HPP
  • trunk/openjdk/hotspot/src/os/linux/vm/os_linux.inline.hpp

    r278 r309  
    11/*
    2  * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    2323 */
    2424
     25#ifndef OS_LINUX_VM_OS_LINUX_INLINE_HPP
     26#define OS_LINUX_VM_OS_LINUX_INLINE_HPP
     27
     28#include "runtime/atomic.hpp"
     29#include "runtime/os.hpp"
     30#ifdef TARGET_OS_ARCH_linux_x86
     31# include "atomic_linux_x86.inline.hpp"
     32# include "orderAccess_linux_x86.inline.hpp"
     33#endif
     34#ifdef TARGET_OS_ARCH_linux_sparc
     35# include "atomic_linux_sparc.inline.hpp"
     36# include "orderAccess_linux_sparc.inline.hpp"
     37#endif
     38#ifdef TARGET_OS_ARCH_linux_zero
     39# include "atomic_linux_zero.inline.hpp"
     40# include "orderAccess_linux_zero.inline.hpp"
     41#endif
     42
     43// System includes
     44
     45#include <unistd.h>
     46#include <sys/socket.h>
     47#include <sys/poll.h>
     48#include <netdb.h>
     49
    2550inline void* os::thread_local_storage_at(int index) {
    2651  return pthread_getspecific((pthread_key_t)index);
     
    75100inline void os::bang_stack_shadow_pages() {
    76101}
     102
     103inline void os::dll_unload(void *lib) {
     104  ::dlclose(lib);
     105}
     106
     107inline const int os::default_file_open_flags() { return 0;}
    77108
    78109inline DIR* os::opendir(const char* dirname)
     
    85116{
    86117  return NAME_MAX + sizeof(dirent) + 1;
     118}
     119
     120inline jlong os::lseek(int fd, jlong offset, int whence) {
     121  return (jlong) ::lseek64(fd, offset, whence);
     122}
     123
     124inline int os::fsync(int fd) {
     125  return ::fsync(fd);
     126}
     127
     128inline char* os::native_path(char *path) {
     129  return path;
     130}
     131
     132inline int os::ftruncate(int fd, jlong length) {
     133  return ::ftruncate64(fd, length);
    87134}
    88135
     
    104151}
    105152
    106 inline int os::closedir(DIR *dirp)
    107 {
    108   assert(dirp != NULL, "just checking");
     153inline int os::closedir(DIR *dirp) {
     154  assert(dirp != NULL, "argument is NULL");
    109155  return ::closedir(dirp);
    110156}
     
    124170inline bool os::numa_has_static_binding()   { return true; }
    125171inline bool os::numa_has_group_homing()     { return false;  }
     172
     173inline size_t os::restartable_read(int fd, void *buf, unsigned int nBytes) {
     174  size_t res;
     175  RESTARTABLE( (size_t) ::read(fd, buf, (size_t) nBytes), res);
     176  return res;
     177}
     178
     179inline size_t os::write(int fd, const void *buf, unsigned int nBytes) {
     180  size_t res;
     181  RESTARTABLE((size_t) ::write(fd, buf, (size_t) nBytes), res);
     182  return res;
     183}
     184
     185inline int os::close(int fd) {
     186  return ::close(fd);
     187}
     188
     189inline int os::socket_close(int fd) {
     190  return ::close(fd);
     191}
     192
     193inline int os::socket(int domain, int type, int protocol) {
     194  return ::socket(domain, type, protocol);
     195}
     196
     197inline int os::recv(int fd, char *buf, int nBytes, int flags) {
     198  RESTARTABLE_RETURN_INT(::recv(fd, buf, nBytes, (unsigned int) flags));
     199}
     200
     201inline int os::send(int fd, char *buf, int nBytes, int flags) {
     202  RESTARTABLE_RETURN_INT(::send(fd, buf, nBytes, (unsigned int) flags));
     203}
     204
     205inline int os::raw_send(int fd, char *buf, int nBytes, int flags) {
     206  return os::send(fd, buf, nBytes, flags);
     207}
     208
     209inline int os::timeout(int fd, long timeout) {
     210  julong prevtime,newtime;
     211  struct timeval t;
     212
     213  gettimeofday(&t, NULL);
     214  prevtime = ((julong)t.tv_sec * 1000)  +  t.tv_usec / 1000;
     215
     216  for(;;) {
     217    struct pollfd pfd;
     218
     219    pfd.fd = fd;
     220    pfd.events = POLLIN | POLLERR;
     221
     222    int res = ::poll(&pfd, 1, timeout);
     223
     224    if (res == OS_ERR && errno == EINTR) {
     225
     226      // On Linux any value < 0 means "forever"
     227
     228      if(timeout >= 0) {
     229        gettimeofday(&t, NULL);
     230        newtime = ((julong)t.tv_sec * 1000)  +  t.tv_usec / 1000;
     231        timeout -= newtime - prevtime;
     232        if(timeout <= 0)
     233          return OS_OK;
     234        prevtime = newtime;
     235      }
     236    } else
     237      return res;
     238  }
     239}
     240
     241inline int os::listen(int fd, int count) {
     242  return ::listen(fd, count);
     243}
     244
     245inline int os::connect(int fd, struct sockaddr *him, int len) {
     246  RESTARTABLE_RETURN_INT(::connect(fd, him, len));
     247}
     248
     249inline int os::accept(int fd, struct sockaddr *him, int *len) {
     250  // This cast is from int to unsigned int on linux.  Since we
     251  // only pass the parameter "len" around the vm and don't try to
     252  // fetch it's value, this cast is safe for now. The java.net group
     253  // may need and want to change this interface someday if socklen_t goes
     254  // to 64 bits on some platform that we support.
     255  // Linux doc says this can't return EINTR, unlike accept() on Solaris
     256
     257  return ::accept(fd, him, (socklen_t *)len);
     258}
     259
     260inline int os::recvfrom(int fd, char *buf, int nBytes, int flags,
     261                         sockaddr *from, int *fromlen) {
     262  RESTARTABLE_RETURN_INT(::recvfrom(fd, buf, nBytes, (unsigned int) flags, from, (socklen_t *)fromlen));
     263}
     264
     265inline int os::sendto(int fd, char *buf, int len, int flags,
     266                        struct sockaddr *to, int tolen) {
     267  RESTARTABLE_RETURN_INT(::sendto(fd, buf, len, (unsigned int) flags, to, tolen));
     268}
     269
     270inline int os::socket_shutdown(int fd, int howto){
     271  return ::shutdown(fd, howto);
     272}
     273
     274inline int os::bind(int fd, struct sockaddr *him, int len){
     275  return ::bind(fd, him, len);
     276}
     277
     278inline int os::get_sock_name(int fd, struct sockaddr *him, int *len){
     279  return ::getsockname(fd, him, (socklen_t *)len);
     280}
     281
     282inline int os::get_host_name(char* name, int namelen){
     283  return ::gethostname(name, namelen);
     284}
     285
     286inline struct hostent*  os::get_host_by_name(char* name) {
     287  return ::gethostbyname(name);
     288}
     289inline int os::get_sock_opt(int fd, int level, int optname,
     290                             char *optval, int* optlen){
     291  return ::getsockopt(fd, level, optname, optval, (socklen_t *)optlen);
     292}
     293
     294inline int os::set_sock_opt(int fd, int level, int optname,
     295                             const char *optval, int optlen){
     296  return ::setsockopt(fd, level, optname, optval, optlen);
     297}
     298#endif // OS_LINUX_VM_OS_LINUX_INLINE_HPP
  • trunk/openjdk/hotspot/src/os/linux/vm/os_share_linux.hpp

    r278 r309  
    11/*
    2  * Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    2323 */
    2424
     25#ifndef OS_LINUX_VM_OS_SHARE_LINUX_HPP
     26#define OS_LINUX_VM_OS_SHARE_LINUX_HPP
     27
    2528// misc
    2629void signalHandler(int, siginfo_t*, ucontext_t*);
     
    3134
    3235#define PROCFILE_LENGTH 128
     36
     37#endif // OS_LINUX_VM_OS_SHARE_LINUX_HPP
  • trunk/openjdk/hotspot/src/os/linux/vm/perfMemory_linux.cpp

    r278 r309  
    11/*
    2  * Copyright (c) 2001, 2006, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    2323 */
    2424
    25 # include "incls/_precompiled.incl"
    26 # include "incls/_perfMemory_linux.cpp.incl"
     25#include "precompiled.hpp"
     26#include "classfile/vmSymbols.hpp"
     27#include "memory/allocation.inline.hpp"
     28#include "memory/resourceArea.hpp"
     29#include "oops/oop.inline.hpp"
     30#include "os_linux.inline.hpp"
     31#include "runtime/handles.inline.hpp"
     32#include "runtime/perfMemory.hpp"
     33#include "utilities/exceptions.hpp"
    2734
    2835// put OS-includes here
     
    629636  }
    630637
    631   return fd;
     638  // Verify that we have enough disk space for this file.
     639  // We'll get random SIGBUS crashes on memory accesses if
     640  // we don't.
     641
     642  for (size_t seekpos = 0; seekpos < size; seekpos += os::vm_page_size()) {
     643    int zero_int = 0;
     644    result = (int)os::seek_to_file_offset(fd, (jlong)(seekpos));
     645    if (result == -1 ) break;
     646    RESTARTABLE(::write(fd, &zero_int, 1), result);
     647    if (result != 1) {
     648      if (errno == ENOSPC) {
     649        warning("Insufficient space for shared memory file:\n   %s\nTry using the -Djava.io.tmpdir= option to select an alternate temp location.\n", filename);
     650      }
     651      break;
     652    }
     653  }
     654
     655  if (result != -1) {
     656    return fd;
     657  } else {
     658    RESTARTABLE(::close(fd), result);
     659    return -1;
     660  }
    632661}
    633662
  • trunk/openjdk/hotspot/src/os/linux/vm/stubRoutines_linux.cpp

    r278 r309  
    11/*
    2  * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    2323 */
    2424
    25 #include "incls/_precompiled.incl"
    26 #include "incls/_stubRoutines_linux.cpp.incl"
     25#include "precompiled.hpp"
     26#include "runtime/os.hpp"
     27#include "runtime/stubRoutines.hpp"
     28
  • trunk/openjdk/hotspot/src/os/linux/vm/threadCritical_linux.cpp

    r278 r309  
    11/*
    2  * Copyright (c) 2001, 2006, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    2323 */
    2424
    25 #include "incls/_precompiled.incl"
    26 #include "incls/_threadCritical_linux.cpp.incl"
     25#include "precompiled.hpp"
     26#include "runtime/threadCritical.hpp"
     27#include "thread_linux.inline.hpp"
    2728
    2829// put OS-includes here
  • trunk/openjdk/hotspot/src/os/linux/vm/thread_linux.inline.hpp

    r278 r309  
    11/*
    2  * Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    2323 */
    2424
     25#ifndef OS_LINUX_VM_THREAD_LINUX_INLINE_HPP
     26#define OS_LINUX_VM_THREAD_LINUX_INLINE_HPP
     27
     28#include "runtime/atomic.hpp"
     29#include "runtime/prefetch.hpp"
     30#include "runtime/thread.hpp"
     31#include "runtime/threadLocalStorage.hpp"
     32#ifdef TARGET_OS_ARCH_linux_x86
     33# include "atomic_linux_x86.inline.hpp"
     34# include "orderAccess_linux_x86.inline.hpp"
     35# include "prefetch_linux_x86.inline.hpp"
     36#endif
     37#ifdef TARGET_OS_ARCH_linux_sparc
     38# include "atomic_linux_sparc.inline.hpp"
     39# include "orderAccess_linux_sparc.inline.hpp"
     40# include "prefetch_linux_sparc.inline.hpp"
     41#endif
     42#ifdef TARGET_OS_ARCH_linux_zero
     43# include "atomic_linux_zero.inline.hpp"
     44# include "orderAccess_linux_zero.inline.hpp"
     45# include "prefetch_linux_zero.inline.hpp"
     46#endif
     47
    2548// Contains inlined functions for class Thread and ThreadLocalStorage
    2649
    2750inline void ThreadLocalStorage::pd_invalidate_all() {} // nothing to do
     51
     52#endif // OS_LINUX_VM_THREAD_LINUX_INLINE_HPP
  • trunk/openjdk/hotspot/src/os/linux/vm/vmError_linux.cpp

    r278 r309  
    11/*
    2  * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    2323 */
    2424
    25 # include "incls/_precompiled.incl"
    26 # include "incls/_vmError_linux.cpp.incl"
     25#include "precompiled.hpp"
     26#include "runtime/arguments.hpp"
     27#include "runtime/os.hpp"
     28#include "runtime/thread.hpp"
     29#include "utilities/vmError.hpp"
    2730
    2831#include <sys/types.h>
     
    4245               "\n\n"
    4346               "Do you want to debug the problem?\n\n"
    44                "To debug, run 'gdb /proc/%d/exe %d'; then switch to thread " INTX_FORMAT "\n"
     47               "To debug, run 'gdb /proc/%d/exe %d'; then switch to thread " INTX_FORMAT " (" INTPTR_FORMAT ")\n"
    4548               "Enter 'yes' to launch gdb automatically (PATH must include gdb)\n"
    4649               "Otherwise, press RETURN to abort...",
    4750               os::current_process_id(), os::current_process_id(),
    48                os::current_thread_id());
     51               os::current_thread_id(), os::current_thread_id());
    4952
    5053    yes = os::message_box("Unexpected Error", buf);
Note: See TracChangeset for help on using the changeset viewer.