Compare commits
2 commits
67a2839d0a
...
9b339273bb
Author | SHA1 | Date | |
---|---|---|---|
![]() |
9b339273bb | ||
![]() |
fbfb728b8f |
9 changed files with 17 additions and 32 deletions
|
@ -44,7 +44,7 @@ AlignTrailingComments:
|
||||||
AllowAllArgumentsOnNextLine: true
|
AllowAllArgumentsOnNextLine: true
|
||||||
AllowAllParametersOfDeclarationOnNextLine: true
|
AllowAllParametersOfDeclarationOnNextLine: true
|
||||||
AllowBreakBeforeNoexceptSpecifier: Never
|
AllowBreakBeforeNoexceptSpecifier: Never
|
||||||
AllowShortBlocksOnASingleLine: Never
|
AllowShortBlocksOnASingleLine: Empty
|
||||||
AllowShortCaseLabelsOnASingleLine: false
|
AllowShortCaseLabelsOnASingleLine: false
|
||||||
AllowShortCompoundRequirementOnASingleLine: true
|
AllowShortCompoundRequirementOnASingleLine: true
|
||||||
AllowShortEnumsOnASingleLine: true
|
AllowShortEnumsOnASingleLine: true
|
||||||
|
|
|
@ -28,8 +28,7 @@ main()
|
||||||
__sync_synchronize();
|
__sync_synchronize();
|
||||||
started = 1;
|
started = 1;
|
||||||
} else {
|
} else {
|
||||||
while(started == 0)
|
while(started == 0) {}
|
||||||
;
|
|
||||||
__sync_synchronize();
|
__sync_synchronize();
|
||||||
printf("hart %d starting\n", cpuid());
|
printf("hart %d starting\n", cpuid());
|
||||||
kvminithart(); // turn on paging
|
kvminithart(); // turn on paging
|
||||||
|
|
|
@ -123,8 +123,7 @@ panic(char *s)
|
||||||
printf(s);
|
printf(s);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
panicked = 1; // freeze uart output from other CPUs
|
panicked = 1; // freeze uart output from other CPUs
|
||||||
for(;;)
|
for(;;) {}
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -60,9 +60,8 @@ acquire(struct spinlock *lk)
|
||||||
if(holding(lk)) // If the lock is already held, panic.
|
if(holding(lk)) // If the lock is already held, panic.
|
||||||
panic("acquire");
|
panic("acquire");
|
||||||
|
|
||||||
// See file header for details
|
// Spin until aquired. See file header for details
|
||||||
while(__sync_lock_test_and_set(&lk->locked, 1) != 0)
|
while(__sync_lock_test_and_set(&lk->locked, 1) != 0) {}
|
||||||
;
|
|
||||||
__sync_synchronize(); // No loads/stores after this point
|
__sync_synchronize(); // No loads/stores after this point
|
||||||
|
|
||||||
// Record info about lock acquisition for holding() and debugging.
|
// Record info about lock acquisition for holding() and debugging.
|
||||||
|
|
|
@ -73,8 +73,7 @@ strncpy(char *s, const char *t, int n)
|
||||||
char *os;
|
char *os;
|
||||||
|
|
||||||
os = s;
|
os = s;
|
||||||
while(n-- > 0 && (*s++ = *t++) != 0)
|
while(n-- > 0 && (*s++ = *t++) != 0) {}
|
||||||
;
|
|
||||||
while(n-- > 0)
|
while(n-- > 0)
|
||||||
*s++ = 0;
|
*s++ = 0;
|
||||||
return os;
|
return os;
|
||||||
|
@ -89,8 +88,7 @@ safestrcpy(char *s, const char *t, int n)
|
||||||
os = s;
|
os = s;
|
||||||
if(n <= 0)
|
if(n <= 0)
|
||||||
return os;
|
return os;
|
||||||
while(--n > 0 && (*s++ = *t++) != 0)
|
while(--n > 0 && (*s++ = *t++) != 0) {}
|
||||||
;
|
|
||||||
*s = 0;
|
*s = 0;
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
@ -100,7 +98,6 @@ strlen(const char *s)
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
for(n = 0; s[n]; n++)
|
for(n = 0; s[n]; n++) {}
|
||||||
;
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,8 +89,7 @@ uartputc(int c)
|
||||||
acquire(&uart_tx_lock);
|
acquire(&uart_tx_lock);
|
||||||
|
|
||||||
if(panicked) {
|
if(panicked) {
|
||||||
for(;;)
|
for(;;) {}
|
||||||
;
|
|
||||||
}
|
}
|
||||||
while(uart_tx_w == uart_tx_r + UART_TX_BUF_SIZE) {
|
while(uart_tx_w == uart_tx_r + UART_TX_BUF_SIZE) {
|
||||||
// buffer is full.
|
// buffer is full.
|
||||||
|
@ -113,13 +112,11 @@ uartputc_sync(int c)
|
||||||
push_off();
|
push_off();
|
||||||
|
|
||||||
if(panicked) {
|
if(panicked) {
|
||||||
for(;;)
|
for(;;) {}
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// wait for Transmit Holding Empty to be set in LSR.
|
// wait for Transmit Holding Empty to be set in LSR.
|
||||||
while((ReadReg(LSR) & LSR_TX_IDLE) == 0)
|
while((ReadReg(LSR) & LSR_TX_IDLE) == 0) {}
|
||||||
;
|
|
||||||
WriteReg(THR, c);
|
WriteReg(THR, c);
|
||||||
|
|
||||||
pop_off();
|
pop_off();
|
||||||
|
|
|
@ -10,8 +10,7 @@ fmtname(char *path)
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
// Find first character after last slash.
|
// Find first character after last slash.
|
||||||
for(p = path + strlen(path); p >= path && *p != '/'; p--)
|
for(p = path + strlen(path); p >= path && *p != '/'; p--) {}
|
||||||
;
|
|
||||||
p++;
|
p++;
|
||||||
|
|
||||||
// Return blank-padded name.
|
// Return blank-padded name.
|
||||||
|
|
|
@ -20,8 +20,7 @@ strcpy(char *s, const char *t)
|
||||||
char *os;
|
char *os;
|
||||||
|
|
||||||
os = s;
|
os = s;
|
||||||
while((*s++ = *t++) != 0)
|
while((*s++ = *t++) != 0) {}
|
||||||
;
|
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,8 +37,7 @@ strlen(const char *s)
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
for(n = 0; s[n]; n++)
|
for(n = 0; s[n]; n++) {}
|
||||||
;
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -823,8 +823,7 @@ preempt(char *s)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if(pid1 == 0)
|
if(pid1 == 0)
|
||||||
for(;;)
|
for(;;) {}
|
||||||
;
|
|
||||||
|
|
||||||
pid2 = fork();
|
pid2 = fork();
|
||||||
if(pid2 < 0) {
|
if(pid2 < 0) {
|
||||||
|
@ -832,8 +831,7 @@ preempt(char *s)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if(pid2 == 0)
|
if(pid2 == 0)
|
||||||
for(;;)
|
for(;;) {}
|
||||||
;
|
|
||||||
|
|
||||||
pipe(pfds);
|
pipe(pfds);
|
||||||
pid3 = fork();
|
pid3 = fork();
|
||||||
|
@ -846,8 +844,7 @@ preempt(char *s)
|
||||||
if(write(pfds[1], "x", 1) != 1)
|
if(write(pfds[1], "x", 1) != 1)
|
||||||
printf("%s: preempt write error", s);
|
printf("%s: preempt write error", s);
|
||||||
close(pfds[1]);
|
close(pfds[1]);
|
||||||
for(;;)
|
for(;;) {}
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
close(pfds[1]);
|
close(pfds[1]);
|
||||||
|
|
Loading…
Add table
Reference in a new issue