OLD | NEW |
1 /* | 1 /* |
2 * kernel_compat.h | 2 * kernel_compat.h |
3 * | 3 * |
4 * Compatibility stuff for building in kernel context where standard | 4 * Compatibility stuff for building in kernel context where standard |
5 * C headers and library are not available. | 5 * C headers and library are not available. |
6 * | 6 * |
7 * Marcus Sundberg | 7 * Marcus Sundberg |
8 * Ingate Systems AB | 8 * Ingate Systems AB |
9 */ | 9 */ |
10 /* | 10 /* |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 printk(__VA_ARGS__);\ | 61 printk(__VA_ARGS__);\ |
62 }\ | 62 }\ |
63 }while(0) | 63 }while(0) |
64 | 64 |
65 #define clock() (jiffies) | 65 #define clock() (jiffies) |
66 #define time(x) (jiffies) | 66 #define time(x) (jiffies) |
67 | 67 |
68 /* rand() implementation. */ | 68 /* rand() implementation. */ |
69 #define RAND_MAX 32767 | 69 #define RAND_MAX 32767 |
70 | 70 |
71 static INLINE int rand(void) | 71 static inline int rand(void) |
72 { | 72 { |
73 uint32_t temp; | 73 uint32_t temp; |
74 get_random_bytes(&temp, sizeof(temp)); | 74 get_random_bytes(&temp, sizeof(temp)); |
75 return temp % (RAND_MAX+1); | 75 return temp % (RAND_MAX+1); |
76 } | 76 } |
77 | 77 |
78 /* stdio/stdlib implementation. */ | 78 /* stdio/stdlib implementation. */ |
79 #define printf(...) printk(__VA_ARGS__) | 79 #define printf(...) printk(__VA_ARGS__) |
80 #define exit(n) panic("%s:%d: exit(%d)\n", __FILE__, __LINE__, (n)) | 80 #define exit(n) panic("%s:%d: exit(%d)\n", __FILE__, __LINE__, (n)) |
81 | 81 |
82 #endif /* SRTP_KERNEL_LINUX */ | 82 #endif /* SRTP_KERNEL_LINUX */ |
83 | 83 |
84 #endif /* KERNEL_COMPAT_H */ | 84 #endif /* KERNEL_COMPAT_H */ |
OLD | NEW |