]> arthur.barton.de Git - ngircd-alex.git/blob - src/portab/portab.h
Only use "__attribute__ ((unused))" if GCC >=2.8 is used
[ngircd-alex.git] / src / portab / portab.h
1 /*
2  * ngIRCd -- The Next Generation IRC Daemon
3  * Copyright (c)2001-2010 Alexander Barton (alex@barton.de)
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  * Please read the file COPYING, README and AUTHORS for more information.
10  *
11  * Portability functions and declarations (header for libngbportab).
12  */
13
14
15 #ifndef __PORTAB__
16 #define __PORTAB__
17
18
19 #include "config.h"
20
21 #ifndef DEBUG
22 # define NDEBUG
23 #endif
24
25 #ifdef HAVE_SYS_TYPES_H
26 # include <sys/types.h>
27 #endif
28
29 #ifdef HAVE_INTTYPES_H
30 # include <inttypes.h>
31 # define NGIRC_GOT_INTTYPES
32 #else
33 # ifdef HAVE_STDINT_H
34 #  include <stdint.h>
35 #  define NGIRC_GOT_INTTYPES
36 # endif
37 #endif
38
39 #ifdef HAVE_STDDEF_H
40 # include <stddef.h>
41 #endif
42
43 #ifdef HAVE_STDBOOL_H
44 # include <stdbool.h>
45 #endif
46
47 /* compiler features */
48
49 #if (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 7))
50 # define PUNUSED(x) __attribute__ ((unused)) x
51 # define UNUSED     __attribute__ ((unused))
52 #else
53 # define PUNUSED(x) x
54 # define UNUSED
55 #endif
56
57 #ifndef PARAMS
58 # if PROTOTYPES
59 #  define PARAMS(args) args
60 # else
61 #  define PARAMS(args) ()
62 # endif
63 #endif
64
65
66 /* datatypes */
67
68 #ifndef PROTOTYPES
69 # ifndef signed
70 #  define signed
71 # endif
72 #endif
73
74 typedef void POINTER;
75
76 #ifdef NGIRC_GOT_INTTYPES
77 typedef uint8_t UINT8;
78 typedef uint16_t UINT16;
79 typedef uint32_t UINT32;
80 #else
81 typedef unsigned char UINT8;
82 typedef unsigned short UINT16;
83 typedef unsigned int UINT32;
84 #endif
85
86 #ifndef HAVE_STDBOOL_H
87 typedef unsigned char bool;
88 #define true (bool)1
89 #define false (bool)0
90 #endif
91
92 #ifndef NULL
93 #ifdef PROTOTYPES
94 # define NULL (void *)0
95 #else
96 # define NULL 0L
97 #endif
98 #endif
99
100 #ifdef NeXT
101 #define S_IRUSR 0000400         /* read permission, owner */
102 #define S_IWUSR 0000200         /* write permission, owner */
103 #define S_IRGRP 0000040         /* read permission, group */
104 #define S_IROTH 0000004         /* read permission, other */
105 #define ssize_t int
106 #endif
107
108 #undef GLOBAL
109 #define GLOBAL
110
111
112 /* SPLint */
113
114
115 #ifdef S_SPLINT_S
116 #include "splint.h"
117 #endif
118
119
120 /* target constants  */
121
122 #ifndef TARGET_OS
123 #define TARGET_OS "unknown"
124 #endif
125
126 #ifndef TARGET_CPU
127 #define TARGET_CPU "unknown"
128 #endif
129
130 #ifndef TARGET_VENDOR
131 #define TARGET_VENDOR "unknown"
132 #endif
133
134
135 /* configure options */
136
137 #ifndef HAVE_socklen_t
138 typedef int socklen_t;                  /* for Mac OS X, amongst others */
139 #endif
140
141 #ifndef HAVE_SNPRINTF
142 extern int snprintf PARAMS(( char *str, size_t count, const char *fmt, ... ));
143 #endif
144
145 #ifndef HAVE_STRLCAT
146 extern size_t strlcat PARAMS(( char *dst, const char *src, size_t size ));
147 #endif
148
149 #ifndef HAVE_STRLCPY
150 extern size_t strlcpy PARAMS(( char *dst, const char *src, size_t size ));
151 #endif
152
153 #ifndef HAVE_STRDUP
154 extern char * strdup PARAMS(( const char *s ));
155 #endif
156
157 #ifndef HAVE_STRTOK_R
158 extern char * strtok_r PARAMS((char *str, const char *delim, char **saveptr));
159 #endif
160
161 #ifndef HAVE_VSNPRINTF
162 #include <stdarg.h>
163 extern int vsnprintf PARAMS(( char *str, size_t count, const char *fmt, va_list args ));
164 #endif
165
166 #ifndef PACKAGE_NAME
167 #define PACKAGE_NAME PACKAGE
168 #endif
169
170 #ifndef PACKAGE_VERSION
171 #define PACKAGE_VERSION VERSION
172 #endif
173
174
175 #endif
176
177
178 /* -eof- */