104 // On success, returns 'outbuf', which now contains the path.
105 // On error, it will return NULL and set errno. The content of 'outbuf' is undefined.
106 // On truncation error ('outbuf' too small), it will return NULL and set errno to ENAMETOOLONG.
107 static char* realpath(const char* filename, char* outbuf, size_t outbuflen);
108 };
109
110 // On POSIX platforms the signal handler is global so we just do the write.
111 static void write_memory_serialize_page_with_handler(JavaThread* thread) {
112 write_memory_serialize_page(thread);
113 }
114
115 /*
116 * Crash protection for the watcher thread. Wrap the callback
117 * with a sigsetjmp and in case of a SIGSEGV/SIGBUS we siglongjmp
118 * back.
119 * To be able to use this - don't take locks, don't rely on destructors,
120 * don't make OS library calls, don't allocate memory, don't print,
121 * don't call code that could leave the heap / memory in an inconsistent state,
122 * or anything else where we are not in control if we suddenly jump out.
123 */
124 class WatcherThreadCrashProtection : public StackObj {
125 public:
126 WatcherThreadCrashProtection();
127 bool call(os::CrashProtectionCallback& cb);
128
129 static void check_crash_protection(int signal, Thread* thread);
130 private:
131 void restore();
132 sigjmp_buf _jmpbuf;
133 };
134
135 #ifndef SOLARIS
136
137 /*
138 * This is the platform-specific implementation underpinning
139 * the ParkEvent class, which itself underpins Java-level monitor
140 * operations. See park.hpp for details.
141 * These event objects are type-stable and immortal - we never delete them.
142 * Events are associated with a thread for the lifetime of the thread.
143 */
144 class PlatformEvent : public CHeapObj<mtInternal> {
145 private:
146 double cachePad[4]; // Increase odds that _mutex is sole occupant of cache line
147 volatile int _event; // Event count/permit: -1, 0 or 1
148 volatile int _nParked; // Indicates if associated thread is blocked: 0 or 1
149 pthread_mutex_t _mutex[1]; // Native mutex for locking
150 pthread_cond_t _cond[1]; // Native condition variable for blocking
|
104 // On success, returns 'outbuf', which now contains the path.
105 // On error, it will return NULL and set errno. The content of 'outbuf' is undefined.
106 // On truncation error ('outbuf' too small), it will return NULL and set errno to ENAMETOOLONG.
107 static char* realpath(const char* filename, char* outbuf, size_t outbuflen);
108 };
109
110 // On POSIX platforms the signal handler is global so we just do the write.
111 static void write_memory_serialize_page_with_handler(JavaThread* thread) {
112 write_memory_serialize_page(thread);
113 }
114
115 /*
116 * Crash protection for the watcher thread. Wrap the callback
117 * with a sigsetjmp and in case of a SIGSEGV/SIGBUS we siglongjmp
118 * back.
119 * To be able to use this - don't take locks, don't rely on destructors,
120 * don't make OS library calls, don't allocate memory, don't print,
121 * don't call code that could leave the heap / memory in an inconsistent state,
122 * or anything else where we are not in control if we suddenly jump out.
123 */
124 class ThreadCrashProtection : public StackObj {
125 public:
126 static bool is_crash_protected(Thread* thr) {
127 return _crash_protection != NULL && _protected_thread == thr;
128 }
129
130 ThreadCrashProtection();
131 bool call(os::CrashProtectionCallback& cb);
132
133 static void check_crash_protection(int signal, Thread* thread);
134 private:
135 static Thread* _protected_thread;
136 static ThreadCrashProtection* _crash_protection;
137 static volatile intptr_t _crash_mux;
138 void restore();
139 sigjmp_buf _jmpbuf;
140 };
141
142 #ifndef SOLARIS
143
144 /*
145 * This is the platform-specific implementation underpinning
146 * the ParkEvent class, which itself underpins Java-level monitor
147 * operations. See park.hpp for details.
148 * These event objects are type-stable and immortal - we never delete them.
149 * Events are associated with a thread for the lifetime of the thread.
150 */
151 class PlatformEvent : public CHeapObj<mtInternal> {
152 private:
153 double cachePad[4]; // Increase odds that _mutex is sole occupant of cache line
154 volatile int _event; // Event count/permit: -1, 0 or 1
155 volatile int _nParked; // Indicates if associated thread is blocked: 0 or 1
156 pthread_mutex_t _mutex[1]; // Native mutex for locking
157 pthread_cond_t _cond[1]; // Native condition variable for blocking
|