types: Use generic type definitions to separate header file
This commit is contained in:
parent
717313c542
commit
95726f7617
|
@ -108,7 +108,7 @@ utils/cpu_feature.h utils/leak_detective.h utils/printf_hook/printf_hook.h \
|
|||
utils/printf_hook/printf_hook_vstr.h utils/printf_hook/printf_hook_builtin.h \
|
||||
utils/parser_helper.h utils/test.h utils/integrity_checker.h utils/process.h \
|
||||
utils/utils/strerror.h utils/compat/windows.h utils/compat/apple.h \
|
||||
utils/utils/atomics.h
|
||||
utils/utils/atomics.h utils/utils/types.h
|
||||
endif
|
||||
|
||||
library.lo : $(top_builddir)/config.status
|
||||
|
|
|
@ -74,27 +74,7 @@
|
|||
#define BUILD_ASSERT_ARRAY(a) \
|
||||
BUILD_ASSERT(!__builtin_types_compatible_p(typeof(a), typeof(&(a)[0])))
|
||||
|
||||
/**
|
||||
* General purpose boolean type.
|
||||
*/
|
||||
#ifdef HAVE_STDBOOL_H
|
||||
# include <stdbool.h>
|
||||
#else
|
||||
# ifndef HAVE__BOOL
|
||||
# define _Bool signed char
|
||||
# endif /* HAVE__BOOL */
|
||||
# define bool _Bool
|
||||
# define false 0
|
||||
# define true 1
|
||||
# define __bool_true_false_are_defined 1
|
||||
#endif /* HAVE_STDBOOL_H */
|
||||
#ifndef FALSE
|
||||
# define FALSE false
|
||||
#endif /* FALSE */
|
||||
#ifndef TRUE
|
||||
# define TRUE true
|
||||
#endif /* TRUE */
|
||||
|
||||
#include "utils/types.h"
|
||||
#include "enum.h"
|
||||
#include "utils/atomics.h"
|
||||
#include "utils/strerror.h"
|
||||
|
@ -433,36 +413,6 @@ static inline void *memset_noop(void *s, int c, size_t n)
|
|||
*/
|
||||
#define TIME_32_BIT_SIGNED_MAX 0x7fffffff
|
||||
|
||||
/**
|
||||
* define some missing fixed width int types on OpenSolaris.
|
||||
* TODO: since the uintXX_t types are defined by the C99 standard we should
|
||||
* probably use those anyway
|
||||
*/
|
||||
#if defined __sun || defined WIN32
|
||||
#include <stdint.h>
|
||||
typedef uint8_t u_int8_t;
|
||||
typedef uint16_t u_int16_t;
|
||||
typedef uint32_t u_int32_t;
|
||||
typedef uint64_t u_int64_t;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_INT128
|
||||
/**
|
||||
* 128 bit wide signed integer, if supported
|
||||
*/
|
||||
typedef __int128 int128_t;
|
||||
/**
|
||||
* 128 bit wide unsigned integer, if supported
|
||||
*/
|
||||
typedef unsigned __int128 u_int128_t;
|
||||
|
||||
# define MAX_INT_TYPE int128_t
|
||||
# define MAX_UINT_TYPE u_int128_t
|
||||
#else
|
||||
# define MAX_INT_TYPE int64_t
|
||||
# define MAX_UINT_TYPE u_int64_t
|
||||
#endif
|
||||
|
||||
typedef enum status_t status_t;
|
||||
|
||||
/**
|
||||
|
@ -575,12 +525,6 @@ enum tty_escape_t {
|
|||
*/
|
||||
char* tty_escape_get(int fd, tty_escape_t escape);
|
||||
|
||||
/**
|
||||
* deprecated pluto style return value:
|
||||
* error message, NULL for success
|
||||
*/
|
||||
typedef const char *err_t;
|
||||
|
||||
/**
|
||||
* Handle struct timeval like an own type.
|
||||
*/
|
||||
|
@ -591,11 +535,6 @@ typedef struct timeval timeval_t;
|
|||
*/
|
||||
typedef struct timespec timespec_t;
|
||||
|
||||
/**
|
||||
* Handle struct chunk_t like an own type.
|
||||
*/
|
||||
typedef struct sockaddr sockaddr_t;
|
||||
|
||||
/**
|
||||
* malloc(), but returns aligned memory.
|
||||
*
|
||||
|
|
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
* Copyright (C) 2008-2014 Tobias Brunner
|
||||
* Copyright (C) 2008 Martin Willi
|
||||
* Hochschule fuer Technik Rapperswil
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup types_i types
|
||||
* @{ @ingroup utils_i
|
||||
*/
|
||||
|
||||
#ifndef TYPES_H_
|
||||
#define TYPES_H_
|
||||
|
||||
/**
|
||||
* General purpose boolean type.
|
||||
*/
|
||||
#ifdef HAVE_STDBOOL_H
|
||||
# include <stdbool.h>
|
||||
#else
|
||||
# ifndef HAVE__BOOL
|
||||
# define _Bool signed char
|
||||
# endif /* HAVE__BOOL */
|
||||
# define bool _Bool
|
||||
# define false 0
|
||||
# define true 1
|
||||
# define __bool_true_false_are_defined 1
|
||||
#endif /* HAVE_STDBOOL_H */
|
||||
#ifndef FALSE
|
||||
# define FALSE false
|
||||
#endif /* FALSE */
|
||||
#ifndef TRUE
|
||||
# define TRUE true
|
||||
#endif /* TRUE */
|
||||
|
||||
/**
|
||||
* define some missing fixed width int types on OpenSolaris.
|
||||
* TODO: since the uintXX_t types are defined by the C99 standard we should
|
||||
* probably use those anyway
|
||||
*/
|
||||
#if defined __sun || defined WIN32
|
||||
#include <stdint.h>
|
||||
typedef uint8_t u_int8_t;
|
||||
typedef uint16_t u_int16_t;
|
||||
typedef uint32_t u_int32_t;
|
||||
typedef uint64_t u_int64_t;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_INT128
|
||||
/**
|
||||
* 128 bit wide signed integer, if supported
|
||||
*/
|
||||
typedef __int128 int128_t;
|
||||
/**
|
||||
* 128 bit wide unsigned integer, if supported
|
||||
*/
|
||||
typedef unsigned __int128 u_int128_t;
|
||||
|
||||
# define MAX_INT_TYPE int128_t
|
||||
# define MAX_UINT_TYPE u_int128_t
|
||||
#else
|
||||
# define MAX_INT_TYPE int64_t
|
||||
# define MAX_UINT_TYPE u_int64_t
|
||||
#endif
|
||||
|
||||
/**
|
||||
* deprecated pluto style return value:
|
||||
* error message, NULL for success
|
||||
*/
|
||||
typedef const char *err_t;
|
||||
|
||||
/**
|
||||
* Handle struct sockaddr as a simpler sockaddr_t type.
|
||||
*/
|
||||
typedef struct sockaddr sockaddr_t;
|
||||
|
||||
#endif /** TYPES_H_ @} */
|
Loading…
Reference in New Issue