These are defined in third_party code, but in code that we control, replace these with calls to our COUNT_OF macro.
Change-Id: I862e7a6b240b085b205fd881ce3c0789baadc649 Tested: Built user and tests. Signed-off-by: Dan Cross <[email protected]> --- tests/cs.c | 5 ++--- user/parlib/debug.c | 4 ++-- user/vmm/io.c | 5 +---- user/vmm/vmx.c | 5 +---- 4 files changed, 6 insertions(+), 13 deletions(-) diff --git a/tests/cs.c b/tests/cs.c index d0de3fc..232c731 100644 --- a/tests/cs.c +++ b/tests/cs.c @@ -23,8 +23,7 @@ #include <ndblib/fcallfmt.h> #include <fcall.h> #include <parlib/spinlock.h> - -#define ARRAY_SIZE(x) (sizeof((x))/sizeof((x)[0])) +#include <ros/common.h> enum { @@ -1723,7 +1722,7 @@ genquery(Mfile *mf, char *query) struct ndbtuple *t; struct ndbs s; - n = getfields(query, attr, ARRAY_SIZE(attr), 1, " "); + n = getfields(query, attr, COUNT_OF(attr), 1, " "); if(n == 0) return "bad query"; diff --git a/user/parlib/debug.c b/user/parlib/debug.c index b8c3d8f..46a3e4e 100644 --- a/user/parlib/debug.c +++ b/user/parlib/debug.c @@ -3,6 +3,7 @@ #include <stdio.h> #include <unistd.h> #include <parlib/spinlock.h> +#include <ros/common.h> int akaros_printf(const char *format, ...) { @@ -22,8 +23,7 @@ static const char *blacklist[] = { static bool is_blacklisted(const char *s) { - #define ARRAY_SIZE(x) (sizeof((x))/sizeof((x)[0])) - for (int i = 0; i < ARRAY_SIZE(blacklist); i++) { + for (int i = 0; i < COUNT_OF(blacklist); i++) { if (!strcmp(blacklist[i], s)) return TRUE; } diff --git a/user/vmm/io.c b/user/vmm/io.c index 2a17b97..9e83057 100644 --- a/user/vmm/io.c +++ b/user/vmm/io.c @@ -21,9 +21,6 @@ #include <vmm/sched.h> #include <ros/arch/trapframe.h> -/* nowhere on my linux system. */ -#define ARRAY_SIZE(x) (sizeof((x))/sizeof((x)[0])) - /* crude PCI bus. Just enough to get virtio working. I would rather not add to this. */ struct pciconfig { uint32_t registers[256]; @@ -51,7 +48,7 @@ void regp(uint32_t **reg) *reg = &allones; int devfn = (cf8>>8) & 0xff; //printf("devfn %d\n", devfn); - if (devfn < ARRAY_SIZE(pcibus)) + if (devfn < COUNT_OF(pcibus)) *reg = &pcibus[devfn].registers[(cf8>>2)&0x3f]; //printf("-->regp *reg 0x%lx\n", **reg); } diff --git a/user/vmm/vmx.c b/user/vmm/vmx.c index f742053..cf3e6fa 100644 --- a/user/vmm/vmx.c +++ b/user/vmm/vmx.c @@ -22,9 +22,6 @@ #include <vmm/sched.h> #include <ros/arch/trapframe.h> -/* nowhere on my linux system. */ -#define ARRAY_SIZE(x) (sizeof((x))/sizeof((x)[0])) - char *vmxexit[] = { VMX_EXIT_REASONS }; @@ -36,7 +33,7 @@ void showstatus(FILE *f, struct guest_thread *vm_thread) char *when = shutdown & VMX_EXIT_REASONS_FAILED_VMENTRY ? "entry" : "exit"; shutdown &= ~VMX_EXIT_REASONS_FAILED_VMENTRY; char *reason = "UNKNOWN"; - if (shutdown < ARRAY_SIZE(vmxexit) && vmxexit[shutdown]) + if (shutdown < COUNT_OF(vmxexit) && vmxexit[shutdown]) reason = vmxexit[shutdown]; fprintf(f, "Shutdown: core %d, %s due to %s(0x%x); ret code 0x%x\n", vm_tf->tf_guest_pcoreid, when, reason, shutdown, -- 2.8.0.rc3.226.g39d4020 -- You received this message because you are subscribed to the Google Groups "Akaros" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. For more options, visit https://groups.google.com/d/optout.
