src/hotspot/os/aix/misc_aix.hpp
author alanb
Thu, 21 Mar 2019 08:41:10 +0000
branchniosocketimpl-branch
changeset 57275 222fa5ed1c91
parent 53244 9807daeb47c4
permissions -rw-r--r--
Add @systemProperty ref to system property to configure old impl
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33743
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
     1
/*
35594
cc13089c6327 8147937: Adapt SAP copyrights to new company name.
goetz
parents: 34647
diff changeset
     2
 * Copyright (c) 2012, 2015 SAP SE. All rights reserved.
33743
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
     4
 *
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
     7
 * published by the Free Software Foundation.
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
     8
 *
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    13
 * accompanied this code).
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    14
 *
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    18
 *
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    21
 * questions.
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    22
 *
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    23
 */
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    24
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    25
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 51139
diff changeset
    26
#ifndef OS_AIX_MISC_AIX_HPP
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 51139
diff changeset
    27
#define OS_AIX_MISC_AIX_HPP
33743
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    28
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    29
// misc_aix.hpp, misc_aix.cpp: convenience functions needed for the OpenJDK AIX
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    30
// port.
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    31
#include "utilities/globalDefinitions.hpp"
34647
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 33743
diff changeset
    32
#include "runtime/globals.hpp"
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 33743
diff changeset
    33
#include "utilities/debug.hpp"
33743
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    34
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    35
#include <pthread.h>
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    36
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    37
// Trace if verbose to tty.
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    38
#define trcVerbose(fmt, ...) { \
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    39
  if (Verbose) { \
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    40
    fprintf(stderr, fmt, ##__VA_ARGS__); \
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    41
    fputc('\n', stderr); fflush(stderr); \
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    42
  } \
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    43
}
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    44
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    45
#define assert0(b) assert((b), "")
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    46
#define guarantee0(b) guarantee((b), "")
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    47
template <class T1, class T2> bool is_aligned_to(T1 what, T2 alignment) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    48
  return (((uintx)(what)) & (((uintx)(alignment)) - 1)) == 0 ? true : false;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    49
}
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    50
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    51
// CritSect: simple critical section implementation using pthread mutexes.
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    52
namespace MiscUtils {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    53
  typedef pthread_mutex_t critsect_t;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    54
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    55
  void init_critsect(MiscUtils::critsect_t* cs);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    56
  void free_critsect(MiscUtils::critsect_t* cs);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    57
  void enter_critsect(MiscUtils::critsect_t* cs);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    58
  void leave_critsect(MiscUtils::critsect_t* cs);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    59
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    60
  // Need to wrap this in an object because we need to dynamically initialize
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    61
  // critical section (because of windows, where there is no way to initialize
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    62
  // a CRITICAL_SECTION statically. On Unix, we could use
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    63
  // PTHREAD_MUTEX_INITIALIZER).
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    64
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    65
  // Note: The critical section does NOT get cleaned up in the destructor. That is
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    66
  // by design: the CritSect class is only ever used as global objects whose
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    67
  // lifetime spans the whole VM life; in that context we don't want the lock to
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    68
  // be cleaned up when global C++ objects are destroyed, but to continue to work
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    69
  // correctly right to the very end of the process life.
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    70
  class CritSect {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    71
    critsect_t _cs;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    72
   public:
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    73
    CritSect()        { init_critsect(&_cs); }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    74
    //~CritSect()       { free_critsect(&_cs); }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    75
    void enter()      { enter_critsect(&_cs); }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    76
    void leave()      { leave_critsect(&_cs); }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    77
  };
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    78
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    79
  class AutoCritSect {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    80
    CritSect* const _pcsobj;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    81
   public:
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    82
    AutoCritSect(CritSect* pcsobj)
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    83
      : _pcsobj(pcsobj)
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    84
    {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    85
      _pcsobj->enter();
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    86
    }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    87
    ~AutoCritSect() {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    88
      _pcsobj->leave();
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    89
    }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    90
  };
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    91
}
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents:
diff changeset
    92
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 51139
diff changeset
    93
#endif // OS_AIX_MISC_AIX_HPP