summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2009-04-10 17:25:47 +0200
committerBruno Haible <bruno@clisp.org>2009-04-10 22:28:44 +0200
commit0ddf471de31d50df52d6ec01a9406f73086c6cb0 (patch)
tree0649226f0f47e368ec824af62f332c1561611080 /lib
parent2247ec07cae76d7ea6f002d9fa8cd917fd03e1cd (diff)
downloadlibunistring-0ddf471de31d50df52d6ec01a9406f73086c6cb0.tar.gz
Provide installable <stdbool.h>, <stdint.h> replacements.
Diffstat (limited to 'lib')
-rw-r--r--lib/Makefile.am45
-rw-r--r--lib/stdint.mini.h128
2 files changed, 173 insertions, 0 deletions
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 86ab54e..36c19ca 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -45,6 +45,51 @@ include_HEADERS = \
# Rules generated and collected by gnulib-tool.
include Makefile.gnulib
+# The <stdbool.h> and <stdint.h> replacements that can be installed.
+nodist_include_HEADERS = \
+ unistring-stdbool.h \
+ unistring-stdint.h
+
+unistring-stdbool.h : $(STDBOOL_H)
+ rm -f $@-t $@
+ if test -n '$(STDBOOL_H)'; then \
+ cp stdbool.h $@-t; \
+ else \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+ echo '#include <stdbool.h>'; \
+ } > $@-t; \
+ fi
+ mv $@-t $@
+BUILT_SOURCES += unistring-stdbool.h
+MOSTLYCLEANFILES += unistring-stdbool.h-t
+CLEANFILES += unistring-stdbool.h
+
+unistring-stdint.h : $(STDINT_H) stdint.mini.h
+ rm -f $@-t $@
+ if test -n '$(STDINT_H)'; then \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+ sed -e 's/@''HAVE_STDINT_H''@/$(HAVE_STDINT_H)/g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''NEXT_STDINT_H''@|$(NEXT_STDINT_H)|g' \
+ -e 's/@''HAVE_SYS_TYPES_H''@/$(HAVE_SYS_TYPES_H)/g' \
+ -e 's/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_H)/g' \
+ -e 's/@''HAVE_SYS_INTTYPES_H''@/$(HAVE_SYS_INTTYPES_H)/g' \
+ -e 's/@''HAVE_SYS_BITYPES_H''@/$(HAVE_SYS_BITYPES_H)/g' \
+ -e 's/include_next/include/' \
+ < $(srcdir)/stdint.mini.h; \
+ } > $@-t; \
+ else \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+ echo '#include <stdint.h>'; \
+ } > $@-t; \
+ fi
+ mv $@-t $@
+BUILT_SOURCES += unistring-stdint.h
+MOSTLYCLEANFILES += unistring-stdint.h-t
+CLEANFILES += unistring-stdint.h
+EXTRA_DIST += stdint.mini.h
+
# Libtool's library version information for libunistring.
# See the libtool documentation, section "Library interface versions".
LTV_CURRENT=0
diff --git a/lib/stdint.mini.h b/lib/stdint.mini.h
new file mode 100644
index 0000000..d6f2cb0
--- /dev/null
+++ b/lib/stdint.mini.h
@@ -0,0 +1,128 @@
+/* Copyright (C) 2001-2002, 2004-2009 Free Software Foundation, Inc.
+ Written by Paul Eggert, Bruno Haible, Sam Steingold, Peter Burwood.
+ This file is part of gnulib.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ 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 Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+/*
+ * Subset of ISO C 99 <stdint.h> for platforms that lack it.
+ * <http://www.opengroup.org/susv3xbd/stdint.h.html>
+ */
+
+#ifndef _UNISTRING_STDINT_H
+
+/* When including a system file that in turn includes <inttypes.h>,
+ use the system <inttypes.h>, not our substitute. This avoids
+ problems with (for example) VMS, whose <sys/bitypes.h> includes
+ <inttypes.h>. */
+#define _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H
+
+/* Get those types that are already defined in other system include
+ files, so that we can "#define int8_t signed char" below without
+ worrying about a later system include file containing a "typedef
+ signed char int8_t;" that will get messed up by our macro. Our
+ macros should all be consistent with the system versions, except
+ for the "fast" types and macros, which we recommend against using
+ in public interfaces due to compiler differences. */
+
+#if @HAVE_STDINT_H@
+# if defined __sgi && ! defined __c99
+ /* Bypass IRIX's <stdint.h> if in C89 mode, since it merely annoys users
+ with "This header file is to be used only for c99 mode compilations"
+ diagnostics. */
+# define __STDINT_H__
+# endif
+ /* Other systems may have an incomplete or buggy <stdint.h>.
+ Include it before <inttypes.h>, since any "#include <stdint.h>"
+ in <inttypes.h> would reinclude us, skipping our contents because
+ _UNISTRING_STDINT_H is defined.
+ The include_next requires a split double-inclusion guard. */
+# if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+# endif
+# @INCLUDE_NEXT@ @NEXT_STDINT_H@
+#endif
+
+#if ! defined _UNISTRING_STDINT_H && ! defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H
+#define _UNISTRING_STDINT_H
+
+/* <sys/types.h> defines some of the stdint.h types as well, on glibc,
+ IRIX 6.5, and OpenBSD 3.8 (via <machine/types.h>).
+ AIX 5.2 <sys/types.h> isn't needed and causes troubles.
+ MacOS X 10.4.6 <sys/types.h> includes <stdint.h> (which is us), but
+ relies on the system <stdint.h> definitions, so include
+ <sys/types.h> after @NEXT_STDINT_H@. */
+#if @HAVE_SYS_TYPES_H@ && ! defined _AIX
+# include <sys/types.h>
+#endif
+
+/* Get LONG_MIN, LONG_MAX, ULONG_MAX. */
+#include <limits.h>
+
+#if @HAVE_INTTYPES_H@
+ /* In OpenBSD 3.8, <inttypes.h> includes <machine/types.h>, which defines
+ int{8,16,32,64}_t, uint{8,16,32,64}_t and __BIT_TYPES_DEFINED__.
+ <inttypes.h> also defines intptr_t and uintptr_t. */
+# include <inttypes.h>
+#elif @HAVE_SYS_INTTYPES_H@
+ /* Solaris 7 <sys/inttypes.h> has the types except the *_fast*_t types, and
+ the macros except for *_FAST*_*, INTPTR_MIN, PTRDIFF_MIN, PTRDIFF_MAX. */
+# include <sys/inttypes.h>
+#endif
+
+#if @HAVE_SYS_BITYPES_H@ && ! defined __BIT_TYPES_DEFINED__
+ /* Linux libc4 >= 4.6.7 and libc5 have a <sys/bitypes.h> that defines
+ int{8,16,32,64}_t and __BIT_TYPES_DEFINED__. In libc5 >= 5.2.2 it is
+ included by <sys/types.h>. */
+# include <sys/bitypes.h>
+#endif
+
+#undef _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H
+
+
+/* 7.18.1.1. Exact-width integer types */
+
+/* Here we assume a standard architecture where the hardware integer
+ types have 8, 16, 32, optionally 64 bits. */
+
+#undef int8_t
+#undef uint8_t
+typedef signed char unistring_int8_t;
+typedef unsigned char unistring_uint8_t;
+#define int8_t unistring_int8_t
+#define uint8_t unistring_uint8_t
+
+#undef int16_t
+#undef uint16_t
+typedef short int unistring_int16_t;
+typedef unsigned short int unistring_uint16_t;
+#define int16_t unistring_int16_t
+#define uint16_t unistring_uint16_t
+
+#undef int32_t
+#undef uint32_t
+typedef int unistring_int32_t;
+typedef unsigned int unistring_uint32_t;
+#define int32_t unistring_int32_t
+#define uint32_t unistring_uint32_t
+
+/* Avoid collision with Solaris 2.5.1 <pthread.h> etc. */
+#define _UINT8_T
+#define _UINT32_T
+#define _UINT64_T
+
+
+#endif /* _UNISTRING_STDINT_H */
+#endif /* !defined _UNISTRING_STDINT_H && !defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H */