Advertisement
Guest User

anthony gorecki anthony@anthonygorecki.ca

a guest
Nov 14th, 2015
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.77 KB | None | 0 0
  1. Sat Nov 14 04:01:15 EST 2015
  2. dev/libgc-proj/proj-make.txt
  3. #===============================================================================
  4. # This file is part of Libgc-proj.
  5. # Copyright (C) 2015 Anthony Gorecki <anthony@anthonygorecki.ca>
  6. #
  7. # Libgc-proj is free software: you can redistribute it and/or modify it under
  8. # the terms of the GNU General Public License as published by the Free Software
  9. # Foundation, either version 3 of the License, or (at your option) any later
  10. # version.
  11. #
  12. # Libgc-proj is distributed in the hope that it will be useful, but WITHOUT ANY
  13. # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  14. # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License along with
  17. # Libgc-proj. If not, see <http://www.gnu.org/licenses/>.
  18. #===============================================================================
  19. # gc-proj-conf (tracks config; can reconfigure)
  20. # gc-proj-make (will rebuild changed files; will rebuild only necessary after conf change)
  21. # gc-proj-inst (installs all built targets)
  22.  
  23. DTGT gc-proj
  24.  
  25. TGEN dev
  26. MAKE
  27. EXEC lib/pkgconfig/make.sh $PREF
  28. INST
  29. COPY include/gc $PREF/include
  30. MOVE lib/pkgconfig/gc-proj.pc.tmp $PREF/lib/pkgconfig/gc-proj.pc
  31.  
  32. TLIB gc-proj
  33. dev/libgc-base/src/ct/u8b.c
  34. //==============================================================================
  35. // This file is part of Libgc-base.
  36. // Copyright (C) 2015 Anthony Gorecki <anthony@anthonygorecki.ca>
  37. //
  38. // Libgc-base is free software: you can redistribute it and/or modify it under
  39. // the terms of the GNU General Public License as published by the Free Software
  40. // Foundation, either version 3 of the License, or (at your option) any later
  41. // version.
  42. //
  43. // Libgc-base is distributed in the hope that it will be useful, but WITHOUT ANY
  44. // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  45. // A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  46. //
  47. // You should have received a copy of the GNU General Public License along with
  48. // Libgc-base. If not, see <http://www.gnu.org/licenses/>.
  49. //==============================================================================
  50. #include <gc/mem.h>
  51.  
  52. #include <gc/u8b.h>
  53.  
  54.  
  55.  
  56. //==============================================================================
  57. // Initialization and deinitialization
  58. //==============================================================================
  59. u8 u8b_init(struct u8b_i *buf, struct u8b_c *conf)
  60. {
  61. buf->dbeg = mem_alloc(conf->size);
  62.  
  63. if (unlikely(buf->dbeg == NULL))
  64. return 1;
  65.  
  66. buf->cbeg = size;
  67. buf->ccur = 0;
  68. buf->dcur = NULL;
  69. return 0;
  70. }
  71.  
  72.  
  73. void u8b_deinit(struct u8b_i *buf)
  74. {
  75. mem_dealloc(buf->dbeg);
  76. }
  77.  
  78.  
  79.  
  80. //==============================================================================
  81. // Utility
  82. //==============================================================================
  83. void u8b_rda(struct u8b_i *buf, u32 size)
  84. {
  85. // circular buffer
  86. buf->cread -= size;
  87. buf->cwrite += size;
  88. buf->dread += size;
  89. }
  90.  
  91.  
  92. u32 u8b_rdgc(struct u8b_i *buf)
  93. {
  94. return buf->cread;
  95. }
  96.  
  97.  
  98. void u8b_wra(struct u8b_i *buf, u32 size)
  99. {
  100. buf->cread += size;
  101. buf->cwrite -= size;
  102. buf->dwrite += size;
  103. }
  104.  
  105.  
  106. u32 u8b_wrgc(struct u8b_i *buf)
  107. {
  108. return buf->cwrite;
  109. }
  110.  
  111.  
  112.  
  113. //==============================================================================
  114. // Peeking
  115. //==============================================================================
  116. u8 u8b_peek1(struct u8b_i *buf)
  117. {
  118. return buf->dread[0];
  119. }
  120.  
  121.  
  122. u16 u8b_peek2(struct u8b_i *buf)
  123. {
  124. u8 cdata[2];
  125.  
  126. cdata[0] = buf->dread[0];
  127. cdata[1] = buf->dread[1];
  128.  
  129. return (u16)cdata;
  130. }
  131. dev/libgc-base/src/util/pars.c
  132. //==============================================================================
  133. // This file is part of Libgc-base.
  134. // Copyright (C) 2015 Anthony Gorecki <anthony@anthonygorecki.ca>
  135. //
  136. // Libgc-base is free software: you can redistribute it and/or modify it under
  137. // the terms of the GNU General Public License as published by the Free Software
  138. // Foundation, either version 3 of the License, or (at your option) any later
  139. // version.
  140. //
  141. // Libgc-base is distributed in the hope that it will be useful, but WITHOUT ANY
  142. // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  143. // A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  144. //
  145. // You should have received a copy of the GNU General Public License along with
  146. // Libgc-base. If not, see <http://www.gnu.org/licenses/>.
  147. //==============================================================================
  148. #include <gc/pars.h>
  149.  
  150.  
  151.  
  152. //==============================================================================
  153. // "u8's"
  154. //==============================================================================
  155. u8 pars_u8c(struct u8b_i *buf, u8 data)
  156. {
  157. u32 orig_cnt = u8b_cnt(buf);
  158.  
  159. while (u8b_cnt(buf)) {
  160. if (u8b_peek1(buf) != data)
  161. break;
  162.  
  163. u8b_adv(buf, 1);
  164. }
  165.  
  166. return !(u8b_cnt(buf) < orig_cnt);
  167. }
  168.  
  169.  
  170. u8 pars_u8c2(struct u8b_i *buf, u8 data1, u8 data2)
  171. {
  172. u8 cdata[] = {data1, data2};
  173. u32 orig_cnt = u8b_cnt(buf);
  174.  
  175. while (u8b_cnt(buf) >= 2) {
  176. if (u8b_peek2(buf) != (u16)cdata)
  177. break;
  178.  
  179. u8b_adv(buf, 2);
  180. }
  181.  
  182. return !(u8b_cnt(buf) < orig_cnt);
  183. }
  184.  
  185.  
  186.  
  187. //==============================================================================
  188. // New line characters
  189. //==============================================================================
  190. u8 pars_nld(struct u8b_i *buf, u8 types)
  191. {
  192. assert((types & NL_RN) || (types & NL_N) || (types & NL_R));
  193.  
  194. u8 rn[] = {'\r', '\n'};
  195.  
  196. if (u8b_cnt(buf) >= 2 && (types & NL_RN) && u8b_peek2(buf) == (u16)rn)
  197. return NL_RN;
  198.  
  199. if (u8b_cnt(buf)) {
  200. if ((types & NL_N) && u8b_peek(buf) == '\n')
  201. return NL_N;
  202.  
  203. if ((types & NL_R) && u8b_peek(buf) == '\r')
  204. return NL_R;
  205. }
  206.  
  207. return 0;
  208. }
  209.  
  210.  
  211. u8 pars_nlcs(struct u8b_i *buf, u8 types)
  212. {
  213. u8 dtype = pars_nld(buf, types);
  214.  
  215. if (unlikely(!dtype))
  216. return 1;
  217.  
  218. if ((dtype & NL_RN)) {
  219. u8b_adv(buf, 2);
  220. pars_u8c2(buf, '\r', '\n');
  221. }
  222.  
  223. else {
  224. u8b_adv(buf, 1);
  225.  
  226. if ((dtype & NL_N))
  227. pars_u8c(buf, '\n');
  228.  
  229. if ((dtype & NL_R))
  230. pars_u8c(buf, '\r');
  231. }
  232.  
  233. return 0;
  234. }
  235.  
  236.  
  237. u8 pars_nlcm(struct u8b_i *buf, u8 types)
  238. {
  239. u8 ret = 1;
  240.  
  241. for (;;) {
  242. if (pars_nlcs(buf, types))
  243. break;
  244.  
  245. ret = 0;
  246. }
  247.  
  248. return ret;
  249. }
  250.  
  251. dev/libgc-base/src/os/unix/proc.c
  252. //==============================================================================
  253. // This file is part of Libgc-base.
  254. // Copyright (C) 2015 Anthony Gorecki <anthony@anthonygorecki.ca>
  255. //
  256. // Libgc-base is free software: you can redistribute it and/or modify it under
  257. // the terms of the GNU General Public License as published by the Free Software
  258. // Foundation, either version 3 of the License, or (at your option) any later
  259. // version.
  260. //
  261. // Libgc-base is distributed in the hope that it will be useful, but WITHOUT ANY
  262. // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  263. // A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  264. //
  265. // You should have received a copy of the GNU General Public License along with
  266. // Libgc-base. If not, see <http://www.gnu.org/licenses/>.
  267. //==============================================================================
  268. // proc_st_init, proc_st_next, ...
  269. #include <gc/proc.h>
  270.  
  271.  
  272.  
  273. //==============================================================================
  274. // Execution
  275. //==============================================================================
  276. u8 proc_exec(void)
  277. {
  278. }
  279. dev/libgc-base/src/os/unix/mem.c
  280. //==============================================================================
  281. // This file is part of Libgc-base.
  282. // Copyright (C) 2015 Anthony Gorecki <anthony@anthonygorecki.ca>
  283. //
  284. // Libgc-base is free software: you can redistribute it and/or modify it under
  285. // the terms of the GNU General Public License as published by the Free Software
  286. // Foundation, either version 3 of the License, or (at your option) any later
  287. // version.
  288. //
  289. // Libgc-base is distributed in the hope that it will be useful, but WITHOUT ANY
  290. // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  291. // A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  292. //
  293. // You should have received a copy of the GNU General Public License along with
  294. // Libgc-base. If not, see <http://www.gnu.org/licenses/>.
  295. //==============================================================================
  296. #include <gc/mem.h>
  297.  
  298. #include <stdlib.h>
  299. #include <string.h>
  300.  
  301.  
  302.  
  303. //==============================================================================
  304. // Allocation, reallocation and deallocation
  305. //==============================================================================
  306. void *mem_alloc(size_t size)
  307. {
  308. return malloc(size);
  309. }
  310.  
  311.  
  312. void *mem_realloc(void *ptr, size_t size)
  313. {
  314. return realloc(ptr, size);
  315. }
  316.  
  317.  
  318. void mem_dealloc(void *ptr)
  319. {
  320. free(ptr);
  321. }
  322.  
  323.  
  324.  
  325. //==============================================================================
  326. // Utility
  327. //==============================================================================
  328. s8 mem_comp(void *data1, void *data2, size_t size)
  329. {
  330. return memcmp(data1, data2, size);
  331. }
  332.  
  333.  
  334. void mem_copy(void *dest, void *src, size_t size)
  335. {
  336. memcpy(dest, src, size);
  337. }
  338.  
  339.  
  340. void mem_move(void *dest, void *src, size_t size)
  341. {
  342. memmove(dest, src, size);
  343. }
  344.  
  345.  
  346. void mem_set(void *ptr, u8 data, size_t size)
  347. {
  348. memset(ptr, data, size);
  349. }
  350. dev/libgc-base/src/os/unix/file.c
  351. //==============================================================================
  352. // This file is part of Libgc-base.
  353. // Copyright (C) 2015 Anthony Gorecki <anthony@anthonygorecki.ca>
  354. //
  355. // Libgc-base is free software: you can redistribute it and/or modify it under
  356. // the terms of the GNU General Public License as published by the Free Software
  357. // Foundation, either version 3 of the License, or (at your option) any later
  358. // version.
  359. //
  360. // Libgc-base is distributed in the hope that it will be useful, but WITHOUT ANY
  361. // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  362. // A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  363. //
  364. // You should have received a copy of the GNU General Public License along with
  365. // Libgc-base. If not, see <http://www.gnu.org/licenses/>.
  366. //==============================================================================
  367. #include <gc/file.h>
  368.  
  369. #include <unistd.h>
  370.  
  371.  
  372.  
  373. //==============================================================================
  374. // Initialization and deinitialization
  375. //==============================================================================
  376. u8 file_init(struct file_i *file, struct file_c *conf)
  377. {
  378. if (!(conf->flags & DIO_CREAT))
  379. file->fd = open(conf->path, conf->flags);
  380.  
  381. else
  382. file->fd = open(conf->path, conf->flags, conf->mode);
  383.  
  384. if (unlikely(file->fd == -1))
  385. return 1;
  386.  
  387. return 0;
  388. }
  389.  
  390.  
  391. void file_deinit(struct file_i *file)
  392. {
  393. close(file->fd);
  394. }
  395.  
  396.  
  397.  
  398. //==============================================================================
  399. // Read and write
  400. //==============================================================================
  401. u8 file_read(struct file_i *file, struct u8b_i *buf)
  402. {
  403. ssize_t size = read(file->fd, buf->dwrite, buf->cwrite);
  404.  
  405. if (unlikely(size == -1))
  406. return 1;
  407.  
  408. u8b_wrr(buf, size);
  409. return 0;
  410. }
  411.  
  412.  
  413. u8 file_write(struct file_i *file, struct u8b_i *buf)
  414. {
  415. ssize_t size = write(file->fd, buf->dread, buf->cread);
  416.  
  417. if (unlikely(size == -1))
  418. return 1;
  419.  
  420. u8b_rdr(buf, size);
  421. return 0;
  422. }
  423.  
  424.  
  425.  
  426. //==============================================================================
  427. // Utility
  428. //==============================================================================
  429. u8 file_gstats(struct file_i *file, struct file_stats *stats)
  430. {
  431. if (unlikely(fstat(file->fd, &stats->data)))
  432. return 1;
  433.  
  434. return 0;
  435. }
  436. dev/libgc-base/make.sh
  437. gcc -o libgc-base -shared -I include -std=c11 -Wall -Wextra -Wpedantic -Werror `find src -type f -name '*.c'`
  438. dev/libgc-base/include/gc/proc.h
  439. //==============================================================================
  440. // This file is part of Libgc-base.
  441. // Copyright (C) 2015 Anthony Gorecki <anthony@anthonygorecki.ca>
  442. //
  443. // Libgc-base is free software: you can redistribute it and/or modify it under
  444. // the terms of the GNU General Public License as published by the Free Software
  445. // Foundation, either version 3 of the License, or (at your option) any later
  446. // version.
  447. //
  448. // Libgc-base is distributed in the hope that it will be useful, but WITHOUT ANY
  449. // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  450. // A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  451. //
  452. // You should have received a copy of the GNU General Public License along with
  453. // Libgc-base. If not, see <http://www.gnu.org/licenses/>.
  454. //==============================================================================
  455. #pragma once
  456.  
  457. #include <gc/common.h>
  458.  
  459. #if defined(__use_gnu_bktrc)
  460. #include <gc/proc-gnu-bktrc.h>
  461. #endif
  462.  
  463. #if defined(__use_lunwind)
  464. #include <gc/proc-lunwind.h>
  465. #endif
  466.  
  467. // Null function pointers for systems where back traces are not supported.
  468. dev/libgc-base/include/gc/common.h
  469. //==============================================================================
  470. // This file is part of Libgc-base.
  471. // Copyright (C) 2015 Anthony Gorecki <anthony@anthonygorecki.ca>
  472. //
  473. // Libgc-base is free software: you can redistribute it and/or modify it under
  474. // the terms of the GNU General Public License as published by the Free Software
  475. // Foundation, either version 3 of the License, or (at your option) any later
  476. // version.
  477. //
  478. // Libgc-base is distributed in the hope that it will be useful, but WITHOUT ANY
  479. // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  480. // A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  481. //
  482. // You should have received a copy of the GNU General Public License along with
  483. // Libgc-base. If not, see <http://www.gnu.org/licenses/>.
  484. //==============================================================================
  485. #pragma once
  486.  
  487. #include <stddef.h>
  488. #include <stdint.h>
  489.  
  490. #define likely(EXPR) __builtin_expect(EXPR, 1)
  491. #define unlikely(EXPR) __builtin_expect(EXPR, 0)
  492.  
  493. typedef int8_t s8;
  494. typedef int16_t s16;
  495. typedef int32_t s32;
  496. typedef int64_t s64;
  497.  
  498. typedef uint8_t u8;
  499. typedef uint16_t u16;
  500. typedef uint32_t u32;
  501. typedef uint64_t u64;
  502. dev/libgc-base/include/gc/u8b.h
  503. //==============================================================================
  504. // This file is part of Libgc-base.
  505. // Copyright (C) 2015 Anthony Gorecki <anthony@anthonygorecki.ca>
  506. //
  507. // Libgc-base is free software: you can redistribute it and/or modify it under
  508. // the terms of the GNU General Public License as published by the Free Software
  509. // Foundation, either version 3 of the License, or (at your option) any later
  510. // version.
  511. //
  512. // Libgc-base is distributed in the hope that it will be useful, but WITHOUT ANY
  513. // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  514. // A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  515. //
  516. // You should have received a copy of the GNU General Public License along with
  517. // Libgc-base. If not, see <http://www.gnu.org/licenses/>.
  518. //==============================================================================
  519. #pragma once
  520.  
  521. #include <gc/common.h>
  522.  
  523. struct u8b_i {
  524. };
  525. dev/libgc-base/include/gc/pars.h
  526. //==============================================================================
  527. // This file is part of Libgc-base.
  528. // Copyright (C) 2015 Anthony Gorecki <anthony@anthonygorecki.ca>
  529. //
  530. // Libgc-base is free software: you can redistribute it and/or modify it under
  531. // the terms of the GNU General Public License as published by the Free Software
  532. // Foundation, either version 3 of the License, or (at your option) any later
  533. // version.
  534. //
  535. // Libgc-base is distributed in the hope that it will be useful, but WITHOUT ANY
  536. // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  537. // A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  538. //
  539. // You should have received a copy of the GNU General Public License along with
  540. // Libgc-base. If not, see <http://www.gnu.org/licenses/>.
  541. //==============================================================================
  542. #pragma once
  543.  
  544. #include <gc/u8b.h>
  545. dev/libgc-base/include/gc/file.h
  546. //==============================================================================
  547. // This file is part of Libgc-base.
  548. // Copyright (C) 2015 Anthony Gorecki <anthony@anthonygorecki.ca>
  549. //
  550. // Libgc-base is free software: you can redistribute it and/or modify it under
  551. // the terms of the GNU General Public License as published by the Free Software
  552. // Foundation, either version 3 of the License, or (at your option) any later
  553. // version.
  554. //
  555. // Libgc-base is distributed in the hope that it will be useful, but WITHOUT ANY
  556. // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  557. // A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  558. //
  559. // You should have received a copy of the GNU General Public License along with
  560. // Libgc-base. If not, see <http://www.gnu.org/licenses/>.
  561. //==============================================================================
  562. #pragma once
  563.  
  564. #include <gc/u8b.h>
  565.  
  566. #include <sys/stat.h>
  567. #include <fcntl.h>
  568.  
  569. struct file_i {
  570. int fd;
  571. };
  572.  
  573. struct file_c {
  574. const char *path;
  575. int flags;
  576. mode_t mode;
  577. };
  578.  
  579. struct file_stats {
  580. struct stat data;
  581. };
  582. dev/libgc-base/include/gc/mem.h
  583. //==============================================================================
  584. // This file is part of Libgc-base.
  585. // Copyright (C) 2015 Anthony Gorecki <anthony@anthonygorecki.ca>
  586. //
  587. // Libgc-base is free software: you can redistribute it and/or modify it under
  588. // the terms of the GNU General Public License as published by the Free Software
  589. // Foundation, either version 3 of the License, or (at your option) any later
  590. // version.
  591. //
  592. // Libgc-base is distributed in the hope that it will be useful, but WITHOUT ANY
  593. // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  594. // A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  595. //
  596. // You should have received a copy of the GNU General Public License along with
  597. // Libgc-base. If not, see <http://www.gnu.org/licenses/>.
  598. //==============================================================================
  599. #pragma once
  600.  
  601. #include <gc/common.h>
  602.  
  603. void* mem_alloc(size_t);
  604. void* mem_realloc(void*, size_t);
  605. void mem_dealloc(void*);
  606.  
  607. u8 mem_comp(void*, void*, size_t);
  608. void mem_copy(void*, void*, size_t);
  609. void mem_move(void*, void*, size_t);
  610. void mem_set(void*, u8, size_t);
  611. dev/doc/includes.txt
  612. External Gc headers, Gc header for local file, all other headers; groups
  613. separated by a single new line.
  614. dev/doc/code-style.txt
  615. Soft limit for line length is 80 characters, hard limit is 100 characters.
  616.  
  617. Conditional statements requiring multiple lines should indent the subsequent
  618. lines with two tabs (one additional tab, relative the the code following the
  619. conditional statement).
  620. dev/doc/func-naming.txt
  621. Hard limit for function name first part is five characters. Soft limit is
  622. four characters.
  623.  
  624. Function name hard limit for second part is five characters (initialization /
  625. activation). Does not apply to names that have been shortened to individual
  626. characters per word.
  627.  
  628. Struct member name soft limit is four characters.
  629. script/upload-pastebin.sh
  630. cd /root
  631. date > upload-data.txt
  632.  
  633. echo 'Files:'
  634.  
  635. files=$(find dev -name '*.c' -o -name '*.h' -o -name '*.py' -o -name '*.sh' -o -name '*.txt' -o -name '.vimrc')
  636.  
  637. for file in $files; do
  638. echo " $file"
  639. echo $file >> upload-data.txt
  640. cat $file >> upload-data.txt
  641. done
  642.  
  643. files=$(find script -name '*.c' -o -name '*.h' -o -name '*.py' -o -name '*.sh' -o -name '*.txt' -o -name '.vimrc')
  644.  
  645. for file in $files; do
  646. echo " $file"
  647. echo $file >> upload-data.txt
  648. cat $file >> upload-data.txt
  649. done
  650.  
  651. echo
  652. echo -n 'URL: '
  653. python ./script/intrn/upload-pastebin.py `cat script/intrn/dev-key`
  654. rm upload-data.txt
  655. script/intrn/upload-pastebin.py
  656. import pastebin_python
  657. import sys
  658.  
  659. pb = pastebin_python.pastebin.PastebinPython(api_dev_key=sys.argv[1])
  660. print pb.createPasteFromFile('upload-data.txt', 'anthony gorecki anthony@anthonygorecki.ca', '', '0', 'N')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement