Advertisement
Guest User

anthony gorecki anthony@anthonygorecki.ca

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