hailo-inference/cpp_inference/c_common.h
2022-03-31 11:10:10 +02:00

51 lines
1.7 KiB
C

/**
* Copyright 2020 (C) Hailo Technologies Ltd.
* All rights reserved.
*
* Hailo Technologies Ltd. ("Hailo") disclaims any warranties, including, but not limited to,
* the implied warranties of merchantability and fitness for a particular purpose.
* This software is provided on an "AS IS" basis, and Hailo has no obligation to provide maintenance,
* support, updates, enhancements, or modifications.
*
* You may use this software in the development of any project.
* You shall not reproduce, modify or distribute this software without prior written permission.
**/
/**
* @ file example_common.h
* Common macros and defines used by Hailort Examples
**/
#ifndef _EXAMPLE_COMMON_H_
#define _EXAMPLE_COMMON_H_
#include <stdio.h>
#include <stdlib.h>
#define FREE(var) \
do { \
if (NULL != (var)) { \
free(var); \
var = NULL; \
} \
} while(0)
#define REQUIRE_ACTION(cond, action, label, ...) \
do { \
if (!(cond)) { \
printf(__VA_ARGS__); \
printf("\n"); \
action; \
goto label; \
} \
} while(0)
#define REQUIRE_SUCCESS(status, label, ...) REQUIRE_ACTION((HAILO_SUCCESS == (status)), , label, __VA_ARGS__)
#define ARRAY_LENGTH(__array) (sizeof((__array)) / sizeof((__array)[0]))
#define NSEC_IN_SEC (1e+9)
#endif /* _EXAMPLE_COMMON_H_ */