stdlibs.h
[目次 | 型・クラス・構造体 | マクロ]
1|/**************************************************************************
2|* 1. <<< 標準ライブラリ・モジュール [StdLibs] >>>
3|*【補足】
4|*・使い方は、stdlibs.htm を参照。
5|***************************************************************************/
6|
7|#ifndef __STDLIBS_H
8|#define __STRLIBS_H
9|
10|/*----------------------------------------------------------------------
11|[Module Property]
12|name = StdLibs
13|title = 標準ライブラリ・モジュール
14|category = 基本型
15|src = stdlibs.c
16|depend =
17|priority =
18|accord =
19|----------------------------------------------------------------------*/
20|
21|#ifndef USES_PRIORITY_HEADER
22|/*[START_OF_PRIORITY_HEADER]*/
23|
24|#define USES_STDLIBS
25|
26|/*[END_OF_PRIORITY_HEADER]*/
27|#endif /* USES_PRIORITY_HEADER */
28|
29|
30|
31|/**************************************************************************
32|* 2. <<< モジュール設定(1): ターゲット環境 >>>
33|***************************************************************************/
34|
35|#ifndef STDLIBS_SETTING
36|
37| #ifdef FOR_NSTD
38| #define STDLIBS_NO_STDLIB /* コンパイラ付属の標準ライブラリを使用しない */
39| #endif
40|
41|#define STDLIBS_SETTING
42|#endif
43|
44|
45|
46|/**************************************************************************
47|* 3. <<< モジュール設定(2): インクルードするファイル >>>
48|*【補足】
49|*・これらは、通常、ローカル設定にします。
50|* (compone.h をインクルードする前に行います)
51|*・ここに書かれていないヘッダファイルは、本モジュールは対応していません。
52|* 普通に #include してください。
53|***************************************************************************/
54|
55|/* インクルードするヘッダファイルに相当する #define を有効にします */
56|
57| #define STDLIBS_INCLUDE_MATH_H
58| #define STDLIBS_INCLUDE_LIMITS_H
59| #define STDLIBS_INCLUDE_STDIO_H
60| #define STDLIBS_INCLUDE_STDLIB_H
61| #define STDLIBS_INCLUDE_STRING_H
62| #define STDLIBS_INCLUDE_STDARG_H
63| #define STDLIBS_INCLUDE_SETJMP_H
64| #define STDLIBS_INCLUDE_STDDEF_H
65|
66|#define STDLIBS_INCLUDE
67|
68|
69|/*------------------------------------------------------------------------*/
70|/* 4. <<< Interface Area ----------------------------------------------- >>> */
71|/*------------------------------------------------------------------------*/
72|
73|#ifdef __cplusplus
74|extern "C" {
75|#endif
76|
77|
78|/***********************************************************
79|* 5. <<< stddef.h: [size_t] >>>
80|************************************************************/
81|
82|#ifdef STDLIBS_INCLUDE_STDDEF_H
83|#ifndef STDLIBS_CUT_STDDEF_H
84|#ifndef __INC_VSTDLIBH
85|
86|#if !defined(STDLIBS_NO_STDLIB) && !defined(FOR_WINCE)
87| #include <stddef.h>
88|#else
89| typedef unsigned int size_t;
90| #if !defined(offsetof) && !defined(FOR_WINCE)
91| #define offsetof(st,memb) ((int)(&( ((st*)0)->memb )))
92| #endif
93|#endif
94|
95|#endif
96|#endif
97|#endif
98|
99|
100|
101|/***********************************************************
102|* 6. <<< limits.h >>>
103|************************************************************/
104|
105|#ifdef STDLIBS_INCLUDE_LIMITS_H
106|
107|#ifndef STDLIBS_NO_STDLIB
108| #include <limits.h>
109|#else
110|
111|/* 7. <<< int 型の最大最小 [INT_MAX, INT_MIN] >>> */
112|#ifdef INT_MAX
113|#undef INT_MAX
114|#endif
115|#ifdef INT_MIN
116|#undef INT_MIN
117|#endif
118|
119|#ifdef _16BIT
120|#define INT_MAX 0x7FFF
121|#define INT_MIN -0x8000
122|#endif
123|
124|#ifdef _32BIT
125|#define INT_MAX 0x7FFFFFFF
126|#ifdef _MSC_VER
127|#define INT_MIN -0x7FFFFFFF /* VC の場合、警告が出てしまう(バグ) */
128|#else
129|#ifdef FOR_GHS
130|#define INT_MIN -0x7FFFFFFF /* GHS の場合、エラーが出てしまう(バグ) */
131|#else
132|#define INT_MIN -0x80000000
133|#endif /* FOR_GHS */
134|#endif /* _MSC_VER */
135|#endif /* _32BIT */
136|
137|
138|#endif
139|
140|#endif
141|
142|
143|
144|/***********************************************************
145|* 8. <<< math.h >>>
146|************************************************************/
147|
148|#ifdef STDLIBS_INCLUDE_MATH_H
149|
150|#ifndef STDLIBS_NO_STDLIB
151|#ifndef FOR_CODEW
152| #ifdef abs
153| #undef abs
154| #endif
155| #if defined(WIN32) && defined(__cplusplus)
156| }
157| #endif
158| #include <math.h>
159| #if defined(WIN32) && defined(__cplusplus)
160| extern "C" {
161| #endif
162|#endif
163|
164|#else
165|
166| #define abs(x) ((x)>=0 ? x : -(x))
167| #define fabs(x) ((x)>=0 ? x : -(x))
168|
169|#endif
170|
171|#endif
172|
173|
174|
175|/***********************************************************
176|* 9. <<< setjmp.h >>>
177|************************************************************/
178|
179|#ifdef STDLIBS_INCLUDE_SETJMP_H
180|
181|#ifdef FOR_CODEW
182| #ifndef USES_LONGJMPS
183| #error need LongJmps Module
184| #endif
185|#endif
186|
187|#ifndef STDLIBS_NO_STDLIB
188|#ifndef FOR_CODEW
189| #include <setjmp.h>
190|#endif
191|#endif
192|
193|#endif
194|
195|
196|
197|/***********************************************************
198|* 10. <<< stdarg.h >>>
199|************************************************************/
200|
201|#ifdef STDLIBS_INCLUDE_STDARG_H
202|
203|#ifndef __INC_VSTDARGH
204|#ifndef STDLIBS_NO_STDLIB
205| #include <stdarg.h>
206|#else
207| #ifdef FOR_GHS
208| typedef struct { char *va_list; int va_stkmod7; } va_list;
209| #define va_start(ap,lstprm) ((ap).va_list= (char *)&__va_ansiarg, \
210| ((ap).va_stkmod7 = (int)__va_stkarg&7))
211| #define va_arg(p, mode) ((mode *)((p).va_list = (char *)(((int)(p).va_list +\
212| (__va_align(mode)>4?(((p).va_stkmod7 !=((int)(p).va_list&7))*4):0)+ 3) & ~3) + \
213| sizeof(mode)))[-1]
214| #define va_end(p)
215| #endif
216|#endif
217|#endif
218|
219|#endif
220|
221|
222|
223|/***********************************************************
224|* 11. <<< stdio.h >>>
225|************************************************************/
226|#ifdef STDLIBS_INCLUDE_STDIO_H
227|
228|#ifndef STDLIBS_NO_STDLIB
229|#ifndef FOR_CODEW
230|#ifndef FOR_GNU
231|#ifndef __INC_VSTDLIBH
232| #include <stdio.h>
233| #ifndef __STDIO_H
234| #define __STDIO_H
235| #endif
236|#endif
237|#endif
238|#endif
239|#endif
240|
241|#ifndef __STDIO_H
242| #ifndef FOR_CODEW
243| #define NULL ((void*)0)
244| #endif
245|#endif
246|
247|#endif
248|
249|
250|
251|/***********************************************************
252|* 12. <<< stdlib.h >>>
253|************************************************************/
254|
255|#ifdef STDLIBS_INCLUDE_STDLIB_H
256|
257|#ifndef __INC_VSTDLIBH
258| #ifndef STDLIBS_NO_STDLIB
259| #ifndef FOR_CODEW
260| #ifndef FOR_GNU
261| #include <stdlib.h>
262| #ifndef __STDLIB_H
263| #define __STDLIB_H
264| #endif
265| #ifdef FOR_WINCE
266| #include <windef.h> /* _MAX_PATH の実体 */
267| #endif
268| #endif
269| #ifdef FOR_GHS
270| #define _MAX_PATH 260
271| #define _MAX_FNAME 260
272| #endif
273| #endif
274| #else
275| #define abs(x) ((x)>=0 ? x : -(x))
276| #endif
277|#else
278| #define abs(x) ((x)>=0 ? x : -(x))
279| int inkey(void);
280| int sdvex_inkey(void);
281| #define inkey sdvex_inkey
282|#endif
283|
284|#endif
285|
286|
287|/***********************************************************
288|* 13. <<< string.h >>>
289|************************************************************/
290|#ifdef STDLIBS_INCLUDE_STRING_H
291|
292|#ifndef STDLIBS_NO_STDLIB
293|#ifndef FOR_GNU
294| #include <string.h>
295| #ifndef __STRING_H
296| #define __STRING_H
297| #endif
298| #ifdef FOR_GHS
299| int stricmp( const char* a, const char* b );
300| #endif
301|#endif
302|#endif
303|
304|#endif
305|
306|
307|
308|/***********************************************************
309|* 14. <<< time.h >>>
310|************************************************************/
311|
312|#ifdef STDLIBS_INCLUDE_TIME_H
313|
314|#ifndef STDLIBS_NO_STDLIB
315|#ifndef FOR_GNU
316| #include <time.h>
317| #ifndef __TIME_H
318| #define __TIME_H
319| #endif
320|#endif
321|#endif
322|
323|#endif
324|
325|
326|
327|/*------------------------------------------------------------------------*/
328|/* 15. <<< Mapping Area ------------------------------------------------- >>> */
329|/*------------------------------------------------------------------------*/
330|
331|
332|
333|#ifdef __cplusplus
334|}
335|#endif
336|
337|#endif
338|
339|
340|