]> pd.if.org Git - pdclib.old/blob - Readme.rst
Convert readme to be in reStructuredText format (for nice formatting)
[pdclib.old] / Readme.rst
1 PDCLib - the `Public Domain C Library<http://pdclib.e43.eu>`_\r
2 ================================\r
3 \r
4 What is it\r
5 ----------\r
6 \r
7 This is a C Standard Library - what's defined in ISO/IEC 9899 "Information \r
8 technology — Programming languages — C" or extensions to the above defined in\r
9 ISO/IEC 14882 "Information technology — Programming languages — C++". A few \r
10 extensions may optionally be provided.\r
11 \r
12 License\r
13 -------\r
14 \r
15 Written in 2003-2012 by Martin "Solar" Baute,\r
16            2012-     by Owen Shepherd\r
17 \r
18 To the extent possible under law, the author(s) have dedicated all copyright \r
19 and related and neighboring rights to this software to the public domain \r
20 worldwide. This software is distributed without any warranty.\r
21 \r
22 You should have received a copy of the CC0 Public Domain Dedication along with \r
23 this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.\r
24 \r
25     **Exception:** Portions of the test suite are under different licenses. \r
26     Where this is the case, it is clearly noted in the relevant location.\r
27 \r
28     The license of this code has no bearing upon the licensing of the built \r
29     library (as it does not comprise part of it).\r
30 \r
31     At the time this was written, this exception only applies to portions of the\r
32     printf test suite, which are released under the terms of the 2-clause BSD\r
33     license (see testing/printf_testcases.h for full details)\r
34 \r
35 Terms for extensions\r
36 --------------------\r
37 Extensions are permitted only if they pass the following tests:\r
38 \r
39 Pre-existing wide usage\r
40     On most systems, the system C library must maintain its application binary\r
41     interface for long periods of time (potentially eternity). Existing wide \r
42     usage demonstrates utility\r
43 \r
44 In keeping with the spirit of the standard\r
45     The extension should respect the design, intentions and conventions of the C\r
46     standard, and feel like a natural extension to the offered capability. \r
47 \r
48 Not system dependent\r
49     The extension should not add any additional dependencies on the underlying \r
50     system\r
51 \r
52 Non-duplicative\r
53     Extensions should not duplicate functionality already provided by the \r
54     standard\r
55 \r
56 Disabled by default\r
57     PDCLib will always default to a "strictly conforming" mode exposing only\r
58     functionality offered by the version of the standard specified by the\r
59     __STDC_VERSION__, __STDC__ or __cplusplus macro; extensions will only be \r
60     exposed when requested.\r
61 \r
62 Additionally, extra consideration will be given to extensions which are \r
63 difficult or impossible to implement without access to internal structures of \r
64 the C library.\r
65 \r
66 Conrete Examples:\r
67 \r
68 strndup\r
69     **Included.** strndup is easily defined in terms of existing standard \r
70     functions, follows  the standard's naming conventions, is in wide usage, and\r
71     does not duplicate  features already provided.\r
72 \r
73 posix_memalign\r
74     **Rejected.** Has existing wide usage, is not system dependent (can be \r
75     implemented, albeit inefficiently, on top of malloc), but naming is not \r
76     consistent with the naming used by the standard (posix_ prefix) and \r
77     duplicates functionality provided by the C11 standard\r
78 \r
79 open, close, read, write, ...\r
80     **Rejected.** Widely used, but duplicates functionality provided by the \r
81     standard (FILE objects set to be unbuffered), and not able to implement full\r
82     semantics (e.g. in relation to POSIX fork and other functionality from the \r
83     same defining standard) in a platform-neutral way\r
84 \r
85 strl*\r
86     **Rejected.** Used somewhat widely, in keeping with the standard, not system\r
87     dependent, but duplicative of functionality provided by (optional) Annex K \r
88     of the C standard. \r
89 \r
90 flockfile, funlockfile, getc_unlocked, putc_unlocked, fwrite_unlocked, ...\r
91     **Accepted.** Provide functionality not provided by the standard (and \r
92     useful in light of the C11 addition of threading). Can be trivially \r
93     implemented in terms of the <threads.h> mutex functions and the bodies of \r
94     the existing I/O functions, and impossible to implement externally\r
95 \r
96 Internals\r
97 ---------\r
98 \r
99 As a namespace convention, everything (files, typedefs, functions,\r
100 macros) not defined in ISO/IEC 9899 is prefixed with _PDCLIB.\r
101 The standard defines any identifiers starting with '_' and a capital\r
102 letter as reserved for the implementation, and since the chances of\r
103 your compiler using an identifier in the _PDCLIB range are slim,\r
104 any strictly conforming application should work with this library.\r
105 \r
106 PDCLib consists of several parts:\r
107 \r
108 1) standard headers;\r
109 2) implementation files for standard functions;\r
110 3) internal header files keeping complex stuff out of the standard\r
111    headers;\r
112 4) the central, platform-specific file _PDCLIB_config.h;\r
113 5) platform-specific implementation files;\r
114 \r
115 The standard headers (in ./includes/) only contain what they are\r
116 defined to contain. Where additional logic or macro magic is\r
117 necessary, that is deferred to the internal files. This has been done\r
118 so that the headers are actually educational as to what they provide\r
119 (as opposed to how the library does it).\r
120 \r
121 There is a seperate implementation file (in ./function/{header}/) for\r
122 every function defined by the standard, named {function}.c. Not only\r
123 does this avoid linking in huge amounts of unused code when you use\r
124 but a single function, it also allows the optimization overlay to work\r
125 (see below).\r
126 \r
127 (The directory ./functions/_PDCLIB/ contains internal and helper\r
128 functions that are not part of the standard.)\r
129 \r
130 Then there are internal header files (in ./internal/), which contain\r
131 all the "black magic" and "code fu" that was kept out of the standard\r
132 headers. You should not have to touch them if you want to adapt PDCLib\r
133 to a new platform. Note that, if you *do* have to touch them, I would\r
134 consider it a serious design flaw, and would be happy to fix it in the\r
135 next PDCLib release. Any adaption work should be covered by the steps\r
136 detailed below.\r
137 \r
138 For adapting PDCLib to a new platform (the trinity of CPU, operating\r
139 system, and compiler), make a copy of ./platform/example/ named\r
140 ./platform/{your_platform}/, and modify the files of your copy to suit\r
141 the constraints of your platform. When you are done, copy the contents\r
142 of your platform directory over the source directory structure\r
143 of PDCLib (or link them into the appropriate places). That should be\r
144 all that is actually required to make PDCLib work for your platform.\r
145 \r
146 Future directions\r
147 -----------------\r
148 Obviously, full C89, C99 and C11 conformance; and full support for the \r
149 applicable portions of C++98, C++03 and C++11 (the version which acomplishes \r
150 this will be christened "1.0").\r
151 \r
152 Support for "optimization overlays." These would allow efficient \r
153 implementations of certain functions on individual platforms, for example \r
154 memcpy, strcpy and memset. This requires further work to only compile in one\r
155 version of a given function.\r
156 \r
157 Post 1.0, support for C11 Annexe K "Bounds checking interfaces"\r
158 \r
159 Development Status\r
160 ------------------\r
161 \r
162 v0.1 - 2004-12-12\r
163 Freestanding-only C99 implementation without any overlay, and missing\r
164 the INTN_C() / UINTN_C() macros. <float.h> still has the enquire.c\r
165 values hardcoded into it; not sure whether to include enquire.c in the\r
166 package, to leave <float.h> to the overlay, or devise some parameterized\r
167 macro magic as for <limits.h> / <stdint.h>. Not thoroughly tested, but\r
168 I had to make the 0.1 release sometime so why not now.\r
169 \r
170 v0.2 - 2005-01-12\r
171 Adds implementations for <string.h> (excluding strerror()), INTN_C() /\r
172 UINTN_C() macros, and some improvements in the internal headers.\r
173 Test drivers still missing, but added warnings about that.\r
174 \r
175 v0.3 - 2005-11-21\r
176 Adds test drivers, fixes some bugs in <string.h>.\r
177 \r
178 v0.4 - 2005-02-06\r
179 Implementations for parts of <stdlib.h>. Still missing are the floating\r
180 point conversions, and the wide-/multibyte-character functions.\r
181 \r
182 v0.4.1 - 2006-11-16\r
183 With v0.5 (<stdio.h>) taking longer than expected, v0.4.1 was set up as\r
184 a backport of bugfixes in the current development code.\r
185 - #1  realloc( NULL, size ) fails           (fixed)\r
186 - #2  stdlib.h - insufficient documentation (fixed)\r
187 - #4  Misspelled name in credits            (fixed)\r
188 - #5  malloc() splits off too-small nodes   (fixed)\r
189 - #6  qsort() stack overflow                (fixed)\r
190 - #7  malloc() bug in list handling         (fixed)\r
191 - #8  strncmp() does not terminate at '\0'  (fixed)\r
192 - #9  stdint.h dysfunctional                (fixed)\r
193 - #10 NULL redefinition warnings            (fixed)\r
194 \r
195 v0.5 - 2010-12-22\r
196 Implementations for <inttypes.h>, <errno.h>, most parts of <stdio.h>,\r
197 and strerror() from <string.h>.\r
198 Still no locale / wide-char support. Enabled all GCC compiler warnings I\r
199 could find, and fixed everything that threw a warning. (You see this,\r
200 maintainers of Open Source software? No warnings whatsoever. Stop telling\r
201 me it cannot be done.) Fixed all known bugs in the v0.4 release.\r
202 \r
203 Near Future\r
204 -----------\r
205 Current development directions are:\r
206 \r
207 Implement portions of the C11 standard that have a direct impact on the way \r
208 that PDCLib itself is built. For example, in order to support multithreading,\r
209 PDCLib needs a threading abstraction; therefore, C11's thread library is being\r
210 implemented to provide the backing for this (as there is no purpose in \r
211 implementing two abstractions)\r
212 \r
213 Cleanup portions of <stdio.h>, particularly the backend. _PDCLIB_fillbuffer and\r
214 _PDCLIB_flushbuffer in particular do not feel 'well' factored and need to know\r
215 too much about FILE's internals. \r
216 \r
217 Modularize the library somewhat. This can already be seen with components under \r
218 "opt/". This structure is preliminary; it will likely change as the process \r
219 continues.