crt.nut 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  1. --
  2. -- Copyright (C) 2004 by egnite Software GmbH. All rights reserved.
  3. --
  4. -- Redistribution and use in source and binary forms, with or without
  5. -- modification, are permitted provided that the following conditions
  6. -- are met:
  7. --
  8. -- 1. Redistributions of source code must retain the above copyright
  9. -- notice, this list of conditions and the following disclaimer.
  10. -- 2. Redistributions in binary form must reproduce the above copyright
  11. -- notice, this list of conditions and the following disclaimer in the
  12. -- documentation and/or other materials provided with the distribution.
  13. -- 3. Neither the name of the copyright holders nor the names of
  14. -- contributors may be used to endorse or promote products derived
  15. -- from this software without specific prior written permission.
  16. --
  17. -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  18. -- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  19. -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  20. -- FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  21. -- COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  22. -- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  23. -- BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  24. -- OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  25. -- AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  26. -- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  27. -- THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  28. -- SUCH DAMAGE.
  29. --
  30. -- For additional information see http://www.ethernut.de/
  31. --
  32. -- Operating system functions
  33. --
  34. -- $Log$
  35. -- Revision 1.14 2009/02/18 12:48:27 olereinhardt
  36. -- 2009-02-18 Ole Reinhardt <ole.reinhardt@thermotemp.de>
  37. -- Added CRT_UNSETENV_POSIX, enable it when building for ARM using Newlib since
  38. -- version 1.17.0 to avoid compile errors for unsetenv in setenv.c.
  39. --
  40. -- Revision 1.13 2009/02/13 14:44:25 haraldkipp
  41. -- Debug versions of heap routines added.
  42. --
  43. -- Revision 1.12 2009/02/06 15:45:03 haraldkipp
  44. -- Routines using heap memory moved from c to crt module.
  45. -- We now have strdup() and calloc().
  46. --
  47. -- Revision 1.11 2008/10/10 11:51:38 haraldkipp
  48. -- Floating point provision added.
  49. --
  50. -- Revision 1.10 2008/06/28 07:49:33 haraldkipp
  51. -- Added floating point support for stdio running on ARM.
  52. --
  53. -- Revision 1.9 2008/01/31 09:09:07 haraldkipp
  54. -- Added stdlib environment.
  55. --
  56. -- Revision 1.8 2005/08/05 11:25:01 olereinhardt
  57. -- Added seek.c, tell.c
  58. --
  59. -- Revision 1.7 2005/06/26 11:33:31 chaac
  60. -- Added forgotten kbhit.c to build process.
  61. --
  62. -- Revision 1.6 2004/11/24 14:48:34 haraldkipp
  63. -- crt/crt.nut
  64. --
  65. -- Revision 1.5 2004/09/07 19:09:53 haraldkipp
  66. -- Split program space I/O
  67. --
  68. -- Revision 1.4 2004/08/18 16:05:38 haraldkipp
  69. -- Use consistent directory structure
  70. --
  71. -- Revision 1.3 2004/08/18 13:46:09 haraldkipp
  72. -- Fine with avr-gcc
  73. --
  74. -- Revision 1.2 2004/08/03 15:09:31 haraldkipp
  75. -- Another change of everything
  76. --
  77. -- Revision 1.1 2004/06/07 16:35:53 haraldkipp
  78. -- First release
  79. --
  80. --
  81. nutcrt =
  82. {
  83. --
  84. -- Low level I/O
  85. --
  86. {
  87. name = "nutcrt_file",
  88. brief = "Low level file I/O",
  89. requires = { "DEV_FILE" },
  90. provides = { "CRT_FILE" },
  91. sources =
  92. {
  93. "close.c",
  94. "clrerr.c",
  95. "ioctl.c",
  96. "open.c",
  97. "select.c",
  98. },
  99. options =
  100. {
  101. {
  102. macro = "CRT_DISABLE_SELECT_POLL",
  103. brief = "Disable select() and poll()",
  104. description = "Disable build of select() and poll() to save some flash ressources and "..
  105. "to ensure real-time behaviour. The select wait queue handling in some "..
  106. "drivers may introduce non deterministic interrupt latencies, if the "..
  107. "driver is used together with the select functions.",
  108. flavor = "boolean",
  109. file = "include/cfg/crt.h"
  110. }
  111. },
  112. },
  113. {
  114. name = "nutcrt_read",
  115. brief = "Low level file read",
  116. requires = { "DEV_READ", "CRT_FILE" },
  117. provides = { "CRT_READ" },
  118. sources =
  119. {
  120. "getf.c",
  121. "read.c",
  122. }
  123. },
  124. {
  125. name = "nutcrt_write",
  126. brief = "Low Level Write",
  127. requires = { "DEV_WRITE", "CRT_FILE" },
  128. provides = { "CRT_WRITE" },
  129. sources =
  130. {
  131. "putf.c",
  132. "write.c"
  133. }
  134. },
  135. {
  136. name = "nutcrt_write_p",
  137. brief = "Low Level Write (PGM-Space)",
  138. requires = { "HW_MCU_AVR", "DEV_WRITE", "CRT_FILE" },
  139. provides = { "CRT_WRITE_P" },
  140. sources =
  141. {
  142. "write_p.c"
  143. }
  144. },
  145. --
  146. -- Stream I/O
  147. --
  148. {
  149. name = "nutcrt_stream",
  150. brief = "File Streams",
  151. provides = { "CRT_STREAM" },
  152. sources =
  153. {
  154. "fclose.c",
  155. "fcloseall.c",
  156. "fdopen.c",
  157. "feof.c",
  158. "ferror.c",
  159. "fflush.c",
  160. "filelength.c",
  161. "fileno.c",
  162. "flushall.c",
  163. "fmode.c",
  164. "fopen.c",
  165. "fpurge.c",
  166. "freopen.c",
  167. "fseek.c",
  168. "ftell.c",
  169. "funopen.c",
  170. "seek.c",
  171. "tell.c"
  172. },
  173. options =
  174. {
  175. {
  176. macro = "STDIO_FLOATING_POINT",
  177. brief = "Floating point",
  178. description = "Enables floating point support for standard input/output.",
  179. flavor = "boolean",
  180. provides = { "FLOATING_POINT_IO" },
  181. file = "include/cfg/crt.h"
  182. },
  183. {
  184. macro = "STDIO_64_BIT",
  185. brief = "Handling of 64-bit values",
  186. description = "Enables handling of 64-bit values for standard input/output.",
  187. flavor = "boolean",
  188. provides = { "FLOATING_64_BIT" },
  189. file = "include/cfg/crt.h"
  190. },
  191. {
  192. macro = "FOPEN_MAX",
  193. brief = "Max. Open Streams",
  194. description = "Maximum number of concurrently opened filedescriptors / streams.\n\n"..
  195. "Default is 8",
  196. type = "integer",
  197. flavor = "booldata",
  198. file = "include/cfg/crt.h"
  199. }
  200. }
  201. },
  202. {
  203. name = "nutcrt_istream",
  204. brief = "File Stream Input",
  205. provides = { "CRT_STREAM_READ" },
  206. sources =
  207. {
  208. "fgetc.c",
  209. "fgets.c",
  210. "fread.c",
  211. "fscanf.c",
  212. "getc.c",
  213. "getchar.c",
  214. "gets.c",
  215. "kbhit.c",
  216. "scanf.c",
  217. "ungetc.c",
  218. "vfscanf.c"
  219. }
  220. },
  221. {
  222. name = "nutcrt_istream_p",
  223. brief = "File Stream Input (PGM-Space)",
  224. requires = { "HW_MCU_AVR" },
  225. provides = { "CRT_STREAM_READ_P" },
  226. sources =
  227. {
  228. "fscanf_p.c",
  229. "scanf_p.c",
  230. "vfscanf_p.c"
  231. }
  232. },
  233. {
  234. name = "nutcrt_ostream",
  235. brief = "File Stream Output",
  236. provides = { "CRT_STREAM_WRITE" },
  237. sources =
  238. {
  239. "fprintf.c",
  240. "fputc.c",
  241. "fputs.c",
  242. "fwrite.c",
  243. "printf.c",
  244. "putc.c",
  245. "putchar.c",
  246. "puts.c",
  247. "vfprintf.c"
  248. }
  249. },
  250. {
  251. name = "nutcrt_ostream_p",
  252. brief = "File Stream Output (PGM-Space)",
  253. requires = { "HW_MCU_AVR" },
  254. provides = { "CRT_STREAM_WRITE_P" },
  255. sources =
  256. {
  257. "fprintf_p.c",
  258. "fputs_p.c",
  259. "fwrite_p.c",
  260. "printf_p.c",
  261. "puts_p.c",
  262. "vfprintf_p.c"
  263. }
  264. },
  265. --
  266. -- String I/O
  267. --
  268. {
  269. name = "nutcrt_fstrio",
  270. brief = "Formatted String I/O",
  271. sources =
  272. {
  273. "asprintf.c",
  274. "sprintf.c",
  275. "snprintf.c",
  276. "sscanf.c",
  277. "vasprintf.c",
  278. "vsprintf.c",
  279. "vsnprintf.c",
  280. "vsscanf.c"
  281. }
  282. },
  283. {
  284. name = "nutcrt_fstrio_p",
  285. brief = "Formatted String I/O (PGM-Space)",
  286. requires = { "HW_MCU_AVR" },
  287. sources =
  288. {
  289. "sprintf_p.c",
  290. "snprintf_p.c",
  291. "sscanf_p.c",
  292. "vsprintf_p.c",
  293. "vsnprintf_p.c",
  294. "vsscanf_p.c"
  295. }
  296. },
  297. {
  298. name = "nutcrt_vis",
  299. brief = "Visual String Codec",
  300. sources =
  301. { "vis.c", "unvis.c" }
  302. },
  303. --
  304. -- Date and time
  305. --
  306. {
  307. name = "nutcrt_time",
  308. brief = "Time and date",
  309. provides = { "CRT_DATETIME" },
  310. sources =
  311. {
  312. "gmtime.c",
  313. "localtime.c",
  314. "asctime.c",
  315. "mktime.c",
  316. "time.c",
  317. "timeofday.c",
  318. "tzset.c"
  319. }
  320. },
  321. --
  322. -- Date and time
  323. --
  324. {
  325. name = "nutcrt_errno",
  326. brief = "Global errno",
  327. sources = { "errno.c" }
  328. },
  329. --
  330. -- Heap memory
  331. --
  332. {
  333. name = "nutcrt_malloc",
  334. brief = "Heap memory",
  335. description = "Although some runtime libraries provide "..
  336. "identical routines, we better use our own to avoid "..
  337. "memory management conflicts.",
  338. requires = { "NUT_HEAPMEM" },
  339. provides = { "CRT_HEAPMEM" },
  340. sources =
  341. {
  342. "calloc.c",
  343. "calloc_dbg.c",
  344. "malloc.c",
  345. "malloc_dbg.c",
  346. "realloc.c",
  347. "realloc_dbg.c",
  348. "strdup.c",
  349. "strdup_dbg.c"
  350. }
  351. },
  352. {
  353. name = "nutcrt_sbrk",
  354. brief = "Library Heap Support",
  355. requires = { "NUT_HEAPMEM", "TOOL_ARMLIB" },
  356. provides = { "CRT_SBRK" },
  357. sources = { "sbrk.c" }
  358. },
  359. --
  360. -- Environment
  361. --
  362. {
  363. name = "nutcrt_environ",
  364. brief = "Environment",
  365. description = "Nut/OS provides Posix like environment variables. They are stored "..
  366. "in non-volatile memory and are immediately available after reboot.\n\n"..
  367. "The Nut/OS libraries do not use environment variables, because in most "..
  368. "cases they occupy significantly more memory space than directly storing "..
  369. "specific configuration structures at pre-defined memory locations. "..
  370. "Application code, however, may benefit from portability. Furthermore, "..
  371. "in situations where only a few out of a large number of settings need "..
  372. "to be overridden, environment variables may even save non-volatile "..
  373. "memory space.",
  374. requires = { "NUT_HEAPMEM" },
  375. sources = { "getenv.c", "putenv.c", "setenv.c", "environ.c" },
  376. options =
  377. {
  378. {
  379. macro = "ENVIRON_EE_OFFSET",
  380. brief = "Location",
  381. description = "This is the non-volatile memory address offset, where the "..
  382. "runtime library expects the list of environment variables.\n\n"..
  383. "Note, that changing this value will invalidate previously "..
  384. "stored environment after upgrading to this new version. You must "..
  385. "also make sure, that this memory area will not conflict with "..
  386. "others, specifically system and network configurations.\n\n"..
  387. "This items is available only if the target system offers any "..
  388. "non-volatile memory. Check the non-volatile memory "..
  389. "module in the device driver section.",
  390. requires = { "DEV_NVMEM" },
  391. default = "256",
  392. type = "integer",
  393. file = "include/cfg/eeprom.h"
  394. },
  395. {
  396. macro = "CRT_UNSETENV_POSIX",
  397. brief = "Posix compatible unsetenv",
  398. description = "Enable posix compatible definition of unsetenv. Newlib since version "..
  399. "1.17.0 declares unsetenv returning int. Older versions are declared "..
  400. "as void function. This will help to avoid compilation errors because "..
  401. "of incompatible declarations.",
  402. flavor = "boolean",
  403. file = "include/cfg/crt.h"
  404. }
  405. },
  406. },
  407. --
  408. -- Misc
  409. --
  410. {
  411. name = "nutcrt_strtok_r",
  412. brief = "Recursive strtok",
  413. requires = { "TOOL_ICC" },
  414. sources = { "strtok_r.c" }
  415. }
  416. }