mirror of
				https://github.com/open5gs/open5gs.git
				synced 2025-11-03 21:43:25 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			367 lines
		
	
	
		
			8.0 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			367 lines
		
	
	
		
			8.0 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
/* Licensed to the Apache Software Foundation (ASF) under one or more
 | 
						|
 * contributor license agreements.  See the NOTICE file distributed with
 | 
						|
 * this work for additional information regarding copyright ownership.
 | 
						|
 * The ASF licenses this file to You under the Apache License, Version 2.0
 | 
						|
 * (the "License"); you may not use this file except in compliance with
 | 
						|
 * the License.  You may obtain a copy of the License at
 | 
						|
 *
 | 
						|
 *     http://www.apache.org/licenses/LICENSE-2.0
 | 
						|
 *
 | 
						|
 * Unless required by applicable law or agreed to in writing, software
 | 
						|
 * distributed under the License is distributed on an "AS IS" BASIS,
 | 
						|
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
						|
 * See the License for the specific language governing permissions and
 | 
						|
 * limitations under the License.
 | 
						|
 */
 | 
						|
 | 
						|
 | 
						|
#ifndef __CORE_H__
 | 
						|
#define __CORE_H__
 | 
						|
 | 
						|
/* GENERATED FILE WARNING!  DO NOT EDIT core.h
 | 
						|
 *
 | 
						|
 * You must modify core.h.in instead.
 | 
						|
 *
 | 
						|
 * And please, make an effort to stub core.hw and core.hnw in the process.
 | 
						|
 */
 | 
						|
 | 
						|
#ifdef HAVE_CONFIG_H
 | 
						|
#include "config.h"
 | 
						|
#endif
 | 
						|
 | 
						|
/**
 | 
						|
 * @file core.h
 | 
						|
 * @brief CORE Platform Definitions
 | 
						|
 */
 | 
						|
 | 
						|
/**
 | 
						|
 * @defgroup CORE Core Runtime library
 | 
						|
 * @{
 | 
						|
 */
 | 
						|
 | 
						|
#if HAVE_SYS_TYPES_H
 | 
						|
#include <sys/types.h>
 | 
						|
#endif
 | 
						|
 | 
						|
#if defined(__cplusplus) && !defined(__STDC_CONSTANT_MACROS)
 | 
						|
/* C99 7.18.4 requires that stdint.h only exposes INT64_C 
 | 
						|
 * and UINT64_C for C++ implementations if this is defined: */
 | 
						|
#define __STDC_CONSTANT_MACROS
 | 
						|
#endif
 | 
						|
 | 
						|
#if HAVE_CTYPE_H
 | 
						|
#include <ctype.h>
 | 
						|
#endif
 | 
						|
 | 
						|
#if HAVE_ERRNO_H
 | 
						|
#include <errno.h>
 | 
						|
#endif
 | 
						|
 | 
						|
#if HAVE_FCNTL_H
 | 
						|
#include <fcntl.h>
 | 
						|
#endif
 | 
						|
 | 
						|
#if HAVE_NET_IF_H_
 | 
						|
#include <net/if.h>
 | 
						|
#endif
 | 
						|
 | 
						|
#if HAVE_PTHREAD_H
 | 
						|
#include <pthread.h>
 | 
						|
#endif
 | 
						|
 | 
						|
#if HAVE_SIGNAL_H
 | 
						|
#include <signal.h>
 | 
						|
#endif
 | 
						|
 | 
						|
#if HAVE_SEMAPHORE_H
 | 
						|
#include <semaphore.h>
 | 
						|
#endif
 | 
						|
 | 
						|
#if HAVE_STDARG_H
 | 
						|
#include <stdarg.h>
 | 
						|
#endif
 | 
						|
 | 
						|
#if HAVE_STDIO_H
 | 
						|
#include <stdio.h>
 | 
						|
#endif
 | 
						|
 | 
						|
#if HAVE_STDINT_H
 | 
						|
#include <stdint.h>
 | 
						|
#endif
 | 
						|
 | 
						|
#if HAVE_STDLIB_H
 | 
						|
#include <stdlib.h>
 | 
						|
#endif
 | 
						|
 | 
						|
#if HAVE_STRING_H
 | 
						|
#include <string.h>
 | 
						|
#endif
 | 
						|
 | 
						|
#if HAVE_STRINGS_H
 | 
						|
#include <strings.h>
 | 
						|
#endif
 | 
						|
 | 
						|
#if HAVE_TIME_H
 | 
						|
#include <time.h>
 | 
						|
#endif
 | 
						|
 | 
						|
#if HAVE_UNISTD_H
 | 
						|
#include <unistd.h>
 | 
						|
#endif
 | 
						|
 | 
						|
#if HAVE_NET_IF_DL_H
 | 
						|
#include <net/if_dl.h>
 | 
						|
#endif
 | 
						|
 | 
						|
#if HAVE_NETINET_ETHER_H
 | 
						|
#include <netinet/ether.h>
 | 
						|
#endif
 | 
						|
 | 
						|
#if HAVE_NETINET_IN_H
 | 
						|
#include <netinet/in.h>
 | 
						|
#endif
 | 
						|
 | 
						|
#if HAVE_NETINET_SCTP_H
 | 
						|
#include <netinet/sctp.h>
 | 
						|
#endif
 | 
						|
 | 
						|
#if HAVE_SYS_IOCTL_H
 | 
						|
#include <sys/ioctl.h>
 | 
						|
#endif
 | 
						|
 | 
						|
#if HAVE_SYS_PARAM_H
 | 
						|
#include <sys/param.h>
 | 
						|
#endif
 | 
						|
 | 
						|
#if HAVE_SYS_STAT_H
 | 
						|
#include <sys/stat.h>
 | 
						|
#endif
 | 
						|
 | 
						|
#if HAVE_SYS_TIME_H
 | 
						|
#include <sys/time.h>
 | 
						|
#endif
 | 
						|
 | 
						|
#if HAVE_SYS_WAIT_H
 | 
						|
#include <sys/wait.h>
 | 
						|
#endif
 | 
						|
 | 
						|
/* header files for PATH_MAX, _POSIX_PATH_MAX */
 | 
						|
#if HAVE_LIMITS_H
 | 
						|
#include <limits.h>
 | 
						|
#else
 | 
						|
#if HAVE_SYS_SYSLIMITS_H
 | 
						|
#include <sys/syslimits.h>
 | 
						|
#endif
 | 
						|
#endif
 | 
						|
 | 
						|
#if HAVE_SYS_UIO_H
 | 
						|
#include <sys/uio.h>
 | 
						|
#endif
 | 
						|
 | 
						|
#ifdef __cplusplus
 | 
						|
extern "C" {
 | 
						|
#endif
 | 
						|
 | 
						|
/* Typedefs that CORE needs. */
 | 
						|
 | 
						|
typedef  char                   c_int8_t;
 | 
						|
typedef  unsigned char          c_uint8_t;
 | 
						|
 | 
						|
typedef  @short_value@          c_int16_t;
 | 
						|
typedef  unsigned @short_value@ c_uint16_t;
 | 
						|
 | 
						|
typedef  @int_value@            c_int32_t;
 | 
						|
typedef  unsigned @int_value@   c_uint32_t;
 | 
						|
 | 
						|
#define C_SIZEOF_VOIDP @voidp_size@
 | 
						|
 | 
						|
typedef  @long_value@           c_int64_t;
 | 
						|
typedef  unsigned @long_value@  c_uint64_t;
 | 
						|
 | 
						|
#if C_SIZEOF_VOIDP == 8
 | 
						|
typedef  c_uint64_t            	c_uintptr_t;
 | 
						|
typedef  c_int64_t             	c_intptr_t;
 | 
						|
#else
 | 
						|
typedef  c_uint32_t            	c_uintptr_t;
 | 
						|
typedef  c_int32_t             	c_intptr_t;
 | 
						|
#endif
 | 
						|
 | 
						|
/* Mechanisms to properly type numeric literals */
 | 
						|
@int64_literal@
 | 
						|
@uint64_literal@
 | 
						|
 | 
						|
@int64_t_fmt@
 | 
						|
@uint64_t_fmt@
 | 
						|
@uint64_t_hex_fmt@
 | 
						|
 | 
						|
#ifdef INT16_MIN
 | 
						|
#define C_INT16_MIN   INT16_MIN
 | 
						|
#else
 | 
						|
#define C_INT16_MIN   (-0x7fff - 1)
 | 
						|
#endif
 | 
						|
 | 
						|
#ifdef INT16_MAX
 | 
						|
#define C_INT16_MAX  INT16_MAX
 | 
						|
#else
 | 
						|
#define C_INT16_MAX   (0x7fff)
 | 
						|
#endif
 | 
						|
 | 
						|
#ifdef UINT16_MAX
 | 
						|
#define C_UINT16_MAX  UINT16_MAX
 | 
						|
#else
 | 
						|
#define C_UINT16_MAX  (0xffff)
 | 
						|
#endif
 | 
						|
 | 
						|
#ifdef INT32_MIN
 | 
						|
#define C_INT32_MIN   INT32_MIN
 | 
						|
#else
 | 
						|
#define C_INT32_MIN   (-0x7fffffff - 1)
 | 
						|
#endif
 | 
						|
 | 
						|
#ifdef INT32_MAX
 | 
						|
#define C_INT32_MAX  INT32_MAX
 | 
						|
#else
 | 
						|
#define C_INT32_MAX  0x7fffffff
 | 
						|
#endif
 | 
						|
 | 
						|
#ifdef UINT32_MAX
 | 
						|
#define C_UINT32_MAX  UINT32_MAX
 | 
						|
#else
 | 
						|
#define C_UINT32_MAX  (0xffffffffU)
 | 
						|
#endif
 | 
						|
 | 
						|
#ifdef INT64_MIN
 | 
						|
#define C_INT64_MIN   INT64_MIN
 | 
						|
#else
 | 
						|
#define C_INT64_MIN   (C_INT64_C(-0x7fffffffffffffff) - 1)
 | 
						|
#endif
 | 
						|
 | 
						|
#ifdef INT64_MAX
 | 
						|
#define C_INT64_MAX   INT64_MAX
 | 
						|
#else
 | 
						|
#define C_INT64_MAX   C_INT64_C(0x7fffffffffffffff)
 | 
						|
#endif
 | 
						|
 | 
						|
#ifdef UINT64_MAX
 | 
						|
#define C_UINT64_MAX  UINT64_MAX
 | 
						|
#else
 | 
						|
#define C_UINT64_MAX  C_UINT64_C(0xffffffffffffffff)
 | 
						|
#endif
 | 
						|
 | 
						|
/* Definitions that CORE programs need to work properly. */
 | 
						|
 | 
						|
/** 
 | 
						|
 * Thread callbacks from CORE functions must be declared with THREAD_FUNC, 
 | 
						|
 * so that they follow the platform's calling convention.
 | 
						|
 * <PRE>
 | 
						|
 *
 | 
						|
 * void* THREAD_FUNC my_thread_entry_fn(core_thread_t *thd, void *data);
 | 
						|
 *
 | 
						|
 * </PRE>
 | 
						|
 */
 | 
						|
#define THREAD_FUNC
 | 
						|
 | 
						|
/**
 | 
						|
 * The public CORE functions are declared with CORE_DECLARE(), so they may
 | 
						|
 * use the most appropriate calling convention.  Public CORE functions with 
 | 
						|
 * variable arguments must use CORE_DECLARE_NONSTD().
 | 
						|
 *
 | 
						|
 * @remark Both the declaration and implementations must use the same macro.
 | 
						|
 *
 | 
						|
 * <PRE>
 | 
						|
 * CORE_DECLARE(rettype) core_func(args)
 | 
						|
 * </PRE>
 | 
						|
 * @see CORE_DECLARE_NONSTD @see CORE_DECLARE_DATA
 | 
						|
 * @remark Note that when CORE compiles the library itself, it passes the 
 | 
						|
 * symbol -DCORE_DECLARE_EXPORT to the compiler on some platforms (e.g. Win32) 
 | 
						|
 * to export public symbols from the dynamic library build.\n
 | 
						|
 * The user must define the CORE_DECLARE_STATIC when compiling to target
 | 
						|
 * the static CORE library on some platforms (e.g. Win32.)  The public symbols 
 | 
						|
 * are neither exported nor imported when CORE_DECLARE_STATIC is defined.\n
 | 
						|
 * By default, compiling an application and including the CORE public
 | 
						|
 * headers, without defining CORE_DECLARE_STATIC, will prepare the code to be
 | 
						|
 * linked to the dynamic library.
 | 
						|
 */
 | 
						|
#define CORE_DECLARE(type)            type 
 | 
						|
 | 
						|
/**
 | 
						|
 * The public CORE functions using variable arguments are declared with 
 | 
						|
 * CORE_DECLARE_NONSTD(), as they must follow the C language calling convention.
 | 
						|
 * @see CORE_DECLARE @see CORE_DECLARE_DATA
 | 
						|
 * @remark Both the declaration and implementations must use the same macro.
 | 
						|
 * <PRE>
 | 
						|
 *
 | 
						|
 * CORE_DECLARE_NONSTD(rettype) core_func(args, ...);
 | 
						|
 *
 | 
						|
 * </PRE>
 | 
						|
 */
 | 
						|
#define CORE_DECLARE_NONSTD(type)     type
 | 
						|
 | 
						|
/**
 | 
						|
 * The public CORE variables are declared with CORE_DECLARE_DATA.
 | 
						|
 * This assures the appropriate indirection is invoked at compile time.
 | 
						|
 * @see CORE_DECLARE @see CORE_DECLARE_NONSTD
 | 
						|
 * @remark Note that the declaration and implementations use different forms,
 | 
						|
 * but both must include the macro.
 | 
						|
 * 
 | 
						|
 * <PRE>
 | 
						|
 *
 | 
						|
 * extern CORE_DECLARE_DATA type core_variable;\n
 | 
						|
 * CORE_DECLARE_DATA type core_variable = value;
 | 
						|
 *
 | 
						|
 * </PRE>
 | 
						|
 */
 | 
						|
#define CORE_DECLARE_DATA
 | 
						|
 | 
						|
#if defined(PATH_MAX)
 | 
						|
#define C_PATH_MAX       PATH_MAX
 | 
						|
#elif defined(_POSIX_PATH_MAX)
 | 
						|
#define C_PATH_MAX       _POSIX_PATH_MAX
 | 
						|
#else
 | 
						|
#error no decision has been made on C_PATH_MAX for your platform
 | 
						|
#endif
 | 
						|
 | 
						|
/** @} */
 | 
						|
 | 
						|
/* Definitions that only Win32 programs need to compile properly. */
 | 
						|
 | 
						|
#if WORDS_BIGENDIAN
 | 
						|
#define ED2(x1, x2) x1 x2
 | 
						|
#define ED3(x1, x2, x3) x1 x2 x3
 | 
						|
#define ED4(x1, x2, x3, x4) x1 x2 x3 x4
 | 
						|
#define ED5(x1, x2, x3, x4, x5) x1 x2 x3 x4 x5
 | 
						|
#define ED6(x1, x2, x3, x4, x5, x6) x1 x2 x3 x4 x5 x6
 | 
						|
#define ED7(x1, x2, x3, x4, x5, x6, x7) x1 x2 x3 x4 x5 x6 x7
 | 
						|
#define ED8(x1, x2, x3, x4, x5, x6, x7, x8) x1 x2 x3 x4 x5 x6 x7 x8
 | 
						|
#else
 | 
						|
#define ED2(x1, x2) x2 x1
 | 
						|
#define ED3(x1, x2, x3) x3 x2 x1
 | 
						|
#define ED4(x1, x2, x3, x4) x4 x3 x2 x1
 | 
						|
#define ED5(x1, x2, x3, x4, x5) x5 x4 x3 x2 x1
 | 
						|
#define ED6(x1, x2, x3, x4, x5, x6) x6 x5 x4 x3 x2 x1
 | 
						|
#define ED7(x1, x2, x3, x4, x5, x6, x7) x7 x6 x5 x4 x3 x2 x1
 | 
						|
#define ED8(x1, x2, x3, x4, x5, x6, x7, x8) x8 x7 x6 x5 x4 x3 x2 x1
 | 
						|
#endif
 | 
						|
 | 
						|
/** FALSE */
 | 
						|
#ifndef FALSE
 | 
						|
#define FALSE 0
 | 
						|
#endif
 | 
						|
/** TRUE */
 | 
						|
#ifndef TRUE
 | 
						|
#define TRUE (!FALSE)
 | 
						|
#endif
 | 
						|
 | 
						|
/* CORE_ALIGN() is only to be used to align on a power of 2 boundary */
 | 
						|
#define CORE_ALIGN(size, boundary) \
 | 
						|
        (((size) + ((boundary) - 1)) & ~((boundary) - 1))
 | 
						|
 | 
						|
/** Default alignment */
 | 
						|
#define CORE_ALIGN_DEFAULT(size) CORE_ALIGN(size, 4)
 | 
						|
 | 
						|
#ifdef __cplusplus
 | 
						|
}
 | 
						|
#endif
 | 
						|
 | 
						|
#endif /* CORE_H */
 |