]> xenbits.xensource.com Git - people/royger/xen-test-framework.git/commitdiff
Introduce macros for basic number manipulation
authorAndrew Cooper <andrew.cooper3@citrix.com>
Sat, 24 Oct 2015 10:17:17 +0000 (11:17 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 2 Dec 2015 10:45:19 +0000 (10:45 +0000)
And sprinkle them through the existing code.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
arch/x86/link.lds.S
include/arch/x86/page.h
include/xtf/asm_macros.h
include/xtf/lib.h
include/xtf/numbers.h [new file with mode: 0644]

index 93e362a21302ba77b06b4bc86719c2c27b5891b4..031e2cd51b43b215378760a5ffd1e8561b11e9d8 100644 (file)
@@ -2,6 +2,8 @@
  * Common linker file for all x86 environments
  */
 
+#include <xtf/numbers.h>
+
 /* Don't clobber the ld directive */
 #undef i386
 
@@ -36,7 +38,7 @@ ENTRY(_start)
 
 SECTIONS
 {
-        . = 0x10000;
+        . = MB(1);
 
         .text : {
                 *(.text)
index 5d9a5f189c68becbfdb45d6745f6caf1cb40a3ed..adb8016ff7aa99d9d00beac21c23c44f41cf3d81 100644 (file)
@@ -1,17 +1,15 @@
 #ifndef XTF_X86_PAGE_H
 #define XTF_X86_PAGE_H
 
+#include <xtf/numbers.h>
+
 /*
  * Nomenclature inherited from Xen.
  */
 
 #define PAGE_SHIFT              12
 
-#ifdef __ASSEMBLY__
-#define PAGE_SIZE               (1 << PAGE_SHIFT)
-#else
-#define PAGE_SIZE               (1L << PAGE_SHIFT)
-#endif
+#define PAGE_SIZE               (_AC(1, L) << PAGE_SHIFT)
 
 #define PAGE_MASK               (~(PAGE_SIZE - 1))
 
index 4f356b2e8e79e787d52d4f728cfb4f4116cc4d5d..4d0092cb1314b91ff502b4cf296a54e19439e17d 100644 (file)
@@ -6,6 +6,8 @@
 #ifndef XTF_ASM_MACROS_H
 #define XTF_ASM_MACROS_H
 
+#include <xtf/numbers.h>
+
 /* Declare data at the architectures width. */
 #if defined(__x86_64__)
 # define _WORD .quad
index fa7d68479b57541a58480d79b47fa7ddd22753fe..86f9f0a0d715a359abba543fc80e01f6c5384d86 100644 (file)
@@ -3,6 +3,7 @@
 
 #include <xtf/types.h>
 #include <xtf/compiler.h>
+#include <xtf/numbers.h>
 
 #include <arch/x86/lib.h>
 
diff --git a/include/xtf/numbers.h b/include/xtf/numbers.h
new file mode 100644 (file)
index 0000000..aa36f40
--- /dev/null
@@ -0,0 +1,35 @@
+/**
+ * @file include/xtf/numbers.h
+ *
+ * Primatives for number manipulation.
+ */
+#ifndef XTF_NUMBERS_H
+#define XTF_NUMBERS_H
+
+/**
+ * Create an integer usable in both C and Assembly, even when @p suf is
+ * needed.
+ */
+#ifdef __ASSEMBLY__
+# define _AC(num, suf) num
+#else
+# define _AC(num, suf) __tok(num, suf)
+# define __tok(a, b)   (a ## b)
+#endif
+
+#define KB(num) (_AC(num, ULL) << 10)
+#define MB(num) (_AC(num, ULL) << 20)
+#define GB(num) (_AC(num, ULL) << 30)
+#define TB(num) (_AC(num, ULL) << 40)
+
+#endif /* XTF_NUMBERS_H */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */