Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hack fix the switch-return bug. Think there's a Language.C bug lurking.
- Loading branch information
Showing
4 changed files
with
59 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#ifdef ATOMIC_ALL_NIGHTERS | ||
/* function annotations */ | ||
#define MAY_SLEEP __attribute__((atomic_all_nighters("might_sleep"))) | ||
|
||
/* context-changing annotations */ | ||
#define ENTER_ATOMIC __attribute__((atomic_all_nighters("wont_sleep","force_disable"))) | ||
#define EXIT_ATOMIC __attribute__((atomic_all_nighters("wont_sleep","force_enable"))) | ||
#define ENTER_ATOMIC_NESTED __attribute__((atomic_all_nighters("wont_sleep","enter_nested"))) | ||
#define EXIT_ATOMIC_NESTED __attribute__((atomic_all_nighters("wont_sleep","exit_nested"))) | ||
|
||
#else | ||
#define MAY_SLEEP | ||
#define ENTER_ATOMIC | ||
#define EXIT_ATOMIC | ||
#define ENTER_ATOMIC_NESTED | ||
#define EXIT_ATOMIC_NESTED | ||
#endif | ||
|
||
struct mutex; | ||
struct spinlock; | ||
|
||
void mutex_lock(struct mutex *mp) MAY_SLEEP; | ||
void mutex_unlock(struct mutex *mp) MAY_SLEEP; | ||
|
||
void spin_lock(struct spinlock *sp) ENTER_ATOMIC_NESTED; | ||
void spin_unlock(struct spinlock *sp) EXIT_ATOMIC_NESTED; | ||
|
||
struct spinlock *a; | ||
struct spinlock *b; | ||
struct mutex *m; | ||
|
||
int x; | ||
int y; | ||
int z; | ||
|
||
ENTER_ATOMIC void disable_interrupts(); | ||
EXIT_ATOMIC void enable_interrupts(); | ||
|
||
int EXIT_ATOMIC main() { | ||
// This should fail. | ||
// IGNORE: Apparent bug in Language.C? Putting braces around works. | ||
switch (x) { | ||
case 0: | ||
enable_interrupts(); | ||
return; | ||
} | ||
enable_interrupts(); | ||
return 0; | ||
} |