Skip to content

Commit 981ed1c

Browse files
committed
Consistently return error numbers
Return old thread priority
1 parent 546f150 commit 981ed1c

17 files changed

Lines changed: 129 additions & 124 deletions

File tree

gc/ogc/lwp.h

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ typedef u32 lwpq_t;
101101
\param[in] stack_size size of the provided stack. If 0, the default STACKSIZE of 8Kb is taken.
102102
\param[in] prio priority on which the newly created thread runs.
103103
104-
\return 0 on success, <0 on error
104+
\return 0 on success, non-zero on error
105105
*/
106106
s32 LWP_CreateThread(lwp_t *thethread,void* (*entry)(void *),void *arg,void *stackbase,u32 stack_size,u8 prio);
107107

@@ -110,7 +110,7 @@ s32 LWP_CreateThread(lwp_t *thethread,void* (*entry)(void *),void *arg,void *sta
110110
\brief Suspend the given thread.
111111
\param[in] thethread handle to the thread context which should be suspended.
112112
113-
\return 0 on success, <0 on error
113+
\return 0 on success, non-zero on error
114114
*/
115115
s32 LWP_SuspendThread(lwp_t thethread);
116116

@@ -119,7 +119,7 @@ s32 LWP_SuspendThread(lwp_t thethread);
119119
\brief Resume the given thread.
120120
\param[in] thethread handle to the thread context which should be resumed.
121121
122-
\return 0 on success, <0 on error
122+
\return 0 on success, non-zero on error
123123
*/
124124
s32 LWP_ResumeThread(lwp_t thethread);
125125

@@ -145,19 +145,19 @@ lwp_t LWP_GetSelf(void);
145145
\brief Get the priority of the given thread.
146146
\param[in] thethread handle to the thread context whos priority should be returned. If NULL, the current thread will be taken.
147147
148-
\return 0 on success, <0 on error
148+
\return current thread priority
149149
*/
150150
s32 LWP_GetThreadPriority(lwp_t thethread);
151151

152152

153-
/*! \fn void LWP_SetThreadPriority(lwp_t thethread,u32 prio)
153+
/*! \fn s32 LWP_SetThreadPriority(lwp_t thethread,u32 prio)
154154
\brief Set the priority of the given thread.
155155
\param[in] thethread handle to the thread context whos priority should be changed. If NULL, the current thread will be taken.
156156
\param[in] prio new priority to set
157157
158-
\return none
158+
\return old thread priority
159159
*/
160-
void LWP_SetThreadPriority(lwp_t thethread,u32 prio);
160+
s32 LWP_SetThreadPriority(lwp_t thethread,u32 prio);
161161

162162

163163
/*! \fn void LWP_YieldThread(void)
@@ -182,34 +182,34 @@ void LWP_Reschedule(u32 prio);
182182
\param[in] thethread handle to the thread's context which should be joined to wait on termination.
183183
\param[in] value_ptr pointer-pointer to a variable to receive the return code of the terminated thread.
184184
185-
\return 0 on success, <0 on error
185+
\return 0 on success, non-zero on error
186186
*/
187187
s32 LWP_JoinThread(lwp_t thethread,void **value_ptr);
188188

189189

190-
/*! \fn void LWP_InitQueue(lwpq_t *thequeue)
190+
/*! \fn s32 LWP_InitQueue(lwpq_t *thequeue)
191191
\brief Initialize the thread synchronization queue
192192
\param[in] thequeue pointer to a lwpq_t handle.
193193
194-
\return 0 on success, <0 on error
194+
\return 0 on success, non-zero on error
195195
*/
196196
s32 LWP_InitQueue(lwpq_t *thequeue);
197197

198198

199-
/*! \fn void LWP_CloseQueue(lwpq_t thequeue)
199+
/*! \fn s32 LWP_CloseQueue(lwpq_t thequeue)
200200
\brief Close the thread synchronization queue and releas the handle
201201
\param[in] thequeue handle to the thread's synchronization queue
202202
203-
\return none
203+
\return 0 on success, non-zero on error
204204
*/
205-
void LWP_CloseQueue(lwpq_t thequeue);
205+
s32 LWP_CloseQueue(lwpq_t thequeue);
206206

207207

208208
/*! \fn s32 LWP_ThreadSleep(lwpq_t thequeue)
209209
\brief Pushes the current thread onto the given thread synchronization queue and sets the thread state to blocked.
210210
\param[in] thequeue handle to the thread's synchronization queue to push the thread on
211211
212-
\return 0 on success, <0 on error
212+
\return 0 on success, non-zero on error
213213
*/
214214
s32 LWP_ThreadSleep(lwpq_t thequeue);
215215

@@ -219,27 +219,27 @@ s32 LWP_ThreadSleep(lwpq_t thequeue);
219219
\param[in] thequeue handle to the thread's synchronization queue to push the thread on
220220
\param[in] reltime pointer to a timespec structure holding the relative time for the timeout.
221221
222-
\return 0 on success, <0 on error
222+
\return 0 on success, non-zero on error
223223
*/
224224
s32 LWP_ThreadTimedSleep(lwpq_t thequeue,const struct timespec *reltime);
225225

226226

227-
/*! \fn void LWP_ThreadSignal(lwpq_t thequeue)
227+
/*! \fn s32 LWP_ThreadSignal(lwpq_t thequeue)
228228
\brief Signals one thread to be revmoved from the thread synchronization queue and sets it back to running state.
229229
\param[in] thequeue handle to the thread's synchronization queue to pop the blocked thread off
230230
231-
\return none
231+
\return 0 on success, non-zero on error
232232
*/
233-
void LWP_ThreadSignal(lwpq_t thequeue);
233+
s32 LWP_ThreadSignal(lwpq_t thequeue);
234234

235235

236-
/*! \fn void LWP_ThreadBroadcast(lwpq_t thequeue)
236+
/*! \fn s32 LWP_ThreadBroadcast(lwpq_t thequeue)
237237
\brief Removes all blocked threads from the thread synchronization queue and sets them back to running state.
238238
\param[in] thequeue handle to the thread's synchronization queue to pop the blocked threads off
239239
240-
\return none
240+
\return 0 on success, non-zero on error
241241
*/
242-
void LWP_ThreadBroadcast(lwpq_t thequeue);
242+
s32 LWP_ThreadBroadcast(lwpq_t thequeue);
243243

244244
#ifdef __cplusplus
245245
}

gc/ogc/message.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,6 @@ distribution.
6565

6666
#define MQ_BOX_NULL 0xffffffff
6767

68-
#define MQ_ERROR_SUCCESSFUL 0
69-
#define MQ_ERROR_TOOMANY -5
70-
7168
#define MQ_MSG_BLOCK 0
7269
#define MQ_MSG_NOBLOCK 1
7370

@@ -95,18 +92,18 @@ typedef void* mqmsg_t;
9592
\param[out] mqbox pointer to the mqbox_t handle.
9693
\param[in] count maximum number of messages the queue can hold
9794
98-
\return 0 on success, <0 on error
95+
\return 0 on success, non-zero on error
9996
*/
10097
s32 MQ_Init(mqbox_t *mqbox,u32 count);
10198

10299

103-
/*! \fn void MQ_Close(mqbox_t mqbox)
100+
/*! \fn s32 MQ_Close(mqbox_t mqbox)
104101
\brief Closes the message queue and releases all memory.
105102
\param[in] mqbox handle to the mqbox_t structure.
106103
107-
\return none
104+
\return 0 on success, non-zero on error
108105
*/
109-
void MQ_Close(mqbox_t mqbox);
106+
s32 MQ_Close(mqbox_t mqbox);
110107

111108

112109
/*! \fn BOOL MQ_Send(mqbox_t mqbox,mqmsg_t msg,u32 flags)

gc/ogc/mutex.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ typedef u32 mutex_t;
8282
\param[out] mutex pointer to a mutex_t handle.
8383
\param[in] use_recursive whether to allow the thread, whithin the same context, to enter multiple times the lock or not.
8484
85-
\return 0 on success, <0 on error
85+
\return 0 on success, non-zero on error
8686
*/
8787
s32 LWP_MutexInit(mutex_t *mutex,bool use_recursive);
8888

@@ -91,7 +91,7 @@ s32 LWP_MutexInit(mutex_t *mutex,bool use_recursive);
9191
\brief Close mutex lock, release all threads and handles locked on this mutex.
9292
\param[in] mutex handle to the mutex_t structure.
9393
94-
\return 0 on success, <0 on error
94+
\return 0 on success, non-zero on error
9595
*/
9696
s32 LWP_MutexDestroy(mutex_t mutex);
9797

@@ -100,7 +100,7 @@ s32 LWP_MutexDestroy(mutex_t mutex);
100100
\brief Enter the mutex lock.
101101
\param[in] mutex handle to the mutex_t structure.
102102
103-
\return 0 on success, <0 on error
103+
\return 0 on success, non-zero on error
104104
*/
105105
s32 LWP_MutexLock(mutex_t mutex);
106106

@@ -110,7 +110,7 @@ s32 LWP_MutexLock(mutex_t mutex);
110110
\param[in] mutex handle to the mutex_t structure.
111111
\param[in] reltime pointer to a timespec structure holding the relative time for the timeout.
112112
113-
\return 0 on success, <0 on error
113+
\return 0 on success, non-zero on error
114114
*/
115115
s32 LWP_MutexTimedLock(mutex_t mutex,const struct timespec *reltime);
116116

@@ -119,7 +119,7 @@ s32 LWP_MutexTimedLock(mutex_t mutex,const struct timespec *reltime);
119119
\brief Try to enter the mutex lock.
120120
\param[in] mutex handle to the mutex_t structure.
121121
122-
\return 0: on first aquire, 1: would lock
122+
\return 0 on success, non-zero on error
123123
*/
124124
s32 LWP_MutexTryLock(mutex_t mutex);
125125

@@ -128,7 +128,7 @@ s32 LWP_MutexTryLock(mutex_t mutex);
128128
\brief Release the mutex lock and let other threads process further on this mutex.
129129
\param[in] mutex handle to the mutex_t structure.
130130
131-
\return 0 on success, <0 on error
131+
\return 0 on success, non-zero on error
132132
*/
133133
s32 LWP_MutexUnlock(mutex_t mutex);
134134

gc/ogc/semaphore.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ typedef u32 sem_t;
8383
\param[in] start start count of the semaphore
8484
\param[in] max maximum count of the semaphore
8585
86-
\return 0 on success, <0 on error
86+
\return 0 on success, non-zero on error
8787
*/
8888
s32 LWP_SemInit(sem_t *sem,u32 start,u32 max);
8989

@@ -92,7 +92,7 @@ s32 LWP_SemInit(sem_t *sem,u32 start,u32 max);
9292
\brief Close and destroy a semaphore, release all threads and handles locked on this semaphore.
9393
\param[in] sem handle to the sem_t structure.
9494
95-
\return 0 on success, <0 on error
95+
\return 0 on success, non-zero on error
9696
*/
9797
s32 LWP_SemDestroy(sem_t sem);
9898

@@ -101,7 +101,7 @@ s32 LWP_SemDestroy(sem_t sem);
101101
\brief Count down semaphore counter and enter lock if counter <=0
102102
\param[in] sem handle to the sem_t structure.
103103
104-
\return 0 on success, <0 on error
104+
\return 0 on success, non-zero on error
105105
*/
106106
s32 LWP_SemWait(sem_t sem);
107107

@@ -111,7 +111,7 @@ s32 LWP_SemWait(sem_t sem);
111111
\param[in] sem handle to the sem_t structure.
112112
\param[in] reltime pointer to a timespec structure holding the relative time for the timeout.
113113
114-
\return 0 on success, <0 on error
114+
\return 0 on success, non-zero on error
115115
*/
116116
s32 LWP_SemTimedWait(sem_t sem,const struct timespec *reltime);
117117

@@ -120,7 +120,7 @@ s32 LWP_SemTimedWait(sem_t sem,const struct timespec *reltime);
120120
\brief Count down semaphore counter and try to enter lock if counter <=0
121121
\param[in] sem handle to the sem_t structure.
122122
123-
\return 0 on success, <0 on error
123+
\return 0 on success, non-zero on error
124124
*/
125125
s32 LWP_SemTryWait(sem_t sem);
126126

@@ -129,7 +129,7 @@ s32 LWP_SemTryWait(sem_t sem);
129129
\brief Count up semaphore counter and release lock if counter >0
130130
\param[in] sem handle to the sem_t structure.
131131
132-
\return 0 on success, <0 on error
132+
\return 0 on success, non-zero on error
133133
*/
134134
s32 LWP_SemPost(sem_t sem);
135135

@@ -139,7 +139,7 @@ s32 LWP_SemPost(sem_t sem);
139139
\param[in] sem handle to the sem_t structure.
140140
\param[out] value pointer to receive the current count of the semaphore
141141
142-
\return 0 on success, <0 on error
142+
\return 0 on success, non-zero on error
143143
*/
144144
s32 LWP_SemGetValue(sem_t sem,u32 *value);
145145

gc/ogc/system.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ s8 SYS_GetCoreTemperature(void);
320320
\brief Create/initialize sysalarm structure
321321
\param[in] thealarm pointer to the handle to store the created alarm context identifier
322322
323-
\return 0 on succuess, non-zero on error
323+
\return 0 on success, non-zero on error
324324
*/
325325
s32 SYS_CreateAlarm(syswd_t *thealarm);
326326

@@ -331,7 +331,7 @@ s32 SYS_CreateAlarm(syswd_t *thealarm);
331331
\param[in] tp pointer to timespec structure holding the time to fire the alarm
332332
\param[in] cb pointer to callback which is called when the alarm fires.
333333
334-
\return 0 on succuess, non-zero on error
334+
\return 0 on success, non-zero on error
335335
*/
336336
s32 SYS_SetAlarm(syswd_t thealarm,const struct timespec *tp,alarmcallback cb,void *cbarg);
337337

@@ -343,7 +343,7 @@ s32 SYS_SetAlarm(syswd_t thealarm,const struct timespec *tp,alarmcallback cb,voi
343343
\param[in] tp_period pointer to timespec structure holding the interval for all following alarm triggers.
344344
\param[in] cb pointer to callback which is called when the alarm fires.
345345
346-
\return 0 on succuess, non-zero on error
346+
\return 0 on success, non-zero on error
347347
*/
348348
s32 SYS_SetPeriodicAlarm(syswd_t thealarm,const struct timespec *tp_start,const struct timespec *tp_period,alarmcallback cb,void *cbarg);
349349

@@ -352,7 +352,7 @@ s32 SYS_SetPeriodicAlarm(syswd_t thealarm,const struct timespec *tp_start,const
352352
\brief Remove the given alarm context from the list of contexts and destroy it
353353
\param[in] thealarm identifier to the alarm context to be removed and destroyed
354354
355-
\return 0 on succuess, non-zero on error
355+
\return 0 on success, non-zero on error
356356
*/
357357
s32 SYS_RemoveAlarm(syswd_t thealarm);
358358

@@ -361,7 +361,7 @@ s32 SYS_RemoveAlarm(syswd_t thealarm);
361361
\brief Cancel the alarm, but do not remove from the list of contexts.
362362
\param[in] thealarm identifier to the alram context to be canceled
363363
364-
\return 0 on succuess, non-zero on error
364+
\return 0 on success, non-zero on error
365365
*/
366366
s32 SYS_CancelAlarm(syswd_t thealarm);
367367

libaesnd/aesndmp3player.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ s32 MP3Player_PlayBuffer(const void *buffer,s32 len,void (*filterfunc)(struct ma
8686
mp3cb_data = &rambuffer;
8787
mp3read = _mp3ramcopy;
8888
mp3filterfunc = filterfunc;
89-
if(LWP_CreateThread(&hStreamPlay,StreamPlay,NULL,StreamPlay_Stack,STACKSIZE,80)<0) {
89+
if(LWP_CreateThread(&hStreamPlay,StreamPlay,NULL,StreamPlay_Stack,STACKSIZE,80)!=0) {
9090
return -1;
9191
}
9292
return 0;
@@ -99,7 +99,7 @@ s32 MP3Player_PlayFile(void *cb_data,s32 (*reader)(void *,void *,s32),void (*fil
9999
mp3cb_data = cb_data;
100100
mp3read = reader;
101101
mp3filterfunc = filterfunc;
102-
if(LWP_CreateThread(&hStreamPlay,StreamPlay,NULL,StreamPlay_Stack,STACKSIZE,80)<0) {
102+
if(LWP_CreateThread(&hStreamPlay,StreamPlay,NULL,StreamPlay_Stack,STACKSIZE,80)!=0) {
103103
return -1;
104104
}
105105
return 0;

libasnd/mp3player.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ s32 MP3Player_PlayBuffer(const void *buffer,s32 len,void (*filterfunc)(struct ma
240240
mp3cb_data = &rambuffer;
241241
mp3read = _mp3ramcopy;
242242
mp3filterfunc = filterfunc;
243-
if(LWP_CreateThread(&hStreamPlay,StreamPlay,NULL,StreamPlay_Stack,STACKSIZE,80)<0) {
243+
if(LWP_CreateThread(&hStreamPlay,StreamPlay,NULL,StreamPlay_Stack,STACKSIZE,80)!=0) {
244244
return -1;
245245
}
246246
return 0;
@@ -253,7 +253,7 @@ s32 MP3Player_PlayFile(void *cb_data,s32 (*reader)(void *,void *,s32),void (*fil
253253
mp3cb_data = cb_data;
254254
mp3read = reader;
255255
mp3filterfunc = filterfunc;
256-
if(LWP_CreateThread(&hStreamPlay,StreamPlay,NULL,StreamPlay_Stack,STACKSIZE,80)<0) {
256+
if(LWP_CreateThread(&hStreamPlay,StreamPlay,NULL,StreamPlay_Stack,STACKSIZE,80)!=0) {
257257
return -1;
258258
}
259259
return 0;

libmodplay/gcmodplay.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ static s32 SndBufStart(MODSNDBUF *sndbuf)
153153

154154
curr_audio = 0;
155155
sndPlaying = TRUE;
156-
if(LWP_CreateThread(&hplayer,player,NULL,player_stack,STACKSIZE,80)!=-1) {
156+
if(LWP_CreateThread(&hplayer,player,NULL,player_stack,STACKSIZE,80)==0) {
157157
#ifndef __AESNDLIB_H__
158158
AUDIO_RegisterDMACallback(dmaCallback);
159159
AUDIO_InitDMA((u32)audioBuf[curr_audio],SNDBUFFERSIZE);

0 commit comments

Comments
 (0)