Advertisement
Guest User

anthony gorecki anthony@anthonygorecki.ca

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