Added to the repository
Showing
2 changed files
with
127 additions
and
0 deletions
lib/stdbool.h
0 → 100644
1 | /* Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. | ||
2 | Written by Bruno Haible <haible@clisp.cons.org>, 2001. | ||
3 | |||
4 | This program is free software; you can redistribute it and/or modify | ||
5 | it under the terms of the GNU General Public License as published by | ||
6 | the Free Software Foundation; either version 2, or (at your option) | ||
7 | any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program; if not, write to the Free Software Foundation, | ||
16 | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | ||
17 | |||
18 | #ifndef _STDBOOL_H | ||
19 | #define _STDBOOL_H | ||
20 | |||
21 | /* ISO C 99 <stdbool.h> for platforms that lack it. */ | ||
22 | |||
23 | /* Usage suggestions: | ||
24 | |||
25 | Programs that use <stdbool.h> should be aware of some limitations | ||
26 | and standards compliance issues. | ||
27 | |||
28 | Standards compliance: | ||
29 | |||
30 | - <stdbool.h> must be #included before 'bool', 'false', 'true' | ||
31 | can be used. | ||
32 | |||
33 | - You cannot assume that sizeof (bool) == 1. | ||
34 | |||
35 | - Programs should not undefine the macros bool, true, and false, | ||
36 | as C99 lists that as an "obsolescent feature". | ||
37 | |||
38 | Limitations of this substitute, when used in a C89 environment: | ||
39 | |||
40 | - <stdbool.h> must be #included before the '_Bool' type can be used. | ||
41 | |||
42 | - You cannot assume that _Bool is a typedef; it might be a macro. | ||
43 | |||
44 | - In C99, casts and automatic conversions to '_Bool' or 'bool' are | ||
45 | performed in such a way that every nonzero value gets converted | ||
46 | to 'true', and zero gets converted to 'false'. This doesn't work | ||
47 | with this substitute. With this substitute, only the values 0 and 1 | ||
48 | give the expected result when converted to _Bool' or 'bool'. | ||
49 | |||
50 | Also, it is suggested that programs use 'bool' rather than '_Bool'; | ||
51 | this isn't required, but 'bool' is more common. */ | ||
52 | |||
53 | |||
54 | /* 7.16. Boolean type and values */ | ||
55 | |||
56 | /* BeOS <sys/socket.h> already #defines false 0, true 1. We use the same | ||
57 | definitions below, but temporarily we have to #undef them. */ | ||
58 | #ifdef __BEOS__ | ||
59 | # include <OS.h> /* defines bool but not _Bool */ | ||
60 | # undef false | ||
61 | # undef true | ||
62 | #endif | ||
63 | |||
64 | /* For the sake of symbolic names in gdb, we define true and false as | ||
65 | enum constants, not only as macros. | ||
66 | It is tempting to write | ||
67 | typedef enum { false = 0, true = 1 } _Bool; | ||
68 | so that gdb prints values of type 'bool' symbolically. But if we do | ||
69 | this, values of type '_Bool' may promote to 'int' or 'unsigned int' | ||
70 | (see ISO C 99 6.7.2.2.(4)); however, '_Bool' must promote to 'int' | ||
71 | (see ISO C 99 6.3.1.1.(2)). So we add a negative value to the | ||
72 | enum; this ensures that '_Bool' promotes to 'int'. */ | ||
73 | #if !(defined __cplusplus || defined __BEOS__) | ||
74 | # if !0 | ||
75 | # if defined __SUNPRO_C && (__SUNPRO_C < 0x550 || __STDC__ == 1) | ||
76 | /* Avoid stupid "warning: _Bool is a keyword in ISO C99". */ | ||
77 | # define _Bool signed char | ||
78 | enum { false = 0, true = 1 }; | ||
79 | # else | ||
80 | typedef enum { _Bool_must_promote_to_int = -1, false = 0, true = 1 } _Bool; | ||
81 | # endif | ||
82 | # endif | ||
83 | #else | ||
84 | typedef bool _Bool; | ||
85 | #endif | ||
86 | #define bool _Bool | ||
87 | |||
88 | /* The other macros must be usable in preprocessor directives. */ | ||
89 | #define false 0 | ||
90 | #define true 1 | ||
91 | #define __bool_true_false_are_defined 1 | ||
92 | |||
93 | #endif /* _STDBOOL_H */ |
m4/unlocked-io.m4
0 → 100644
1 | # unlocked-io.m4 serial 11 | ||
2 | |||
3 | # Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software | ||
4 | # Foundation, Inc. | ||
5 | # | ||
6 | # This file is free software; the Free Software Foundation | ||
7 | # gives unlimited permission to copy and/or distribute it, | ||
8 | # with or without modifications, as long as this notice is preserved. | ||
9 | |||
10 | dnl From Jim Meyering. | ||
11 | dnl | ||
12 | dnl See if the glibc *_unlocked I/O macros or functions are available. | ||
13 | dnl Use only those *_unlocked macros or functions that are declared | ||
14 | dnl (because some of them were declared in Solaris 2.5.1 but were removed | ||
15 | dnl in Solaris 2.6, whereas we want binaries built on Solaris 2.5.1 to run | ||
16 | dnl on Solaris 2.6). | ||
17 | |||
18 | AC_DEFUN([gl_FUNC_GLIBC_UNLOCKED_IO], | ||
19 | [ | ||
20 | AC_DEFINE([USE_UNLOCKED_IO], 1, | ||
21 | [Define to 1 if you want getc etc. to use unlocked I/O if available. | ||
22 | Unlocked I/O can improve performance in unithreaded apps, | ||
23 | but it is not safe for multithreaded apps.]) | ||
24 | |||
25 | dnl Persuade glibc and Solaris <stdio.h> to declare | ||
26 | dnl fgets_unlocked(), fputs_unlocked() etc. | ||
27 | AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) | ||
28 | |||
29 | AC_CHECK_DECLS_ONCE( | ||
30 | [clearerr_unlocked feof_unlocked ferror_unlocked | ||
31 | fflush_unlocked fgets_unlocked fputc_unlocked fputs_unlocked | ||
32 | fread_unlocked fwrite_unlocked getc_unlocked | ||
33 | getchar_unlocked putc_unlocked putchar_unlocked]) | ||
34 | ]) |
-
Please register or sign in to post a comment