X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Futil.c;h=e02f59fb0a0af60d4a71b3c66d297badc86aa924;hb=2c8fcc9cd6a7bbb948f6c79879e89c7ed791c9b1;hp=5e90ecb5093c419432621c0d0b2bb3358ea66967;hpb=aad29cd1a1fb76aa68a9c404a47b66ac516149b5;p=openvswitch diff --git a/lib/util.c b/lib/util.c index 5e90ecb5..e02f59fb 100644 --- a/lib/util.c +++ b/lib/util.c @@ -696,3 +696,32 @@ ctz(uint32_t n) #endif } } + +/* Returns true if the 'n' bytes starting at 'p' are zeros. */ +bool +is_all_zeros(const uint8_t *p, size_t n) +{ + size_t i; + + for (i = 0; i < n; i++) { + if (p[i] != 0x00) { + return false; + } + } + return true; +} + +/* Returns true if the 'n' bytes starting at 'p' are 0xff. */ +bool +is_all_ones(const uint8_t *p, size_t n) +{ + size_t i; + + for (i = 0; i < n; i++) { + if (p[i] != 0xff) { + return false; + } + } + return true; +} +