case 0:
VLOG_ABORT("%s: assertion %s failed in %s()",
where, condition, function);
- NOT_REACHED();
+ OVS_NOT_REACHED();
case 1:
fprintf(stderr, "%s: assertion %s failed in %s()",
set_program_name__(const char *argv0, const char *version, const char *date,
const char *time)
{
- const char *slash = strrchr(argv0, '/');
+#ifdef _WIN32
+ char *basename;
+ size_t max_len = strlen(argv0) + 1;
+ if (program_name) {
+ return;
+ }
+ basename = xmalloc(max_len);
+ _splitpath_s(argv0, NULL, 0, NULL, 0, basename, max_len, NULL, 0);
+ assert_single_threaded();
+ program_name = basename;
+#else
+ const char *slash = strrchr(argv0, '/');
assert_single_threaded();
-
program_name = slash ? slash + 1 : argv0;
+#endif
free(program_version);
}
}
-bool
-str_to_uint(const char *s, int base, unsigned int *u)
-{
- return str_to_int(s, base, (int *) u);
-}
-
-bool
-str_to_ulong(const char *s, int base, unsigned long *ul)
-{
- return str_to_long(s, base, (long *) ul);
-}
-
-bool
-str_to_ullong(const char *s, int base, unsigned long long *ull)
-{
- return str_to_llong(s, base, (long long *) ull);
-}
-
/* Converts floating-point string 's' into a double. If successful, stores
* the double in '*d' and returns true; on failure, stores 0 in '*d' and
* returns false.
}
#endif
-#if !(__GNUC__ >= 4 && defined(__corei7))
+#if NEED_COUNT_1BITS_8
#define INIT1(X) \
((((X) & (1 << 0)) != 0) + \
(((X) & (1 << 1)) != 0) + \
case SCAN_INTMAX_T:
case SCAN_PTRDIFF_T:
case SCAN_SIZE_T:
- NOT_REACHED();
+ OVS_NOT_REACHED();
}
return s;
}
/* This is an implementation of the standard sscanf() function, with the
* following exceptions:
*
- * - It returns true if the entire template was successfully scanned and
+ * - It returns true if the entire format was successfully scanned and
* converted, false if any conversion failed.
*
* - The standard doesn't define sscanf() behavior when an out-of-range value
* - %p is not supported.
*/
bool
-ovs_scan(const char *s, const char *template, ...)
+ovs_scan(const char *s, const char *format, ...)
{
const char *const start = s;
bool ok = false;
const char *p;
va_list args;
- va_start(args, template);
- p = template;
+ va_start(args, format);
+ p = format;
while (*p != '\0') {
struct scan_spec spec;
unsigned char c = *p++;
return ok;
}
+#ifdef _WIN32
+\f
+/* Calls FormatMessage() with GetLastError() as an argument. Returns
+ * pointer to a buffer that receives the null-terminated string that specifies
+ * the formatted message and that has to be freed by the caller with
+ * LocalFree(). */
+char *
+ovs_lasterror_to_string(void)
+{
+ char *buffer;
+ FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM
+ | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(), 0,
+ (char *)&buffer, 0, NULL);
+ return buffer;
+}
+#endif