This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
tango-tfe/common/include/tfe_utils.h

33 lines
1.1 KiB
C
Raw Normal View History

/*
* @file tfe_utils.h
* This file provides common usage marcos and helper functions.
*/
#pragma once
#include <MESA/MESA_handle_logger.h>
#define TFE_STRING_MAX 2048
#define TFE_SYMBOL_MAX 64
#ifndef TFE_CONFIG_BACKLOG_DEFAULT
#define TFE_CONFIG_BACKLOG_DEFAULT 20
#endif
#define ALLOC(type, number) ((type *)calloc(sizeof(type), number))
#define likely(expr) __builtin_expect((expr), 1)
#define unlikely(expr) __builtin_expect((expr), 0)
#define TFE_LOG_ERROR(handler, fmt, ...) \
do { MESA_handle_runtime_log(handler, RLOG_LV_FATAL, NULL, fmt, ##__VA_ARGS__); } while(0) \
#define TFE_LOG_INFO(handler, fmt, ...) \
do { MESA_handle_runtime_log(handler, RLOG_LV_INFO, NULL, fmt, ##__VA_ARGS__); } while(0) \
#define TFE_LOG_DEBUG(handler, fmt, ...) \
do { MESA_handle_runtime_log(handler, RLOG_LV_DEBUG, NULL, fmt, ##__VA_ARGS__); } while(0) \
int addr_sock_to_layer(struct sockaddr * sock_addr, int sockaddrlen, struct layer_addr * layer_addr);
int addr_layer_to_sock(struct layer_addr * layer_addr, struct sockaddr * sock_addr);
char* tfe_strdup(const char* s);