author | alanb |
Thu, 21 Mar 2019 08:41:10 +0000 | |
branch | niosocketimpl-branch |
changeset 57275 | 222fa5ed1c91 |
parent 53244 | 9807daeb47c4 |
permissions | -rw-r--r-- |
33743 | 1 |
/* |
35594 | 2 |
* Copyright (c) 2012, 2015 SAP SE. All rights reserved. |
33743 | 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 |
*/ |
|
24 |
||
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 | 28 |
|
29 |
// misc_aix.hpp, misc_aix.cpp: convenience functions needed for the OpenJDK AIX |
|
30 |
// port. |
|
31 |
#include "utilities/globalDefinitions.hpp" |
|
34647 | 32 |
#include "runtime/globals.hpp" |
33 |
#include "utilities/debug.hpp" |
|
33743 | 34 |
|
35 |
#include <pthread.h> |
|
36 |
||
37 |
// Trace if verbose to tty. |
|
38 |
#define trcVerbose(fmt, ...) { \ |
|
39 |
if (Verbose) { \ |
|
40 |
fprintf(stderr, fmt, ##__VA_ARGS__); \ |
|
41 |
fputc('\n', stderr); fflush(stderr); \ |
|
42 |
} \ |
|
43 |
} |
|
44 |
||
45 |
#define assert0(b) assert((b), "") |
|
46 |
#define guarantee0(b) guarantee((b), "") |
|
47 |
template <class T1, class T2> bool is_aligned_to(T1 what, T2 alignment) { |
|
48 |
return (((uintx)(what)) & (((uintx)(alignment)) - 1)) == 0 ? true : false; |
|
49 |
} |
|
50 |
||
51 |
// CritSect: simple critical section implementation using pthread mutexes. |
|
52 |
namespace MiscUtils { |
|
53 |
typedef pthread_mutex_t critsect_t; |
|
54 |
||
55 |
void init_critsect(MiscUtils::critsect_t* cs); |
|
56 |
void free_critsect(MiscUtils::critsect_t* cs); |
|
57 |
void enter_critsect(MiscUtils::critsect_t* cs); |
|
58 |
void leave_critsect(MiscUtils::critsect_t* cs); |
|
59 |
||
60 |
// Need to wrap this in an object because we need to dynamically initialize |
|
61 |
// critical section (because of windows, where there is no way to initialize |
|
62 |
// a CRITICAL_SECTION statically. On Unix, we could use |
|
63 |
// PTHREAD_MUTEX_INITIALIZER). |
|
64 |
||
65 |
// Note: The critical section does NOT get cleaned up in the destructor. That is |
|
66 |
// by design: the CritSect class is only ever used as global objects whose |
|
67 |
// lifetime spans the whole VM life; in that context we don't want the lock to |
|
68 |
// be cleaned up when global C++ objects are destroyed, but to continue to work |
|
69 |
// correctly right to the very end of the process life. |
|
70 |
class CritSect { |
|
71 |
critsect_t _cs; |
|
72 |
public: |
|
73 |
CritSect() { init_critsect(&_cs); } |
|
74 |
//~CritSect() { free_critsect(&_cs); } |
|
75 |
void enter() { enter_critsect(&_cs); } |
|
76 |
void leave() { leave_critsect(&_cs); } |
|
77 |
}; |
|
78 |
||
79 |
class AutoCritSect { |
|
80 |
CritSect* const _pcsobj; |
|
81 |
public: |
|
82 |
AutoCritSect(CritSect* pcsobj) |
|
83 |
: _pcsobj(pcsobj) |
|
84 |
{ |
|
85 |
_pcsobj->enter(); |
|
86 |
} |
|
87 |
~AutoCritSect() { |
|
88 |
_pcsobj->leave(); |
|
89 |
} |
|
90 |
}; |
|
91 |
} |
|
92 |
||
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
51139
diff
changeset
|
93 |
#endif // OS_AIX_MISC_AIX_HPP |