]> git.ipfire.org Git - people/ms/strongswan.git/commitdiff
types: Use generic type definitions to separate header file
authorMartin Willi <martin@revosec.ch>
Wed, 15 Apr 2015 13:55:33 +0000 (15:55 +0200)
committerMartin Willi <martin@revosec.ch>
Thu, 16 Apr 2015 12:49:19 +0000 (14:49 +0200)
src/libstrongswan/Makefile.am
src/libstrongswan/utils/utils.h
src/libstrongswan/utils/utils/types.h [new file with mode: 0644]

index ab986958e016ada12effbad0c9ff17ec98bd16fb..a5681d6b22de8c4037dd961433048f42e22b9049 100644 (file)
@@ -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
index bd3245d2311d39978669fdbe513a7727f816f368..cf6a41b85f4a49d241bf9bbef40996f54f816f47 100644 (file)
 #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.
  *
diff --git a/src/libstrongswan/utils/utils/types.h b/src/libstrongswan/utils/utils/types.h
new file mode 100644 (file)
index 0000000..056c2e0
--- /dev/null
@@ -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_ @} */