src/share/vm/libadt/port.hpp

Mon, 12 Aug 2019 18:30:40 +0300

author
apetushkov
date
Mon, 12 Aug 2019 18:30:40 +0300
changeset 9858
b985cbb00e68
parent 6472
2b8e28fdf503
child 6876
710a3c8b516e
permissions
-rw-r--r--

8223147: JFR Backport
8199712: Flight Recorder
8203346: JFR: Inconsistent signature of jfr_add_string_constant
8195817: JFR.stop should require name of recording
8195818: JFR.start should increase autogenerated name by one
8195819: Remove recording=x from jcmd JFR.check output
8203921: JFR thread sampling is missing fixes from JDK-8194552
8203929: Limit amount of data for JFR.dump
8203664: JFR start failure after AppCDS archive created with JFR StartFlightRecording
8003209: JFR events for network utilization
8207392: [PPC64] Implement JFR profiling
8202835: jfr/event/os/TestSystemProcess.java fails on missing events
Summary: Backport JFR from JDK11. Initial integration
Reviewed-by: neugens

     1 /*
     2  * Copyright (c) 1997, 2013, 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.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    22  *
    23  */
    25 #ifndef SHARE_VM_LIBADT_PORT_HPP
    26 #define SHARE_VM_LIBADT_PORT_HPP
    28 #include "utilities/top.hpp"
    30 // Typedefs for portable compiling
    32 #if defined(__GNUC__)
    34 #define INTERFACE       #pragma interface
    35 #define IMPLEMENTATION  #pragma implementation
    36 //INTERFACE
    37 #include <stddef.h>
    38 #include <stdlib.h>
    39 #include <string.h>
    41 // Access to the C++ class virtual function pointer
    42 // Put the class in the macro
    43 typedef void *VPTR;
    44 // G++ puts it at the end of the base class
    45 #define ACCESS_VPTR(class) VPTR&vptr(){return*(VPTR*)((char*)this+sizeof(class)-sizeof(void*));}
    47 #elif defined(__TURBOC__)
    49 #include <mem.h>
    50 #include <string.h>
    51 extern "C" int stricmp(const char *, const char *);
    52 inline void bcopy(const void *s, void *d, int l) { memmove(d,s,l); }
    53 inline void bzero(void *p, int l) { memset(p,0,l); }
    54 inline int bcmp(const void *s, const void *d, int l) { return memcmp(s,d,l); }
    55 inline int min( int a, int b) { return a < b ? a : b; }
    56 inline int max( int a, int b) { return a > b ? a : b; }
    57 //strcasecmp moved to globalDefinitions_visCPP.hpp
    58 //inline int strcasecmp(const char *s1, const char *s2) { return stricmp(s1,s2); }
    59 inline long abs( long x ) { return x < 0 ? -x : x; }
    60 // Access to the C++ class virtual function pointer
    61 // Put the class in the macro
    62 typedef void near *VPTR;
    63 // BorlandC puts it up front
    64 #define ACCESS_VPTR(class) VPTR&vptr(){return*(VPTR*)this;}
    66 #elif defined(__hpux)
    68 #define INTERFACE
    69 #define IMPLEMENTATION
    70 #define signed
    71 #include <strings.h>
    72 #include <stdlib.h>
    73 inline long min( long a, long b) { return a < b ? a : b; }
    74 inline long max( long a, long b) { return a > b ? a : b; }
    75 inline int min( int a, int b) { return a < b ? a : b; }
    76 inline int max( int a, int b) { return a > b ? a : b; }
    77 inline long abs( long x ) { return x < 0 ? -x : x; }
    79 #elif defined(__MOTO__)
    80 // Motorola's mcc
    81 #define INTERFACE
    82 #define IMPLEMENTATION
    83 #include <stdlib.h>
    84 #include <memory.h>
    85 inline int min( int a, int b) { return a < b ? a : b; }
    86 inline int max( int a, int b) { return a > b ? a : b; }
    88 #elif defined(_AIX)
    89 // IBM's xlC compiler
    90 #define INTERFACE
    91 #define IMPLEMENTATION
    92 #include <stdlib.h>
    93 #include <memory.h>
    95 #elif defined(_MSC_VER)
    96 // Microsoft Visual C++
    97 //#define INTERFACE
    98 #define IMPLEMENTATION
    99 #include <stdlib.h>
   100 #undef small
   101 //strcasecmp moved to globalDefinitions_visCPP.hpp
   102 //inline int strcasecmp(const char *s1, const char *s2) { return stricmp(s1,s2); }
   105 #elif defined(SPARC_WORKS)
   107 #define INTERFACE
   108 #define IMPLEMENTATION
   110 #include <stddef.h>
   111 #include <stdlib.h>
   112 #include <string.h>
   114 #elif defined(SOLARIS)
   116 #define INTERFACE
   117 #define IMPLEMENTATION
   119 #include <stddef.h>
   120 #include <stdlib.h>
   121 #include <string.h>
   124 #elif defined(__TANDEM)
   126 // This case is for the Tandem Business Unit of Compaq Computer Corporation.
   127 // The Tandem case must precede the AT&T case,
   128 // because the Tandem c89 compiler also defines __cplusplus.
   130 #include "port_tandem.hpp"
   132 #elif defined(__cplusplus)
   133 // AT&Ts cfront
   134 #define INTERFACE
   135 #define IMPLEMENTATION
   136 #include <unistd.h>
   137 #define signed
   138 // #include <bstring.h>
   139 inline int min( int a, int b) { return a < b ? a : b; }
   140 inline int max( int a, int b) { return a > b ? a : b; }
   142 #else  // All other machines
   144 #define signed
   145 extern "C" void bcopy(void *b1, void *b2, int len);
   146 inline int min( int a, int b) { return a < b ? a : b; }
   147 inline int max( int a, int b) { return a > b ? a : b; }
   149 #endif
   151 //-----------------------------------------------------------------------------
   152 // Safer memory allocations
   153 #ifdef SAFE_MEMORY
   154 #define malloc(size)        safe_malloc(__FILE__,__LINE__,size)
   155 #define free(ptr)           safe_free(__FILE__,__LINE__,ptr)
   156 #define realloc(ptr,size)   safe_realloc(__FILE__,__LINE__,ptr,size)
   157 #define calloc(nitems,size) safe_calloc(__FILE__,__LINE__,nitems,size)
   158 #define strdup(ptr)         safe_strdup(__FILE__,__LINE__,ptr)
   159 extern void *safe_malloc (const char *file, unsigned line, unsigned size);
   160 extern void  safe_free   (const char *file, unsigned line, void *ptr);
   161 extern void *safe_calloc (const char *file, unsigned line, unsigned nitems, unsigned size);
   162 extern void *safe_realloc(const char *file, unsigned line, void *ptr, unsigned size);
   163 extern char *safe_strdup (const char *file, unsigned line, const char *src);
   164 inline void *operator new( size_t size ) throw() { return malloc(size); }
   165 inline void operator delete( void *ptr )         { free(ptr); }
   166 #endif
   168 //-----------------------------------------------------------------------------
   169 // And now, the bit-size-specified integer sizes
   170 typedef signed char int8;
   171 typedef unsigned char uint8;
   172 typedef unsigned char byte;
   174 // All uses of *int16 changed to 32-bit to speed up compiler on Intel
   175 //typedef signed short int16;   // Exactly 16bits signed
   176 //typedef unsigned short uint16;        // Exactly 16bits unsigned
   177 //const unsigned int min_uint16 = 0x0000;    // smallest uint16
   178 //const unsigned int max_uint16 = 0xFFFF;    // largest  uint16
   180 typedef unsigned int uint;      // When you need a fast >=16bit unsigned value
   181 /*typedef int int; */           // When you need a fast >=16bit value
   182 const unsigned int max_uint = (uint)-1;
   183 typedef int32_t int32;   // Exactly 32bits signed
   184 typedef uint32_t uint32; // Exactly 32bits unsigned
   186 // Bit-sized floating point and long thingies
   187 #ifndef __TANDEM
   188 // Do not define these for Tandem, because they conflict with typedefs in softieee.h.
   189 typedef float float32;          // 32-bit float
   190 typedef double float64;         // 64-bit float
   191 #endif // __TANDEM
   193 typedef jlong int64;            // Java long for my 64-bit type
   194 typedef julong uint64;          // Java long for my 64-bit type
   196 //-----------------------------------------------------------------------------
   197 // Nice constants
   198 uint32 gcd( uint32 x, uint32 y );
   199 int ff1( uint32 mask );
   200 int fh1( uint32 mask );
   201 uint32 rotate32( uint32 x, int32 cnt );
   204 //-----------------------------------------------------------------------------
   205 extern uint32 heap_totalmem;      // Current total memory allocation
   206 extern uint32 heap_highwater;     // Highwater mark to date for memory usage
   208 #endif // SHARE_VM_LIBADT_PORT_HPP

mercurial