Skip to content

Commit 7897233

Browse files
authored
lwp inline refactor (#138)
* `lwp_mutex.h`: remove unnecessary declaration and macro * include inline source files in the other source files that need to use them * remove ifdef inlines from headers remove `-DLIBOGC_INTERNAL` flag from `CFLAGS` in makefile as this is the only thing that it was used for `lwp_states.h`: remove entire `extern` block because this was the only thing in it * `lwp_mutex.inl`: turn `__lwp_mutex_seize` from macro into inline function also include `lwp_threads.h` since it uses `extern lwp_cntrl _thr_executing` * libogc: remove header includes that were just for the inline functions * `Makefile`: add libogc directory to include path allow other libraries to access the inline functions in the `*.inl` files stored there see [this comment](#138 (comment)) in the draft PR * other libraries: remove header includes that were just for the inline functions `lwip/netif/loopif.c`: remove duplicate `#include "lwp_watchdog.h"` apparently its been there the whole time? mostly whitespace around header includes sometimes move include directives around if it makes more sense outside of libogc: change from `"local"` to `<system>` where it made sense to do so --------- Co-authored-by: muff1nOS <[email protected]>
1 parent 5fbff84 commit 7897233

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+183
-117
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ wii
66
gc/ogc/libversion.h
77
*.bz2
88
docs
9-
warn.log
9+
warn.log

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ WIIKEYBLIB := $(LIBDIR)/libwiikeyboard
7676
STUBSLIB := $(LIBDIR)/libgclibstubs
7777

7878
#---------------------------------------------------------------------------------
79-
DEFINCS := -I$(BASEDIR) -I$(BASEDIR)/gc
79+
DEFINCS := -I$(BASEDIR) -I$(BASEDIR)/gc -I$(OGCDIR)
8080
INCLUDES := $(DEFINCS) -I$(BASEDIR)/gc/netif -I$(BASEDIR)/gc/ipv4 \
8181
-I$(BASEDIR)/gc/ogc -I$(BASEDIR)/gc/ogc/machine \
8282
-I$(BASEDIR)/gc/modplay \
@@ -99,7 +99,7 @@ MACHDEP += -DHW_DOL
9999
INCLUDES += -I$(BASEDIR)/cube
100100
endif
101101

102-
CFLAGS := $(FALSE_POSITIVES) -DLIBOGC_INTERNAL -g -O2 -fno-strict-aliasing -Wall $(MACHDEP) $(INCLUDES)
102+
CFLAGS := $(FALSE_POSITIVES) -g -O2 -fno-strict-aliasing -Wall $(MACHDEP) $(INCLUDES)
103103
ASFLAGS := $(MACHDEP) -mregnames -D_LANGUAGE_ASSEMBLY $(INCLUDES)
104104

105105
#---------------------------------------------------------------------------------

gc/ogc/lwp_heap.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,6 @@ void* __lwp_heap_allocate(heap_cntrl *theheap,u32 size);
4949
BOOL __lwp_heap_free(heap_cntrl *theheap,void *ptr);
5050
u32 __lwp_heap_getinfo(heap_cntrl *theheap,heap_iblock *theinfo);
5151

52-
#ifdef LIBOGC_INTERNAL
53-
#include <libogc/lwp_heap.inl>
54-
#endif
55-
5652
#ifdef __cplusplus
5753
}
5854
#endif

gc/ogc/lwp_messages.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,6 @@ u32 __lwpmq_flush(mq_cntrl *mqueue);
6868
u32 __lwpmq_flush_support(mq_cntrl *mqueue);
6969
void __lwpmq_flush_waitthreads(mq_cntrl *mqueue);
7070

71-
#ifdef LIBOGC_INTERNAL
72-
#include <libogc/lwp_messages.inl>
73-
#endif
74-
7571
#ifdef __cplusplus
7672
}
7773
#endif

gc/ogc/lwp_mutex.h

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -46,29 +46,6 @@ u32 __lwp_mutex_surrender(lwp_mutex *mutex);
4646
void __lwp_mutex_seize_irq_blocking(lwp_mutex *mutex,u64 timeout);
4747
void __lwp_mutex_flush(lwp_mutex *mutex,u32 status);
4848

49-
static __inline__ u32 __lwp_mutex_seize_irq_trylock(lwp_mutex *mutex,u32 *isr_level);
50-
51-
#define __lwp_mutex_seize(_mutex_t,_id,_wait,_timeout,_level) \
52-
do { \
53-
if(__lwp_mutex_seize_irq_trylock(_mutex_t,&_level)) { \
54-
if(!_wait) { \
55-
_CPU_ISR_Restore(_level); \
56-
_thr_executing->wait.ret_code = LWP_MUTEX_UNSATISFIED_NOWAIT; \
57-
} else { \
58-
__lwp_threadqueue_csenter(&(_mutex_t)->wait_queue); \
59-
_thr_executing->wait.queue = &(_mutex_t)->wait_queue; \
60-
_thr_executing->wait.id = _id; \
61-
__lwp_thread_dispatchdisable(); \
62-
_CPU_ISR_Restore(_level); \
63-
__lwp_mutex_seize_irq_blocking(_mutex_t,(u64)_timeout); \
64-
} \
65-
} \
66-
} while(0)
67-
68-
#ifdef LIBOGC_INTERNAL
69-
#include <libogc/lwp_mutex.inl>
70-
#endif
71-
7249
#ifdef __cplusplus
7350
}
7451
#endif

gc/ogc/lwp_objmgr.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@ lwp_obj* __lwp_objmgr_get(lwp_objinfo *info,u32 id);
3838
lwp_obj* __lwp_objmgr_getisrdisable(lwp_objinfo *info,u32 id,u32 *p_level);
3939
lwp_obj* __lwp_objmgr_getnoprotection(lwp_objinfo *info,u32 id);
4040

41-
#ifdef LIBOGC_INTERNAL
42-
#include <libogc/lwp_objmgr.inl>
43-
#endif
44-
4541
#ifdef __cplusplus
4642
}
4743
#endif

gc/ogc/lwp_priority.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ extern u32 _prio_bitmap[];
2222

2323
void __lwp_priority_init(void);
2424

25-
#ifdef LIBOGC_INTERNAL
26-
#include <libogc/lwp_priority.inl>
27-
#endif
28-
2925
#ifdef __cplusplus
3026
}
3127
#endif

gc/ogc/lwp_queue.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ void __lwp_queue_append(lwp_queue *,lwp_node *);
3030
void __lwp_queue_extract(lwp_node *);
3131
void __lwp_queue_insert(lwp_node *,lwp_node *);
3232

33-
#ifdef LIBOGC_INTERNAL
34-
#include <libogc/lwp_queue.inl>
35-
#endif
36-
3733
#ifdef __cplusplus
3834
}
3935
#endif

gc/ogc/lwp_sema.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ u32 __lwp_sema_surrender(lwp_sema *sema,u32 id);
3333
u32 __lwp_sema_seize(lwp_sema *sema,u32 id,u32 wait,u64 timeout);
3434
void __lwp_sema_flush(lwp_sema *sema,u32 status);
3535

36-
#ifdef LIBOGC_INTERNAL
37-
#include <libogc/lwp_sema.inl>
38-
#endif
39-
4036
#ifdef __cplusplus
4137
}
4238
#endif

gc/ogc/lwp_stack.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ extern "C" {
1616
u32 __lwp_stack_allocate(lwp_cntrl *,u32);
1717
void __lwp_stack_free(lwp_cntrl *);
1818

19-
#ifdef LIBOGC_INTERNAL
20-
#include <libogc/lwp_stack.inl>
21-
#endif
22-
2319
#ifdef __cplusplus
2420
}
2521
#endif

gc/ogc/lwp_states.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#ifndef ___LWP_STATES_H__
22
#define ___LWP_STATES_H__
33

4-
#include <gctypes.h>
5-
64
#define LWP_STATES_READY 0x00000000
75
#define LWP_STATES_DORMANT 0x00000001
86
#define LWP_STATES_SUSPENDED 0x00000002
@@ -33,16 +31,4 @@
3331
LWP_STATES_WAITING_FOR_PERIOD | LWP_STATES_WAITING_FOR_EVENT | \
3432
LWP_STATES_WAITING_ON_THREADQ | LWP_STATES_INTERRUPTIBLE_BY_SIGNAL)
3533

36-
#ifdef __cplusplus
37-
extern "C" {
38-
#endif
39-
40-
#ifdef LIBOGC_INTERNAL
41-
#include <libogc/lwp_states.inl>
42-
#endif
43-
44-
#ifdef __cplusplus
45-
}
46-
#endif
47-
4834
#endif

gc/ogc/lwp_threadq.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@ void __lwp_threadqueue_extractfifo(lwp_thrqueue *queue,lwp_cntrl *thethread);
2828
void __lwp_threadqueue_extractpriority(lwp_thrqueue *queue,lwp_cntrl *thethread);
2929
u32 __lwp_threadqueue_extractproxy(lwp_cntrl *thethread);
3030

31-
#ifdef LIBOGC_INTERNAL
32-
#include <libogc/lwp_threadq.inl>
33-
#endif
34-
3531
#ifdef __cplusplus
3632
}
3733
#endif

gc/ogc/lwp_threads.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,6 @@ void __lwp_rotate_readyqueue(u32);
9696
void __lwp_thread_delayended(void *);
9797
void __lwp_thread_tickle_timeslice(void *);
9898

99-
#ifdef LIBOGC_INTERNAL
100-
#include <libogc/lwp_threads.inl>
101-
#endif
102-
10399
#ifdef __cplusplus
104100
}
105101
#endif

gc/ogc/lwp_watchdog.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,6 @@ u32 __lwp_wd_remove(lwp_queue *header,wd_cntrl *wd);
9797
void __lwp_wd_tickle(lwp_queue *queue);
9898
void __lwp_wd_adjust(lwp_queue *queue,u32 dir,s64 interval);
9999

100-
#ifdef LIBOGC_INTERNAL
101-
#include <libogc/lwp_watchdog.inl>
102-
#endif
103-
104100
#ifdef __cplusplus
105101
}
106102
#endif

gc/ogc/lwp_wkspace.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ extern heap_cntrl __wkspace_heap;
1212

1313
void __lwp_wkspace_init(u32 size);
1414

15-
#ifdef LIBOGC_INTERNAL
16-
#include <libogc/lwp_wkspace.inl>
17-
#endif
18-
1915
#ifdef __cplusplus
2016
}
2117
#endif

gc/ogc/sys_state.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ extern "C" {
1616

1717
extern u32 _sys_state_curr;
1818

19-
#ifdef LIBOGC_INTERNAL
20-
#include <libogc/sys_state.inl>
21-
#endif
22-
2319
#ifdef __cplusplus
2420
}
2521
#endif

libdb/debug.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@
88
#include "spinlock.h"
99
#include "lwp.h"
1010
#include "lwp_threads.h"
11-
#include "sys_state.h"
1211
#include "context.h"
1312
#include "cache.h"
1413
#include "video.h"
1514
#include "ogcsys.h"
1615

17-
#include "lwp_config.h"
16+
#include "lwp_threads.inl"
1817

1918
#include "tcpip.h"
2019
#include "geckousb.h"

libogc/arqueue.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ distribution.
3636
#include "processor.h"
3737
#include "arqueue.h"
3838

39+
#include "lwp_queue.inl"
40+
3941
//#define _ARQ_DEBUG
4042

4143
static u32 __ARQChunkSize;

libogc/cond.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ distribution.
3737
#include "lwp_config.h"
3838
#include "cond.h"
3939

40+
#include "lwp_objmgr.inl"
41+
#include "lwp_threadq.inl"
42+
#include "lwp_threads.inl"
43+
#include "lwp_watchdog.inl"
44+
4045
#define LWP_OBJTYPE_COND 5
4146

4247
#define LWP_CHECK_COND(hndl) \

libogc/decrementer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ distribution.
3333
#include <stdlib.h>
3434
#include "asm.h"
3535
#include "processor.h"
36-
#include "lwp_threads.h"
37-
#include "lwp_watchdog.h"
3836
#include "context.h"
3937

38+
#include "lwp_watchdog.inl"
39+
4040
//#define _DECEX_DEBUG
4141

4242
#ifdef _DECEX_DEBUG

libogc/dvd.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ distribution.
4646
#include "system.h"
4747
#include "dvd.h"
4848

49+
#include "lwp_queue.inl"
50+
4951
//#define _DVD_DEBUG
5052

5153
#define DVD_BRK (1<<0)

libogc/exi.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ distribution.
3737
#include "spinlock.h"
3838
#include "exi.h"
3939
#include "gcutil.h"
40+
#include "lwp_queue.h"
41+
42+
#include "lwp_queue.inl"
4043

4144
//#define _EXI_DEBUG
4245

libogc/ipc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ distribution.
4646
#include "cache.h"
4747
#include "system.h"
4848
#include "lwp_heap.h"
49-
#include "lwp_wkspace.h"
49+
50+
#include "lwp_wkspace.inl"
5051

5152
//#define DEBUG_IPC
5253

libogc/lwp.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,17 @@ distribution.
3232
#include <errno.h>
3333
#include "asm.h"
3434
#include "processor.h"
35+
#include "lwp.h"
3536
#include "lwp_threadq.h"
3637
#include "lwp_threads.h"
3738
#include "lwp_wkspace.h"
3839
#include "lwp_objmgr.h"
3940
#include "lwp_config.h"
40-
#include "lwp.h"
41+
42+
#include "lwp_objmgr.inl"
43+
#include "lwp_states.inl"
44+
#include "lwp_threadq.inl"
45+
#include "lwp_threads.inl"
4146

4247
#define LWP_OBJTYPE_THREAD 1
4348
#define LWP_OBJTYPE_TQUEUE 2

libogc/lwp_heap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#include <stdlib.h>
22
#include <system.h>
33
#include <processor.h>
4-
#include <sys_state.h>
5-
#include <lwp_config.h>
64

75
#include "lwp_heap.h"
86

7+
#include "lwp_heap.inl"
8+
#include "sys_state.inl"
99

1010
u32 __lwp_heap_init(heap_cntrl *theheap,void *start_addr,u32 size,u32 pg_size)
1111
{

libogc/lwp_heap.inl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#ifndef __LWP_HEAP_INL__
22
#define __LWP_HEAP_INL__
33

4+
#include "lwp_heap.h"
5+
46
static __inline__ heap_block* __lwp_heap_head(heap_cntrl *theheap)
57
{
68
return (heap_block*)&theheap->start;

libogc/lwp_messages.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
#include <stdlib.h>
22
#include "asm.h"
33
#include "lwp_messages.h"
4-
#include "lwp_wkspace.h"
4+
5+
#include "lwp_messages.inl"
6+
#include "lwp_queue.inl"
7+
#include "lwp_threadq.inl"
8+
#include "lwp_wkspace.inl"
59

610
void __lwpmq_msg_insert(mq_cntrl *mqueue,mq_buffercntrl *msg,u32 type)
711
{

libogc/lwp_messages.inl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#ifndef __MESSAGE_INL__
22
#define __MESSAGE_INL__
33

4+
#include "lwp_messages.h"
5+
6+
#include "lwp_queue.inl"
7+
48
static __inline__ void __lwpmq_set_notify(mq_cntrl *mqueue,mq_notifyhandler handler,void *arg)
59
{
610
mqueue->notify_handler = handler;

libogc/lwp_mutex.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#include "asm.h"
22
#include "lwp_mutex.h"
33

4+
#include "lwp_mutex.inl"
5+
#include "lwp_threads.inl"
6+
47
void __lwp_mutex_initialize(lwp_mutex *mutex,lwp_mutex_attr *attrs,u32 init_lock)
58
{
69
mutex->atrrs = *attrs;

0 commit comments

Comments
 (0)