< prev index next >

src/os/aix/vm/misc_aix.cpp

Print this page




  36 
  37 void MiscUtils::free_critsect(MiscUtils::critsect_t* cs) {
  38   const int rc = pthread_mutex_destroy(cs);
  39   assert0(rc == 0);
  40 }
  41 
  42 void MiscUtils::enter_critsect(MiscUtils::critsect_t* cs) {
  43   const int rc = pthread_mutex_lock(cs);
  44   assert0(rc == 0);
  45 }
  46 
  47 void MiscUtils::leave_critsect(MiscUtils::critsect_t* cs) {
  48   const int rc = pthread_mutex_unlock(cs);
  49   assert0(rc == 0);
  50 }
  51 
  52 bool MiscUtils::is_readable_pointer(const void* p) {
  53   if (!CanUseSafeFetch32()) {
  54     return true;
  55   }
  56   int* const aligned = (int*) align_ptr_down(p, 4);
  57   int cafebabe = 0xcafebabe;
  58   int deadbeef = 0xdeadbeef;
  59   return (SafeFetch32(aligned, cafebabe) != cafebabe) ||
  60          (SafeFetch32(aligned, deadbeef) != deadbeef);
  61 }
  62 
  63 


  36 
  37 void MiscUtils::free_critsect(MiscUtils::critsect_t* cs) {
  38   const int rc = pthread_mutex_destroy(cs);
  39   assert0(rc == 0);
  40 }
  41 
  42 void MiscUtils::enter_critsect(MiscUtils::critsect_t* cs) {
  43   const int rc = pthread_mutex_lock(cs);
  44   assert0(rc == 0);
  45 }
  46 
  47 void MiscUtils::leave_critsect(MiscUtils::critsect_t* cs) {
  48   const int rc = pthread_mutex_unlock(cs);
  49   assert0(rc == 0);
  50 }
  51 
  52 bool MiscUtils::is_readable_pointer(const void* p) {
  53   if (!CanUseSafeFetch32()) {
  54     return true;
  55   }
  56   int* const aligned = (int*) align_down(p, 4);
  57   int cafebabe = 0xcafebabe;
  58   int deadbeef = 0xdeadbeef;
  59   return (SafeFetch32(aligned, cafebabe) != cafebabe) ||
  60          (SafeFetch32(aligned, deadbeef) != deadbeef);
  61 }
  62 
  63 
< prev index next >