Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) |
| 3 | * Licensed under the GPL |
| 4 | */ |
| 5 | |
| 6 | #ifndef __CHOOSE_MODE_H__ |
| 7 | #define __CHOOSE_MODE_H__ |
| 8 | |
| 9 | #include "uml-config.h" |
| 10 | |
| 11 | #if defined(UML_CONFIG_MODE_TT) && defined(UML_CONFIG_MODE_SKAS) |
| 12 | #define CHOOSE_MODE(tt, skas) (mode_tt ? (tt) : (skas)) |
| 13 | |
Paolo 'Blaisorblade' Giarrusso | 9c340d8 | 2005-04-16 15:25:39 -0700 | [diff] [blame] | 14 | extern int mode_tt; |
| 15 | static inline void *__choose_mode(void *tt, void *skas) { |
| 16 | return mode_tt ? tt : skas; |
| 17 | } |
| 18 | |
| 19 | #define __CHOOSE_MODE(tt, skas) (*( (typeof(tt) *) __choose_mode(&(tt), &(skas)))) |
| 20 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | #elif defined(UML_CONFIG_MODE_SKAS) |
| 22 | #define CHOOSE_MODE(tt, skas) (skas) |
| 23 | |
| 24 | #elif defined(UML_CONFIG_MODE_TT) |
| 25 | #define CHOOSE_MODE(tt, skas) (tt) |
| 26 | #endif |
| 27 | |
| 28 | #define CHOOSE_MODE_PROC(tt, skas, args...) \ |
| 29 | CHOOSE_MODE(tt(args), skas(args)) |
| 30 | |
Paolo 'Blaisorblade' Giarrusso | 9c340d8 | 2005-04-16 15:25:39 -0700 | [diff] [blame] | 31 | #ifndef __CHOOSE_MODE |
| 32 | #define __CHOOSE_MODE(tt, skas) CHOOSE_MODE(tt, skas) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | #endif |
| 34 | |
Paolo 'Blaisorblade' Giarrusso | 9c340d8 | 2005-04-16 15:25:39 -0700 | [diff] [blame] | 35 | #endif |