Skip to content

Commit e1d541f

Browse files
committed
Apply code style
1 parent ab8f1fe commit e1d541f

18 files changed

Lines changed: 378 additions & 345 deletions

src/audio/dos/SDL_dosaudio_sb.c

Lines changed: 106 additions & 104 deletions
Large diffs are not rendered by default.

src/audio/dos/SDL_dosaudio_sb.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
#ifndef SDL_dosaudio_sb_h_
2424
#define SDL_dosaudio_sb_h_
2525

26-
#include "../SDL_sysaudio.h"
2726
#include "../../core/dos/SDL_dos.h"
27+
#include "../SDL_sysaudio.h"
2828

2929
struct SDL_PrivateAudioData
3030
{

src/core/dos/SDL_dos.c

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
void *DOS_AllocateConventionalMemory(const int len, _go32_dpmi_seginfo *seginfo)
2828
{
29-
seginfo->size = (len + 15) / 16; // this is in "paragraphs"
29+
seginfo->size = (len + 15) / 16; // this is in "paragraphs"
3030
if (_go32_dpmi_allocate_dos_memory(seginfo) != 0) {
3131
SDL_OutOfMemory();
3232
return NULL;
@@ -45,14 +45,14 @@ void *DOS_AllocateDMAMemory(const int len, _go32_dpmi_seginfo *seginfo)
4545
// a boundary. This is the standard technique used by Allegro, MIDAS, and
4646
// every other DOS audio library; allocate-check-retry would add complexity
4747
// for zero benefit.
48-
uint8_t *ptr = (uint8_t *) DOS_AllocateConventionalMemory(len * 2, seginfo);
48+
uint8_t *ptr = (uint8_t *)DOS_AllocateConventionalMemory(len * 2, seginfo);
4949
if (!ptr) {
5050
return NULL;
5151
}
5252

5353
// if we're past the end of a page, use the second half of the block.
5454
const uint32_t physical = (seginfo->rm_segment * 16);
55-
if ((physical >> 16) != ((physical+len) >> 16)) {
55+
if ((physical >> 16) != ((physical + len) >> 16)) {
5656
ptr += len;
5757
}
5858
return ptr;
@@ -65,23 +65,24 @@ void DOS_FreeConventionalMemory(_go32_dpmi_seginfo *seginfo)
6565

6666
char *DOS_GetFarPtrCString(const Uint32 segoffset)
6767
{
68-
if (!segoffset) { // let's just treat this as a NULL pointer.
68+
if (!segoffset) { // let's just treat this as a NULL pointer.
6969
return NULL;
7070
}
7171

72-
const unsigned long ofs = (unsigned long) (((segoffset & 0xFFFF0000) >> 12) + (segoffset & 0xFFFF));
72+
const unsigned long ofs = (unsigned long)(((segoffset & 0xFFFF0000) >> 12) + (segoffset & 0xFFFF));
7373
size_t len;
7474

75-
for (len = 0; _farpeekb(_dos_ds, ofs+len) != '\0'; len++) {}
75+
for (len = 0; _farpeekb(_dos_ds, ofs + len) != '\0'; len++) {
76+
}
7677

77-
len++; // null terminator.
78+
len++; // null terminator.
7879
char *retval = SDL_malloc(len);
7980
if (!retval) {
8081
return NULL;
8182
}
8283

8384
for (size_t i = 0; i < len; i++) {
84-
retval[i] = (char) _farpeekb(_dos_ds, ofs+i);
85+
retval[i] = (char)_farpeekb(_dos_ds, ofs + i);
8586
}
8687
return retval;
8788
}
@@ -95,16 +96,16 @@ void DOS_HookInterrupt(int irq, DOS_InterruptHookFn fn, DOS_InterruptHook *hook)
9596
hook->irq = irq;
9697
hook->interrupt_vector = DOS_IRQToVector(irq);
9798
hook->irq_handler_seginfo.pm_selector = _go32_my_cs();
98-
hook->irq_handler_seginfo.pm_offset = (uint32_t) fn;
99+
hook->irq_handler_seginfo.pm_offset = (uint32_t)fn;
99100
_go32_dpmi_get_protected_mode_interrupt_vector(hook->interrupt_vector, &hook->original_irq_handler_seginfo);
100101
_go32_dpmi_chain_protected_mode_interrupt_vector(hook->interrupt_vector, &hook->irq_handler_seginfo);
101102

102103
// enable interrupt on the correct PIC
103104
if (irq > 7) {
104-
outportb(0xA1, inportb(0xA1) & ~(1 << (irq - 8))); // unmask on slave PIC
105-
outportb(0x21, inportb(0x21) & ~(1 << 2)); // ensure cascade (IRQ2) is unmasked
105+
outportb(0xA1, inportb(0xA1) & ~(1 << (irq - 8))); // unmask on slave PIC
106+
outportb(0x21, inportb(0x21) & ~(1 << 2)); // ensure cascade (IRQ2) is unmasked
106107
} else {
107-
outportb(0x21, inportb(0x21) & ~(1 << irq)); // unmask on master PIC
108+
outportb(0x21, inportb(0x21) & ~(1 << irq)); // unmask on master PIC
108109
}
109110
}
110111

@@ -119,9 +120,9 @@ void DOS_UnhookInterrupt(DOS_InterruptHook *hook, bool disable_interrupt)
119120

120121
if (disable_interrupt) {
121122
if (hook->irq > 7) {
122-
outportb(0xA1, inportb(0xA1) | (1 << (hook->irq - 8))); // mask on slave PIC
123+
outportb(0xA1, inportb(0xA1) | (1 << (hook->irq - 8))); // mask on slave PIC
123124
} else {
124-
outportb(0x21, inportb(0x21) | (1 << hook->irq)); // mask on master PIC
125+
outportb(0x21, inportb(0x21) | (1 << hook->irq)); // mask on master PIC
125126
}
126127
}
127128

@@ -138,6 +139,4 @@ void DOS_UnhookInterrupt(DOS_InterruptHook *hook, bool disable_interrupt)
138139
SDL_zerop(hook);
139140
}
140141

141-
142142
#endif // defined(SDL_PLATFORM_DOS)
143-

src/core/dos/SDL_dos.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ extern "C" {
6363
// C pointer usable from protected mode.
6464
SDL_FORCE_INLINE void *DOS_PhysicalToLinear(const Uint32 physical)
6565
{
66-
return (void *) (physical + __djgpp_conventional_base);
66+
return (void *)(physical + __djgpp_conventional_base);
6767
}
6868

6969
SDL_FORCE_INLINE Uint32 DOS_LinearToPhysical(void *linear)
7070
{
71-
return ((Uint32) linear) - __djgpp_conventional_base;
71+
return ((Uint32)linear) - __djgpp_conventional_base;
7272
}
7373

7474
SDL_FORCE_INLINE int DOS_IRQToVector(int irq)
@@ -89,27 +89,27 @@ SDL_FORCE_INLINE void DOS_EnableInterrupts(void)
8989
// Grab a single byte from a segment:offset.
9090
SDL_FORCE_INLINE Uint8 DOS_PeekUint8(const Uint32 segoffset)
9191
{
92-
return (Uint8) _farpeekb(_dos_ds, ((segoffset & 0xFFFF0000) >> 12) + (segoffset & 0xFFFF));
92+
return (Uint8)_farpeekb(_dos_ds, ((segoffset & 0xFFFF0000) >> 12) + (segoffset & 0xFFFF));
9393
}
9494

9595
// Grab a single 16-bit word from a segment:offset.
9696
SDL_FORCE_INLINE Uint16 DOS_PeekUint16(const Uint32 segoffset)
9797
{
98-
return (Uint16) _farpeekw(_dos_ds, ((segoffset & 0xFFFF0000) >> 12) + (segoffset & 0xFFFF));
98+
return (Uint16)_farpeekw(_dos_ds, ((segoffset & 0xFFFF0000) >> 12) + (segoffset & 0xFFFF));
9999
}
100100

101101
// Grab a single 32-bit dword from a segment:offset.
102102
SDL_FORCE_INLINE Uint32 DOS_PeekUint32(const Uint32 segoffset)
103103
{
104-
return (Uint32) _farpeekl(_dos_ds, ((segoffset & 0xFFFF0000) >> 12) + (segoffset & 0xFFFF));
104+
return (Uint32)_farpeekl(_dos_ds, ((segoffset & 0xFFFF0000) >> 12) + (segoffset & 0xFFFF));
105105
}
106106

107107
SDL_FORCE_INLINE void DOS_EndOfInterrupt(int irq)
108108
{
109109
if (irq > 7) {
110-
outportb(0xA0, 0x20); // Send EOI to slave PIC (PIC2) for IRQs 8-15
110+
outportb(0xA0, 0x20); // Send EOI to slave PIC (PIC2) for IRQs 8-15
111111
}
112-
outportb(0x20, 0x20); // Send EOI to master PIC (PIC1) — always needed (cascade)
112+
outportb(0x20, 0x20); // Send EOI to master PIC (PIC1) — always needed (cascade)
113113
}
114114

115115
// Allocate memory under the 640k line; various real mode services and DMA transfers need this.
@@ -131,13 +131,13 @@ typedef struct DOS_InterruptHook
131131
{
132132
DOS_InterruptHookFn fn;
133133
int irq;
134-
int interrupt_vector; // this is the _vector_ number, not the IRQ number!
134+
int interrupt_vector; // this is the _vector_ number, not the IRQ number!
135135
_go32_dpmi_seginfo irq_handler_seginfo;
136136
_go32_dpmi_seginfo original_irq_handler_seginfo;
137137

138138
} DOS_InterruptHook;
139139

140-
void DOS_HookInterrupt(int irq, DOS_InterruptHookFn fn, DOS_InterruptHook *hook); // `irq` is the IRQ number, not the interrupt vector number!
140+
void DOS_HookInterrupt(int irq, DOS_InterruptHookFn fn, DOS_InterruptHook *hook); // `irq` is the IRQ number, not the interrupt vector number!
141141
void DOS_UnhookInterrupt(DOS_InterruptHook *hook, bool disable_interrupt);
142142

143143
// Ends C function definitions when using C++

src/core/dos/SDL_dos_scheduler.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040
// Thread table — static array, no dynamic allocation needed
4141
static DOS_ThreadContext threads[DOS_MAX_THREADS];
42-
static int current_thread = 0; // Index of currently running thread
42+
static int current_thread = 0; // Index of currently running thread
4343
static bool scheduler_initialized = false;
4444

4545
// Find the next runnable thread using round-robin scheduling.
@@ -52,7 +52,7 @@ static int FindNextRunnable(int start)
5252
return idx;
5353
}
5454
}
55-
return -1; // No other thread is runnable
55+
return -1; // No other thread is runnable
5656
}
5757

5858
// Trampoline function that runs on a new thread's stack.
@@ -72,7 +72,8 @@ static void ThreadTrampoline(void)
7272
DOS_ExitThread(result);
7373

7474
// Should never reach here
75-
for (;;) {}
75+
for (;;) {
76+
}
7677
}
7778

7879
void DOS_SchedulerInit(void)
@@ -121,7 +122,7 @@ int DOS_CreateThread(int (*fn)(void *), void *arg, size_t stack_size)
121122
}
122123

123124
if (tid < 0) {
124-
return -1; // No free slots
125+
return -1; // No free slots
125126
}
126127

127128
if (stack_size == 0) {
@@ -161,12 +162,12 @@ int DOS_CreateThread(int (*fn)(void *), void *arg, size_t stack_size)
161162
// Stack grows downward, so SP starts at the top.
162163
// Align to 16 bytes for ABI compliance.
163164
Uint8 *stack_top = (Uint8 *)stack + stack_size;
164-
stack_top = (Uint8 *)((uintptr_t)stack_top & ~0xFUL); // 16-byte align
165+
stack_top = (Uint8 *)((uintptr_t)stack_top & ~0xFUL); // 16-byte align
165166

166167
// Leave room for a fake return address (the trampoline never returns,
167168
// but the ABI expects one on the stack at function entry)
168169
stack_top -= sizeof(void *);
169-
*(void **)stack_top = NULL; // Fake return address
170+
*(void **)stack_top = NULL; // Fake return address
170171

171172
ctx->env[0].__esp = (unsigned long)(uintptr_t)stack_top;
172173
ctx->env[0].__ebp = (unsigned long)(uintptr_t)stack_top;
@@ -186,7 +187,7 @@ void DOS_Yield(void)
186187

187188
int next = FindNextRunnable(current_thread);
188189
if (next < 0) {
189-
return; // No other runnable thread, continue current
190+
return; // No other runnable thread, continue current
190191
}
191192

192193
int prev = current_thread;
@@ -237,7 +238,7 @@ void DOS_ExitThread(int status)
237238
// (This shouldn't happen in practice — the main thread should
238239
// always be runnable or waiting.)
239240
for (;;) {
240-
__asm__ __volatile__("hlt"); // Wait for interrupt before retrying
241+
__asm__ __volatile__("hlt"); // Wait for interrupt before retrying
241242
next = FindNextRunnable(current_thread);
242243
if (next >= 0) {
243244
current_thread = next;
@@ -298,7 +299,7 @@ void DOS_BlockCurrentThread(void)
298299
void DOS_DestroyThread(int thread_id)
299300
{
300301
if (thread_id <= 0 || thread_id >= DOS_MAX_THREADS) {
301-
return; // Can't destroy main thread (0) or invalid IDs
302+
return; // Can't destroy main thread (0) or invalid IDs
302303
}
303304

304305
DOS_ThreadContext *ctx = &threads[thread_id];

src/core/dos/SDL_dos_scheduler.h

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,30 +37,32 @@ extern "C" {
3737
#define DOS_DEFAULT_STACK_SIZE (64 * 1024)
3838

3939
// Thread states
40-
typedef enum {
41-
DOS_THREAD_FREE = 0, // Slot is available
42-
DOS_THREAD_READY, // Runnable
43-
DOS_THREAD_RUNNING, // Currently executing
44-
DOS_THREAD_BLOCKED, // Waiting on a semaphore/mutex
45-
DOS_THREAD_FINISHED // Thread function returned
40+
typedef enum
41+
{
42+
DOS_THREAD_FREE = 0, // Slot is available
43+
DOS_THREAD_READY, // Runnable
44+
DOS_THREAD_RUNNING, // Currently executing
45+
DOS_THREAD_BLOCKED, // Waiting on a semaphore/mutex
46+
DOS_THREAD_FINISHED // Thread function returned
4647
} DOS_ThreadState;
4748

4849
// Per-thread context
49-
typedef struct DOS_ThreadContext {
50-
jmp_buf env; // Saved CPU state for context switch
50+
typedef struct DOS_ThreadContext
51+
{
52+
jmp_buf env; // Saved CPU state for context switch
5153
DOS_ThreadState state;
52-
int id; // Thread ID (index into thread table)
53-
void *stack_base; // malloc'd stack memory
54-
size_t stack_size;
55-
int exit_status; // Return value from thread function
54+
int id; // Thread ID (index into thread table)
55+
void *stack_base; // malloc'd stack memory
56+
size_t stack_size;
57+
int exit_status; // Return value from thread function
5658

5759
// Entry point
58-
int (*entry_fn)(void *);
59-
void *entry_arg;
60+
int (*entry_fn)(void *);
61+
void *entry_arg;
6062

6163
// Join support
62-
volatile bool finished; // Set when thread function returns
63-
int join_waiter; // ID of thread waiting in WaitThread, or -1
64+
volatile bool finished; // Set when thread function returns
65+
int join_waiter; // ID of thread waiting in WaitThread, or -1
6466
} DOS_ThreadContext;
6567

6668
// Initialize the scheduler. Must be called before any thread operations.

src/filesystem/dos/SDL_sysfilesystem.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222

2323
#ifdef SDL_FILESYSTEM_DOS
2424

25-
#include <sys/stat.h>
2625
#include <dir.h>
26+
#include <sys/stat.h>
2727

2828
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2929
// System dependent filesystem routines
@@ -32,7 +32,7 @@
3232

3333
char *SDL_SYS_GetBasePath(void)
3434
{
35-
extern const char *SDL_argv0; // from src/main/dos/SDL_sysmain_runapp.c
35+
extern const char *SDL_argv0; // from src/main/dos/SDL_sysmain_runapp.c
3636
char *searched = searchpath(SDL_argv0);
3737
if (!searched) {
3838
SDL_SetError("argv[0] not found by searchpath");

0 commit comments

Comments
 (0)