Advertisement
Guest User

anthony gorecki anthony@anthonygorecki.ca

a guest
Nov 19th, 2015
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 27.20 KB | None | 0 0
  1. Thu Nov 19 04:37:21 EST 2015
  2. ./dev/gc-base-lib/proj-make.txt
  3. //==============================================================================
  4. // This file is part of Gc-Base-Lib.
  5. // Copyright (C) 2015 Anthony Gorecki <agorecki@gcproj.org>
  6. //
  7. // Gc-Base-Lib is free software: you can redistribute it and/or modify it under
  8. // the terms of the GNU General Public License as published by the Free Software
  9. // Foundation, either version 3 of the License, or (at your option) any later
  10. // version.
  11. //
  12. // Gc-Base-Lib is distributed in the hope that it will be useful, but WITHOUT
  13. // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  14. // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  15. // details.
  16. //
  17. // You should have received a copy of the GNU General Public License along with
  18. // Gc-Base-Lib. If not, see <http://www.gnu.org/licenses/>.
  19. //==============================================================================
  20. # gc-proj-conf (tracks config; can reconfigure)
  21. # gc-proj-make (will rebuild changed files; will rebuild only necessary after conf change)
  22. # gc-proj-inst (installs all built targets)
  23.  
  24. DTGT gc-proj
  25.  
  26. TGEN dev
  27. MAKE
  28. EXEC lib/pkgconfig/make.sh $PREF
  29. INST
  30. COPY include/gc $PREF/include
  31. MOVE lib/pkgconfig/gc-proj.pc.tmp $PREF/lib/pkgconfig/gc-proj.pc
  32.  
  33. TLIB gc-proj
  34. ./dev/gc-base-lib/src/ct/u8_bcss.c
  35. //==============================================================================
  36. // This file is part of Gc-Base-Lib.
  37. // Lockless circular buffer, supporting a single producer and single consumer.
  38. // Copyright (C) 2015 Anthony Gorecki <agorecki@gcproj.org>
  39. //
  40. // Gc-Base-Lib is free software: you can redistribute it and/or modify it under
  41. // the terms of the GNU General Public License as published by the Free Software
  42. // Foundation, either version 3 of the License, or (at your option) any later
  43. // version.
  44. //
  45. // Gc-Base-Lib is distributed in the hope that it will be useful, but WITHOUT
  46. // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  47. // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  48. // details.
  49. //
  50. // You should have received a copy of the GNU General Public License along with
  51. // Gc-Base-Lib. If not, see <http://www.gnu.org/licenses/>.
  52. //==============================================================================
  53. #include <gc/mem.h>
  54.  
  55. #include <gc/u8_bcss.h>
  56.  
  57.  
  58.  
  59. //==============================================================================
  60. // Initialization and deinitialization
  61. //==============================================================================
  62. u8 u8_bcss_init(struct u8_bcss_i *buf, struct u8_bcss_c *conf)
  63. {
  64. buf->dbeg = mem_alloc(conf->size);
  65.  
  66. if (unlikely(buf->dbeg == NULL))
  67. return 1;
  68.  
  69. buf->cbeg = size;
  70. buf->ccur = 0;
  71. buf->dcur = buf->dbeg; // Read pointer
  72. return 0;
  73. }
  74.  
  75.  
  76. void u8_bcss_deinit(struct u8_bcss_i *buf)
  77. {
  78. mem_dealloc(buf->dbeg);
  79. }
  80.  
  81.  
  82.  
  83. //==============================================================================
  84. // Input and output
  85. //==============================================================================
  86. void u8_bcss_ia(struct u8_bcss_i *buf, u32 size)
  87. {
  88. u32 off = buf->din - buf->dbeg + size;
  89.  
  90. if (off < buf->cbeg - 1)
  91. buf->din += size;
  92.  
  93. else // Wrap around.
  94. buf->din = buf->dbeg + off - buf->cbeg;
  95.  
  96. atmc_fsub(&buf->cin, size);
  97. atmc_fadd(&buf->cout, size);
  98. }
  99.  
  100.  
  101. u32 u8_bcss_igc(struct u8_bcss_i *buf)
  102. {
  103. return atmc_load(&buf->cin);
  104. }
  105.  
  106.  
  107. u32 u8_bcss_igcc(struct u8_bcss_i *buf)
  108. {
  109.  
  110. }
  111.  
  112.  
  113. void u8_bcss_oa(struct u8_bcss_i *buf, u32 size)
  114. {
  115. u32 off = buf->dout - buf->dbeg + size;
  116.  
  117. if (off < buf->cbeg - 1)
  118. buf->dout += size;
  119.  
  120. else // Wrap around.
  121. buf->dout = buf->dbeg + off - buf->cbeg;
  122.  
  123. atmc_fsub(&buf->cout, size);
  124. atmc_fadd(&buf->cin, size);
  125. }
  126.  
  127.  
  128. u32 u8_bcss_ogc(struct u8_bcss_i *buf)
  129. {
  130. return atmc_load(&buf->cout);
  131. }
  132.  
  133.  
  134. u32 u8_bcss_ogcc(struct u8_bcss_i *buf)
  135. {
  136. u32 off_out = buf->dout - buf->dbeg;
  137. u32 orig_cout = atmc_load(&buf->cout);
  138.  
  139. if (off_out + orig_cout < buf->cbeg - 1)
  140. return orig_cout;
  141.  
  142. return buf->cbeg - off_out;
  143. }
  144.  
  145.  
  146.  
  147. //==============================================================================
  148. // Peeking
  149. //==============================================================================
  150. u8 u8_bcss_peek1(struct u8_bcss_i *buf)
  151. {
  152. return buf->dread[0];
  153. }
  154.  
  155.  
  156. u16 u8_bcss_peek2(struct u8_bcss_i *buf)
  157. {
  158. u8 cdata[2];
  159.  
  160. cdata[0] = buf->dread[0];
  161. cdata[1] = buf->dread[1];
  162.  
  163. return (u16)cdata;
  164. }
  165. ./dev/gc-base-lib/src/ct/u8_ib.c
  166. //==============================================================================
  167. // This file is part of Gc-Base-Lib.
  168. // Copyright (C) 2015 Anthony Gorecki <agorecki@gcproj.org>
  169. //
  170. // Gc-Base-Lib is free software: you can redistribute it and/or modify it under
  171. // the terms of the GNU General Public License as published by the Free Software
  172. // Foundation, either version 3 of the License, or (at your option) any later
  173. // version.
  174. //
  175. // Gc-Base-Lib is distributed in the hope that it will be useful, but WITHOUT
  176. // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  177. // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  178. // details.
  179. //
  180. // You should have received a copy of the GNU General Public License along with
  181. // Gc-Base-Lib. If not, see <http://www.gnu.org/licenses/>.
  182. //==============================================================================
  183. #include <gc/mem.h>
  184.  
  185. #include <gc/u8_ib.h>
  186.  
  187.  
  188.  
  189. //==============================================================================
  190. // Initialization and deinitialization
  191. //==============================================================================
  192. u8 u8_ib_init(struct u8_ib_i *ibuf, struct u8_ib_c *conf)
  193. {
  194. ibuf->buf = mem_alloc(conf->sbuf);
  195.  
  196. if (unlikely(conf->sbuf && ibuf->buf == NULL))
  197. return 1;
  198.  
  199. if (unlikely(conf->f->init(ibuf->buf, conf->buf))) {
  200. mem_dealloc(ibuf->buf);
  201. return 1;
  202. }
  203.  
  204. ibuf->f = conf->f;
  205. return 0;
  206. }
  207.  
  208.  
  209. void u8_ib_deinit(struct u8_ib_i *ibuf)
  210. {
  211. ibuf->f->deinit(ibuf->buf);
  212. }
  213.  
  214.  
  215.  
  216. //==============================================================================
  217. // Input and output
  218. //==============================================================================
  219. void u8_ib_ia(struct u8_ib_i *ibuf, u32 size)
  220. {
  221. ibuf->f->ia(ibuf->buf, size);
  222. }
  223.  
  224.  
  225. u32 u8_ib_igc(struct u8_ib_i *ibuf)
  226. {
  227. return ibuf->f->igc(ibuf->buf);
  228. }
  229.  
  230.  
  231. u32 u8_ib_igcc(struct u8_ib_i *ibuf)
  232. {
  233. return ibuf->f->igcc(ibuf->buf);
  234. }
  235.  
  236.  
  237. void u8_ib_oa(struct u8_ib_i *ibuf, u32 size)
  238. {
  239. ibuf->f->oa(ibuf->buf, size);
  240. }
  241.  
  242.  
  243. u32 u8_ib_ogc(struct u8_ib_i *ibuf)
  244. {
  245. return ibuf->f->ogc(ibuf->buf);
  246. }
  247.  
  248.  
  249. u32 u8_ib_ogcc(struct u8_ib_i *ibuf)
  250. {
  251. return ibuf->f->ogcc(ibuf->buf);
  252. }
  253. ./dev/gc-base-lib/src/ct/u8_b.c
  254. ./dev/gc-base-lib/src/ct/u8_bc.c
  255. //==============================================================================
  256. // This file is part of Gc-Base-Lib.
  257. // Simple circular buffer, supporting nonsimultaneous input and output.
  258. // Copyright (C) 2015 Anthony Gorecki <agorecki@gcproj.org>
  259. //
  260. // Gc-Base-Lib is free software: you can redistribute it and/or modify it under
  261. // the terms of the GNU General Public License as published by the Free Software
  262. // Foundation, either version 3 of the License, or (at your option) any later
  263. // version.
  264. //
  265. // Gc-Base-Lib is distributed in the hope that it will be useful, but WITHOUT
  266. // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  267. // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  268. // details.
  269. //
  270. // You should have received a copy of the GNU General Public License along with
  271. // Gc-Base-Lib. If not, see <http://www.gnu.org/licenses/>.
  272. //==============================================================================
  273. #include <gc/mem.h>
  274.  
  275. #include <gc/u8_bc.h>
  276.  
  277.  
  278.  
  279. //==============================================================================
  280. // Initialization and deinitialization
  281. //==============================================================================
  282. u8 u8_bc_init(struct u8_bc_i *buf, struct u8_bc_c *conf)
  283. {
  284. buf->dbeg = mem_alloc(conf->size);
  285.  
  286. if (unlikely(buf->dbeg == NULL))
  287. return 1;
  288.  
  289. buf->cbeg = size;
  290. buf->ccur = 0;
  291. buf->dcur = buf->dbeg; // Read pointer
  292. return 0;
  293. }
  294.  
  295.  
  296. void u8_bc_deinit(struct u8_bc_i *buf)
  297. {
  298. mem_dealloc(buf->dbeg);
  299. }
  300.  
  301.  
  302.  
  303. //==============================================================================
  304. // Input and output
  305. //==============================================================================
  306. void u8_bc_ia(struct u8_bc_i *buf, u32 size)
  307. {
  308. u32 off = buf->din - buf->dbeg + size;
  309.  
  310. if (off < buf->cbeg - 1)
  311. buf->din += size;
  312.  
  313. else // Wrap around.
  314. buf->din = buf->dbeg + off - buf->cbeg;
  315.  
  316. atmc_fsub(&buf->cin, size);
  317. atmc_fadd(&buf->cout, size);
  318. }
  319.  
  320.  
  321. u32 u8_bc_igc(struct u8_bc_i *buf)
  322. {
  323. return atmc_load(&buf->cin);
  324. }
  325.  
  326.  
  327. u32 u8_bc_igcc(struct u8_bc_i *buf)
  328. {
  329.  
  330. }
  331.  
  332.  
  333. void u8_bc_oa(struct u8_bc_i *buf, u32 size)
  334. {
  335. u32 off = buf->dout - buf->dbeg + size;
  336.  
  337. if (off < buf->cbeg - 1)
  338. buf->dout += size;
  339.  
  340. else // Wrap around.
  341. buf->dout = buf->dbeg + off - buf->cbeg;
  342.  
  343. atmc_fsub(&buf->cout, size);
  344. atmc_fadd(&buf->cin, size);
  345. }
  346.  
  347.  
  348. u32 u8_bc_ogc(struct u8_bc_i *buf)
  349. {
  350. return atmc_load(&buf->cout);
  351. }
  352.  
  353.  
  354. u32 u8_bc_ogcc(struct u8_bc_i *buf)
  355. {
  356. u32 off_out = buf->dout - buf->dbeg;
  357. u32 orig_cout = atmc_load(&buf->cout);
  358.  
  359. if (off_out + orig_cout < buf->cbeg - 1)
  360. return orig_cout;
  361.  
  362. return buf->cbeg - off_out;
  363. }
  364.  
  365.  
  366.  
  367. //==============================================================================
  368. // Peeking
  369. //==============================================================================
  370. u8 u8_bc_peek1(struct u8_bc_i *buf)
  371. {
  372. return buf->dread[0];
  373. }
  374.  
  375.  
  376. u16 u8_bc_peek2(struct u8_bc_i *buf)
  377. {
  378. u8 cdata[2];
  379.  
  380. cdata[0] = buf->dread[0];
  381. cdata[1] = buf->dread[1];
  382.  
  383. return (u16)cdata;
  384. }
  385. ./dev/gc-base-lib/src/util/pars.c
  386. //==============================================================================
  387. // This file is part of Gc-Base-Lib.
  388. // Copyright (C) 2015 Anthony Gorecki <agorecki@gcproj.org>
  389. //
  390. // Gc-Base-Lib is free software: you can redistribute it and/or modify it under
  391. // the terms of the GNU General Public License as published by the Free Software
  392. // Foundation, either version 3 of the License, or (at your option) any later
  393. // version.
  394. //
  395. // Gc-Base-Lib is distributed in the hope that it will be useful, but WITHOUT
  396. // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  397. // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  398. // details.
  399. //
  400. // You should have received a copy of the GNU General Public License along with
  401. // Gc-Base-Lib. If not, see <http://www.gnu.org/licenses/>.
  402. //==============================================================================
  403. #include <gc/pars.h>
  404.  
  405.  
  406.  
  407. //==============================================================================
  408. // "u8's"
  409. //==============================================================================
  410. u8 pars_u8c(struct pars_i *pars, u8 data)
  411. {
  412. u32 orig_cnt = u8b_cnt(&pars->buf);
  413.  
  414. while (u8b_cnt(&pars->buf)) {
  415. if (u8b_peek1(&pars->buf) != data)
  416. break;
  417.  
  418. u8b_adv(&pars->buf, 1);
  419. }
  420.  
  421. return !(u8b_cnt(&pars->buf) < orig_cnt);
  422. }
  423.  
  424.  
  425. u8 pars_u8c2(struct pars_i *pars, u8 data1, u8 data2)
  426. {
  427. u8 cdata[] = {data1, data2};
  428. u32 orig_cnt = u8b_cnt(&pars->buf);
  429.  
  430. while (u8b_cnt(&pars->buf) >= 2) {
  431. if (u8b_peek2(&pars->buf) != (u16)cdata)
  432. break;
  433.  
  434. u8b_adv(&pars->buf, 2);
  435. }
  436.  
  437. return !(u8b_cnt(&pars->buf) < orig_cnt);
  438. }
  439.  
  440.  
  441.  
  442. //==============================================================================
  443. // New line characters
  444. //==============================================================================
  445. u8 pars_nld(struct pars_i *pars, u8 types)
  446. {
  447. assert((types & NL_RN) || (types & NL_N) || (types & NL_R));
  448.  
  449. u8 rn[] = {'\r', '\n'};
  450.  
  451. if (u8b_cnt(&pars->buf) >= 2 && (types & NL_RN)
  452. && u8b_peek2(&pars->buf) == (u16)rn)
  453. return NL_RN;
  454.  
  455. if (u8b_cnt(&pars->buf)) {
  456. if ((types & NL_N) && u8b_peek(&pars->buf) == '\n')
  457. return NL_N;
  458.  
  459. if ((types & NL_R) && u8b_peek(&pars->buf) == '\r')
  460. return NL_R;
  461. }
  462.  
  463. return 0;
  464. }
  465.  
  466.  
  467. u8 pars_nlcs(struct pars_i *pars, u8 types)
  468. {
  469. u8 dtype = pars_nld(pars, types);
  470.  
  471. if (unlikely(!dtype))
  472. return 1;
  473.  
  474. if ((dtype & NL_RN)) {
  475. u8b_adv(&pars->buf, 2);
  476. pars_u8c2(pars, '\r', '\n');
  477. }
  478.  
  479. else {
  480. u8b_adv(&pars->buf, 1);
  481.  
  482. if ((dtype & NL_N))
  483. pars_u8c(pars, '\n');
  484.  
  485. if ((dtype & NL_R))
  486. pars_u8c(pars, '\r');
  487. }
  488.  
  489. return 0;
  490. }
  491.  
  492.  
  493. u8 pars_nlcm(struct pars_i *pars, u8 types)
  494. {
  495. u8 ret = 1;
  496.  
  497. for (;;) {
  498. if (pars_nlcs(pars, types))
  499. break;
  500.  
  501. ret = 0;
  502. }
  503.  
  504. return ret;
  505. }
  506.  
  507. ./dev/gc-base-lib/src/os/unix/proc.c
  508. //==============================================================================
  509. // This file is part of Gc-Base-Lib.
  510. // Copyright (C) 2015 Anthony Gorecki <agorecki@gcproj.org>
  511. //
  512. // Gc-Base-Lib is free software: you can redistribute it and/or modify it under
  513. // the terms of the GNU General Public License as published by the Free Software
  514. // Foundation, either version 3 of the License, or (at your option) any later
  515. // version.
  516. //
  517. // Gc-Base-Lib is distributed in the hope that it will be useful, but WITHOUT
  518. // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  519. // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  520. // details.
  521. //
  522. // You should have received a copy of the GNU General Public License along with
  523. // Gc-Base-Lib. If not, see <http://www.gnu.org/licenses/>.
  524. //==============================================================================
  525. // proc_st_init, proc_st_next, ...
  526. #include <gc/proc.h>
  527.  
  528.  
  529.  
  530. //==============================================================================
  531. // Execution
  532. //==============================================================================
  533. u8 proc_exec(void)
  534. {
  535. }
  536. ./dev/gc-base-lib/src/os/unix/mem.c
  537. //==============================================================================
  538. // This file is part of Gc-Base-Lib.
  539. // Copyright (C) 2015 Anthony Gorecki <agorecki@gcproj.org>
  540. //
  541. // Gc-Base-Lib is free software: you can redistribute it and/or modify it under
  542. // the terms of the GNU General Public License as published by the Free Software
  543. // Foundation, either version 3 of the License, or (at your option) any later
  544. // version.
  545. //
  546. // Gc-Base-Lib is distributed in the hope that it will be useful, but WITHOUT
  547. // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  548. // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  549. // details.
  550. //
  551. // You should have received a copy of the GNU General Public License along with
  552. // Gc-Base-Lib. If not, see <http://www.gnu.org/licenses/>.
  553. //==============================================================================
  554. #include <gc/mem.h>
  555.  
  556. #include <stdlib.h>
  557. #include <string.h>
  558.  
  559.  
  560.  
  561. //==============================================================================
  562. // Allocation, reallocation and deallocation
  563. //==============================================================================
  564. void *mem_alloc(size_t size)
  565. {
  566. return malloc(size);
  567. }
  568.  
  569.  
  570. void *mem_realloc(void *ptr, size_t size)
  571. {
  572. return realloc(ptr, size);
  573. }
  574.  
  575.  
  576. void mem_dealloc(void *ptr)
  577. {
  578. free(ptr);
  579. }
  580.  
  581.  
  582.  
  583. //==============================================================================
  584. // Utility
  585. //==============================================================================
  586. s8 mem_comp(void *data1, void *data2, size_t size)
  587. {
  588. return memcmp(data1, data2, size);
  589. }
  590.  
  591.  
  592. void mem_copy(void *dest, void *src, size_t size)
  593. {
  594. memcpy(dest, src, size);
  595. }
  596.  
  597.  
  598. void mem_move(void *dest, void *src, size_t size)
  599. {
  600. memmove(dest, src, size);
  601. }
  602.  
  603.  
  604. void mem_set(void *ptr, u8 data, size_t size)
  605. {
  606. memset(ptr, data, size);
  607. }
  608. ./dev/gc-base-lib/src/os/unix/file.c
  609. //==============================================================================
  610. // This file is part of Gc-Base-Lib.
  611. // Copyright (C) 2015 Anthony Gorecki <agorecki@gcproj.org>
  612. //
  613. // Gc-Base-Lib is free software: you can redistribute it and/or modify it under
  614. // the terms of the GNU General Public License as published by the Free Software
  615. // Foundation, either version 3 of the License, or (at your option) any later
  616. // version.
  617. //
  618. // Gc-Base-Lib is distributed in the hope that it will be useful, but WITHOUT
  619. // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  620. // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  621. // details.
  622. //
  623. // You should have received a copy of the GNU General Public License along with
  624. // Gc-Base-Lib. If not, see <http://www.gnu.org/licenses/>.
  625. //==============================================================================
  626. #include <gc/file.h>
  627.  
  628. #include <unistd.h>
  629.  
  630.  
  631.  
  632. //==============================================================================
  633. // Initialization and deinitialization
  634. //==============================================================================
  635. u8 file_init(struct file_i *file, struct file_c *conf)
  636. {
  637. if (!(conf->flags & DIO_CREAT))
  638. file->fd = open(conf->path, conf->flags);
  639.  
  640. else
  641. file->fd = open(conf->path, conf->flags, conf->mode);
  642.  
  643. if (unlikely(file->fd == -1))
  644. return 1;
  645.  
  646. return 0;
  647. }
  648.  
  649.  
  650. void file_deinit(struct file_i *file)
  651. {
  652. close(file->fd);
  653. }
  654.  
  655.  
  656.  
  657. //==============================================================================
  658. // Read and write
  659. //==============================================================================
  660. u8 file_read(struct file_i *file, struct u8b_i *buf)
  661. {
  662. ssize_t size = read(file->fd, buf->dwrite, u8b_wrgcc(buf));
  663.  
  664. if (unlikely(size == -1))
  665. return 1;
  666.  
  667. u8b_wra(buf, size);
  668. return 0;
  669. }
  670.  
  671.  
  672. u8 file_write(struct file_i *file, struct u8b_i *buf)
  673. {
  674. ssize_t size = write(file->fd, buf->dread, u8b_rdgcc(buf));
  675.  
  676. if (unlikely(size == -1))
  677. return 1;
  678.  
  679. u8b_rda(buf, size);
  680. return 0;
  681. }
  682.  
  683.  
  684.  
  685. //==============================================================================
  686. // Utility
  687. //==============================================================================
  688. u8 file_gstats(struct file_i *file, struct file_stats *stats)
  689. {
  690. if (unlikely(fstat(file->fd, &stats->data)))
  691. return 1;
  692.  
  693. return 0;
  694. }
  695. ./dev/gc-base-lib/make.sh
  696. gcc -o libgc-base -shared -I include -std=c11 -Wall -Wextra -Wpedantic -Werror `find src -type f -name '*.c'`
  697. ./dev/gc-base-lib/include/gc/proc.h
  698. //==============================================================================
  699. // This file is part of Gc-Base-Lib.
  700. // Copyright (C) 2015 Anthony Gorecki <agorecki@gcproj.org>
  701. //
  702. // Gc-Base-Lib is free software: you can redistribute it and/or modify it under
  703. // the terms of the GNU General Public License as published by the Free Software
  704. // Foundation, either version 3 of the License, or (at your option) any later
  705. // version.
  706. //
  707. // Gc-Base-Lib is distributed in the hope that it will be useful, but WITHOUT
  708. // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  709. // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  710. // details.
  711. //
  712. // You should have received a copy of the GNU General Public License along with
  713. // Gc-Base-Lib. If not, see <http://www.gnu.org/licenses/>.
  714. //==============================================================================
  715. #pragma once
  716.  
  717. #include <gc/common.h>
  718.  
  719. #if defined(__use_gnu_bktrc)
  720. #include <gc/proc-gnu-bktrc.h>
  721. #endif
  722.  
  723. #if defined(__use_lunwind)
  724. #include <gc/proc-lunwind.h>
  725. #endif
  726.  
  727. // Null function pointers for systems where back traces are not supported.
  728. ./dev/gc-base-lib/include/gc/common.h
  729. //==============================================================================
  730. // This file is part of Gc-Base-Lib.
  731. // Copyright (C) 2015 Anthony Gorecki <agorecki@gcproj.org>
  732. //
  733. // Gc-Base-Lib is free software: you can redistribute it and/or modify it under
  734. // the terms of the GNU General Public License as published by the Free Software
  735. // Foundation, either version 3 of the License, or (at your option) any later
  736. // version.
  737. //
  738. // Gc-Base-Lib is distributed in the hope that it will be useful, but WITHOUT
  739. // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  740. // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  741. // details.
  742. //
  743. // You should have received a copy of the GNU General Public License along with
  744. // Gc-Base-Lib. If not, see <http://www.gnu.org/licenses/>.
  745. //==============================================================================
  746. #pragma once
  747.  
  748. #include <stddef.h>
  749. #include <stdint.h>
  750.  
  751. #define likely(EXPR) __builtin_expect(EXPR, 1)
  752. #define unlikely(EXPR) __builtin_expect(EXPR, 0)
  753.  
  754. typedef int8_t s8;
  755. typedef int16_t s16;
  756. typedef int32_t s32;
  757. typedef int64_t s64;
  758.  
  759. typedef uint8_t u8;
  760. typedef uint16_t u16;
  761. typedef uint32_t u32;
  762. typedef uint64_t u64;
  763. ./dev/gc-base-lib/include/gc/atmc.h
  764. //==============================================================================
  765. // This file is part of Gc-Base-Lib.
  766. // Copyright (C) 2015 Anthony Gorecki <agorecki@gcproj.org>
  767. //
  768. // Gc-Base-Lib is free software: you can redistribute it and/or modify it under
  769. // the terms of the GNU General Public License as published by the Free Software
  770. // Foundation, either version 3 of the License, or (at your option) any later
  771. // version.
  772. //
  773. // Gc-Base-Lib is distributed in the hope that it will be useful, but WITHOUT
  774. // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  775. // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  776. // details.
  777. //
  778. // You should have received a copy of the GNU General Public License along with
  779. // Gc-Base-Lib. If not, see <http://www.gnu.org/licenses/>.
  780. //==============================================================================
  781. #pragma once
  782.  
  783. #include <gc/common.h>
  784.  
  785. typedef _Atomic s8 as8;
  786. typedef _Atomic s16 as16;
  787. typedef _Atomic s32 as32;
  788. typedef _Atomic s64 as64;
  789.  
  790. typedef _Atomic u8 au8;
  791. typedef _Atomic u16 au16;
  792. typedef _Atomic u32 au32;
  793. typedef _Atomic u64 au64;
  794.  
  795. #define atmc_fadd atomic_fetch_add
  796. #define atmc_fsub atomic_fetch_sub
  797. #define atmc_load atomic_load
  798. ./dev/gc-base-lib/include/gc/u8b.h
  799. //==============================================================================
  800. // This file is part of Gc-Base-Lib.
  801. // Copyright (C) 2015 Anthony Gorecki <agorecki@gcproj.org>
  802. //
  803. // Gc-Base-Lib is free software: you can redistribute it and/or modify it under
  804. // the terms of the GNU General Public License as published by the Free Software
  805. // Foundation, either version 3 of the License, or (at your option) any later
  806. // version.
  807. //
  808. // Gc-Base-Lib is distributed in the hope that it will be useful, but WITHOUT
  809. // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  810. // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  811. // details.
  812. //
  813. // You should have received a copy of the GNU General Public License along with
  814. // Gc-Base-Lib. If not, see <http://www.gnu.org/licenses/>.
  815. //==============================================================================
  816. #pragma once
  817.  
  818. #include <gc/atmc.h>
  819.  
  820. struct u8b_i {
  821. u32 cbeg;
  822. au32 cin;
  823. au32 cout;
  824. u8 *dbeg;
  825. u8 *din;
  826. u8 *dout;
  827. };
  828. ./dev/gc-base-lib/include/gc/pars.h
  829. //==============================================================================
  830. // This file is part of Gc-Base-Lib.
  831. // Copyright (C) 2015 Anthony Gorecki <agorecki@gcproj.org>
  832. //
  833. // Gc-Base-Lib is free software: you can redistribute it and/or modify it under
  834. // the terms of the GNU General Public License as published by the Free Software
  835. // Foundation, either version 3 of the License, or (at your option) any later
  836. // version.
  837. //
  838. // Gc-Base-Lib is distributed in the hope that it will be useful, but WITHOUT
  839. // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  840. // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  841. // details.
  842. //
  843. // You should have received a copy of the GNU General Public License along with
  844. // Gc-Base-Lib. If not, see <http://www.gnu.org/licenses/>.
  845. //==============================================================================
  846. #pragma once
  847.  
  848. #include <gc/u8b.h>
  849.  
  850. struct pars_i {
  851. struct u8b_i buf;
  852. };
  853. ./dev/gc-base-lib/include/gc/file.h
  854. //==============================================================================
  855. // This file is part of Gc-Base-Lib.
  856. // Copyright (C) 2015 Anthony Gorecki <agorecki@gcproj.org>
  857. //
  858. // Gc-Base-Lib is free software: you can redistribute it and/or modify it under
  859. // the terms of the GNU General Public License as published by the Free Software
  860. // Foundation, either version 3 of the License, or (at your option) any later
  861. // version.
  862. //
  863. // Gc-Base-Lib is distributed in the hope that it will be useful, but WITHOUT
  864. // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  865. // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  866. // details.
  867. //
  868. // You should have received a copy of the GNU General Public License along with
  869. // Gc-Base-Lib. If not, see <http://www.gnu.org/licenses/>.
  870. //==============================================================================
  871. #pragma once
  872.  
  873. #include <gc/u8b.h>
  874.  
  875. #include <sys/stat.h>
  876. #include <fcntl.h>
  877.  
  878. struct file_i {
  879. int fd;
  880. };
  881.  
  882. struct file_c {
  883. const char *path;
  884. int flags;
  885. mode_t mode;
  886. };
  887.  
  888. struct file_stats {
  889. struct stat data;
  890. };
  891. ./dev/gc-base-lib/include/gc/mem.h
  892. //==============================================================================
  893. // This file is part of Gc-Base-Lib.
  894. // Copyright (C) 2015 Anthony Gorecki <agorecki@gcproj.org>
  895. //
  896. // Gc-Base-Lib is free software: you can redistribute it and/or modify it under
  897. // the terms of the GNU General Public License as published by the Free Software
  898. // Foundation, either version 3 of the License, or (at your option) any later
  899. // version.
  900. //
  901. // Gc-Base-Lib is distributed in the hope that it will be useful, but WITHOUT
  902. // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  903. // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  904. // details.
  905. //
  906. // You should have received a copy of the GNU General Public License along with
  907. // Gc-Base-Lib. If not, see <http://www.gnu.org/licenses/>.
  908. //==============================================================================
  909. #pragma once
  910.  
  911. #include <gc/common.h>
  912.  
  913. void* mem_alloc(size_t);
  914. void* mem_realloc(void*, size_t);
  915. void mem_dealloc(void*);
  916.  
  917. u8 mem_comp(void*, void*, size_t);
  918. void mem_copy(void*, void*, size_t);
  919. void mem_move(void*, void*, size_t);
  920. void mem_set(void*, u8, size_t);
  921. ./dev/doc/includes.txt
  922. External Gc headers, Gc header for local file, all other headers; groups
  923. separated by a single new line.
  924. ./dev/doc/func-args.txt
  925. Structs are always used for info and conf varaibles so their contents /
  926. implementation can easily be changed later and without modifying the code of
  927. software using the libraries.
  928. ./dev/doc/code-style.txt
  929. Soft limit for line length is 80 characters, hard limit is 100 characters.
  930.  
  931. Conditional statements requiring multiple lines should indent the subsequent
  932. lines with two tabs (one additional tab, relative the the code following the
  933. conditional statement).
  934. ./dev/doc/func-naming.txt
  935. Hard limit for function name first part is five characters. Soft limit is
  936. four characters.
  937.  
  938. Function name hard limit for second part is five characters (initialization /
  939. activation). Does not apply to names that have been shortened to individual
  940. characters per word.
  941.  
  942. Struct member name soft limit is four characters.
  943. ./script/upload-pastebin.sh
  944. cd /root
  945.  
  946. echo 'Files:'
  947.  
  948. files=$(find -name '*.c' -o -name '*.h' -o -name '*.py' -o -name '*.sh' -o -name '*.txt' -o -name '.vimrc')
  949.  
  950. date > upload-data.txt
  951.  
  952. for file in $files; do
  953. echo " $file"
  954. echo $file >> upload-data.txt
  955. cat $file >> upload-data.txt
  956. done
  957.  
  958. echo
  959. echo -n 'URL: '
  960. python ./script/intrn/upload-pastebin.py `cat script/intrn/dev-key`
  961. rm upload-data.txt
  962. ./script/intrn/upload-pastebin.py
  963. import pastebin_python
  964. import sys
  965.  
  966. pb = pastebin_python.pastebin.PastebinPython(api_dev_key=sys.argv[1])
  967. print pb.createPasteFromFile('upload-data.txt', 'anthony gorecki anthony@anthonygorecki.ca', '', '0', 'N')
  968. ./.vimrc
  969. set ts=4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement