Advertisement
Guest User

anthony gorecki anthony@anthonygorecki.ca

a guest
Nov 27th, 2015
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 42.57 KB | None | 0 0
  1. Fri Nov 27 06:01:29 EST 2015
  2. ./gc-base-lib/2/src/ct/tavl.c
  3. ./gc-base-lib/2/src/ct/trbll.c
  4. ./gc-base-lib/2/src/ct/it.c
  5. ./gc-base-lib/2/src/svc/atq.c
  6. ./gc-base-lib/2/src/svc/tpool_a.c
  7. ./gc-base-lib/2/src/os/linux/aio.txt
  8. kernel aio linux 512, 2048 or other sector size, as determined by the underlying
  9. block device. can get this value via ioctl.
  10.  
  11. also can do simple kernel aio implementation better than libaio. use this instead.
  12. see firefox bookmark "own aio impl" x2
  13.  
  14. aio works for block size increments. reads / writes other than that size to the
  15. beginning or end of the file will be blocking. see firefox bookmark "blocking aio".
  16. this has not been verified.
  17. ./gc-base-lib/2/src/os/linux/this_dir.txt
  18. linux specific things like signalfd, timerfd, kernel aio go in this directory
  19. ./gc-base-lib/2/src/os/unix/pcnd.c
  20. ./gc-base-lib/2/src/os/unix/mtx_attr.c
  21. ./gc-base-lib/2/src/os/unix/cnd_attr.c
  22. ./gc-base-lib/2/src/os/unix/mtx.c
  23. ./gc-base-lib/2/src/os/unix/cnd.c
  24. ./gc-base-lib/2/src/os/unix/thrd.c
  25. ./gc-base-lib/2/src/os/unix/pmtx.c
  26. ./gc-base-lib/1/src/ct/u8bcss.c
  27. //==============================================================================
  28. // This file is part of Gc-Base-Lib.
  29. // Lockless circular buffer, supporting a single producer and single consumer.
  30. // Copyright (C) 2015 Anthony Gorecki <agorecki@gcproj.org>
  31. //
  32. // Gc-Base-Lib is free software: you can redistribute it and/or modify it under
  33. // the terms of the GNU General Public License as published by the Free Software
  34. // Foundation, either version 3 of the License, or (at your option) any later
  35. // version.
  36. //
  37. // Gc-Base-Lib is distributed in the hope that it will be useful, but WITHOUT
  38. // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  39. // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  40. // details.
  41. //
  42. // You should have received a copy of the GNU General Public License along with
  43. // Gc-Base-Lib. If not, see <http://www.gnu.org/licenses/>.
  44. //==============================================================================
  45. #include <gc/mem.h>
  46.  
  47. #include <gc/u8bcss.h>
  48.  
  49. // Two variable "u8_a" type, member 1 is "dbeg", member 2 is "cbeg".
  50. //
  51. // Minimum size for this buffer implementation is two bytes. Check for this in
  52. // conf validation.
  53. //
  54. // Implementation should work out figures using the nonatomic 'scout' member.
  55. // Contig is inteded for buffer output, where parsers might need a certain
  56. // number of contiguous bytes to function properly. Support is also provided for
  57. // contiguous bytes for buffer input, should it be useful. These numbers are
  58. // designed to represent the /minimum/ that the application can handle.
  59. //
  60. // This buffer is not designed to handle circumstances in which the read or
  61. // write address needs to be aligned to some specific value, or when the reads
  62. // and writes need to be of a particular size. In other words, it is not
  63. // designed for linux kernel aio or any other kind of disk aio.
  64. //
  65. // This buffer is a candidate for sync and async network io, and sync disk io,
  66. // as well as unix pipes.
  67. //
  68. // Buffer conversion will be available: u8bcss -> u8_b for pars_ -> publish
  69. // changes back to original u8bcss once finished. This will work for more
  70. // advanced to less advanced buffers, and the other way around. Will have a
  71. // similar style to the (file) input and output functions at the end of this
  72. // file. This might only be for contiguous io segments. The buffer conversion
  73. // function is not responsible for doing any initialization or deinitialization
  74. // of the target buffer.
  75.  
  76.  
  77.  
  78. //==============================================================================
  79. // Initialization
  80. //==============================================================================
  81. __dllexp u8 u8bcss_init(struct u8bcss_i *buf, struct u8bcss_c *conf)
  82. {
  83. // Atomic members need to be initialized before being used. Do that here.
  84.  
  85. buf->scin = conf->scin; // U16
  86. buf->scout = conf->scout;
  87. buf->cin = buf->cbeg - conf->scntg;
  88. buf->cout = 0;
  89. buf->din = buf->dbeg + conf->scntg;
  90. buf->dout = buf->dbeg + conf->scntg;
  91. return 0;
  92. }
  93.  
  94.  
  95.  
  96. //==============================================================================
  97. // Advance
  98. //==============================================================================
  99. __dllexp void u8bcss_ia(struct u8bcss_i *buf, u32 size)
  100. {
  101. u32 off = buf->din - buf->dbeg + size;
  102.  
  103. if (off < buf->cbeg - 1)
  104. buf->din += size;
  105.  
  106. else // Wrap around.
  107. buf->din = buf->dbeg + off - buf->cbeg;
  108.  
  109. atmc_fsub(&buf->cin, size);
  110. atmc_fadd(&buf->cout, size);
  111. }
  112.  
  113.  
  114. __dllexp void u8bcss_oa(struct u8bcss_i *buf, u32 size)
  115. {
  116. u32 off = buf->dout - buf->dbeg + size;
  117.  
  118. if (off < buf->cbeg - 1)
  119. buf->dout += size;
  120.  
  121. else // Wrap around.
  122. buf->dout = buf->dbeg + off - buf->cbeg;
  123.  
  124. atmc_fsub(&buf->cout, size);
  125. atmc_fadd(&buf->cin, size);
  126. }
  127.  
  128.  
  129.  
  130. //==============================================================================
  131. // Count
  132. //==============================================================================
  133. __dllexp u32 u8bcss_igc(struct u8bcss_i *buf)
  134. {
  135. return atmc_load(&buf->cin);
  136. }
  137.  
  138.  
  139. __dllexp u32 u8bcss_ogc(struct u8bcss_i *buf)
  140. {
  141. return atmc_load(&buf->cout);
  142. }
  143.  
  144.  
  145.  
  146. //==============================================================================
  147. // Contiguous count and pointer
  148. //==============================================================================
  149. __dllexp u32 u8bcss_igcc(struct u8bcss_i *buf)
  150. {
  151. u32 off_in = buf->din - buf->dbeg;
  152. u32 orig_cin = atmc_load(&buf->cin);
  153.  
  154. if (off_in + orig_cin < buf->cbeg - 1)
  155. return orig_cout;
  156.  
  157. return buf->cbeg - off_in;
  158. }
  159.  
  160.  
  161. __dllexp u8 *u8bcss_igcp(struct u8bcss_i *buf)
  162. {
  163. return buf->din;
  164. }
  165.  
  166.  
  167. __dllexp u32 u8bcss_ogcc(struct u8bcss_i *buf)
  168. {
  169. u32 off_out = buf->dout - buf->dbeg;
  170. u32 orig_cout = atmc_load(&buf->cout);
  171.  
  172. if (off_out + orig_cout < buf->cbeg - 1)
  173. return orig_cout;
  174.  
  175. return buf->cbeg - off_out;
  176. }
  177.  
  178.  
  179. __dllexp u8 *u8bcss_ogcp(struct u8bcss_i *buf)
  180. {
  181. return buf->dout;
  182. }
  183.  
  184.  
  185.  
  186. //==============================================================================
  187. // Peeking
  188. //==============================================================================
  189. __dllexp u8 u8bcss_op1(struct u8bcss_i *buf)
  190. {
  191. return buf->dout[0];
  192. }
  193.  
  194.  
  195. __dllexp u16 u8bcss_op2(struct u8bcss_i *buf)
  196. {
  197. u8 data[2];
  198.  
  199. data[0] = buf->dout[0];
  200.  
  201. if (buf->dout <= buf->dbeg + buf->cbeg - 2)
  202. data[1] = buf->dout[1];
  203.  
  204. else
  205. data[1] = buf->dbeg[0];
  206.  
  207. return (u16)data;
  208. }
  209.  
  210.  
  211.  
  212. //==============================================================================
  213. // Input and output
  214. //==============================================================================
  215. __dllexp u8 u8bcss_if(struct u8bcss_i *buf, u8 (*fin)(void*, u8*, u32, u32*),
  216. void *arg)
  217. {
  218. u32 ret;
  219.  
  220. if (unlikely(fin(arg, buf->din, u8bcss_igcc(buf), &ret)))
  221. return 1;
  222.  
  223. u8bcss_ia(buf, ret);
  224. return 0;
  225. }
  226.  
  227.  
  228. __dllexp u8 u8bcss_of(struct u8bcss_i *buf, u8 (*fout)(void*, u8*, u32, u32*),
  229. void *arg)
  230. {
  231. u32 ret;
  232.  
  233. if (unlikely(fout(arg, buf->dout, u8bcss_ogcc(buf), &ret)))
  234. return 1;
  235.  
  236. u8bcss_oa(buf, ret);
  237. return 0;
  238. }
  239. ./gc-base-lib/1/src/ct/u8ib.c
  240. //==============================================================================
  241. // This file is part of Gc-Base-Lib.
  242. // Copyright (C) 2015 Anthony Gorecki <agorecki@gcproj.org>
  243. //
  244. // Gc-Base-Lib is free software: you can redistribute it and/or modify it under
  245. // the terms of the GNU General Public License as published by the Free Software
  246. // Foundation, either version 3 of the License, or (at your option) any later
  247. // version.
  248. //
  249. // Gc-Base-Lib is distributed in the hope that it will be useful, but WITHOUT
  250. // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  251. // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  252. // details.
  253. //
  254. // You should have received a copy of the GNU General Public License along with
  255. // Gc-Base-Lib. If not, see <http://www.gnu.org/licenses/>.
  256. //==============================================================================
  257. #include <gc/mem.h>
  258.  
  259. #include <gc/u8ib.h>
  260.  
  261.  
  262.  
  263. //==============================================================================
  264. // Initialization and deinitialization
  265. //==============================================================================
  266. CT_WRAP_MSI2D1(__dllexp, u8ib);
  267.  
  268.  
  269. u8 u8ib_init_ms(struct u8ib_i *ibuf, struct u8ib_c *conf)
  270. {
  271. MS_BEG(0);
  272.  
  273. MS_SP {
  274. ibuf->buf = mem_alloc(conf->sbuf);
  275. MS_EV(ibuf->buf != NULL || !conf->sbuf);
  276. }
  277.  
  278. MS_SP { MS_EV(!conf->f->init(ibuf->buf, conf->buf)); }
  279. MS_SP { ibuf->f = conf->f; }
  280. return 0;
  281. }
  282.  
  283.  
  284. void u8ib_deinit_ms(struct u8ib_i *ibuf, u8 step)
  285. {
  286. MS_BEG(step);
  287. MS_EM;
  288. MS_SP { ibuf->f->deinit(ibuf->buf); }
  289. MS_SP { mem_dealloc(ibuf->buf); }
  290. }
  291.  
  292.  
  293.  
  294. //==============================================================================
  295. // Advance
  296. //==============================================================================
  297. __dllexp void u8ib_ia(struct u8ib_i *ibuf, u32 size)
  298. {
  299. ibuf->f->ia(ibuf->buf, size);
  300. }
  301.  
  302.  
  303. __dllexp void u8ib_oa(struct u8ib_i *ibuf, u32 size)
  304. {
  305. ibuf->f->oa(ibuf->buf, size);
  306. }
  307.  
  308.  
  309.  
  310. //==============================================================================
  311. // Count
  312. //==============================================================================
  313. __dllexp u32 u8ib_igc(struct u8ib_i *ibuf)
  314. {
  315. return ibuf->f->igc(ibuf->buf);
  316. }
  317.  
  318.  
  319. __dllexp u32 u8ib_ogc(struct u8ib_i *ibuf)
  320. {
  321. return ibuf->f->ogc(ibuf->buf);
  322. }
  323.  
  324.  
  325.  
  326. //==============================================================================
  327. // Contiguous count and pointer
  328. //==============================================================================
  329. __dllexp u32 u8ib_igcc(struct u8ib_i *ibuf)
  330. {
  331. return ibuf->f->igcc(ibuf->buf);
  332. }
  333.  
  334.  
  335. __dllexp u8 *u8ib_igcp(struct u8ib_i *ibuf)
  336. {
  337. return ibuf->f->igcp(ibuf->buf);
  338. }
  339.  
  340.  
  341. __dllexp u32 u8ib_ogcc(struct u8ib_i *ibuf)
  342. {
  343. return ibuf->f->ogcc(ibuf->buf);
  344. }
  345.  
  346.  
  347. __dllexp u8 *u8ib_ogcp(struct u8ib_i *ibuf)
  348. {
  349. return ibuf->f->ogcp(ibuf->buf);
  350. }
  351.  
  352.  
  353.  
  354. //==============================================================================
  355. // Peeking
  356. //==============================================================================
  357. __dllexp u8 u8ib_op1(struct u8ib_i *ibuf)
  358. {
  359. return ibuf->f->op1(ibuf->buf);
  360. }
  361.  
  362.  
  363. __dllexp u16 u8ib_op2(struct u8ib_i *ibuf)
  364. {
  365. return ibuf->f->op2(ibuf->buf);
  366. }
  367.  
  368.  
  369.  
  370. //==============================================================================
  371. // Input and output
  372. //==============================================================================
  373. __dllexp u8 u8ib_if(struct u8ib_i *ibuf, u8 (*fin)(void*, u8*, u32, u32*),
  374. void *arg)
  375. {
  376. return ibuf->if(ibuf->buf, fin, arg);
  377. }
  378.  
  379.  
  380. __dllexp u8 u8ib_of(struct u8ib_i *ibuf, u8 (*fout)(void*, u8*, u32, u32*),
  381. void *arg)
  382. {
  383. return ibuf->of(ibuf->buf, fout, arg);
  384. }
  385. ./gc-base-lib/1/src/ct/u8a.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/mem.h>
  404.  
  405. #include <gc/u8a.h>
  406.  
  407.  
  408.  
  409. //==============================================================================
  410. // Initialization and deinitialization
  411. //==============================================================================
  412. __dllexp u8 u8a_init(u8 **arr, u32 *size, struct u8a_c *conf)
  413. {
  414. *arr = mem_alloc(conf->size);
  415.  
  416. if (unlikely(*arr == NULL && conf->size))
  417. return 1;
  418.  
  419. *size = conf->size;
  420. return 0;
  421. }
  422.  
  423.  
  424. __dllexp void u8a_deinit(u8 **arr)
  425. {
  426. mem_dealloc(*arr);
  427. }
  428.  
  429.  
  430.  
  431. //==============================================================================
  432. // Ranges
  433. //==============================================================================
  434. __dllexp u32 u8a_rm(u8 *arr, u32 size, u8 lower, u8 upper)
  435. {
  436. while (size && *arr >= lower && *arr <= upper) {
  437. ++arr;
  438. --size;
  439. }
  440.  
  441. return size;
  442. }
  443.  
  444.  
  445. __dllexp u32 u8a_rma(u8 *arr, u32 size, u8 *arng, u8 crng)
  446. {
  447. while (size && !u8_rma(*arr, arng, crng)) {
  448. ++arr;
  449. --size;
  450. }
  451.  
  452. return size;
  453. }
  454.  
  455.  
  456.  
  457. //==============================================================================
  458. // Values
  459. //==============================================================================
  460. __dllexp u32 u8a_vm(u8 *arr, u32 size, u8 val)
  461. {
  462. while (size && *arr == val) {
  463. ++arr;
  464. --size;
  465. }
  466.  
  467. return size;
  468. }
  469.  
  470.  
  471. __dllexp u32 u8a_vm2(u8 *arr, u32 size, u8 val1, u8 val2) // For new lines.
  472. {
  473. while (size >= 2 && *arr == val1 && *(arr+1) == val2) {
  474. arr += 2;
  475. size -= 2;
  476. }
  477.  
  478. return size;
  479. }
  480.  
  481.  
  482. __dllexp u32 u8a_vma(u8 *arr, u32 size, u8 *aval, u8 cval)
  483. {
  484. while (size && !u8_vma(*arr, aval, cval)) {
  485. ++arr;
  486. --size;
  487. }
  488.  
  489. return size;
  490. }
  491.  
  492.  
  493.  
  494. //==============================================================================
  495. // Special characters
  496. //==============================================================================
  497. __dllexp u32 u8a_sm(u8 *arr, u32 size, u8 spec, u8 esc)
  498. {
  499. return size;
  500. }
  501.  
  502.  
  503. __dllexp u32 u8a_sma(u8 *arr, u32 size, u8 *aspec, u8 cspec, u8 esc)
  504. {
  505. // Match array of nonescaped special characters; escape character can also
  506. // be escaped (use bool "escaped" var)
  507. //
  508. // use separate function to match escape char?
  509.  
  510. return size;
  511. }
  512.  
  513.  
  514.  
  515. //==============================================================================
  516. // New line characters
  517. //==============================================================================
  518. __dllexp u8 u8a_nld(u8 *arr, u32 size, u8 types)
  519. {
  520. assert((types & NL_RN) || (types & NL_N) || (types & NL_R));
  521.  
  522. if (size >= 2 && (types & NL_RN) && *arr == '\r' && *(arr+1) == '\n')
  523. return NL_RN;
  524.  
  525. if (size) {
  526. if ((types & NL_N) && *arr == '\n')
  527. return NL_N;
  528.  
  529. if ((types & NL_R) && *arr == '\r')
  530. return NL_R;
  531. }
  532.  
  533. return 0;
  534. }
  535.  
  536.  
  537. __dllexp u32 u8a_nlm(u8 *arr, u32 size, u8 types)
  538. {
  539. assert((types & NL_RN) || (types & NL_N) || (types & NL_R));
  540.  
  541. if ((types & NL_RN))
  542. return u8a_vm2(arr, size, '\r', '\n');
  543.  
  544. if ((types & NL_N))
  545. return u8a_vm(arr, size, '\n');
  546.  
  547. return u8a_vm(arr, size, '\r');
  548. }
  549.  
  550.  
  551. __dllexp u32 u8a_nlmm(u8 *arr, u32 size, u8 types)
  552. {
  553. u32 rem;
  554.  
  555. for (;;) {
  556. rem = u8a_nlm(arr, size, types);
  557.  
  558. if (rem >= size)
  559. break;
  560.  
  561. arr += size - rem;
  562. size = rem;
  563. }
  564.  
  565. return size;
  566. }
  567. ./gc-base-lib/1/src/ct/u8b.c
  568. ./gc-base-lib/1/src/ct/u8bc.c
  569. //==============================================================================
  570. // This file is part of Gc-Base-Lib.
  571. // Simple circular buffer, supporting nonsimultaneous input and output.
  572. // Copyright (C) 2015 Anthony Gorecki <agorecki@gcproj.org>
  573. //
  574. // Gc-Base-Lib is free software: you can redistribute it and/or modify it under
  575. // the terms of the GNU General Public License as published by the Free Software
  576. // Foundation, either version 3 of the License, or (at your option) any later
  577. // version.
  578. //
  579. // Gc-Base-Lib is distributed in the hope that it will be useful, but WITHOUT
  580. // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  581. // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  582. // details.
  583. //
  584. // You should have received a copy of the GNU General Public License along with
  585. // Gc-Base-Lib. If not, see <http://www.gnu.org/licenses/>.
  586. //==============================================================================
  587. #include <gc/mem.h>
  588.  
  589. #include <gc/u8bc.h>
  590.  
  591.  
  592.  
  593. //==============================================================================
  594. // Initialization and deinitialization
  595. //==============================================================================
  596. u8 u8bc_init(struct u8bc_i *buf, struct u8bc_c *conf)
  597. {
  598. // Minimum size for this buffer implementation is two bytes. Check for this
  599. // in conf validation.
  600.  
  601. buf->dbeg = mem_alloc(conf->size);
  602.  
  603. if (unlikely(buf->dbeg == NULL))
  604. return 1;
  605.  
  606. buf->cbeg = size;
  607. return 0;
  608. }
  609.  
  610.  
  611. void u8bc_deinit(struct u8bc_i *buf)
  612. {
  613. mem_dealloc(buf->dbeg);
  614. }
  615.  
  616.  
  617.  
  618. //==============================================================================
  619. // Advance
  620. //==============================================================================
  621. void u8bc_ia(struct u8bc_i *buf, u32 size)
  622. {
  623. u32 off = buf->din - buf->dbeg + size;
  624.  
  625. if (off < buf->cbeg - 1)
  626. buf->din += size;
  627.  
  628. else // Wrap around.
  629. buf->din = buf->dbeg + off - buf->cbeg;
  630.  
  631. atmc_fsub(&buf->cin, size);
  632. atmc_fadd(&buf->cout, size);
  633. }
  634.  
  635.  
  636. void u8bc_oa(struct u8bc_i *buf, u32 size)
  637. {
  638. u32 off = buf->dout - buf->dbeg + size;
  639.  
  640. if (off < buf->cbeg - 1)
  641. buf->dout += size;
  642.  
  643. else // Wrap around.
  644. buf->dout = buf->dbeg + off - buf->cbeg;
  645.  
  646. atmc_fsub(&buf->cout, size);
  647. atmc_fadd(&buf->cin, size);
  648. }
  649.  
  650.  
  651.  
  652. //==============================================================================
  653. // Count
  654. //==============================================================================
  655. u32 u8bc_igc(struct u8bc_i *buf)
  656. {
  657. return atmc_load(&buf->cin);
  658. }
  659.  
  660.  
  661. u32 u8bc_ogc(struct u8bc_i *buf)
  662. {
  663. return atmc_load(&buf->cout);
  664. }
  665.  
  666.  
  667.  
  668. //==============================================================================
  669. // Contiguous count and pointer
  670. //==============================================================================
  671. u32 u8bc_igcc(struct u8bc_i *buf)
  672. {
  673. u32 off_in = buf->din - buf->dbeg;
  674. u32 orig_cin = atmc_load(&buf->cin);
  675.  
  676. if (off_in + orig_cin < buf->cbeg - 1)
  677. return orig_cout;
  678.  
  679. return buf->cbeg - off_in;
  680. }
  681.  
  682.  
  683. u8 *u8bc_igcp(struct u8bc_i *buf)
  684. {
  685. return buf->din;
  686. }
  687.  
  688.  
  689. u32 u8bc_ogcc(struct u8bc_i *buf)
  690. {
  691. u32 off_out = buf->dout - buf->dbeg;
  692. u32 orig_cout = atmc_load(&buf->cout);
  693.  
  694. if (off_out + orig_cout < buf->cbeg - 1)
  695. return orig_cout;
  696.  
  697. return buf->cbeg - off_out;
  698. }
  699.  
  700.  
  701. u8 *u8bc_ogcp(struct u8bc_i *buf)
  702. {
  703. return buf->dout;
  704. }
  705.  
  706.  
  707.  
  708. //==============================================================================
  709. // Peeking
  710. //==============================================================================
  711. u8 u8bc_op1(struct u8bc_i *buf)
  712. {
  713. return buf->dout[0];
  714. }
  715.  
  716.  
  717. u16 u8bc_op2(struct u8bc_i *buf)
  718. {
  719. u8 data[2];
  720.  
  721. data[0] = buf->dout[0];
  722.  
  723. if (buf->dout <= buf->dbeg + buf->cbeg - 2)
  724. data[1] = buf->dout[1];
  725.  
  726. else
  727. data[1] = buf->dbeg[0];
  728.  
  729. return (u16)data;
  730. }
  731.  
  732.  
  733.  
  734. //==============================================================================
  735. // Input and output
  736. //==============================================================================
  737. u8 u8bc_if(struct u8bc_i *buf, u8 (*fin)(void*, u8*, u32, u32*),
  738. void *arg)
  739. {
  740. u32 ret;
  741.  
  742. if (unlikely(fin(arg, buf->din, u8bc_igcc(buf), &ret)))
  743. return 1;
  744.  
  745. u8bc_ia(buf, ret);
  746. return 0;
  747. }
  748.  
  749.  
  750. u8 u8bc_of(struct u8bc_i *buf, u8 (*fout)(void*, u8*, u32, u32*),
  751. void *arg)
  752. {
  753. u32 ret;
  754.  
  755. if (unlikely(fout(arg, buf->dout, u8bc_ogcc(buf), &ret)))
  756. return 1;
  757.  
  758. u8bc_oa(buf, ret);
  759. return 0;
  760. }
  761. ./gc-base-lib/1/src/util/pars.c
  762. //==============================================================================
  763. // This file is part of Gc-Base-Lib.
  764. // Copyright (C) 2015 Anthony Gorecki <agorecki@gcproj.org>
  765. //
  766. // Gc-Base-Lib is free software: you can redistribute it and/or modify it under
  767. // the terms of the GNU General Public License as published by the Free Software
  768. // Foundation, either version 3 of the License, or (at your option) any later
  769. // version.
  770. //
  771. // Gc-Base-Lib is distributed in the hope that it will be useful, but WITHOUT
  772. // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  773. // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  774. // details.
  775. //
  776. // You should have received a copy of the GNU General Public License along with
  777. // Gc-Base-Lib. If not, see <http://www.gnu.org/licenses/>.
  778. //==============================================================================
  779. #include <gc/pars.h>
  780.  
  781. // If it is possible to convert between buffer types, this should probably be
  782. // moved to u8_a. u8_a_nlcs et al.
  783. //
  784. // This parser requires exclusive access the the buffer region provided by buf.
  785. // For multiple reader buffers, it's expected that a block of data will be read,
  786. // converted to a u8_b for the parser, and treated as a contiguous array.
  787.  
  788. ./gc-base-lib/1/src/pt/u8.c
  789. //==============================================================================
  790. // This file is part of Gc-Base-Lib.
  791. // Copyright (C) 2015 Anthony Gorecki <agorecki@gcproj.org>
  792. //
  793. // Gc-Base-Lib is free software: you can redistribute it and/or modify it under
  794. // the terms of the GNU General Public License as published by the Free Software
  795. // Foundation, either version 3 of the License, or (at your option) any later
  796. // version.
  797. //
  798. // Gc-Base-Lib is distributed in the hope that it will be useful, but WITHOUT
  799. // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  800. // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  801. // details.
  802. //
  803. // You should have received a copy of the GNU General Public License along with
  804. // Gc-Base-Lib. If not, see <http://www.gnu.org/licenses/>.
  805. //==============================================================================
  806. #include <gc/u8.h>
  807.  
  808.  
  809.  
  810. //==============================================================================
  811. // Ranges and values
  812. //==============================================================================
  813. __dllexp u8 u8_rma(u8 data, u8 *arng, u8 crng)
  814. {
  815. while (crng) {
  816. if (data >= *arng && data <= *(++arng))
  817. return 0;
  818.  
  819. ++arng;
  820. --crng;
  821. }
  822.  
  823. return 1;
  824. }
  825.  
  826.  
  827. __dllexp u8_vma(u8 data, u8 *aval, u8 cval)
  828. {
  829. while (cval) {
  830. if (data == *aval)
  831. return 0;
  832.  
  833. ++aval;
  834. --cval;
  835. }
  836.  
  837. return 1;
  838. }
  839. ./gc-base-lib/1/src/os/unix/proc.c
  840. //==============================================================================
  841. // This file is part of Gc-Base-Lib.
  842. // Copyright (C) 2015 Anthony Gorecki <agorecki@gcproj.org>
  843. //
  844. // Gc-Base-Lib is free software: you can redistribute it and/or modify it under
  845. // the terms of the GNU General Public License as published by the Free Software
  846. // Foundation, either version 3 of the License, or (at your option) any later
  847. // version.
  848. //
  849. // Gc-Base-Lib is distributed in the hope that it will be useful, but WITHOUT
  850. // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  851. // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  852. // details.
  853. //
  854. // You should have received a copy of the GNU General Public License along with
  855. // Gc-Base-Lib. If not, see <http://www.gnu.org/licenses/>.
  856. //==============================================================================
  857. // proc_st_init, proc_st_next, ...
  858. #include <gc/proc.h>
  859.  
  860.  
  861.  
  862. //==============================================================================
  863. // Execution
  864. //==============================================================================
  865. __dllexp u8 proc_exec(void)
  866. {
  867. }
  868. ./gc-base-lib/1/src/os/unix/mem.c
  869. //==============================================================================
  870. // This file is part of Gc-Base-Lib.
  871. // Copyright (C) 2015 Anthony Gorecki <agorecki@gcproj.org>
  872. //
  873. // Gc-Base-Lib is free software: you can redistribute it and/or modify it under
  874. // the terms of the GNU General Public License as published by the Free Software
  875. // Foundation, either version 3 of the License, or (at your option) any later
  876. // version.
  877. //
  878. // Gc-Base-Lib is distributed in the hope that it will be useful, but WITHOUT
  879. // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  880. // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  881. // details.
  882. //
  883. // You should have received a copy of the GNU General Public License along with
  884. // Gc-Base-Lib. If not, see <http://www.gnu.org/licenses/>.
  885. //==============================================================================
  886. #include <gc/mem.h>
  887.  
  888. #include <stdlib.h>
  889. #include <string.h>
  890.  
  891.  
  892.  
  893. //==============================================================================
  894. // Allocation, reallocation and deallocation
  895. //==============================================================================
  896. __dllexp void *mem_alloc(size_t size)
  897. {
  898. return malloc(size);
  899. }
  900.  
  901.  
  902. __dllexp void *mem_realloc(void *ptr, size_t size)
  903. {
  904. return realloc(ptr, size);
  905. }
  906.  
  907.  
  908. __dllexp void mem_dealloc(void *ptr)
  909. {
  910. free(ptr);
  911. }
  912.  
  913.  
  914.  
  915. //==============================================================================
  916. // Utility
  917. //==============================================================================
  918. __dllexp s8 mem_comp(void *data1, void *data2, size_t size)
  919. {
  920. return memcmp(data1, data2, size);
  921. }
  922.  
  923.  
  924. __dllexp void mem_copy(void *dest, void *src, size_t size)
  925. {
  926. memcpy(dest, src, size);
  927. }
  928.  
  929.  
  930. __dllexp void mem_move(void *dest, void *src, size_t size)
  931. {
  932. memmove(dest, src, size);
  933. }
  934.  
  935.  
  936. __dllexp void mem_set(void *ptr, u8 data, size_t size)
  937. {
  938. memset(ptr, data, size);
  939. }
  940. ./gc-base-lib/1/src/os/unix/file.c
  941. //==============================================================================
  942. // This file is part of Gc-Base-Lib.
  943. // Copyright (C) 2015 Anthony Gorecki <agorecki@gcproj.org>
  944. //
  945. // Gc-Base-Lib is free software: you can redistribute it and/or modify it under
  946. // the terms of the GNU General Public License as published by the Free Software
  947. // Foundation, either version 3 of the License, or (at your option) any later
  948. // version.
  949. //
  950. // Gc-Base-Lib is distributed in the hope that it will be useful, but WITHOUT
  951. // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  952. // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  953. // details.
  954. //
  955. // You should have received a copy of the GNU General Public License along with
  956. // Gc-Base-Lib. If not, see <http://www.gnu.org/licenses/>.
  957. //==============================================================================
  958. #include <gc/file.h>
  959.  
  960. #include <unistd.h>
  961.  
  962.  
  963.  
  964. //==============================================================================
  965. // Initialization and deinitialization
  966. //==============================================================================
  967. __dllexp u8 file_init(struct file_i *file, struct file_c *conf)
  968. {
  969. if (!(conf->flags & FILE_CREAT))
  970. file->fd = open(conf->path, conf->flags);
  971.  
  972. else
  973. file->fd = open(conf->path, conf->flags, conf->mode);
  974.  
  975. if (unlikely(file->fd == -1))
  976. return 1;
  977.  
  978. return 0;
  979. }
  980.  
  981.  
  982. __dllexp void file_deinit(struct file_i *file)
  983. {
  984. close(file->fd);
  985. }
  986.  
  987.  
  988.  
  989. //==============================================================================
  990. // Read and write
  991. //==============================================================================
  992. __dllexp u8 file_read(struct file_i *file, u8 *buf, u32 size, u32 *ret)
  993. {
  994. ssize_t bytes = read(file->fd, buf, size);
  995.  
  996. if (unlikely(bytes == -1))
  997. return 1;
  998.  
  999. *ret = bytes;
  1000. return 0;
  1001. }
  1002.  
  1003.  
  1004. __dllexp u8 file_write(struct file_i *file, u8 *buf, u32 size, u32 *ret)
  1005. {
  1006. ssize_t bytes = write(file->fd, buf, size);
  1007.  
  1008. if (unlikely(bytes == -1))
  1009. return 1;
  1010.  
  1011. *ret = bytes;
  1012. return 0;
  1013. }
  1014.  
  1015.  
  1016.  
  1017. //==============================================================================
  1018. // Utility
  1019. //==============================================================================
  1020. __dllexp u8 file_gstats(struct file_i *file, struct file_stats *stats)
  1021. {
  1022. if (unlikely(fstat(file->fd, &stats->data)))
  1023. return 1;
  1024.  
  1025. return 0;
  1026. }
  1027. ./gc-base-lib/1/gc-proj.txt
  1028. #===============================================================================
  1029. # This file is part of Gc-Base-Lib.
  1030. # Copyright (C) 2015 Anthony Gorecki <agorecki@gcproj.org>
  1031. #
  1032. # Gc-Base-Lib is free software: you can redistribute it and/or modify it under
  1033. # the terms of the GNU General Public License as published by the Free Software
  1034. # Foundation, either version 3 of the License, or (at your option) any later
  1035. # version.
  1036. #
  1037. # Gc-Base-Lib is distributed in the hope that it will be useful, but WITHOUT
  1038. # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  1039. # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  1040. #
  1041. # You should have received a copy of the GNU General Public License along with
  1042. # Gc-Base-Lib. If not, see <http://www.gnu.org/licenses/>.
  1043. #===============================================================================
  1044. # gc-proj-conf (tracks config; can reconfigure; if you aren't going to make 'dev'
  1045. # it won't be configured -- per target config)
  1046. # gc-proj-make (will rebuild changed files; will rebuild only necessary after conf change)
  1047. # gc-proj-inst (installs all built targets)
  1048. #
  1049. # Note: This file does not include operating system specific support yet.
  1050.  
  1051.  
  1052. TGEN dev # Make this into TDEV after parser works properly.
  1053. CONF
  1054. VARS
  1055. DIR inc
  1056. DIR pkgconfig
  1057.  
  1058. MAKE
  1059. EXEC lib/pkgconfig/make.sh $DPKGCONFIG # This should be replaced with 'sed'.
  1060.  
  1061. INST
  1062. COPY inc/gc $DINC
  1063. MOVE lib/pkgconfig/gc-base.pc.tmp $DPKGCONFIG/gc-base.pc
  1064.  
  1065.  
  1066. TLIB lib
  1067. CONF
  1068. # DEF (default target; overrides first lib or exe target if specified)
  1069. # note that the precedence of targets to be chosen first could (and
  1070. # probably should be determined by selecting a profile for the given
  1071. # programming language / project type. Documentation projects, for
  1072. # instance would not have the same precedence settings as a c project.
  1073.  
  1074. # NDIR LIB (implied by target type).
  1075.  
  1076. DLNK pthread # Need pthread library.
  1077.  
  1078. FEAT alloc # Feature to select memory allocator.
  1079. llalloc # Lockless alloc. Default option is first.
  1080. DLNK llalloc # Add to the list of libraries to link dynamically.
  1081.  
  1082. libc # Fall back to standard libc allocator.
  1083. # Nothing to do.
  1084.  
  1085. FEAT st # Feature to select stack tracing implementation.
  1086. unwind # libunwind
  1087. PCFG unwind # Use pkg-config to add cflags and libs.
  1088.  
  1089. gnubt # GNU backtrace functions
  1090. LNKF rdynamic # Add -rdynamic linker flag.
  1091. ./gc-base-lib/1/make.sh
  1092. gcc -o libgc-base -shared -I include -std=c11 -Wall -Wextra -Wpedantic -Werror `find src -type f -name '*.c'`
  1093. ./gc-base-lib/1/inc/gc/macro/ms.h
  1094. //==============================================================================
  1095. // This file is part of Gc-Base-Lib.
  1096. // Copyright (C) 2015 Anthony Gorecki <agorecki@gcproj.org>
  1097. //
  1098. // Gc-Base-Lib is free software: you can redistribute it and/or modify it under
  1099. // the terms of the GNU General Public License as published by the Free Software
  1100. // Foundation, either version 3 of the License, or (at your option) any later
  1101. // version.
  1102. //
  1103. // Gc-Base-Lib is distributed in the hope that it will be useful, but WITHOUT
  1104. // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  1105. // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  1106. // details.
  1107. //
  1108. // You should have received a copy of the GNU General Public License along with
  1109. // Gc-Base-Lib. If not, see <http://www.gnu.org/licenses/>.
  1110. //==============================================================================
  1111. #pragma once
  1112.  
  1113. #define MS_BEG(STEP)
  1114. #define MS_EM
  1115. #define MS_SP
  1116. #define MS_EV
  1117. ./gc-base-lib/1/inc/gc/proc.h
  1118. //==============================================================================
  1119. // This file is part of Gc-Base-Lib.
  1120. // Copyright (C) 2015 Anthony Gorecki <agorecki@gcproj.org>
  1121. //
  1122. // Gc-Base-Lib is free software: you can redistribute it and/or modify it under
  1123. // the terms of the GNU General Public License as published by the Free Software
  1124. // Foundation, either version 3 of the License, or (at your option) any later
  1125. // version.
  1126. //
  1127. // Gc-Base-Lib is distributed in the hope that it will be useful, but WITHOUT
  1128. // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  1129. // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  1130. // details.
  1131. //
  1132. // You should have received a copy of the GNU General Public License along with
  1133. // Gc-Base-Lib. If not, see <http://www.gnu.org/licenses/>.
  1134. //==============================================================================
  1135. #pragma once
  1136.  
  1137. #include <gc/common.h>
  1138.  
  1139. #if defined(__use_gnu_bktrc)
  1140. #include <gc/proc-gnu-bktrc.h>
  1141. #endif
  1142.  
  1143. #if defined(__use_lunwind)
  1144. #include <gc/proc-lunwind.h>
  1145. #endif
  1146.  
  1147. // Null function pointers for systems where back traces are not supported.
  1148. ./gc-base-lib/1/inc/gc/common.h
  1149. //==============================================================================
  1150. // This file is part of Gc-Base-Lib.
  1151. // Copyright (C) 2015 Anthony Gorecki <agorecki@gcproj.org>
  1152. //
  1153. // Gc-Base-Lib is free software: you can redistribute it and/or modify it under
  1154. // the terms of the GNU General Public License as published by the Free Software
  1155. // Foundation, either version 3 of the License, or (at your option) any later
  1156. // version.
  1157. //
  1158. // Gc-Base-Lib is distributed in the hope that it will be useful, but WITHOUT
  1159. // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  1160. // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  1161. // details.
  1162. //
  1163. // You should have received a copy of the GNU General Public License along with
  1164. // Gc-Base-Lib. If not, see <http://www.gnu.org/licenses/>.
  1165. //==============================================================================
  1166. #pragma once
  1167.  
  1168. #include <stddef.h>
  1169. #include <stdint.h>
  1170.  
  1171. // "__unused" is expected to be provided by a system library. Define it in this
  1172. // file only if it is missing on the host system.
  1173.  
  1174. #define likely(EXPR) __builtin_expect(EXPR, 1)
  1175. #define unlikely(EXPR) __builtin_expect(EXPR, 0)
  1176.  
  1177. typedef int8_t s8;
  1178. typedef int16_t s16;
  1179. typedef int32_t s32;
  1180. typedef int64_t s64;
  1181.  
  1182. typedef uint8_t u8;
  1183. typedef uint16_t u16;
  1184. typedef uint32_t u32;
  1185. typedef uint64_t u64;
  1186. ./gc-base-lib/1/inc/gc/u8_ib.h
  1187. //==============================================================================
  1188. // This file is part of Gc-Base-Lib.
  1189. // Copyright (C) 2015 Anthony Gorecki <agorecki@gcproj.org>
  1190. //
  1191. // Gc-Base-Lib is free software: you can redistribute it and/or modify it under
  1192. // the terms of the GNU General Public License as published by the Free Software
  1193. // Foundation, either version 3 of the License, or (at your option) any later
  1194. // version.
  1195. //
  1196. // Gc-Base-Lib is distributed in the hope that it will be useful, but WITHOUT
  1197. // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  1198. // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  1199. // details.
  1200. //
  1201. // You should have received a copy of the GNU General Public License along with
  1202. // Gc-Base-Lib. If not, see <http://www.gnu.org/licenses/>.
  1203. //==============================================================================
  1204. #pragma once
  1205.  
  1206. #include <gc/ct.h>
  1207.  
  1208. struct u8_ib_i {
  1209. };
  1210.  
  1211. struct u8_ib_c {
  1212. };
  1213. ./gc-base-lib/1/inc/gc/atmc.h
  1214. //==============================================================================
  1215. // This file is part of Gc-Base-Lib.
  1216. // Copyright (C) 2015 Anthony Gorecki <agorecki@gcproj.org>
  1217. //
  1218. // Gc-Base-Lib is free software: you can redistribute it and/or modify it under
  1219. // the terms of the GNU General Public License as published by the Free Software
  1220. // Foundation, either version 3 of the License, or (at your option) any later
  1221. // version.
  1222. //
  1223. // Gc-Base-Lib is distributed in the hope that it will be useful, but WITHOUT
  1224. // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  1225. // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  1226. // details.
  1227. //
  1228. // You should have received a copy of the GNU General Public License along with
  1229. // Gc-Base-Lib. If not, see <http://www.gnu.org/licenses/>.
  1230. //==============================================================================
  1231. #pragma once
  1232.  
  1233. #include <gc/common.h>
  1234.  
  1235. typedef _Atomic s8 as8;
  1236. typedef _Atomic s16 as16;
  1237. typedef _Atomic s32 as32;
  1238. typedef _Atomic s64 as64;
  1239.  
  1240. typedef _Atomic u8 au8;
  1241. typedef _Atomic u16 au16;
  1242. typedef _Atomic u32 au32;
  1243. typedef _Atomic u64 au64;
  1244.  
  1245. #define atmc_fadd atomic_fetch_add
  1246. #define atmc_fsub atomic_fetch_sub
  1247. #define atmc_load atomic_load
  1248. ./gc-base-lib/1/inc/gc/ct.h
  1249. //==============================================================================
  1250. // This file is part of Gc-Base-Lib.
  1251. // Copyright (C) 2015 Anthony Gorecki <agorecki@gcproj.org>
  1252. //
  1253. // Gc-Base-Lib is free software: you can redistribute it and/or modify it under
  1254. // the terms of the GNU General Public License as published by the Free Software
  1255. // Foundation, either version 3 of the License, or (at your option) any later
  1256. // version.
  1257. //
  1258. // Gc-Base-Lib is distributed in the hope that it will be useful, but WITHOUT
  1259. // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  1260. // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  1261. // details.
  1262. //
  1263. // You should have received a copy of the GNU General Public License along with
  1264. // Gc-Base-Lib. If not, see <http://www.gnu.org/licenses/>.
  1265. //==============================================================================
  1266. #pragma once
  1267.  
  1268. #include <gc/macro/ms.h>
  1269.  
  1270. // Configuration for composite types needs space for two offsets (u16's), to
  1271. // allow for two variable types (such as "u8_a").
  1272.  
  1273. #define CT_M1V 1 // Member 1 pass by value.
  1274. #define CT_M2V 2 // Member 2 pass by value.
  1275. #define CT_M2D 4 // Member 2 pass to deinit.
  1276.  
  1277. #define CT_WRAP_MSI2D1(PREF) \
  1278. u8 PREF##_init_ms(struct PREF##_i*, struct PREF##_c*); \
  1279. void PREF##_deinit_ms(struct PREF##_i*); \
  1280. u8 PREF##_init(struct PREF##_i *info, struct PREF##_c *conf) \
  1281. { \
  1282. u8 step = PREF##_init_ms(info, conf); \
  1283. if (!step) \
  1284. return 0; \
  1285. PREF##_deinit_ms(info, step); \
  1286. return 1; \
  1287. } \
  1288. void PREF##_deinit(struct PREF##_i *info) \
  1289. { \
  1290. PREF##_deinit_ms(info, 0); \
  1291. }
  1292. ./gc-base-lib/1/inc/gc/u8b.h
  1293. //==============================================================================
  1294. // This file is part of Gc-Base-Lib.
  1295. // Copyright (C) 2015 Anthony Gorecki <agorecki@gcproj.org>
  1296. //
  1297. // Gc-Base-Lib is free software: you can redistribute it and/or modify it under
  1298. // the terms of the GNU General Public License as published by the Free Software
  1299. // Foundation, either version 3 of the License, or (at your option) any later
  1300. // version.
  1301. //
  1302. // Gc-Base-Lib is distributed in the hope that it will be useful, but WITHOUT
  1303. // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  1304. // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  1305. // details.
  1306. //
  1307. // You should have received a copy of the GNU General Public License along with
  1308. // Gc-Base-Lib. If not, see <http://www.gnu.org/licenses/>.
  1309. //==============================================================================
  1310. #pragma once
  1311.  
  1312. #include <gc/atmc.h>
  1313.  
  1314. struct u8b_i {
  1315. u32 cbeg;
  1316. au32 cin;
  1317. au32 cout;
  1318. u8 *dbeg;
  1319. u8 *din;
  1320. u8 *dout;
  1321. };
  1322. ./gc-base-lib/1/inc/gc/pars.h
  1323. //==============================================================================
  1324. // This file is part of Gc-Base-Lib.
  1325. // Copyright (C) 2015 Anthony Gorecki <agorecki@gcproj.org>
  1326. //
  1327. // Gc-Base-Lib is free software: you can redistribute it and/or modify it under
  1328. // the terms of the GNU General Public License as published by the Free Software
  1329. // Foundation, either version 3 of the License, or (at your option) any later
  1330. // version.
  1331. //
  1332. // Gc-Base-Lib is distributed in the hope that it will be useful, but WITHOUT
  1333. // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  1334. // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  1335. // details.
  1336. //
  1337. // You should have received a copy of the GNU General Public License along with
  1338. // Gc-Base-Lib. If not, see <http://www.gnu.org/licenses/>.
  1339. //==============================================================================
  1340. #pragma once
  1341.  
  1342. #include <gc/u8b.h>
  1343.  
  1344. struct pars_i {
  1345. struct u8b_i buf;
  1346. };
  1347. ./gc-base-lib/1/inc/gc/file.h
  1348. //==============================================================================
  1349. // This file is part of Gc-Base-Lib.
  1350. // Copyright (C) 2015 Anthony Gorecki <agorecki@gcproj.org>
  1351. //
  1352. // Gc-Base-Lib is free software: you can redistribute it and/or modify it under
  1353. // the terms of the GNU General Public License as published by the Free Software
  1354. // Foundation, either version 3 of the License, or (at your option) any later
  1355. // version.
  1356. //
  1357. // Gc-Base-Lib is distributed in the hope that it will be useful, but WITHOUT
  1358. // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  1359. // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  1360. // details.
  1361. //
  1362. // You should have received a copy of the GNU General Public License along with
  1363. // Gc-Base-Lib. If not, see <http://www.gnu.org/licenses/>.
  1364. //==============================================================================
  1365. #pragma once
  1366.  
  1367. #include <gc/u8b.h>
  1368.  
  1369. #include <sys/stat.h>
  1370. #include <fcntl.h>
  1371.  
  1372. struct file_i {
  1373. int fd;
  1374. };
  1375.  
  1376. struct file_c {
  1377. const char *path;
  1378. int flags;
  1379. mode_t mode;
  1380. };
  1381.  
  1382. struct file_stats {
  1383. struct stat data;
  1384. };
  1385. ./gc-base-lib/1/inc/gc/mem.h
  1386. //==============================================================================
  1387. // This file is part of Gc-Base-Lib.
  1388. // Copyright (C) 2015 Anthony Gorecki <agorecki@gcproj.org>
  1389. //
  1390. // Gc-Base-Lib is free software: you can redistribute it and/or modify it under
  1391. // the terms of the GNU General Public License as published by the Free Software
  1392. // Foundation, either version 3 of the License, or (at your option) any later
  1393. // version.
  1394. //
  1395. // Gc-Base-Lib is distributed in the hope that it will be useful, but WITHOUT
  1396. // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  1397. // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  1398. // details.
  1399. //
  1400. // You should have received a copy of the GNU General Public License along with
  1401. // Gc-Base-Lib. If not, see <http://www.gnu.org/licenses/>.
  1402. //==============================================================================
  1403. #pragma once
  1404.  
  1405. #include <gc/common.h>
  1406.  
  1407. void* mem_alloc(size_t);
  1408. void* mem_realloc(void*, size_t);
  1409. void mem_dealloc(void*);
  1410.  
  1411. u8 mem_comp(void*, void*, size_t);
  1412. void mem_copy(void*, void*, size_t);
  1413. void mem_move(void*, void*, size_t);
  1414. void mem_set(void*, u8, size_t);
  1415. ./_script/upload-pastebin.sh
  1416. cd /home/agorecki/dev
  1417.  
  1418. echo 'Files:'
  1419.  
  1420. files=$(find -name '*.c' -o -name '*.h' -o -name '*.py' -o -name '*.sh' -o -name '*.txt' -o -name '.vimrc')
  1421.  
  1422. date > upload-data.txt
  1423.  
  1424. for file in $files; do
  1425. echo " $file"
  1426. echo $file >> upload-data.txt
  1427. cat $file >> upload-data.txt
  1428. done
  1429.  
  1430. echo
  1431. echo -n 'URL: '
  1432. python ./_script/intrn/upload-pastebin.py `cat _script/intrn/dev-key`
  1433. rm upload-data.txt
  1434. ./_script/intrn/upload-pastebin.py
  1435. import pastebin_python
  1436. import sys
  1437.  
  1438. pb = pastebin_python.pastebin.PastebinPython(api_dev_key=sys.argv[1])
  1439. print pb.createPasteFromFile('upload-data.txt', 'anthony gorecki anthony@anthonygorecki.ca', '', '0', 'N')
  1440. ./doc/includes.txt
  1441. External Gc headers, Gc header for local file, all other headers; groups
  1442. separated by a single new line.
  1443. ./doc/func-args.txt
  1444. Structs are always used for info and conf varaibles so their contents /
  1445. implementation can easily be changed later and without modifying the code of
  1446. software using the libraries.
  1447. ./doc/code-style.txt
  1448. Soft limit for line length is 80 characters, hard limit is 100 characters.
  1449.  
  1450. Conditional statements requiring multiple lines should indent the subsequent
  1451. lines with two tabs (one additional tab, relative the the code following the
  1452. conditional statement).
  1453. ./doc/func-naming.txt
  1454. Hard limit for function name first part is five characters. Soft limit is
  1455. four characters.
  1456.  
  1457. Function name hard limit for second part is five characters (initialization /
  1458. activation). Does not apply to names that have been shortened to individual
  1459. characters per word.
  1460.  
  1461. Struct member name soft limit is four characters.
  1462. ./doc/secure-coding.txt
  1463. Parser memory errors are treated as "no match".
  1464.  
  1465. Invalid flag arguments are treated as "no match".
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement