Remove remaining unnecessary 'volatile' qualifiers

This commit is contained in:
Pawel Dziepak
2013-11-06 00:03:07 +01:00
parent d929eb20ba
commit 73ad2473e7
45 changed files with 69 additions and 68 deletions
+2 -2
View File
@@ -66,7 +66,7 @@ extern void __length_error (const char *);
#endif #endif
#ifdef __HAIKU__ #ifdef __HAIKU__
extern "C" __haiku_int32 atomic_add(volatile __haiku_int32* value, extern "C" __haiku_int32 atomic_add(__haiku_int32* value,
__haiku_int32 addvalue); __haiku_int32 addvalue);
#endif /* __HAIKU__ */ #endif /* __HAIKU__ */
@@ -82,7 +82,7 @@ private:
charT* data () { return reinterpret_cast<charT *>(this + 1); } charT* data () { return reinterpret_cast<charT *>(this + 1); }
charT& operator[] (size_t s) { return data () [s]; } charT& operator[] (size_t s) { return data () [s]; }
#ifdef __HAIKU__ #ifdef __HAIKU__
charT* grab () { if (selfish) return clone (); atomic_add((volatile __haiku_int32*) &ref, 1); return data (); } charT* grab () { if (selfish) return clone (); atomic_add((__haiku_int32*) &ref, 1); return data (); }
void release() { if (atomic_add((__haiku_int32*) &ref, -1) == 1) delete this; } void release() { if (atomic_add((__haiku_int32*) &ref, -1) == 1) delete this; }
#else #else
charT* grab () { if (selfish) return clone (); ++ref; return data (); } charT* grab () { if (selfish) return clone (); ++ref; return data (); }
+1 -1
View File
@@ -113,7 +113,7 @@ private:
private: private:
bool fStarted; bool fStarted;
area_id fArea; area_id fArea;
volatile BPrivate::media::TimeSourceTransmit* fBuf; BPrivate::media::TimeSourceTransmit* fBuf;
BPrivate::media::SlaveNodes* fSlaveNodes; BPrivate::media::SlaveNodes* fSlaveNodes;
area_id _reserved_area; area_id _reserved_area;
+1 -1
View File
@@ -54,7 +54,7 @@ private:
virtual status_t _Reserved_Renderer_3(int32, void *); virtual status_t _Reserved_Renderer_3(int32, void *);
virtual status_t _Reserved_Renderer_4(int32, void *); virtual status_t _Reserved_Renderer_4(int32, void *);
volatile int32 fRefCount; // How much we're still usefull? int32 fRefCount; // How much we're still usefull?
BGLView* fView; // Never forget who is the boss! BGLView* fView; // Never forget who is the boss!
ulong fOptions; // Keep that tune in memory ulong fOptions; // Keep that tune in memory
BGLDispatcher* fDispatcher; // Our personal OpenGL API call dispatcher BGLDispatcher* fDispatcher; // Our personal OpenGL API call dispatcher
@@ -14,7 +14,7 @@
typedef struct lock { typedef struct lock {
sem_id sem; sem_id sem;
vint32 count; int32 count;
} lock; } lock;
+1 -1
View File
@@ -14,7 +14,7 @@
typedef struct lock { typedef struct lock {
sem_id sem; sem_id sem;
vint32 count; int32 count;
} lock; } lock;
@@ -17,7 +17,7 @@ enum {
}; };
struct messaging_area_header { struct messaging_area_header {
vint32 lock_counter; int32 lock_counter;
int32 size; // set to 0, when area is discarded int32 size; // set to 0, when area is discarded
area_id kernel_area; area_id kernel_area;
area_id next_kernel_area; area_id next_kernel_area;
+1 -1
View File
@@ -47,7 +47,7 @@ typedef struct rw_lock {
struct rw_lock_waiter* waiters; struct rw_lock_waiter* waiters;
spinlock lock; spinlock lock;
thread_id holder; thread_id holder;
vint32 count; int32 count;
int32 owner_count; int32 owner_count;
int16 active_readers; int16 active_readers;
// Only > 0 while a writer is waiting: number // Only > 0 while a writer is waiting: number
+1 -1
View File
@@ -406,7 +406,7 @@ private:
TeamTimeUserTimerList fCPUTimeUserTimers; TeamTimeUserTimerList fCPUTimeUserTimers;
// protected by scheduler lock // protected by scheduler lock
TeamUserTimeUserTimerList fUserTimeUserTimers; TeamUserTimeUserTimerList fUserTimeUserTimers;
vint32 fUserDefinedTimerCount; // accessed atomically int32 fUserDefinedTimerCount; // accessed atomically
}; };
+1 -1
View File
@@ -68,7 +68,7 @@ struct team_debug_info {
thread_id causing_thread; thread_id causing_thread;
// thread that caused the debugger to be attached; -1 for manual // thread that caused the debugger to be attached; -1 for manual
// debugger attachment (or no debugger installed) // debugger attachment (or no debugger installed)
vint32 image_event; int32 image_event;
// counter incremented whenever an image is created/deleted // counter incremented whenever an image is created/deleted
struct ConditionVariable* debugger_changed_condition; struct ConditionVariable* debugger_changed_condition;
+1 -1
View File
@@ -136,7 +136,7 @@ public:
#endif #endif
#if DEBUG_PAGE_ACCESS #if DEBUG_PAGE_ACCESS
vint32 accessing_thread; int32 accessing_thread;
#endif #endif
#if VM_PAGE_ALLOCATION_TRACKING_AVAILABLE #if VM_PAGE_ALLOCATION_TRACKING_AVAILABLE
+2 -2
View File
@@ -17,12 +17,12 @@ struct select_sync;
typedef struct select_info { typedef struct select_info {
struct select_info* next; // next in the object's list struct select_info* next; // next in the object's list
struct select_sync* sync; struct select_sync* sync;
vint32 events; int32 events;
uint16 selected_events; uint16 selected_events;
} select_info; } select_info;
typedef struct select_sync { typedef struct select_sync {
vint32 ref_count; int32 ref_count;
sem_id sem; sem_id sem;
uint32 count; uint32 count;
struct select_info* set; struct select_info* set;
+1 -1
View File
@@ -54,7 +54,7 @@ private:
private: private:
sem_id fSemaphore; sem_id fSemaphore;
vint32 fAtom; int32 fAtom;
_shared_buffer_info fInfos[kMaxBuffers]; _shared_buffer_info fInfos[kMaxBuffers];
int32 fCount; int32 fCount;
+1 -1
View File
@@ -53,7 +53,7 @@ status_t TestForAddonExistence(const char* name, directory_which which,
// Reference counted object // Reference counted object
class Object { class Object {
private: private:
volatile int32 fRefCount; int32 fRefCount;
public: public:
// After construction reference count is 1 // After construction reference count is 1
@@ -151,7 +151,7 @@ struct acpi_ec_cookie {
mutex ec_lock; mutex ec_lock;
int ec_burstactive; int ec_burstactive;
int ec_sci_pending; int ec_sci_pending;
vint32 ec_gencount; int32 ec_gencount;
ConditionVariable ec_condition_var; ConditionVariable ec_condition_var;
int ec_suspending; int ec_suspending;
}; };
@@ -25,7 +25,7 @@ hda_open(const char* name, uint32 flags, void** cookie)
if (controller == NULL) if (controller == NULL)
return ENODEV; return ENODEV;
if (controller->opened != 0) if (atomic_get(&controller->opened) != 0)
return B_BUSY; return B_BUSY;
status_t status = hda_hw_init(controller); status_t status = hda_hw_init(controller);
@@ -65,7 +65,7 @@ struct hda_multi;
*/ */
struct hda_controller { struct hda_controller {
struct pci_info pci_info; struct pci_info pci_info;
vint32 opened; int32 opened;
const char* devfs_path; const char* devfs_path;
area_id regs_area; area_id regs_area;
@@ -97,7 +97,7 @@ virtual status_t ReadMACAddress(ether_address_t *address);
bool fRemoved; bool fRemoved;
bool fHasConnection; bool fHasConnection;
bool fNonBlocking; bool fNonBlocking;
vint32 fInsideNotify; int32 fInsideNotify;
// interface and device infos // interface and device infos
uint16 fFrameSize; uint16 fFrameSize;
@@ -162,7 +162,7 @@ static void _NotifyCallback(void *cookie, int32 status,
bool fHasConnection; bool fHasConnection;
bool fTXBufferFull; bool fTXBufferFull;
bool fNonBlocking; bool fNonBlocking;
vint32 fInsideNotify; int32 fInsideNotify;
// pipes for notifications, data io and tx packet size // pipes for notifications, data io and tx packet size
usb_pipe fNotifyEndpoint; usb_pipe fNotifyEndpoint;
@@ -45,7 +45,7 @@ static void _NotifyCallback(void *cookie, int32 status,
status_t fStatus; status_t fStatus;
bool fOpen; bool fOpen;
bool fRemoved; bool fRemoved;
vint32 fInsideNotify; int32 fInsideNotify;
usb_device fDevice; usb_device fDevice;
uint16 fVendorID; uint16 fVendorID;
uint16 fProductID; uint16 fProductID;
+1 -1
View File
@@ -63,7 +63,7 @@ class Semaphore {
private: private:
sem_id fSemaphore; sem_id fSemaphore;
#ifdef USE_BENAPHORE #ifdef USE_BENAPHORE
vint32 fCount; int32 fCount;
#endif #endif
}; };
@@ -107,7 +107,7 @@ private:
uint32 fRepairCount; uint32 fRepairCount;
mutex fRepairLock; mutex fRepairLock;
vint32 fXID; int32 fXID;
}; };
@@ -179,7 +179,7 @@ WebCamMediaAddOn::FillDefaultFlavorInfo(flavor_info* info)
info->info = "USB Web Camera"; info->info = "USB Web Camera";
info->kinds = B_BUFFER_PRODUCER | B_CONTROLLABLE | B_PHYSICAL_INPUT; info->kinds = B_BUFFER_PRODUCER | B_CONTROLLABLE | B_PHYSICAL_INPUT;
info->flavor_flags = 0;//B_FLAVOR_IS_GLOBAL; info->flavor_flags = 0;//B_FLAVOR_IS_GLOBAL;
info->internal_id = atomic_add((vint32 *)&fInternalIDCounter, 1); info->internal_id = atomic_add((int32*)&fInternalIDCounter, 1);
info->possible_count = 1;//0; info->possible_count = 1;//0;
info->in_format_count = 0; info->in_format_count = 0;
info->in_format_flags = 0; info->in_format_flags = 0;
@@ -21,7 +21,7 @@ class Referenceable {
bool Release(); bool Release();
private: private:
vint32 fReferenceCount; int32 fReferenceCount;
}; };
#endif // REFERENCABLE_H #endif // REFERENCABLE_H
+1 -1
View File
@@ -149,7 +149,7 @@ private:
bool fStarted; // has Start() been called? bool fStarted; // has Start() been called?
sem_id fWaitForThreads; // to exit sem_id fWaitForThreads; // to exit
int32 fN; // the number of used filter threads int32 fN; // the number of used filter threads
volatile int32 fNumberOfThreads; // the current number of FilterThreads int32 fNumberOfThreads; // the current number of FilterThreads
volatile bool fIsRunning; // FilterThreads should process data as long as it is true volatile bool fIsRunning; // FilterThreads should process data as long as it is true
BBitmap* fSrcImage; BBitmap* fSrcImage;
bool fDestImageInitialized; bool fDestImageInitialized;
+1 -1
View File
@@ -86,7 +86,7 @@ private:
CacheList fCacheEntriesByAge; CacheList fCacheEntriesByAge;
QueueMap fQueueMap; QueueMap fQueueMap;
QueueDeque fQueue; QueueDeque fQueue;
vint32 fThreadCount; int32 fThreadCount;
int32 fMaxThreadCount; int32 fMaxThreadCount;
uint64 fBytes; uint64 fBytes;
uint64 fMaxBytes; uint64 fMaxBytes;
+3 -3
View File
@@ -1205,9 +1205,9 @@ TermParse::_ReadParserBuffer()
fBuffer->Unlock(); fBuffer->Unlock();
// wait for new input from pty // wait for new input from pty
if (fReadBufferSize == 0) { if (atomic_get(&fReadBufferSize) == 0) {
status_t status = B_OK; status_t status = B_OK;
while (fReadBufferSize == 0 && status == B_OK) { while (atomic_get(&fReadBufferSize) == 0 && status == B_OK) {
do { do {
status = acquire_sem(fReaderSem); status = acquire_sem(fReaderSem);
} while (status == B_INTERRUPTED); } while (status == B_INTERRUPTED);
@@ -1224,7 +1224,7 @@ TermParse::_ReadParserBuffer()
} }
} }
int32 toRead = fReadBufferSize; int32 toRead = atomic_get(&fReadBufferSize);
if (toRead > ESC_PARSER_BUFFER_SIZE) if (toRead > ESC_PARSER_BUFFER_SIZE)
toRead = ESC_PARSER_BUFFER_SIZE; toRead = ESC_PARSER_BUFFER_SIZE;
+1 -1
View File
@@ -73,7 +73,7 @@ private:
uint fBufferPosition; uint fBufferPosition;
uchar fReadBuffer[READ_BUF_SIZE]; uchar fReadBuffer[READ_BUF_SIZE];
vint32 fReadBufferSize; int32 fReadBufferSize;
uchar fParserBuffer[ESC_PARSER_BUFFER_SIZE]; uchar fParserBuffer[ESC_PARSER_BUFFER_SIZE];
int32 fParserBufferSize; int32 fParserBufferSize;
@@ -463,7 +463,7 @@ int
ieee80211_node_dectestref(struct ieee80211_node* ni) ieee80211_node_dectestref(struct ieee80211_node* ni)
{ {
// atomic_add returns old value // atomic_add returns old value
return atomic_add((vint32*)&ni->ni_refcnt, -1) == 1; return atomic_add((int32*)&ni->ni_refcnt, -1) == 1;
} }
+1 -1
View File
@@ -19,7 +19,7 @@
#endif #endif
static vint32 gID = 1; static int32 gID = 1;
BRawNetBuffer::BRawNetBuffer() BRawNetBuffer::BRawNetBuffer()
+1 -1
View File
@@ -74,7 +74,7 @@ private:
uint32 fBeginHeader[3]; uint32 fBeginHeader[3];
uint32 fEndHeader[3]; uint32 fEndHeader[3];
thread_id fRescanThread; thread_id fRescanThread;
vint32 fRescanRequested; int32 fRescanRequested;
BLocker fRescanLock; BLocker fRescanLock;
}; };
+1 -1
View File
@@ -89,7 +89,7 @@ class PrintServerApp : public BApplication, public FolderListener {
BBitmap *fSelectedIconMini; BBitmap *fSelectedIconMini;
BBitmap *fSelectedIconLarge; BBitmap *fSelectedIconLarge;
#endif #endif
vint32 fReferences; int32 fReferences;
sem_id fHasReferences; sem_id fHasReferences;
Settings *fSettings; Settings *fSettings;
bool fUseConfigWindow; bool fUseConfigWindow;
+1 -1
View File
@@ -110,7 +110,7 @@ private:
// the next job to process // the next job to process
Job* fJob; Job* fJob;
// the current nmber of processing threads // the current nmber of processing threads
vint32 fProcessing; int32 fProcessing;
// stop processing // stop processing
bool fAbort; bool fAbort;
static BObjectList<Printer> sPrinters; static BObjectList<Printer> sPrinters;
@@ -50,7 +50,7 @@ struct MimeSnifferAddonManager::AddonReference {
private: private:
BMimeSnifferAddon* fAddon; BMimeSnifferAddon* fAddon;
vint32 fReferenceCount; int32 fReferenceCount;
}; };
@@ -39,7 +39,7 @@ private:
std::list<RegistrarThread*>::iterator& RemoveThread(std::list<RegistrarThread*>::iterator &i); std::list<RegistrarThread*>::iterator& RemoveThread(std::list<RegistrarThread*>::iterator &i);
std::list<RegistrarThread*> fThreads; std::list<RegistrarThread*> fThreads;
vint32 fThreadCount; int32 fThreadCount;
}; };
#endif // THREAD_MANAGER_H #endif // THREAD_MANAGER_H
@@ -17,8 +17,8 @@
struct X86PagingStructures : DeferredDeletable { struct X86PagingStructures : DeferredDeletable {
phys_addr_t pgdir_phys; phys_addr_t pgdir_phys;
vint32 ref_count; int32 ref_count;
vint32 active_on_cpus; int32 active_on_cpus;
// mask indicating on which CPUs the map is currently used // mask indicating on which CPUs the map is currently used
X86PagingStructures(); X86PagingStructures();
+3 -3
View File
@@ -139,10 +139,10 @@ static int32 sCurrentLine = 0;
static debugger_demangle_module_info* sDemangleModule; static debugger_demangle_module_info* sDemangleModule;
static Thread* sDebuggedThread; static Thread* sDebuggedThread;
static vint32 sInDebugger = 0; static int32 sInDebugger = 0;
static bool sPreviousDprintfState; static bool sPreviousDprintfState;
static volatile bool sHandOverKDL = false; static volatile bool sHandOverKDL = false;
static vint32 sHandOverKDLToCPU = -1; static int32 sHandOverKDLToCPU = -1;
static bool sCPUTrapped[B_MAX_CPU_COUNT]; static bool sCPUTrapped[B_MAX_CPU_COUNT];
@@ -1007,7 +1007,7 @@ hand_over_kernel_debugger()
// hand over to another CPU without us noticing. Since this is only // hand over to another CPU without us noticing. Since this is only
// initiated by the user, it is harmless, though. // initiated by the user, it is harmless, though.
sHandOverKDL = true; sHandOverKDL = true;
while (sHandOverKDLToCPU >= 0) while (atomic_get(&sHandOverKDLToCPU) >= 0)
PAUSE(); PAUSE();
} }
+1 -1
View File
@@ -104,7 +104,7 @@ private:
void _WakeUpLocker(); void _WakeUpLocker();
private: private:
vint32 fFlags; int32 fFlags;
static Bucket sBuckets[kBucketCount]; static Bucket sBuckets[kBucketCount];
}; };
+2 -2
View File
@@ -99,7 +99,7 @@ remove_user_mutex_entry(UserMutexEntry* entry)
static status_t static status_t
user_mutex_lock_locked(vint32* mutex, addr_t physicalAddress, const char* name, user_mutex_lock_locked(int32* mutex, addr_t physicalAddress, const char* name,
uint32 flags, bigtime_t timeout, MutexLocker& locker) uint32 flags, bigtime_t timeout, MutexLocker& locker)
{ {
// mark the mutex locked + waiting // mark the mutex locked + waiting
@@ -148,7 +148,7 @@ user_mutex_lock_locked(vint32* mutex, addr_t physicalAddress, const char* name,
static void static void
user_mutex_unlock_locked(vint32* mutex, addr_t physicalAddress, uint32 flags) user_mutex_unlock_locked(int32* mutex, addr_t physicalAddress, uint32 flags)
{ {
if (UserMutexEntry* entry = sUserMutexTable.Lookup(physicalAddress)) { if (UserMutexEntry* entry = sUserMutexTable.Lookup(physicalAddress)) {
// Someone is waiting -- set the locked flag. It might still be set, // Someone is waiting -- set the locked flag. It might still be set,
+1 -1
View File
@@ -141,7 +141,7 @@ public:
private: private:
char* fName; char* fName;
vint32 fRefCount; int32 fRefCount;
uid_t fUID; uid_t fUID;
gid_t fGID; gid_t fGID;
mode_t fPermissions; mode_t fPermissions;
+2 -2
View File
@@ -631,8 +631,8 @@ static mutex sIpcLock;
static mutex sXsiSemaphoreSetLock; static mutex sXsiSemaphoreSetLock;
static uint32 sGlobalSequenceNumber = 1; static uint32 sGlobalSequenceNumber = 1;
static vint32 sXsiSemaphoreCount = 0; static int32 sXsiSemaphoreCount = 0;
static vint32 sXsiSemaphoreSetCount = 0; static int32 sXsiSemaphoreSetCount = 0;
// #pragma mark - // #pragma mark -
+4 -4
View File
@@ -29,7 +29,7 @@ struct per_cpu_timer_data {
spinlock lock; spinlock lock;
timer* volatile events; timer* volatile events;
timer* volatile current_event; timer* volatile current_event;
vint32 current_event_in_progress; int32 current_event_in_progress;
bigtime_t real_time_offset; bigtime_t real_time_offset;
}; };
@@ -264,7 +264,7 @@ timer_interrupt()
cpuData.events = (timer*)event->next; cpuData.events = (timer*)event->next;
cpuData.current_event = event; cpuData.current_event = event;
cpuData.current_event_in_progress = 1; atomic_set(&cpuData.current_event_in_progress, 1);
release_spinlock(spinlock); release_spinlock(spinlock);
@@ -277,7 +277,7 @@ timer_interrupt()
if (event->hook) if (event->hook)
rc = event->hook(event); rc = event->hook(event);
cpuData.current_event_in_progress = 0; atomic_set(&cpuData.current_event_in_progress, 0);
acquire_spinlock(spinlock); acquire_spinlock(spinlock);
@@ -447,7 +447,7 @@ cancel_timer(timer* event)
if (cpu != smp_get_current_cpu()) { if (cpu != smp_get_current_cpu()) {
spinLocker.Unlock(); spinLocker.Unlock();
while (cpuData.current_event_in_progress == 1) { while (atomic_get(&cpuData.current_event_in_progress) == 1) {
PAUSE(); PAUSE();
} }
} }
+1 -1
View File
@@ -109,7 +109,7 @@ random_value()
unsigned int unsigned int
secure_random_value() secure_random_value()
{ {
static vint32 count = 0; static int32 count = 0;
uint32 data[8]; uint32 data[8];
data[0] = atomic_add(&count, 1); data[0] = atomic_add(&count, 1);
+10 -9
View File
@@ -119,9 +119,9 @@ static page_num_t sNonExistingPages;
static uint64 sIgnoredPages; static uint64 sIgnoredPages;
// pages of physical memory ignored by the boot loader (and thus not // pages of physical memory ignored by the boot loader (and thus not
// available here) // available here)
static vint32 sUnreservedFreePages; static int32 sUnreservedFreePages;
static vint32 sUnsatisfiedPageReservations; static int32 sUnsatisfiedPageReservations;
static vint32 sModifiedTemporaryPages; static int32 sModifiedTemporaryPages;
static ConditionVariable sFreePageCondition; static ConditionVariable sFreePageCondition;
static mutex sPageDeficitLock = MUTEX_INITIALIZER("page deficit"); static mutex sPageDeficitLock = MUTEX_INITIALIZER("page deficit");
@@ -1407,7 +1407,7 @@ static uint32
reserve_some_pages(uint32 count, uint32 dontTouch) reserve_some_pages(uint32 count, uint32 dontTouch)
{ {
while (true) { while (true) {
int32 freePages = sUnreservedFreePages; int32 freePages = atomic_get(&sUnreservedFreePages);
if (freePages <= (int32)dontTouch) if (freePages <= (int32)dontTouch)
return 0; return 0;
@@ -1456,7 +1456,7 @@ static inline void
unreserve_pages(uint32 count) unreserve_pages(uint32 count)
{ {
atomic_add(&sUnreservedFreePages, count); atomic_add(&sUnreservedFreePages, count);
if (sUnsatisfiedPageReservations != 0) if (atomic_get(&sUnsatisfiedPageReservations) != 0)
wake_up_page_reservation_waiters(); wake_up_page_reservation_waiters();
} }
@@ -1744,7 +1744,8 @@ page_scrubber(void *unused)
snooze(100000); // 100ms snooze(100000); // 100ms
if (sFreePageQueue.Count() == 0 if (sFreePageQueue.Count() == 0
|| sUnreservedFreePages < (int32)sFreePagesTarget) { || atomic_get(&sUnreservedFreePages)
< (int32)sFreePagesTarget) {
continue; continue;
} }
@@ -1880,7 +1881,7 @@ private:
uint32 fMaxPages; uint32 fMaxPages;
uint32 fWrapperCount; uint32 fWrapperCount;
uint32 fTransferCount; uint32 fTransferCount;
vint32 fPendingTransfers; int32 fPendingTransfers;
PageWriteWrapper* fWrappers; PageWriteWrapper* fWrappers;
PageWriteTransfer* fTransfers; PageWriteTransfer* fTransfers;
ConditionVariable fAllFinishedCondition; ConditionVariable fAllFinishedCondition;
@@ -2206,7 +2207,7 @@ PageWriterRun::AddPage(vm_page* page)
uint32 uint32
PageWriterRun::Go() PageWriterRun::Go()
{ {
fPendingTransfers = fTransferCount; atomic_set(&fPendingTransfers, fTransferCount);
fAllFinishedCondition.Init(this, "page writer wait for I/O"); fAllFinishedCondition.Init(this, "page writer wait for I/O");
ConditionVariableEntry waitEntry; ConditionVariableEntry waitEntry;
@@ -3005,7 +3006,7 @@ reserve_pages(uint32 count, int priority, bool dontWait)
bool notifyDaemon = sUnsatisfiedPageReservations == 0; bool notifyDaemon = sUnsatisfiedPageReservations == 0;
sUnsatisfiedPageReservations += count; sUnsatisfiedPageReservations += count;
if (sUnreservedFreePages > dontTouch) { if (atomic_get(&sUnreservedFreePages) > dontTouch) {
// the situation changed // the situation changed
sUnsatisfiedPageReservations -= count; sUnsatisfiedPageReservations -= count;
continue; continue;
@@ -19,7 +19,7 @@ extern char _single_threaded;
static inline int static inline int
__compare_and_swap (volatile int32 *p, int oldval, int newval) __compare_and_swap (volatile int32 *p, int oldval, int newval)
{ {
int32 readval = atomic_test_and_set(p, newval, oldval); int32 readval = atomic_test_and_set((int32*)p, newval, oldval);
return (readval == oldval ? 1 : 0); return (readval == oldval ? 1 : 0);
} }
@@ -55,7 +55,7 @@ pthread_once(pthread_once_t* onceControl, void (*initRoutine)(void))
// initRoutine. All following threads will return right away. // initRoutine. All following threads will return right away.
while (true) { while (true) {
int32 value = atomic_test_and_set((vint32*)&onceControl->state, int32 value = atomic_test_and_set((int32*)&onceControl->state,
STATE_INITIALIZING, STATE_UNINITIALIZED); STATE_INITIALIZING, STATE_UNINITIALIZED);
if (value == STATE_INITIALIZED) if (value == STATE_INITIALIZED)
@@ -83,7 +83,7 @@ pthread_once(pthread_once_t* onceControl, void (*initRoutine)(void))
sem_id semaphore = create_sem(0, "pthread once"); sem_id semaphore = create_sem(0, "pthread once");
if (semaphore >= 0) { if (semaphore >= 0) {
// successfully created -- set it // successfully created -- set it
value = atomic_test_and_set((vint32*)&onceControl->state, value = atomic_test_and_set((int32*)&onceControl->state,
semaphore, STATE_INITIALIZING); semaphore, STATE_INITIALIZING);
if (value == STATE_INITIALIZING) if (value == STATE_INITIALIZING)
value = semaphore; value = semaphore;
@@ -93,7 +93,7 @@ pthread_once(pthread_once_t* onceControl, void (*initRoutine)(void))
// Failed to create the semaphore. Can only happen when the // Failed to create the semaphore. Can only happen when the
// system runs out of semaphores, but we can still handle the // system runs out of semaphores, but we can still handle the
// situation gracefully by spinning. // situation gracefully by spinning.
value = atomic_test_and_set((vint32*)&onceControl->state, value = atomic_test_and_set((int32*)&onceControl->state,
STATE_SPINNING, STATE_INITIALIZING); STATE_SPINNING, STATE_INITIALIZING);
if (value == STATE_INITIALIZING) if (value == STATE_INITIALIZING)
value = STATE_SPINNING; value = STATE_SPINNING;