common.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright 2018 C-SKY Microsystems Co., Ltd.
  3. * Copyright (C) 2021 Alibaba Group Holding Limited
  4. * Author: LuChongzhi <chongzhi.lcz@alibaba-inc.com>
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the "License");
  7. * you may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. *
  18. */
  19. #ifndef __COMMON_H__
  20. #define __COMMON_H__
  21. #include <assert.h>
  22. #include <stdint.h>
  23. #include <stdio.h>
  24. #include <stdlib.h>
  25. #include <unistd.h>
  26. #include <errno.h>
  27. #include <string.h>
  28. #include <pthread.h>
  29. #include <semaphore.h>
  30. #include <mcheck.h>
  31. #include <sys/stat.h>
  32. #include <sys/types.h>
  33. #include "common_errno.h"
  34. #include "common_datatype.h"
  35. #include "syslog.h"
  36. #include "list.h"
  37. #define CHECK_RET_RETURN(ret) \
  38. if (ret != 0) { \
  39. LOG_E("failed, ret=%d\n", ret); \
  40. return ret; \
  41. }
  42. #define CHECK_RET_EXIT(ret) \
  43. if (ret != 0) { \
  44. LOG_E("failed, ret=%d\n", ret); \
  45. exit(ret); \
  46. }
  47. #define CHECK_RET_WARNING(ret) \
  48. if (ret != 0) { \
  49. LOG_W("Warning, ret=%d\n", ret); \
  50. }
  51. #define CHECK_POINTER_RETURN(pointer) \
  52. if (pointer == NULL) { \
  53. LOG_E("pointer is NULL\n"); \
  54. return ERRNO_INVALID_PARAMETER; \
  55. }
  56. #endif /* __COMMON_H__ */