Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Mon Nov 23 02:39:29 EST 2015
- ./dev/gc-base-lib/2/src/ct/tr_i.c
- ./dev/gc-base-lib/2/src/ct/tr_avl.c
- ./dev/gc-base-lib/2/src/ct/tr_rbll.c
- ./dev/gc-base-lib/2/src/svc/atq.c
- ./dev/gc-base-lib/2/src/svc/tpool_a.c
- ./dev/gc-base-lib/2/src/os/linux/aio.txt
- kernel aio linux 512, 2048 or other sector size, as determined by the underlying
- block device. can get this value via ioctl.
- also can do simple kernel aio implementation better than libaio. use this instead.
- see firefox bookmark "own aio impl" x2
- aio works for block size increments. reads / writes other than that size to the
- beginning or end of the file will be blocking. see firefox bookmark "blocking aio".
- this has not been verified.
- ./dev/gc-base-lib/2/src/os/linux/this_dir.txt
- linux specific things like signalfd, timerfd, kernel aio go in this directory
- ./dev/gc-base-lib/2/src/os/unix/pcnd.c
- ./dev/gc-base-lib/2/src/os/unix/mtx_attr.c
- ./dev/gc-base-lib/2/src/os/unix/cnd_attr.c
- ./dev/gc-base-lib/2/src/os/unix/mtx.c
- ./dev/gc-base-lib/2/src/os/unix/cnd.c
- ./dev/gc-base-lib/2/src/os/unix/thrd.c
- ./dev/gc-base-lib/2/src/os/unix/pmtx.c
- ./dev/gc-base-lib/1/proj-make.txt
- //==============================================================================
- // This file is part of Gc-Base-Lib.
- // Copyright (C) 2015 Anthony Gorecki <agorecki@gcproj.org>
- //
- // Gc-Base-Lib is free software: you can redistribute it and/or modify it under
- // the terms of the GNU General Public License as published by the Free Software
- // Foundation, either version 3 of the License, or (at your option) any later
- // version.
- //
- // Gc-Base-Lib is distributed in the hope that it will be useful, but WITHOUT
- // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- // details.
- //
- // You should have received a copy of the GNU General Public License along with
- // Gc-Base-Lib. If not, see <http://www.gnu.org/licenses/>.
- //==============================================================================
- # gc-proj-conf (tracks config; can reconfigure)
- # gc-proj-make (will rebuild changed files; will rebuild only necessary after conf change)
- # gc-proj-inst (installs all built targets)
- DTGT gc-proj
- TGEN dev
- MAKE
- EXEC lib/pkgconfig/make.sh $DPKGCONFIG
- INST
- COPY inc/gc $DINC
- MOVE lib/pkgconfig/gc-proj.pc.tmp $DPKGCONFIG/gc-proj.pc
- TLIB gc-proj
- ./dev/gc-base-lib/1/src/ct/u8_bcss.c
- //==============================================================================
- // This file is part of Gc-Base-Lib.
- // Lockless circular buffer, supporting a single producer and single consumer.
- // Copyright (C) 2015 Anthony Gorecki <agorecki@gcproj.org>
- //
- // Gc-Base-Lib is free software: you can redistribute it and/or modify it under
- // the terms of the GNU General Public License as published by the Free Software
- // Foundation, either version 3 of the License, or (at your option) any later
- // version.
- //
- // Gc-Base-Lib is distributed in the hope that it will be useful, but WITHOUT
- // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- // details.
- //
- // You should have received a copy of the GNU General Public License along with
- // Gc-Base-Lib. If not, see <http://www.gnu.org/licenses/>.
- //==============================================================================
- #include <gc/mem.h>
- #include <gc/u8_bcss.h>
- // Two variable "u8_a" type, member 1 is "dbeg", member 2 is "cbeg".
- //
- // Minimum size for this buffer implementation is two bytes. Check for this in
- // conf validation.
- //
- // Implementation should work out figures using the nonatomic 'scout' member.
- // Contig is inteded for buffer output, where parsers might need a certain
- // number of contiguous bytes to function properly. Support is also provided for
- // contiguous bytes for buffer input, should it be useful. These numbers are
- // designed to represent the /minimum/ that the application can handle.
- //
- // This buffer is not designed to handle circumstances in which the read or
- // write address needs to be aligned to some specific value, or when the reads
- // and writes need to be of a particular size. In other words, it is not
- // designed for linux kernel aio or any other kind of disk aio.
- //
- // This buffer is a candidate for sync and async network io, and sync disk io,
- // as well as unix pipes.
- //
- // Buffer conversion will be available: u8_bcss -> u8_b for pars_ -> publish
- // changes back to original u8_bcss once finished. This will work for more
- // advanced to less advanced buffers, and the other way around. Will have a
- // similar style to the (file) input and output functions at the end of this
- // file. This might only be for contiguous io segments. The buffer conversion
- // function is not responsible for doing any initialization or deinitialization
- // of the target buffer.
- //==============================================================================
- // Initialization
- //==============================================================================
- u8 u8_bcss_init(struct u8_bcss_i *buf, struct u8_bcss_c *conf)
- {
- // Atomic members need to be initialized before being used. Do that here.
- buf->scin = conf->scin; // U16
- buf->scout = conf->scout;
- buf->cin = buf->cbeg - conf->scntg;
- buf->cout = 0;
- buf->din = buf->dbeg + conf->scntg;
- buf->dout = buf->dbeg + conf->scntg;
- return 0;
- }
- //==============================================================================
- // Advance
- //==============================================================================
- void u8_bcss_ia(struct u8_bcss_i *buf, u32 size)
- {
- u32 off = buf->din - buf->dbeg + size;
- if (off < buf->cbeg - 1)
- buf->din += size;
- else // Wrap around.
- buf->din = buf->dbeg + off - buf->cbeg;
- atmc_fsub(&buf->cin, size);
- atmc_fadd(&buf->cout, size);
- }
- void u8_bcss_oa(struct u8_bcss_i *buf, u32 size)
- {
- u32 off = buf->dout - buf->dbeg + size;
- if (off < buf->cbeg - 1)
- buf->dout += size;
- else // Wrap around.
- buf->dout = buf->dbeg + off - buf->cbeg;
- atmc_fsub(&buf->cout, size);
- atmc_fadd(&buf->cin, size);
- }
- //==============================================================================
- // Count
- //==============================================================================
- u32 u8_bcss_igc(struct u8_bcss_i *buf)
- {
- return atmc_load(&buf->cin);
- }
- u32 u8_bcss_ogc(struct u8_bcss_i *buf)
- {
- return atmc_load(&buf->cout);
- }
- //==============================================================================
- // Contiguous count and pointer
- //==============================================================================
- u32 u8_bcss_igcc(struct u8_bcss_i *buf)
- {
- u32 off_in = buf->din - buf->dbeg;
- u32 orig_cin = atmc_load(&buf->cin);
- if (off_in + orig_cin < buf->cbeg - 1)
- return orig_cout;
- return buf->cbeg - off_in;
- }
- u8 *u8_bcss_igcp(struct u8_bcss_i *buf)
- {
- return buf->din;
- }
- u32 u8_bcss_ogcc(struct u8_bcss_i *buf)
- {
- u32 off_out = buf->dout - buf->dbeg;
- u32 orig_cout = atmc_load(&buf->cout);
- if (off_out + orig_cout < buf->cbeg - 1)
- return orig_cout;
- return buf->cbeg - off_out;
- }
- u8 *u8_bcss_ogcp(struct u8_bcss_i *buf)
- {
- return buf->dout;
- }
- //==============================================================================
- // Peeking
- //==============================================================================
- u8 u8_bcss_op1(struct u8_bcss_i *buf)
- {
- return buf->dout[0];
- }
- u16 u8_bcss_op2(struct u8_bcss_i *buf)
- {
- u8 data[2];
- data[0] = buf->dout[0];
- if (buf->dout <= buf->dbeg + buf->cbeg - 2)
- data[1] = buf->dout[1];
- else
- data[1] = buf->dbeg[0];
- return (u16)data;
- }
- //==============================================================================
- // Input and output
- //==============================================================================
- u8 u8_bcss_if(struct u8_bcss_i *buf, u8 (*fin)(void*, u8*, u32, u32*),
- void *arg)
- {
- u32 ret;
- if (unlikely(fin(arg, buf->din, u8_bcss_igcc(buf), &ret)))
- return 1;
- u8_bcss_ia(buf, ret);
- return 0;
- }
- u8 u8_bcss_of(struct u8_bcss_i *buf, u8 (*fout)(void*, u8*, u32, u32*),
- void *arg)
- {
- u32 ret;
- if (unlikely(fout(arg, buf->dout, u8_bcss_ogcc(buf), &ret)))
- return 1;
- u8_bcss_oa(buf, ret);
- return 0;
- }
- ./dev/gc-base-lib/1/src/ct/u8_a.c
- //==============================================================================
- // This file is part of Gc-Base-Lib.
- // Copyright (C) 2015 Anthony Gorecki <agorecki@gcproj.org>
- //
- // Gc-Base-Lib is free software: you can redistribute it and/or modify it under
- // the terms of the GNU General Public License as published by the Free Software
- // Foundation, either version 3 of the License, or (at your option) any later
- // version.
- //
- // Gc-Base-Lib is distributed in the hope that it will be useful, but WITHOUT
- // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- // details.
- //
- // You should have received a copy of the GNU General Public License along with
- // Gc-Base-Lib. If not, see <http://www.gnu.org/licenses/>.
- //==============================================================================
- #include <gc/mem.h>
- #include <gc/u8_a.h>
- // Configuration for composite type "u8_a": CT_M1V
- //==============================================================================
- // Initialization and deinitialization
- //==============================================================================
- u8 u8_a_init(u8 *data, u32 *size, struct u8_a_c *conf)
- {
- *data = mem_alloc(conf->size);
- if (unlikely(*data == NULL && conf->size))
- return 1;
- *size = conf->size;
- return 0;
- }
- void u8_a_deinit(u8 *data)
- {
- mem_dealloc(*data);
- }
- ./dev/gc-base-lib/1/src/ct/u8_ib.c
- //==============================================================================
- // This file is part of Gc-Base-Lib.
- // Copyright (C) 2015 Anthony Gorecki <agorecki@gcproj.org>
- //
- // Gc-Base-Lib is free software: you can redistribute it and/or modify it under
- // the terms of the GNU General Public License as published by the Free Software
- // Foundation, either version 3 of the License, or (at your option) any later
- // version.
- //
- // Gc-Base-Lib is distributed in the hope that it will be useful, but WITHOUT
- // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- // details.
- //
- // You should have received a copy of the GNU General Public License along with
- // Gc-Base-Lib. If not, see <http://www.gnu.org/licenses/>.
- //==============================================================================
- #include <gc/mem.h>
- #include <gc/u8_ib.h>
- //==============================================================================
- // Initialization and deinitialization
- //==============================================================================
- CT_WRAP_MSI2D1(u8_ib);
- u8 u8_ib_init_ms(struct u8_ib_i *ibuf, struct u8_ib_c *conf)
- {
- MS_BEG(0);
- MS_SP {
- ibuf->buf = mem_alloc(conf->sbuf);
- MS_EV(ibuf->buf != NULL || !conf->sbuf);
- }
- MS_SP { MS_EV(!conf->f->init(ibuf->buf, conf->buf)); }
- MS_SP { ibuf->f = conf->f; }
- return 0;
- }
- void u8_ib_deinit_ms(struct u8_ib_i *ibuf, u8 step)
- {
- MS_BEG(step);
- MS_EM;
- MS_SP { ibuf->f->deinit(ibuf->buf); }
- MS_SP { mem_dealloc(ibuf->buf); }
- }
- //==============================================================================
- // Advance
- //==============================================================================
- void u8_ib_ia(struct u8_ib_i *ibuf, u32 size)
- {
- ibuf->f->ia(ibuf->buf, size);
- }
- void u8_ib_oa(struct u8_ib_i *ibuf, u32 size)
- {
- ibuf->f->oa(ibuf->buf, size);
- }
- //==============================================================================
- // Count
- //==============================================================================
- u32 u8_ib_igc(struct u8_ib_i *ibuf)
- {
- return ibuf->f->igc(ibuf->buf);
- }
- u32 u8_ib_ogc(struct u8_ib_i *ibuf)
- {
- return ibuf->f->ogc(ibuf->buf);
- }
- //==============================================================================
- // Contiguous count and pointer
- //==============================================================================
- u32 u8_ib_igcc(struct u8_ib_i *ibuf)
- {
- return ibuf->f->igcc(ibuf->buf);
- }
- u8 *u8_ib_igcp(struct u8_ib_i *ibuf)
- {
- return ibuf->f->igcp(ibuf->buf);
- }
- u32 u8_ib_ogcc(struct u8_ib_i *ibuf)
- {
- return ibuf->f->ogcc(ibuf->buf);
- }
- u8 *u8_ib_ogcp(struct u8_ib_i *ibuf)
- {
- return ibuf->f->ogcp(ibuf->buf);
- }
- //==============================================================================
- // Peeking
- //==============================================================================
- u8 u8_ib_op1(struct u8_ib_i *ibuf)
- {
- return ibuf->f->op1(ibuf->buf);
- }
- u16 u8_ib_op2(struct u8_ib_i *ibuf)
- {
- return ibuf->f->op2(ibuf->buf);
- }
- //==============================================================================
- // Input and output
- //==============================================================================
- u8 u8_ib_if(struct u8_ib_i *ibuf, u8 (*fin)(void*, u8*, u32, u32*), void *arg)
- {
- return ibuf->if(ibuf->buf, fin, arg);
- }
- u8 u8_ib_of(struct u8_ib_i *ibuf, u8 (*fout)(void*, u8*, u32, u32*), void *arg)
- {
- return ibuf->of(ibuf->buf, fout, arg);
- }
- ./dev/gc-base-lib/1/src/ct/u8_b.c
- ./dev/gc-base-lib/1/src/ct/u8_bc.c
- //==============================================================================
- // This file is part of Gc-Base-Lib.
- // Simple circular buffer, supporting nonsimultaneous input and output.
- // Copyright (C) 2015 Anthony Gorecki <agorecki@gcproj.org>
- //
- // Gc-Base-Lib is free software: you can redistribute it and/or modify it under
- // the terms of the GNU General Public License as published by the Free Software
- // Foundation, either version 3 of the License, or (at your option) any later
- // version.
- //
- // Gc-Base-Lib is distributed in the hope that it will be useful, but WITHOUT
- // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- // details.
- //
- // You should have received a copy of the GNU General Public License along with
- // Gc-Base-Lib. If not, see <http://www.gnu.org/licenses/>.
- //==============================================================================
- #include <gc/mem.h>
- #include <gc/u8_bc.h>
- //==============================================================================
- // Initialization and deinitialization
- //==============================================================================
- u8 u8_bc_init(struct u8_bc_i *buf, struct u8_bc_c *conf)
- {
- // Minimum size for this buffer implementation is two bytes. Check for this
- // in conf validation.
- buf->dbeg = mem_alloc(conf->size);
- if (unlikely(buf->dbeg == NULL))
- return 1;
- buf->cbeg = size;
- return 0;
- }
- void u8_bc_deinit(struct u8_bc_i *buf)
- {
- mem_dealloc(buf->dbeg);
- }
- //==============================================================================
- // Advance
- //==============================================================================
- void u8_bc_ia(struct u8_bc_i *buf, u32 size)
- {
- u32 off = buf->din - buf->dbeg + size;
- if (off < buf->cbeg - 1)
- buf->din += size;
- else // Wrap around.
- buf->din = buf->dbeg + off - buf->cbeg;
- atmc_fsub(&buf->cin, size);
- atmc_fadd(&buf->cout, size);
- }
- void u8_bc_oa(struct u8_bc_i *buf, u32 size)
- {
- u32 off = buf->dout - buf->dbeg + size;
- if (off < buf->cbeg - 1)
- buf->dout += size;
- else // Wrap around.
- buf->dout = buf->dbeg + off - buf->cbeg;
- atmc_fsub(&buf->cout, size);
- atmc_fadd(&buf->cin, size);
- }
- //==============================================================================
- // Count
- //==============================================================================
- u32 u8_bc_igc(struct u8_bc_i *buf)
- {
- return atmc_load(&buf->cin);
- }
- u32 u8_bc_ogc(struct u8_bc_i *buf)
- {
- return atmc_load(&buf->cout);
- }
- //==============================================================================
- // Contiguous count and pointer
- //==============================================================================
- u32 u8_bc_igcc(struct u8_bc_i *buf)
- {
- u32 off_in = buf->din - buf->dbeg;
- u32 orig_cin = atmc_load(&buf->cin);
- if (off_in + orig_cin < buf->cbeg - 1)
- return orig_cout;
- return buf->cbeg - off_in;
- }
- u8 *u8_bc_igcp(struct u8_bc_i *buf)
- {
- return buf->din;
- }
- u32 u8_bc_ogcc(struct u8_bc_i *buf)
- {
- u32 off_out = buf->dout - buf->dbeg;
- u32 orig_cout = atmc_load(&buf->cout);
- if (off_out + orig_cout < buf->cbeg - 1)
- return orig_cout;
- return buf->cbeg - off_out;
- }
- u8 *u8_bc_ogcp(struct u8_bc_i *buf)
- {
- return buf->dout;
- }
- //==============================================================================
- // Peeking
- //==============================================================================
- u8 u8_bc_op1(struct u8_bc_i *buf)
- {
- return buf->dout[0];
- }
- u16 u8_bc_op2(struct u8_bc_i *buf)
- {
- u8 data[2];
- data[0] = buf->dout[0];
- if (buf->dout <= buf->dbeg + buf->cbeg - 2)
- data[1] = buf->dout[1];
- else
- data[1] = buf->dbeg[0];
- return (u16)data;
- }
- //==============================================================================
- // Input and output
- //==============================================================================
- u8 u8_bc_if(struct u8_bc_i *buf, u8 (*fin)(void*, u8*, u32, u32*),
- void *arg)
- {
- u32 ret;
- if (unlikely(fin(arg, buf->din, u8_bc_igcc(buf), &ret)))
- return 1;
- u8_bc_ia(buf, ret);
- return 0;
- }
- u8 u8_bc_of(struct u8_bc_i *buf, u8 (*fout)(void*, u8*, u32, u32*),
- void *arg)
- {
- u32 ret;
- if (unlikely(fout(arg, buf->dout, u8_bc_ogcc(buf), &ret)))
- return 1;
- u8_bc_oa(buf, ret);
- return 0;
- }
- ./dev/gc-base-lib/1/src/util/pars.c
- //==============================================================================
- // This file is part of Gc-Base-Lib.
- // Copyright (C) 2015 Anthony Gorecki <agorecki@gcproj.org>
- //
- // Gc-Base-Lib is free software: you can redistribute it and/or modify it under
- // the terms of the GNU General Public License as published by the Free Software
- // Foundation, either version 3 of the License, or (at your option) any later
- // version.
- //
- // Gc-Base-Lib is distributed in the hope that it will be useful, but WITHOUT
- // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- // details.
- //
- // You should have received a copy of the GNU General Public License along with
- // Gc-Base-Lib. If not, see <http://www.gnu.org/licenses/>.
- //==============================================================================
- #include <gc/pars.h>
- // If it is possible to convert between buffer types, this should probably be
- // moved to u8_a. u8_a_nlcs et al.
- //==============================================================================
- // "u8's"
- //==============================================================================
- u8 pars_u8c(struct pars_i *pars, u8 data)
- {
- u32 orig_cnt = u8b_cnt(&pars->buf);
- while (u8b_cnt(&pars->buf)) {
- if (u8b_peek1(&pars->buf) != data)
- break;
- u8b_adv(&pars->buf, 1);
- }
- return !(u8b_cnt(&pars->buf) < orig_cnt);
- }
- u8 pars_u8c2(struct pars_i *pars, u8 data1, u8 data2)
- {
- u8 cdata[] = {data1, data2};
- u32 orig_cnt = u8b_cnt(&pars->buf);
- while (u8b_cnt(&pars->buf) >= 2) {
- if (u8b_peek2(&pars->buf) != (u16)cdata)
- break;
- u8b_adv(&pars->buf, 2);
- }
- return !(u8b_cnt(&pars->buf) < orig_cnt);
- }
- //==============================================================================
- // New line characters
- //==============================================================================
- u8 pars_nld(struct pars_i *pars, u8 types)
- {
- assert((types & NL_RN) || (types & NL_N) || (types & NL_R));
- u8 rn[] = {'\r', '\n'};
- if (u8b_cnt(&pars->buf) >= 2 && (types & NL_RN)
- && u8b_peek2(&pars->buf) == (u16)rn)
- return NL_RN;
- if (u8b_cnt(&pars->buf)) {
- if ((types & NL_N) && u8b_peek(&pars->buf) == '\n')
- return NL_N;
- if ((types & NL_R) && u8b_peek(&pars->buf) == '\r')
- return NL_R;
- }
- return 0;
- }
- u8 pars_nlcs(struct pars_i *pars, u8 types)
- {
- u8 dtype = pars_nld(pars, types);
- if (unlikely(!dtype))
- return 1;
- if ((dtype & NL_RN)) {
- u8b_adv(&pars->buf, 2);
- pars_u8c2(pars, '\r', '\n');
- }
- else {
- u8b_adv(&pars->buf, 1);
- if ((dtype & NL_N))
- pars_u8c(pars, '\n');
- if ((dtype & NL_R))
- pars_u8c(pars, '\r');
- }
- return 0;
- }
- u8 pars_nlcm(struct pars_i *pars, u8 types)
- {
- u8 ret = 1;
- for (;;) {
- if (pars_nlcs(pars, types))
- break;
- ret = 0;
- }
- return ret;
- }
- ./dev/gc-base-lib/1/src/os/unix/proc.c
- //==============================================================================
- // This file is part of Gc-Base-Lib.
- // Copyright (C) 2015 Anthony Gorecki <agorecki@gcproj.org>
- //
- // Gc-Base-Lib is free software: you can redistribute it and/or modify it under
- // the terms of the GNU General Public License as published by the Free Software
- // Foundation, either version 3 of the License, or (at your option) any later
- // version.
- //
- // Gc-Base-Lib is distributed in the hope that it will be useful, but WITHOUT
- // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- // details.
- //
- // You should have received a copy of the GNU General Public License along with
- // Gc-Base-Lib. If not, see <http://www.gnu.org/licenses/>.
- //==============================================================================
- // proc_st_init, proc_st_next, ...
- #include <gc/proc.h>
- //==============================================================================
- // Execution
- //==============================================================================
- u8 proc_exec(void)
- {
- }
- ./dev/gc-base-lib/1/src/os/unix/mem.c
- //==============================================================================
- // This file is part of Gc-Base-Lib.
- // Copyright (C) 2015 Anthony Gorecki <agorecki@gcproj.org>
- //
- // Gc-Base-Lib is free software: you can redistribute it and/or modify it under
- // the terms of the GNU General Public License as published by the Free Software
- // Foundation, either version 3 of the License, or (at your option) any later
- // version.
- //
- // Gc-Base-Lib is distributed in the hope that it will be useful, but WITHOUT
- // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- // details.
- //
- // You should have received a copy of the GNU General Public License along with
- // Gc-Base-Lib. If not, see <http://www.gnu.org/licenses/>.
- //==============================================================================
- #include <gc/mem.h>
- #include <stdlib.h>
- #include <string.h>
- //==============================================================================
- // Allocation, reallocation and deallocation
- //==============================================================================
- void *mem_alloc(size_t size)
- {
- return malloc(size);
- }
- void *mem_realloc(void *ptr, size_t size)
- {
- return realloc(ptr, size);
- }
- void mem_dealloc(void *ptr)
- {
- free(ptr);
- }
- //==============================================================================
- // Utility
- //==============================================================================
- s8 mem_comp(void *data1, void *data2, size_t size)
- {
- return memcmp(data1, data2, size);
- }
- void mem_copy(void *dest, void *src, size_t size)
- {
- memcpy(dest, src, size);
- }
- void mem_move(void *dest, void *src, size_t size)
- {
- memmove(dest, src, size);
- }
- void mem_set(void *ptr, u8 data, size_t size)
- {
- memset(ptr, data, size);
- }
- ./dev/gc-base-lib/1/src/os/unix/file.c
- //==============================================================================
- // This file is part of Gc-Base-Lib.
- // Copyright (C) 2015 Anthony Gorecki <agorecki@gcproj.org>
- //
- // Gc-Base-Lib is free software: you can redistribute it and/or modify it under
- // the terms of the GNU General Public License as published by the Free Software
- // Foundation, either version 3 of the License, or (at your option) any later
- // version.
- //
- // Gc-Base-Lib is distributed in the hope that it will be useful, but WITHOUT
- // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- // details.
- //
- // You should have received a copy of the GNU General Public License along with
- // Gc-Base-Lib. If not, see <http://www.gnu.org/licenses/>.
- //==============================================================================
- #include <gc/file.h>
- #include <unistd.h>
- //==============================================================================
- // Initialization and deinitialization
- //==============================================================================
- u8 file_init(struct file_i *file, struct file_c *conf)
- {
- if (!(conf->flags & FILE_CREAT))
- file->fd = open(conf->path, conf->flags);
- else
- file->fd = open(conf->path, conf->flags, conf->mode);
- if (unlikely(file->fd == -1))
- return 1;
- return 0;
- }
- void file_deinit(struct file_i *file)
- {
- close(file->fd);
- }
- //==============================================================================
- // Read and write
- //==============================================================================
- u8 file_read(struct file_i *file, u8 *buf, u32 size, u32 *ret)
- {
- ssize_t bytes = read(file->fd, buf, size);
- if (unlikely(bytes == -1))
- return 1;
- *ret = bytes;
- return 0;
- }
- u8 file_write(struct file_i *file, u8 *buf, u32 size, u32 *ret)
- {
- ssize_t bytes = write(file->fd, buf, size);
- if (unlikely(bytes == -1))
- return 1;
- *ret = bytes;
- return 0;
- }
- //==============================================================================
- // Utility
- //==============================================================================
- u8 file_gstats(struct file_i *file, struct file_stats *stats)
- {
- if (unlikely(fstat(file->fd, &stats->data)))
- return 1;
- return 0;
- }
- ./dev/gc-base-lib/1/make.sh
- gcc -o libgc-base -shared -I include -std=c11 -Wall -Wextra -Wpedantic -Werror `find src -type f -name '*.c'`
- ./dev/gc-base-lib/1/inc/gc/macro/ms.h
- //==============================================================================
- // This file is part of Gc-Base-Lib.
- // Copyright (C) 2015 Anthony Gorecki <agorecki@gcproj.org>
- //
- // Gc-Base-Lib is free software: you can redistribute it and/or modify it under
- // the terms of the GNU General Public License as published by the Free Software
- // Foundation, either version 3 of the License, or (at your option) any later
- // version.
- //
- // Gc-Base-Lib is distributed in the hope that it will be useful, but WITHOUT
- // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- // details.
- //
- // You should have received a copy of the GNU General Public License along with
- // Gc-Base-Lib. If not, see <http://www.gnu.org/licenses/>.
- //==============================================================================
- #pragma once
- #define MS_BEG(STEP)
- #define MS_EM
- #define MS_SP
- #define MS_EV
- ./dev/gc-base-lib/1/inc/gc/proc.h
- //==============================================================================
- // This file is part of Gc-Base-Lib.
- // Copyright (C) 2015 Anthony Gorecki <agorecki@gcproj.org>
- //
- // Gc-Base-Lib is free software: you can redistribute it and/or modify it under
- // the terms of the GNU General Public License as published by the Free Software
- // Foundation, either version 3 of the License, or (at your option) any later
- // version.
- //
- // Gc-Base-Lib is distributed in the hope that it will be useful, but WITHOUT
- // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- // details.
- //
- // You should have received a copy of the GNU General Public License along with
- // Gc-Base-Lib. If not, see <http://www.gnu.org/licenses/>.
- //==============================================================================
- #pragma once
- #include <gc/common.h>
- #if defined(__use_gnu_bktrc)
- #include <gc/proc-gnu-bktrc.h>
- #endif
- #if defined(__use_lunwind)
- #include <gc/proc-lunwind.h>
- #endif
- // Null function pointers for systems where back traces are not supported.
- ./dev/gc-base-lib/1/inc/gc/common.h
- //==============================================================================
- // This file is part of Gc-Base-Lib.
- // Copyright (C) 2015 Anthony Gorecki <agorecki@gcproj.org>
- //
- // Gc-Base-Lib is free software: you can redistribute it and/or modify it under
- // the terms of the GNU General Public License as published by the Free Software
- // Foundation, either version 3 of the License, or (at your option) any later
- // version.
- //
- // Gc-Base-Lib is distributed in the hope that it will be useful, but WITHOUT
- // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- // details.
- //
- // You should have received a copy of the GNU General Public License along with
- // Gc-Base-Lib. If not, see <http://www.gnu.org/licenses/>.
- //==============================================================================
- #pragma once
- #include <stddef.h>
- #include <stdint.h>
- // "__unused" is expected to be provided by a system library. Define it in this
- // file only if it is missing on the host system.
- #define likely(EXPR) __builtin_expect(EXPR, 1)
- #define unlikely(EXPR) __builtin_expect(EXPR, 0)
- typedef int8_t s8;
- typedef int16_t s16;
- typedef int32_t s32;
- typedef int64_t s64;
- typedef uint8_t u8;
- typedef uint16_t u16;
- typedef uint32_t u32;
- typedef uint64_t u64;
- ./dev/gc-base-lib/1/inc/gc/u8_ib.h
- //==============================================================================
- // This file is part of Gc-Base-Lib.
- // Copyright (C) 2015 Anthony Gorecki <agorecki@gcproj.org>
- //
- // Gc-Base-Lib is free software: you can redistribute it and/or modify it under
- // the terms of the GNU General Public License as published by the Free Software
- // Foundation, either version 3 of the License, or (at your option) any later
- // version.
- //
- // Gc-Base-Lib is distributed in the hope that it will be useful, but WITHOUT
- // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- // details.
- //
- // You should have received a copy of the GNU General Public License along with
- // Gc-Base-Lib. If not, see <http://www.gnu.org/licenses/>.
- //==============================================================================
- #pragma once
- #include <gc/ct.h>
- struct u8_ib_i {
- };
- struct u8_ib_c {
- };
- ./dev/gc-base-lib/1/inc/gc/atmc.h
- //==============================================================================
- // This file is part of Gc-Base-Lib.
- // Copyright (C) 2015 Anthony Gorecki <agorecki@gcproj.org>
- //
- // Gc-Base-Lib is free software: you can redistribute it and/or modify it under
- // the terms of the GNU General Public License as published by the Free Software
- // Foundation, either version 3 of the License, or (at your option) any later
- // version.
- //
- // Gc-Base-Lib is distributed in the hope that it will be useful, but WITHOUT
- // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- // details.
- //
- // You should have received a copy of the GNU General Public License along with
- // Gc-Base-Lib. If not, see <http://www.gnu.org/licenses/>.
- //==============================================================================
- #pragma once
- #include <gc/common.h>
- typedef _Atomic s8 as8;
- typedef _Atomic s16 as16;
- typedef _Atomic s32 as32;
- typedef _Atomic s64 as64;
- typedef _Atomic u8 au8;
- typedef _Atomic u16 au16;
- typedef _Atomic u32 au32;
- typedef _Atomic u64 au64;
- #define atmc_fadd atomic_fetch_add
- #define atmc_fsub atomic_fetch_sub
- #define atmc_load atomic_load
- ./dev/gc-base-lib/1/inc/gc/ct.h
- //==============================================================================
- // This file is part of Gc-Base-Lib.
- // Copyright (C) 2015 Anthony Gorecki <agorecki@gcproj.org>
- //
- // Gc-Base-Lib is free software: you can redistribute it and/or modify it under
- // the terms of the GNU General Public License as published by the Free Software
- // Foundation, either version 3 of the License, or (at your option) any later
- // version.
- //
- // Gc-Base-Lib is distributed in the hope that it will be useful, but WITHOUT
- // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- // details.
- //
- // You should have received a copy of the GNU General Public License along with
- // Gc-Base-Lib. If not, see <http://www.gnu.org/licenses/>.
- //==============================================================================
- #pragma once
- #include <gc/macro/ms.h>
- // Configuration for composite types needs space for two offsets (u16's), to
- // allow for two variable types (such as "u8_a").
- #define CT_M1V 1 // Member 1 pass by value.
- #define CT_M2V 2 // Member 2 pass by value.
- #define CT_M2D 4 // Member 2 pass to deinit.
- #define CT_WRAP_MSI2D1(PREF) \
- u8 PREF##_init_ms(struct PREF##_i*, struct PREF##_c*); \
- void PREF##_deinit_ms(struct PREF##_i*); \
- u8 PREF##_init(struct PREF##_i *info, struct PREF##_c *conf) \
- { \
- u8 step = PREF##_init_ms(info, conf); \
- if (!step) \
- return 0; \
- PREF##_deinit_ms(info, step); \
- return 1; \
- } \
- void PREF##_deinit(struct PREF##_i *info) \
- { \
- PREF##_deinit_ms(info, 0); \
- }
- ./dev/gc-base-lib/1/inc/gc/u8b.h
- //==============================================================================
- // This file is part of Gc-Base-Lib.
- // Copyright (C) 2015 Anthony Gorecki <agorecki@gcproj.org>
- //
- // Gc-Base-Lib is free software: you can redistribute it and/or modify it under
- // the terms of the GNU General Public License as published by the Free Software
- // Foundation, either version 3 of the License, or (at your option) any later
- // version.
- //
- // Gc-Base-Lib is distributed in the hope that it will be useful, but WITHOUT
- // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- // details.
- //
- // You should have received a copy of the GNU General Public License along with
- // Gc-Base-Lib. If not, see <http://www.gnu.org/licenses/>.
- //==============================================================================
- #pragma once
- #include <gc/atmc.h>
- struct u8b_i {
- u32 cbeg;
- au32 cin;
- au32 cout;
- u8 *dbeg;
- u8 *din;
- u8 *dout;
- };
- ./dev/gc-base-lib/1/inc/gc/pars.h
- //==============================================================================
- // This file is part of Gc-Base-Lib.
- // Copyright (C) 2015 Anthony Gorecki <agorecki@gcproj.org>
- //
- // Gc-Base-Lib is free software: you can redistribute it and/or modify it under
- // the terms of the GNU General Public License as published by the Free Software
- // Foundation, either version 3 of the License, or (at your option) any later
- // version.
- //
- // Gc-Base-Lib is distributed in the hope that it will be useful, but WITHOUT
- // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- // details.
- //
- // You should have received a copy of the GNU General Public License along with
- // Gc-Base-Lib. If not, see <http://www.gnu.org/licenses/>.
- //==============================================================================
- #pragma once
- #include <gc/u8b.h>
- struct pars_i {
- struct u8b_i buf;
- };
- ./dev/gc-base-lib/1/inc/gc/file.h
- //==============================================================================
- // This file is part of Gc-Base-Lib.
- // Copyright (C) 2015 Anthony Gorecki <agorecki@gcproj.org>
- //
- // Gc-Base-Lib is free software: you can redistribute it and/or modify it under
- // the terms of the GNU General Public License as published by the Free Software
- // Foundation, either version 3 of the License, or (at your option) any later
- // version.
- //
- // Gc-Base-Lib is distributed in the hope that it will be useful, but WITHOUT
- // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- // details.
- //
- // You should have received a copy of the GNU General Public License along with
- // Gc-Base-Lib. If not, see <http://www.gnu.org/licenses/>.
- //==============================================================================
- #pragma once
- #include <gc/u8b.h>
- #include <sys/stat.h>
- #include <fcntl.h>
- struct file_i {
- int fd;
- };
- struct file_c {
- const char *path;
- int flags;
- mode_t mode;
- };
- struct file_stats {
- struct stat data;
- };
- ./dev/gc-base-lib/1/inc/gc/mem.h
- //==============================================================================
- // This file is part of Gc-Base-Lib.
- // Copyright (C) 2015 Anthony Gorecki <agorecki@gcproj.org>
- //
- // Gc-Base-Lib is free software: you can redistribute it and/or modify it under
- // the terms of the GNU General Public License as published by the Free Software
- // Foundation, either version 3 of the License, or (at your option) any later
- // version.
- //
- // Gc-Base-Lib is distributed in the hope that it will be useful, but WITHOUT
- // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- // details.
- //
- // You should have received a copy of the GNU General Public License along with
- // Gc-Base-Lib. If not, see <http://www.gnu.org/licenses/>.
- //==============================================================================
- #pragma once
- #include <gc/common.h>
- void* mem_alloc(size_t);
- void* mem_realloc(void*, size_t);
- void mem_dealloc(void*);
- u8 mem_comp(void*, void*, size_t);
- void mem_copy(void*, void*, size_t);
- void mem_move(void*, void*, size_t);
- void mem_set(void*, u8, size_t);
- ./dev/doc/includes.txt
- External Gc headers, Gc header for local file, all other headers; groups
- separated by a single new line.
- ./dev/doc/func-args.txt
- Structs are always used for info and conf varaibles so their contents /
- implementation can easily be changed later and without modifying the code of
- software using the libraries.
- ./dev/doc/code-style.txt
- Soft limit for line length is 80 characters, hard limit is 100 characters.
- Conditional statements requiring multiple lines should indent the subsequent
- lines with two tabs (one additional tab, relative the the code following the
- conditional statement).
- ./dev/doc/func-naming.txt
- Hard limit for function name first part is five characters. Soft limit is
- four characters.
- Function name hard limit for second part is five characters (initialization /
- activation). Does not apply to names that have been shortened to individual
- characters per word.
- Struct member name soft limit is four characters.
- ./script/upload-pastebin.sh
- cd /root
- echo 'Files:'
- files=$(find -name '*.c' -o -name '*.h' -o -name '*.py' -o -name '*.sh' -o -name '*.txt' -o -name '.vimrc')
- date > upload-data.txt
- for file in $files; do
- echo " $file"
- echo $file >> upload-data.txt
- cat $file >> upload-data.txt
- done
- echo
- echo -n 'URL: '
- python ./script/intrn/upload-pastebin.py `cat script/intrn/dev-key`
- rm upload-data.txt
- ./script/intrn/upload-pastebin.py
- import pastebin_python
- import sys
- pb = pastebin_python.pastebin.PastebinPython(api_dev_key=sys.argv[1])
- print pb.createPasteFromFile('upload-data.txt', 'anthony gorecki anthony@anthonygorecki.ca', '', '0', 'N')
- ./.vimrc
- set ts=4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement