/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira, Inc.
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include "compiler.h"
+#include "openvswitch/types.h"
#ifndef va_copy
#ifdef __va_copy
#define BUILD_ASSERT_DECL_GCCONLY(EXPR) ((void) 0)
#endif
+/* Like the standard assert macro, except:
+ *
+ * - Writes the failure message to the log.
+ *
+ * - Not affected by NDEBUG. */
+#define ovs_assert(CONDITION) \
+ if (!OVS_LIKELY(CONDITION)) { \
+ ovs_assert_failure(SOURCE_LOCATOR, __func__, #CONDITION); \
+ }
+void ovs_assert_failure(const char *, const char *, const char *) NO_RETURN;
+
/* Casts 'pointer' to 'type' and issues a compiler warning if the cast changes
* anything other than an outermost "const" or "volatile" qualifier.
*
void ovs_error_valist(int err_no, const char *format, va_list)
PRINTF_FORMAT(2, 0);
const char *ovs_retval_to_string(int);
+const char *ovs_strerror(int);
void ovs_hex_dump(FILE *, const void *, size_t, uintptr_t offset, bool ascii);
bool str_to_int(const char *, int base, int *);
int log_2_floor(uint32_t);
int log_2_ceil(uint32_t);
-int popcount(uint32_t);
+unsigned int popcount(uint32_t);
/* Returns the rightmost 1-bit in 'x' (e.g. 01011000 => 00001000), or 0 if 'x'
* is 0. */