1 #include "misc_aix.hpp"
   2 #include "runtime/stubRoutines.hpp"
   3 #include <pthread.h>
   4 
   5 void MiscUtils::init_critsect(MiscUtils::critsect_t* cs) {
   6   const int rc = pthread_mutex_init(cs, NULL);
   7   assert0(rc == 0);
   8 }
   9 
  10 void MiscUtils::free_critsect(MiscUtils::critsect_t* cs) {
  11   const int rc = pthread_mutex_destroy(cs);
  12   assert0(rc == 0);
  13 }
  14 
  15 void MiscUtils::enter_critsect(MiscUtils::critsect_t* cs) {
  16   const int rc = pthread_mutex_lock(cs);
  17   assert0(rc == 0);
  18 }
  19 
  20 void MiscUtils::leave_critsect(MiscUtils::critsect_t* cs) {
  21   const int rc = pthread_mutex_unlock(cs);
  22   assert0(rc == 0);
  23 }
  24 
  25 bool MiscUtils::is_readable_pointer(const void* p) {
  26   if (!CanUseSafeFetch32()) {
  27     return true;
  28   }
  29   int* const aligned = (int*) align_size_down((intptr_t)p, 4);
  30   int cafebabe = 0xcafebabe;
  31   int deadbeef = 0xdeadbeef;
  32   return (SafeFetch32(aligned, cafebabe) != cafebabe) ||
  33          (SafeFetch32(aligned, deadbeef) != deadbeef);
  34 }
  35 
  36