From 70b3420586f7cd64967038a3f799759e2180a641 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Thu, 14 Oct 1999 15:55:06 +0000 Subject: [PATCH] Add support for compilers which do not have cname headers git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@201 a592a061-630c-0410-9148-cb99ea01b6c8 --- ChangeLog | 15 +++++++ acinclude.m4 | 17 ++++++++ configure.in | 1 + src/cheaders/cctype | 7 +++ src/cheaders/cerrno | 7 +++ src/cheaders/cmath | 80 +++++++++++++++++++++++++++++++++++ src/cheaders/csignal | 7 +++ src/cheaders/cstdio | 7 +++ src/cheaders/cstdlib | 23 ++++++++++ src/cheaders/cstring | 96 ++++++++++++++++++++++++++++++++++++++++++ src/cheaders/ctime | 7 +++ src/insets/Makefile.am | 2 +- src/mathed/Makefile.am | 2 +- 13 files changed, 269 insertions(+), 2 deletions(-) create mode 100644 src/cheaders/cctype create mode 100644 src/cheaders/cerrno create mode 100644 src/cheaders/cmath create mode 100644 src/cheaders/csignal create mode 100644 src/cheaders/cstdio create mode 100644 src/cheaders/cstdlib create mode 100644 src/cheaders/cstring create mode 100644 src/cheaders/ctime diff --git a/ChangeLog b/ChangeLog index 1a0e774449..d0edf4e4ee 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +1999-10-14 Jean-Marc Lasgouttes + + * acinclude.m4 (LYX_CXX_CHEADERS): New macro. Checks whether the + C++ compiler provides wrappers for C headers and use our alternate + version otherwise. + + * configure.in: use LYX_CXX_CHEADERS. + + * src/cheader/: new directory, populated with cname headers from + libstdc++-2.8.1. They are a bit old, but probably good enough for + what we want (support compilers who lack them). + + * src/insets/Makefile.am, src/mathed/Makefile.am: remove src/support + from includes. It turns out is was stupid. + 1999-10-14 Lars Gullik Bjønnes * lib/Makefile.am (install-data-local): forgot a ';' diff --git a/acinclude.m4 b/acinclude.m4 index 9338e0f125..d48ed86ae9 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -374,6 +374,23 @@ if test $lyx_cv_cxx_namespace = yes ; then [Define if your C++ compiler has correct support for namespaces]) fi]) +dnl Usage: LYX_CXX_CHEADERS : checks whether the C++ compiler +dnl provides wrappers for C headers and use our alternate version otherwise. +AC_DEFUN(LYX_CXX_CHEADERS,[ +AC_CACHE_CHECK(for C headers wrappers,lyx_cv_cxx_cheaders, + [AC_TRY_CPP([ +#include +#include +#include +#include +#include +#include +#include +#include ],[lyx_cv_cxx_cheaders=yes],[lyx_cv_cxx_cheaders=no])]) +if test $lyx_cv_cxx_cheaders = no ; then + LYX_ADD_INC_DIR(lyx_cppflags,\$(top_srcdir)/src/cheaders) +fi]) + dnl Usage LYX_PATH_XPM: Checks for xpm library and header AC_DEFUN(LYX_PATH_XPM,[ diff --git a/configure.in b/configure.in index cb3739cdaa..f06dce6d43 100644 --- a/configure.in +++ b/configure.in @@ -65,6 +65,7 @@ LYX_CXX_EXPLICIT LYX_CXX_STL_STACK LYX_CXX_STL_STRING LYX_CXX_NAMESPACES +LYX_CXX_CHEADERS LYX_CXX_RTTI ### Libarary Files diff --git a/src/cheaders/cctype b/src/cheaders/cctype new file mode 100644 index 0000000000..e2765aed50 --- /dev/null +++ b/src/cheaders/cctype @@ -0,0 +1,7 @@ +// The -*- C++ -*- character type header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __CCTYPE__ +#define __CCTYPE__ +#include +#endif diff --git a/src/cheaders/cerrno b/src/cheaders/cerrno new file mode 100644 index 0000000000..ce49346959 --- /dev/null +++ b/src/cheaders/cerrno @@ -0,0 +1,7 @@ +// The -*- C++ -*- error number header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __CERRNO__ +#define __CERRNO__ +#include +#endif diff --git a/src/cheaders/cmath b/src/cheaders/cmath new file mode 100644 index 0000000000..21b276c619 --- /dev/null +++ b/src/cheaders/cmath @@ -0,0 +1,80 @@ +// The -*- C++ -*- math functions header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __CMATH__ +#define __CMATH__ + +#ifdef __GNUG__ +#include <_G_config.h> +#endif + +#include + +#ifdef __GNUG__ +#pragma interface "cmath" +#endif + +extern "C++" { +#if 0 +float acos (float); +float asin (float); +float atan (float); +float atan2(float, float); +float ceil (float); +float cos (float); +float cosh (float); +float exp (float); +float fabs (float); +float floor(float); +float fmod (float, float); +float frexp(float, int*); +float modf (float, float*); +float ldexp(float, int); +float log (float); +float log10(float); +float pow (float, float); +float pow (float, int); +float sin (float); +float sinh (float); +float sqrt (float); +float tan (float); +float tanh (float); +#endif + +inline float abs (float x) { return fabs (x); } +#if ! _G_MATH_H_INLINES /* hpux and SCO define this in math.h */ +inline double abs (double x) { return fabs (x); } +#endif + +#if 0 +double pow(double, int); + +long double acos (long double); +long double asin (long double); +long double atan (long double); +long double atan2(long double, long double); +long double ceil (long double); +long double cos (long double); +long double cosh (long double); +long double exp (long double); +long double fabs (long double); +long double floor(long double); +long double frexp(long double, int*); +long double fmod (long double, long double); +long double frexp(long double, int*); +long double log (long double); +long double log10(long double); +long double modf (long double, long double*); +long double pow (long double, long double); +long double pow (long double, int); +long double sin (long double); +long double sinh (long double); +long double sqrt (long double); +long double tan (long double); +long double tanh (long double); +#endif +inline long double abs (long double x) { return fabs (x); } + +} // extern "C++" + +#endif diff --git a/src/cheaders/csignal b/src/cheaders/csignal new file mode 100644 index 0000000000..6febfb7b2e --- /dev/null +++ b/src/cheaders/csignal @@ -0,0 +1,7 @@ +// The -*- C++ -*- signal handling header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __CSIGNAL__ +#define __CSIGNAL__ +#include +#endif diff --git a/src/cheaders/cstdio b/src/cheaders/cstdio new file mode 100644 index 0000000000..1fe1456b5b --- /dev/null +++ b/src/cheaders/cstdio @@ -0,0 +1,7 @@ +// The -*- C++ -*- standard I/O header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __CSTDIO__ +#define __CSTDIO__ +#include +#endif diff --git a/src/cheaders/cstdlib b/src/cheaders/cstdlib new file mode 100644 index 0000000000..e7c1a5160a --- /dev/null +++ b/src/cheaders/cstdlib @@ -0,0 +1,23 @@ +// The -*- C++ -*- standard library header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __CSTDLIB__ +#define __CSTDLIB__ +#include + +#ifdef __GNUG__ +#pragma interface "cstdlib" +#endif + +extern "C++" { + +#if _G_HAS_LABS +inline long abs(long x) { return labs (x); } +#else +inline long abs(long x) { return x >= 0 ? x : -x; } +#endif +//inline ldiv_t div(long x, long y) { return ldiv (x, y); } + +} // extern "C++" + +#endif diff --git a/src/cheaders/cstring b/src/cheaders/cstring new file mode 100644 index 0000000000..d8d03a765b --- /dev/null +++ b/src/cheaders/cstring @@ -0,0 +1,96 @@ +// The -*- C++ -*- null-terminated string header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __CSTRING__ +#define __CSTRING__ + +#include + +#if 0 // Let's not bother with this just yet. +#include + +#ifdef __GNUG__ +#pragma interface "cstring" +#endif + +// The ANSI C prototypes for these functions have a const argument type and +// non-const return type, so we can't use them. + +extern "C++" { +extern inline const char * +_G_strchr (const char *s, int c) +{ + return strchr (s, c); +} + +extern inline char * +_G_strchr (char *s, int c) +{ + return const_cast (strchr (s, c)); +} + +extern inline const char * +_G_strpbrk (const char *s1, const char *s2) +{ + return strpbrk (s1, s2); +} + +extern inline char * +_G_strpbrk (char *s1, const char *s2) +{ + return const_cast (strpbrk (s1, s2)); +} + +extern inline const char * +_G_strrchr (const char *s, int c) +{ + return strrchr (s, c); +} + +extern inline char * +_G_strrchr (char *s, int c) +{ + return const_cast (strrchr (s, c)); +} + +extern inline const char * +_G_strstr (const char *s1, const char *s2) +{ + return strstr (s1, s2); +} + +extern inline char * +_G_strstr (char *s1, const char *s2) +{ + return const_cast (strstr (s1, s2)); +} + +extern inline const void * +_G_memchr (const void *s, int c, size_t n) +{ + return memchr (s, c, n); +} + +extern inline void * +_G_memchr (void *s, int c, size_t n) +{ + return const_cast (memchr (s, c, n)); +} +} // extern "C++" + +// Lose any vendor macros for these functions. +#undef strchr +#undef strpbrk +#undef strrchr +#undef strstr +#undef memchr + +// Ewww, namespace pollution. Anyone have a better idea? +#define strchr _G_strchr +#define strpbrk _G_strpbrk +#define strrchr _G_strrchr +#define strstr _G_strstr +#define memchr _G_memchr +#endif // 0 + +#endif // !defined (__CSTRING__) diff --git a/src/cheaders/ctime b/src/cheaders/ctime new file mode 100644 index 0000000000..0184da5929 --- /dev/null +++ b/src/cheaders/ctime @@ -0,0 +1,7 @@ +// The -*- C++ -*- time header. +// This file is part of the GNU ANSI C++ Library. + +#ifndef __CTIME__ +#define __CTIME__ +#include +#endif diff --git a/src/insets/Makefile.am b/src/insets/Makefile.am index aac101d030..fe37689d1d 100644 --- a/src/insets/Makefile.am +++ b/src/insets/Makefile.am @@ -4,7 +4,7 @@ noinst_PROGRAMS = insets.o LIBS= LDFLAGS= ETAGS_ARGS = --c++ -INCLUDES = -I${srcdir}/../ -I${srcdir}/../support +INCLUDES = -I${srcdir}/../ CXXLINK = $(LD) -r -o $(noinst_PROGRAMS) insets_o_SOURCES = \ diff --git a/src/mathed/Makefile.am b/src/mathed/Makefile.am index 06aadaec5f..534637c67f 100644 --- a/src/mathed/Makefile.am +++ b/src/mathed/Makefile.am @@ -4,7 +4,7 @@ noinst_PROGRAMS = mathed.o LIBS= LDFLAGS= ETAGS_ARGS = --c++ -INCLUDES = -I${top_srcdir}/images -I${srcdir}/../ -I${srcdir}/../support +INCLUDES = -I${top_srcdir}/images -I${srcdir}/../ CXXLINK = $(LD) -r -o $(noinst_PROGRAMS) mathed_o_SOURCES = array.h \ -- 2.39.2