Introduce clang-format

An automated and opinionated style for code. We can decide to change the
style and have the source updated by the clang-format tool by running:

    make format

I've based the style on the Google style with exceptions to better
match
the current source style.

Change-Id: I43f85c7d4ce02ca999805558b25fcab2e43859c6
diff --git a/inc/alloc.h b/inc/alloc.h
index 4277495..4570b1a 100644
--- a/inc/alloc.h
+++ b/inc/alloc.h
@@ -9,4 +9,4 @@
 void *halloc_aligned(size_t size, size_t align);
 void *halloc_aligned_nosync(size_t size, size_t align);
 
-#endif  /* _ALLOC_H */
+#endif /* _ALLOC_H */
diff --git a/inc/api.h b/inc/api.h
index edc9797..edcd9e5 100644
--- a/inc/api.h
+++ b/inc/api.h
@@ -14,4 +14,4 @@
 int32_t api_vcpu_run(uint32_t vm_idx, uint32_t vcpu_idx, struct vcpu **next);
 struct vcpu *api_wait_for_interrupt(void);
 
-#endif  /* _API_H */
+#endif /* _API_H */
diff --git a/inc/arch.h b/inc/arch.h
index 84624fb..195d149 100644
--- a/inc/arch.h
+++ b/inc/arch.h
@@ -5,4 +5,4 @@
 
 void arch_putchar(char c);
 
-#endif  /* _ARCH_H */
+#endif /* _ARCH_H */
diff --git a/inc/cpio.h b/inc/cpio.h
index cc244ce..a563ae6 100644
--- a/inc/cpio.h
+++ b/inc/cpio.h
@@ -16,7 +16,7 @@
 
 void cpio_init(struct cpio *c, const void *buf, size_t size);
 void cpio_init_iter(struct cpio *c, struct cpio_iter *iter);
-bool cpio_next(struct cpio_iter *iter, const char **name,
-	       const void **contents, size_t *size);
+bool cpio_next(struct cpio_iter *iter, const char **name, const void **contents,
+	       size_t *size);
 
-#endif  /* _CPIO_H */
+#endif /* _CPIO_H */
diff --git a/inc/cpu.h b/inc/cpu.h
index 43bd356..0dc561b 100644
--- a/inc/cpu.h
+++ b/inc/cpu.h
@@ -50,4 +50,4 @@
 void vcpu_on(struct vcpu *v);
 void vcpu_off(struct vcpu *v);
 
-#endif  /* _CPU_H */
+#endif /* _CPU_H */
diff --git a/inc/decl_offsets.h b/inc/decl_offsets.h
index e0da1e8..fbcff34 100644
--- a/inc/decl_offsets.h
+++ b/inc/decl_offsets.h
@@ -2,9 +2,8 @@
 #define _DECL_OFFSETS_H
 
 #define DECL(name, type, field) \
-    const size_t DEFINE_OFFSET__##name = offsetof(type, field)
+	const size_t DEFINE_OFFSET__##name = offsetof(type, field)
 
-#define DECL_SIZE(name, type) \
-    const size_t DEFINE_OFFSET__name = sizeof(type)
+#define DECL_SIZE(name, type) const size_t DEFINE_OFFSET__name = sizeof(type)
 
-#endif  /* _DECL_OFFSETS_H */
+#endif /* _DECL_OFFSETS_H */
diff --git a/inc/dlog.h b/inc/dlog.h
index d4c08c0..fca8103 100644
--- a/inc/dlog.h
+++ b/inc/dlog.h
@@ -9,4 +9,4 @@
 
 void dlog_init(void (*pchar)(char));
 
-#endif  /* _DLOG_H */
+#endif /* _DLOG_H */
diff --git a/inc/fdt.h b/inc/fdt.h
index fcc1716..44d629e 100644
--- a/inc/fdt.h
+++ b/inc/fdt.h
@@ -23,7 +23,7 @@
 bool fdt_read_property(const struct fdt_node *node, const char *name,
 		       const char **buf, uint32_t *size);
 
-void fdt_add_mem_reservation(struct fdt_header *hdr,
-			     uint64_t addr, uint64_t len);
+void fdt_add_mem_reservation(struct fdt_header *hdr, uint64_t addr,
+			     uint64_t len);
 
-#endif  /* _FDT_H */
+#endif /* _FDT_H */
diff --git a/inc/mm.h b/inc/mm.h
index 1af7496..82066cd 100644
--- a/inc/mm.h
+++ b/inc/mm.h
@@ -40,4 +40,4 @@
 bool mm_ptable_unmap(struct mm_ptable *t, vaddr_t begin, vaddr_t end, int mode);
 void mm_ptable_defrag(struct mm_ptable *t);
 
-#endif  /* _MM_H */
+#endif /* _MM_H */
diff --git a/inc/spinlock.h b/inc/spinlock.h
index 7761980..dca3efb 100644
--- a/inc/spinlock.h
+++ b/inc/spinlock.h
@@ -7,7 +7,10 @@
 	atomic_flag v;
 };
 
-#define SPINLOCK_INIT {.v = ATOMIC_FLAG_INIT}
+#define SPINLOCK_INIT                 \
+	{                             \
+		.v = ATOMIC_FLAG_INIT \
+	}
 
 static inline void sl_init(struct spinlock *l)
 {
@@ -16,7 +19,8 @@
 
 static inline void sl_lock(struct spinlock *l)
 {
-	while (atomic_flag_test_and_set_explicit(&l->v, memory_order_acquire));
+	while (atomic_flag_test_and_set_explicit(&l->v, memory_order_acquire))
+		;
 }
 
 static inline void sl_unlock(struct spinlock *l)
@@ -24,4 +28,4 @@
 	atomic_flag_clear_explicit(&l->v, memory_order_release);
 }
 
-#endif  /* _SPINLOCK_H */
+#endif /* _SPINLOCK_H */
diff --git a/inc/std.h b/inc/std.h
index 7c10200..d7cc124 100644
--- a/inc/std.h
+++ b/inc/std.h
@@ -48,10 +48,11 @@
 #define htole32(v) __builtin_bswap32(v)
 #define htole64(v) __builtin_bswap64(v)
 
-#else /* __BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__ && __BYTE_ORDER__ != __ORDER_BIG_ENDIAN__ */
+#else /* __BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__ && \
+	 __BYTE_ORDER__ != __ORDER_BIG_ENDIAN__ */
 
 #error "Unsupported byte order"
 
 #endif
 
-#endif  /* STD_H */
+#endif /* STD_H */
diff --git a/inc/vm.h b/inc/vm.h
index 88ae8ac..eb6a386 100644
--- a/inc/vm.h
+++ b/inc/vm.h
@@ -13,4 +13,4 @@
 void vm_start_vcpu(struct vm *vm, size_t index, size_t entry, size_t arg,
 		   bool is_primary);
 
-#endif  /* _VM_H */
+#endif /* _VM_H */