Update README.md
[rpi-open-firmware.git] / lib / common.h
1 #pragma once
2
3 #include "xprintf.h"
4 #include "stdarg.h"
5
6 typedef unsigned long long u64;
7 typedef unsigned long long uint64_t;
8 typedef long long int64_t;
9
10 typedef unsigned int u32;
11 typedef unsigned int uint32_t;
12 typedef int int32_t;
13
14 typedef unsigned short u16;
15 typedef unsigned short uint16_t;
16 typedef short int16_t;
17
18 typedef unsigned char u8;
19 typedef unsigned char uint8_t;
20
21 typedef int bool;
22
23 #define true 1
24 #define false 0
25
26 # define ALWAYS_INLINE __attribute__((always_inline)) inline
27
28 extern void panic(const char* fmt, ...)
29 __attribute__((noreturn))
30 __attribute__ ((format (printf, 1, 2)));
31
32 #define panic_plain(ex, ...) \
33 (panic)(ex, ## __VA_ARGS__)
34 #define __STRINGIFY(x) #x
35 #define LINE_NUMBER(x) __STRINGIFY(x)
36 #define PANIC_LOCATION __FILE__ ":" LINE_NUMBER(__LINE__)
37 #define panic(ex, ...) \
38 (panic)(# ex "@" PANIC_LOCATION, ## __VA_ARGS__)
39
40 #define printf xprintf
41
42 #define _OPEN_SOURCE
43
44 extern void udelay(uint32_t time);
45 extern uint32_t __div64_32(uint64_t *n, uint32_t base);
46
47 #define do_div __div64_32
48
49 /*
50 * this is done like that because clang likes using __builtin_memcpy
51 * which makes LLC choke in a fabulous way.
52 */
53 extern void *__memcpy(void *_dst, const void *_src, unsigned len);
54 #define bcopy(s,d,l) __memcpy(d,s,l)
55 #define memcpy(d,s,l) __memcpy(d,s,l)
This page took 0.072098 seconds and 4 git commands to generate.