Advertisement
Guest User

anthony gorecki anthony@anthonygorecki.ca

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