1 /* Copyright (c) 2002 Canna Project. All rights reserved.
2  *
3  * Permission to use, copy, modify, distribute and sell this software
4  * and its documentation for any purpose is hereby granted without
5  * fee, provided that the above copyright notice appear in all copies
6  * and that both that copyright notice and this permission notice
7  * appear in supporting documentation, and that the name of the
8  * author and contributors not be used in advertising or publicity
9  * pertaining to distribution of the software without specific, written
10  * prior permission.  The author and contributors no representations
11  * about the suitability of this software for any purpose.  It is
12  * provided "as is" without express or implied warranty.
13  *
14  * THE AUTHOR AND CONTRIBUTORS DISCLAIMS ALL WARRANTIES WITH REGARD TO
15  * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
16  * FITNESS, IN NO EVENT SHALL THE AUTHOR AND CONTRIBUTORS BE LIABLE FOR
17  * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
18  * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
19  * CONTRACT, NEGLIGENCE OR OTHER TORTUOUS ACTION, ARISING OUT OF OR IN
20  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21  */
22 
23 /* $Id: ccompat.h,v 1.10 2003/09/25 07:38:11 aida_s Exp $ */
24 
25 #ifndef CCOMPAT_H
26 #define CCOMPAT_H
27 #include "cannaconf.h"
28 
29 #if defined(__STDC__) || defined(__cplusplus)
30 # define pro(x) x
31 #else
32 # define pro(x) ()
33 #endif
34 
35 #ifdef HAVE_STDLIB_H
36 # include <stdlib.h>
37 #else
38 extern char *malloc(), *realloc(), *calloc();
39 extern void free();
40 #endif
41 
42 #ifdef HAVE_STRING_H
43 # include <string.h>
44 #endif
45 #ifdef HAVE_STRINGS_H
46 # include <strings.h>
47 #endif
48 #if !defined(STDC_HEADERS) && defined(HAVE_MEMORY_H)
49 # include <memory.h>
50 #endif
51 #include <errno.h>
52 #ifdef luna68k
53 extern int  errno;
54 #endif
55 
56 #include "canna/sysdep.h"
57 
58 #if defined(HAVE_STRCHR) && !defined(HAVE_INDEX) && !defined(index)
59 # define index(s, c) strchr(s, c)
60 # define rindex(s, c) strrchr(s, c)
61 #elif !defined(HAVE_STRCHR) && defined(HAVE_INDEX) && !defined(strchr)
62 # define strchr(s, c) index(s, c)
63 # define strrchr(s, c) rindex(s, c)
64 #endif
65 
66 #if defined(HAVE_MEMSET) && !defined(HAVE_BZERO) && !defined(bzero)
67 # define bzero(buf, size) ((void)memset((char *)(buf), 0x00, (size)))
68 #endif
69 #if defined(HAVE_MEMCPY) && !defined(HAVE_BCOPY) && !defined(bcopy)
70 # define bcopy(src, dst, size) ((void)memmove((char *)(dst), (char *)(src), (size)))
71 #elif !defined(HAVE_MEMCPY) && defined(HAVE_BCOPY) && !defined(memcpy)
72 /* Don't use return value; bcopy() returns void */
73 # define memcpy(dst, src, size) bcopy((char *)(src), (char *)(dst), (size))
74 # define memmove(dst, src, size) bcopy((char *)(src), (char *)(dst), (size))
75 #endif
76 
77 #include "RKindep/cfuncs.h"
78 
79 #ifdef __GNUC__
80 # define UNUSED_SYMBOL __attribute__((__unused__))
81 # ifdef __ELF__
82 #  ifdef __STDC__
83 #   define	WARN_REFERENCES(sym,msg)	\
84 	__asm__(".section .gnu.warning." #sym);	\
85 	__asm__(".asciz \"" msg "\"");	\
86 	__asm__(".previous")
87 #  else
88 #   define	WARN_REFERENCES(sym,msg)	\
89 	__asm__(".section .gnu.warning.sym"); \
90 	__asm__(".asciz \"msg\"");	\
91 	__asm__(".previous")
92 #  endif	/* __STDC__ */
93 # endif	/* __ELF__ */
94 #endif	/* __GNUC__ */
95 
96 #ifndef WARN_REFERENCES
97 # define WARN_REFERENCES(sym, msg) struct cannahack
98 #endif
99 #ifndef UNUSED_SYMBOL
100 # define UNUSED_SYMBOL
101 #endif
102 
103 #if !defined(lint) && !defined(__CODECENTER__)
104 # define RCSID(id) static const char rcsid[] UNUSED_SYMBOL = id
105 #else
106 # define RCSID(id) struct cannahack
107 #endif
108 
109 #endif /* CCOMPAT_H */
110