提交 7614507b 编写于 作者: W wangguibao

Remove dependency ullib

Change-Id: Ic8db85be0231a896beb228393b52107652f94b31
上级 d0ac317c
......@@ -96,7 +96,6 @@ if(WITH_MKLDNN)
list(APPEND EXTERNAL_LIBS ${MKLDNN_LIB})
endif()
add_subdirectory(ullib)
add_subdirectory(configure)
add_subdirectory(mempool)
add_subdirectory(predictor)
......
......@@ -17,17 +17,16 @@ set_source_files_properties(
PROPERTIES
COMPILE_FLAGS "-Wno-strict-aliasing -Wno-unused-variable -Wno-non-virtual-dtor -Wno-error=non-virtual-dtor -Wno-error=delete-non-virtual-dtor")
add_dependencies(pdserving protobuf boost brpc leveldb pdcodegen
configure ullib mempool)
configure mempool)
target_include_directories(pdserving PUBLIC
${CMAKE_CURRENT_LIST_DIR}/
${CMAKE_CURRENT_BINARY_DIR}/
${CMAKE_CURRENT_BINARY_DIR}/../configure
${CMAKE_CURRENT_LIST_DIR}/../configure/include
${CMAKE_CURRENT_LIST_DIR}/../mempool
${CMAKE_CURRENT_LIST_DIR}/../ullib/include)
${CMAKE_CURRENT_LIST_DIR}/../mempool)
target_link_libraries(pdserving
brpc protobuf boost leveldb configure ullib
brpc protobuf boost leveldb configure
mempool -lpthread -lcrypto -lm -lrt -lssl -ldl -lz)
add_executable(pdserving_exe ${pdserving_srcs})
......@@ -36,18 +35,16 @@ set_source_files_properties(
PROPERTIES
COMPILE_FLAGS "-Wno-strict-aliasing -Wno-unused-variable -Wno-non-virtual-dtor -Wno-error=non-virtual-dtor -Wno-error=delete-non-virtual-dtor")
add_dependencies(pdserving_exe
protobuf boost brpc leveldb pdcodegen configure
ullib mempool)
protobuf boost brpc leveldb pdcodegen configure mempool)
target_include_directories(pdserving_exe PUBLIC
${CMAKE_CURRENT_LIST_DIR}/
${CMAKE_CURRENT_BINARY_DIR}/
${CMAKE_CURRENT_BINARY_DIR}/../configure
${CMAKE_CURRENT_LIST_DIR}/../configure/include
${CMAKE_CURRENT_LIST_DIR}/../mempool
${CMAKE_CURRENT_LIST_DIR}/../ullib/include)
${CMAKE_CURRENT_LIST_DIR}/../mempool)
target_link_libraries(pdserving_exe brpc protobuf leveldb
configure ullib mempool -lpthread -lcrypto -lm -lrt -lssl
configure mempool -lpthread -lcrypto -lm -lrt -lssl
-ldl -lz)
add_library(pdclient ${pdclient_srcs})
......@@ -62,7 +59,6 @@ target_include_directories(pdclient PUBLIC
${CMAKE_CURRENT_BINARY_DIR}/
${CMAKE_CURRENT_BINARY_DIR}/../configure
${CMAKE_CURRENT_LIST_DIR}/../configure/include
${CMAKE_CURRENT_LIST_DIR}/../mempool
${CMAKE_CURRENT_LIST_DIR}/../ullib/include)
${CMAKE_CURRENT_LIST_DIR}/../mempool)
target_link_libraries(pdclient protobuf boost brpc -lpthread -lcrypto -lm -lrt -lssl -ldl -lz)
......@@ -7,7 +7,6 @@ target_include_directories(sdk-cpp PUBLIC
${CMKAE_CURRENT_BINARY_DIR}/
${CMAKE_CURRENT_BINARY_DIR}/../configure
${CMAKE_CURRENT_LIST_DIR}/../configure/include
${CMAKE_CURRENT_LIST_DIR}/../ullib/include
)
target_link_libraries(sdk-cpp brpc configure protobuf leveldb)
......@@ -17,7 +16,7 @@ target_include_directories(ximage PUBLIC
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}/../configure
${CMAKE_CURRENT_LIST_DIR}/../configure/include
${CMAKE_CURRENT_LIST_DIR}/../ullib/include)
)
target_link_libraries(ximage sdk-cpp -lpthread -lcrypto -lm -lrt -lssl -ldl
-lz)
......@@ -27,7 +26,7 @@ target_include_directories(mapcnn_dense PUBLIC
${CMAKE_CURRENT_BINARY_DIR}/
${CMAKE_CURRENT_BINARY_DIR}/../configure
${CMAKE_CURRENT_LIST_DIR}/../configure/include
${CMAKE_CURRENT_LIST_DIR}/../ullib/include)
)
target_link_libraries(mapcnn_dense sdk-cpp -lpthread -lcrypto -lm -lrt -lssl
-ldl -lz)
......@@ -37,7 +36,7 @@ target_include_directories(mapcnn_sparse PUBLIC
${CMAKE_CURRENT_BINARY_DIR}/
${CMAKE_CURRENT_BINARY_DIR}/../configure
${CMAKE_CURRENT_LIST_DIR}/../configure/include
${CMAKE_CURRENT_LIST_DIR}/../ullib/include)
)
target_link_libraries(mapcnn_sparse sdk-cpp -lpthread -lcrypto -lm -lrt -lssl
-ldl -lz)
FILE(GLOB ullib_srcs ${CMAKE_CURRENT_LIST_DIR}/src/*.cpp)
add_library(ullib ${ullib_srcs})
include_directories(${CMAKE_CURRENT_LIST_DIR}/include)
/***************************************************************************
*
* Copyright (c) 2008 Baidu.com, Inc. All Rights Reserved
* $Id: ul_error.h,v 1.3 2009/12/29 03:24:00 baonh Exp $
*
**************************************************************************/
/**
* @file ul_error.h
* @author xiaowei(xiaowei@baidu.com)
* @version $Revision: 1.3 $
* @brief
*
**/
#ifndef _UL_ERROR_H
#define _UL_ERROR_H
enum {
UL_SUCCESS = 0, //处理成功
UL_DETAIL_ERR, //细节错误,ul内部将错误信息打印到线程缓冲区去
UL_ALLOC_ERR, //内存分配错误
UL_MEMSEG, //内存越界
UL_READ_ERR, //io读失败
UL_WRITE_ERR, //io写失败
UL_INVALID_FD, //无效的句柄
UL_NETCONNET_ERR, //网络连接失败
UL_INVALID_PARAM, //无效的传入参数
UL_OPEN_FILE_ERR, //打开文件句柄失败
};
/**
* @brief 设置错误号
*
* @param [in] err : int 要设置的错误号代码
* @return int 成功返回0,其他失败
* @retval
* @see
* @author xiaowei
* @date 2007/12/03 21:13:41
**/
int ul_seterrno(int err);
/**
* @brief 获取错误号
*
* @return int 返回错误号代码
* @retval
* @see
* @author xiaowei
* @date 2007/12/03 21:14:21
**/
int ul_geterrno();
/**
* @brief 根据错误号获取错误信息
*
* @return const char* 返回错误号的错误描述
* @param [in] err : int 错误号代号
* @retval
* @see
* @author xiaowei
* @date 2007/12/05 13:56:12
**/
const char *ul_geterrstr(int err);
/**
* @brief 设置错误提示
*
* @param [in] format : const char* 设置错误信息
* @return int 设置成功返回0,其他失败
* @retval
* @see
* @author xiaowei
* @date 2007/12/03 21:14:45
**/
int ul_seterrbuf(const char *format, ...);
/**
* @brief 获取提示信息缓冲区
*
* @return const char* 成功返回出错缓冲区,
* 失败返回""字符串
* 不会返回NULL指针
* @retval
* @see
* @author xiaowei
* @date 2007/12/03 21:15:28
**/
const char *ul_geterrbuf();
#endif
/* vim: set ts=4 sw=4 tw=100 noet: */
/* vim: set ts=4 sw=4 sts=4 tw=100 noet: */
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <limits.h>
#include "ul_error.h"
static const char *g_errstr[] = {
"CALL SUCCESS",
"CALL UL_GETERR(INT ERRNO) TO FIND DETAIL",
"ALLOC MEMORY FAIL",
"MEMORY SEGMENT",
"READ ERR",
"WRITE ERR",
"INVALID FILE[NET] HANDLE",
"NET CONNECT FAIL",
"INVALID INPUT PARAM",
"OPEN FILE ERR",
};
/**
* 线程内部使用的统一错误号
*/
static pthread_key_t g_ulerrno_key = PTHREAD_KEYS_MAX;
static pthread_once_t g_ulerrno_ronce = PTHREAD_ONCE_INIT;
static void
ul_errno_destroy(void *ptr)
{
if (ptr) {
free(ptr);
}
}
static void
ul_errno_runonce()
{
pthread_key_create(&g_ulerrno_key, ul_errno_destroy);
}
static int *
ul_errno_get_ptr()
{
void *ptr = NULL;
pthread_once(&g_ulerrno_ronce, ul_errno_runonce);
ptr = pthread_getspecific(g_ulerrno_key);
if (ptr == NULL) {
ptr = calloc(1, sizeof(int));
pthread_setspecific(g_ulerrno_key, ptr);
}
return (int *) ptr;
}
int
ul_geterrno()
{
int *errno = ul_errno_get_ptr();
if (errno == NULL) {
return 0;
}
return *errno;
}
int
ul_seterrno(int err)
{
int *errno = ul_errno_get_ptr();
if (errno == NULL) {
return -1;
}
*errno = err;
return 0;
}
const char *
ul_geterrstr(int errno)
{
if (errno < 0 || errno >= (int) (sizeof(g_errstr) / sizeof(g_errstr[0]))) {
return "INVALID ERRNO";
}
if (errno == UL_DETAIL_ERR) {
return ul_geterrbuf();
}
return g_errstr[errno];
}
/**
* 线程内部使用的错误缓冲区
*/
static const unsigned int UL_ERRSTR_BUFSIZE = 1024;
static pthread_key_t g_ulerrbuf_key = PTHREAD_KEYS_MAX;
static pthread_once_t g_ulerrbuf_ronce = PTHREAD_ONCE_INIT;
static void
ul_errbuf_destroy(void *ptr)
{
if (ptr) {
free(ptr);
}
}
static void
ul_errbuf_runonce()
{
pthread_key_create(&g_ulerrbuf_key, ul_errbuf_destroy);
}
static char *
ul_errbuf_get_ptr()
{
void *ptr = NULL;
pthread_once(&g_ulerrbuf_ronce, ul_errbuf_runonce);
ptr = pthread_getspecific(g_ulerrbuf_key);
if (ptr == NULL) {
ptr = calloc(UL_ERRSTR_BUFSIZE, sizeof(char));
pthread_setspecific(g_ulerrbuf_key, ptr);
}
return (char *) ptr;
}
const char *
ul_geterrbuf()
{
char *errbuf = ul_errbuf_get_ptr();
if (errbuf == NULL) {
return "";
}
return (const char *) errbuf;
}
int
ul_seterrbuf(const char *format, ...)
{
char *errbuf = ul_errbuf_get_ptr();
if (errbuf == NULL) {
return -1;
}
va_list args;
va_start(args, format);
vsnprintf(errbuf, UL_ERRSTR_BUFSIZE, format, args);
va_end(args);
return 0;
}
//############################################################
//modified by zhangyan04@baidu.com
class GlobalDestroy
{
public:
~GlobalDestroy()
{
void *ptr;
ptr=pthread_getspecific(g_ulerrno_key);
if(ptr){
free(ptr);
pthread_setspecific(g_ulerrno_key, NULL);
}
ptr=pthread_getspecific(g_ulerrbuf_key);
if(ptr){
free(ptr);
pthread_setspecific(g_ulerrbuf_key, NULL);
}
}
};
static GlobalDestroy g_global_destroy;
//############################################################
/* vim: set ts=4 sw=4 tw=100 noet: */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册