Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sun, Dec 06, 2015 12:21:50 AM
- ./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).
- ./doc/errors.txt
- Code that is (potentially) buggy enough to need asserts should include <gc/err.h>.
- ./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.
- ./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.
- ./doc/includes.txt
- External Gc headers, Gc header for local file, all other headers; groups
- separated by a single new line.
- All Gc headers must ultimately include <gc/base.h>. This is to get system
- wide defines like _GNU_SOURCE and primitive types (u8, etc).
- Includes for files that have a one line description must duplicate that
- description.
- ./doc/secure-coding.txt
- Parser memory errors are treated as "no match".
- Invalid flag arguments are treated as "no match".
- ./gc-base-lib/1/0/gc-proj.txt
- #===============================================================================
- # This file is part of Gc-Base-Lib.
- # Copyright (C) 2016-2017 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; if you aren't going to make 'dev'
- # it won't be configured -- per target config)
- # gc-proj-make (will rebuild changed files; will rebuild only necessary after conf change)
- # gc-proj-inst (installs all built targets)
- #
- # Note: This file does not include operating system specific support yet.
- TGEN dev # Make this into TDEV after parser works properly.
- CONF
- VARS
- DIR inc
- DIR pkgconfig
- MAKE
- EXEC lib/pkgconfig/make.sh $DPKGCONFIG # This should be replaced with 'sed'.
- INST
- COPY inc/gc $DINC
- MOVE lib/pkgconfig/gc-base.pc.tmp $DPKGCONFIG/gc-base.pc
- TLIB lib
- CONF
- # DEF (default target; overrides first lib or exe target if specified)
- # note that the precedence of targets to be chosen first could (and
- # probably should be determined by selecting a profile for the given
- # programming language / project type. Documentation projects, for
- # instance would not have the same precedence settings as a c project.
- # NDIR LIB (implied by target type).
- DLNK pthread # Need pthread library.
- FEAT alloc # Feature to select memory allocator.
- llalloc # Lockless alloc. Default option is first.
- DLNK llalloc # Add to the list of libraries to link dynamically.
- libc # Fall back to standard libc allocator.
- # Nothing to do.
- FEAT st # Feature to select stack tracing implementation.
- unwind # libunwind
- PCFG unwind # Use pkg-config to add cflags and libs.
- gnubt # GNU backtrace functions
- LNKF rdynamic # Add -rdynamic linker flag.
- ./gc-base-lib/1/0/inc/gc/atmc.h
- //==============================================================================
- // This file is part of Gc-Base-Lib.
- // Copyright (C) 2016-2017 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
- ./gc-base-lib/1/0/inc/gc/base.h
- //==============================================================================
- // This file is part of Gc-Base-Lib.
- // Copyright (C) 2016-2017 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;
- ./gc-base-lib/1/0/inc/gc/ct.h
- //==============================================================================
- // This file is part of Gc-Base-Lib.
- // Copyright (C) 2016-2017 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); \
- }
- ./gc-base-lib/1/0/inc/gc/err.h
- //==============================================================================
- // This file is part of Gc-Base-Lib.
- // Copyright (C) 2016-2017 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/base.h>
- #include <assert.h>
- //==============================================================================
- // Configurable definitions
- //==============================================================================
- // These definitions should be set by "gc-proj-conf" in the future.
- #define ERR_ENBEG 2200 // Begin numbering of additional error types from here.
- #define ERR_ENMAX 3000 // Maximum sane value of "errno". Must be "<= U16_MAX".
- //==============================================================================
- // Additional error types
- //==============================================================================
- #define EINVALRET (ERR_ENBEG + 0)
- //==============================================================================
- // Function prototypes
- //==============================================================================
- __dllexp void err(void);
- __dllexp void err_en(int);
- __dllexp void err_msg(const char*);./gc-base-lib/1/0/inc/gc/file.h
- //==============================================================================
- // This file is part of Gc-Base-Lib.
- // Copyright (C) 2016-2017 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;
- };
- ./gc-base-lib/1/0/inc/gc/macro/ms.h
- //==============================================================================
- // This file is part of Gc-Base-Lib.
- // Copyright (C) 2015-2016 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
- ./gc-base-lib/1/0/inc/gc/macro/wrap_posix.h
- //==============================================================================
- // This file is part of Gc-Base-Lib.
- // Copyright (C) 2016-2017 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/err.h>
- //==============================================================================
- // Templates
- //==============================================================================
- #define _WRAP_POSIX(SUCC, FAIL, FNAME, ...) \
- { \
- int _ret = FNAME(__VA_ARGS__); \
- if (unlikely(_ret)) { \
- err_en(_ret); \
- FAIL; \
- } \
- SUCC; \
- }
- //==============================================================================
- // Wrappers
- //==============================================================================
- #define WRAP_POSIX(FNAME, ...) \
- _WRAP_POSIX(return 0, return 1, FNAME, __VA_ARGS__);
- #define WRAP_POSIX_NR(FNAME, ...) \
- _WRAP_POSIX(,, FNAME, __VA_ARGS__);./gc-base-lib/1/0/inc/gc/macro/wrap_unix.h
- //==============================================================================
- // This file is part of Gc-Base-Lib.
- // Copyright (C) 2016-2017 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/err.h>
- //==============================================================================
- // Templates
- //==============================================================================
- #define _WRAP_UNIX(SUCC, FAIL, FNAME, ...) \
- { \
- int _ret = FNAME(__VA_ARGS__); \
- if (unlikely(_ret)) { \
- if (unlikely(_ret != -1)) \
- errno = EINVALRET; \
- err(); \
- FAIL; \
- } \
- SUCC; \
- }
- //==============================================================================
- // Wrappers
- //==============================================================================
- #define WRAP_UNIX(FNAME, ...) \
- _WRAP_UNIX(return 0, return 1, FNAME, __VA_ARGS__);
- #define WRAP_UNIX_NR(FNAME, ...) \
- _WRAP_UNIX(,, FNAME, __VA_ARGS__);./gc-base-lib/1/0/inc/gc/mem.h
- //==============================================================================
- // This file is part of Gc-Base-Lib.
- // Copyright (C) 2016-2017 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);
- ./gc-base-lib/1/0/inc/gc/pars.h
- //==============================================================================
- // This file is part of Gc-Base-Lib.
- // Copyright (C) 2016-2017 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;
- };
- ./gc-base-lib/1/0/inc/gc/proc.h
- //==============================================================================
- // This file is part of Gc-Base-Lib.
- // Copyright (C) 2016-2017 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.
- ./gc-base-lib/1/0/inc/gc/u8b.h
- //==============================================================================
- // This file is part of Gc-Base-Lib.
- // Copyright (C) 2016-2017 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;
- };
- ./gc-base-lib/1/0/inc/gc/u8_ib.h
- //==============================================================================
- // This file is part of Gc-Base-Lib.
- // Copyright (C) 2016-2017 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 {
- };
- ./gc-base-lib/1/0/make.sh
- gcc -o libgc-base -shared -I inc \
- -std=c11 \
- -Wall \
- -Wextra \
- -Wpedantic -Werror \
- src/ct/u8a.c \
- src/os/unix/*.c \
- src/pt/u8.c
- # `find src -type f -name '*.c'`
- ./gc-base-lib/1/0/src/ct/u8a.c
- //==============================================================================
- // This file is part of Gc-Base-Lib.
- // Copyright (C) 2016-2017 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/u8a.h>
- //==============================================================================
- // Initialization and deinitialization
- //==============================================================================
- __dllexp u8 u8a_init(u8 **arr, u32 *size, struct u8a_c *conf)
- {
- *arr = mem_alloc(conf->size);
- if (unlikely(*arr == NULL && conf->size))
- return 1;
- *size = conf->size;
- return 0;
- }
- __dllexp void u8a_deinit(u8 **arr)
- {
- mem_dealloc(*arr);
- }
- //==============================================================================
- // Ranges
- //==============================================================================
- __dllexp u32 u8a_rm(u8 *arr, u32 size, u8 lower, u8 upper)
- {
- while (size && *arr >= lower && *arr <= upper) {
- ++arr;
- --size;
- }
- return size;
- }
- __dllexp u32 u8a_rma(u8 *arr, u32 size, u8 *arng, u8 crng)
- {
- while (size && !u8_rma(*arr, arng, crng)) {
- ++arr;
- --size;
- }
- return size;
- }
- //==============================================================================
- // Values
- //==============================================================================
- __dllexp u32 u8a_vm(u8 *arr, u32 size, u8 val)
- {
- while (size && *arr == val) {
- ++arr;
- --size;
- }
- return size;
- }
- __dllexp u32 u8a_vm2(u8 *arr, u32 size, u8 val1, u8 val2) // For new lines.
- {
- while (size >= 2 && *arr == val1 && *(arr+1) == val2) {
- arr += 2;
- size -= 2;
- }
- return size;
- }
- __dllexp u32 u8a_vma(u8 *arr, u32 size, u8 *aval, u8 cval)
- {
- while (size && !u8_vma(*arr, aval, cval)) {
- ++arr;
- --size;
- }
- return size;
- }
- //==============================================================================
- // Special characters
- //==============================================================================
- __dllexp u32 u8a_sm(u8 *arr, u32 size, u8 spec, u8 esc)
- {
- return size;
- }
- __dllexp u32 u8a_sma(u8 *arr, u32 size, u8 *aspec, u8 cspec, u8 esc)
- {
- // Match array of nonescaped special characters; escape character can also
- // be escaped (use bool "escaped" var)
- //
- // use separate function to match escape char?
- return size;
- }
- //==============================================================================
- // New line characters
- //==============================================================================
- __dllexp u8 u8a_nld(u8 *arr, u32 size, u8 types)
- {
- assert((types & NL_RN) || (types & NL_N) || (types & NL_R));
- if (size >= 2 && (types & NL_RN) && *arr == '\r' && *(arr+1) == '\n')
- return NL_RN;
- if (size) {
- if ((types & NL_N) && *arr == '\n')
- return NL_N;
- if ((types & NL_R) && *arr == '\r')
- return NL_R;
- }
- return 0;
- }
- __dllexp u32 u8a_nlm(u8 *arr, u32 size, u8 types)
- {
- assert((types & NL_RN) || (types & NL_N) || (types & NL_R));
- if ((types & NL_RN))
- return u8a_vm2(arr, size, '\r', '\n');
- if ((types & NL_N))
- return u8a_vm(arr, size, '\n');
- return u8a_vm(arr, size, '\r');
- }
- __dllexp u32 u8a_nlmm(u8 *arr, u32 size, u8 types)
- {
- u32 rem;
- for (;;) {
- rem = u8a_nlm(arr, size, types);
- if (rem >= size)
- break;
- arr += size - rem;
- size = rem;
- }
- return size;
- }
- ./gc-base-lib/1/0/src/ct/u8b.c
- //==============================================================================
- // This file is part of Gc-Base-Lib.
- // Copyright (C) 2016-2017 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/u8b.h>./gc-base-lib/1/0/src/ct/u8bc.c
- //==============================================================================
- // This file is part of Gc-Base-Lib.
- // Simple circular buffer, supporting nonsimultaneous input and output.
- // Copyright (C) 2016-2017 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/u8bc.h>
- //==============================================================================
- // Initialization and deinitialization
- //==============================================================================
- u8 u8bc_init(struct u8bc_i *buf, struct u8bc_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 u8bc_deinit(struct u8bc_i *buf)
- {
- mem_dealloc(buf->dbeg);
- }
- //==============================================================================
- // Advance
- //==============================================================================
- void u8bc_ia(struct u8bc_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 u8bc_oa(struct u8bc_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 u8bc_igc(struct u8bc_i *buf)
- {
- return atmc_load(&buf->cin);
- }
- u32 u8bc_ogc(struct u8bc_i *buf)
- {
- return atmc_load(&buf->cout);
- }
- //==============================================================================
- // Contiguous count and pointer
- //==============================================================================
- u32 u8bc_igcc(struct u8bc_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 *u8bc_igcp(struct u8bc_i *buf)
- {
- return buf->din;
- }
- u32 u8bc_ogcc(struct u8bc_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 *u8bc_ogcp(struct u8bc_i *buf)
- {
- return buf->dout;
- }
- //==============================================================================
- // Peeking
- //==============================================================================
- u8 u8bc_op1(struct u8bc_i *buf)
- {
- return buf->dout[0];
- }
- u16 u8bc_op2(struct u8bc_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 u8bc_if(struct u8bc_i *buf, u8 (*fin)(void*, u8*, u32, u32*),
- void *arg)
- {
- u32 ret;
- if (unlikely(fin(arg, buf->din, u8bc_igcc(buf), &ret)))
- return 1;
- u8bc_ia(buf, ret);
- return 0;
- }
- u8 u8bc_of(struct u8bc_i *buf, u8 (*fout)(void*, u8*, u32, u32*),
- void *arg)
- {
- u32 ret;
- if (unlikely(fout(arg, buf->dout, u8bc_ogcc(buf), &ret)))
- return 1;
- u8bc_oa(buf, ret);
- return 0;
- }
- ./gc-base-lib/1/0/src/ct/u8bcss.c
- //==============================================================================
- // This file is part of Gc-Base-Lib.
- // Lockless circular buffer, supporting a single producer and single consumer.
- // Copyright (C) 2016-2017 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/u8bcss.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: u8bcss -> u8_b for pars_ -> publish
- // changes back to original u8bcss 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
- //==============================================================================
- __dllexp u8 u8bcss_init(struct u8bcss_i *buf, struct u8bcss_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
- //==============================================================================
- __dllexp void u8bcss_ia(struct u8bcss_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);
- }
- __dllexp void u8bcss_oa(struct u8bcss_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
- //==============================================================================
- __dllexp u32 u8bcss_igc(struct u8bcss_i *buf)
- {
- return atmc_load(&buf->cin);
- }
- __dllexp u32 u8bcss_ogc(struct u8bcss_i *buf)
- {
- return atmc_load(&buf->cout);
- }
- //==============================================================================
- // Contiguous count and pointer
- //==============================================================================
- __dllexp u32 u8bcss_igcc(struct u8bcss_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;
- }
- __dllexp u8 *u8bcss_igcp(struct u8bcss_i *buf)
- {
- return buf->din;
- }
- __dllexp u32 u8bcss_ogcc(struct u8bcss_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;
- }
- __dllexp u8 *u8bcss_ogcp(struct u8bcss_i *buf)
- {
- return buf->dout;
- }
- //==============================================================================
- // Peeking
- //==============================================================================
- __dllexp u8 u8bcss_op1(struct u8bcss_i *buf)
- {
- return buf->dout[0];
- }
- __dllexp u16 u8bcss_op2(struct u8bcss_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
- //==============================================================================
- __dllexp u8 u8bcss_if(struct u8bcss_i *buf, u8 (*fin)(void*, u8*, u32, u32*),
- void *arg)
- {
- u32 ret;
- if (unlikely(fin(arg, buf->din, u8bcss_igcc(buf), &ret)))
- return 1;
- u8bcss_ia(buf, ret);
- return 0;
- }
- __dllexp u8 u8bcss_of(struct u8bcss_i *buf, u8 (*fout)(void*, u8*, u32, u32*),
- void *arg)
- {
- u32 ret;
- if (unlikely(fout(arg, buf->dout, u8bcss_ogcc(buf), &ret)))
- return 1;
- u8bcss_oa(buf, ret);
- return 0;
- }
- ./gc-base-lib/1/0/src/ct/u8ib.c
- //==============================================================================
- // This file is part of Gc-Base-Lib.
- // Copyright (C) 2016-2017 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/u8ib.h>
- //==============================================================================
- // Initialization and deinitialization
- //==============================================================================
- CT_WRAP_MSI2D1(__dllexp, u8ib);
- u8 u8ib_init_ms(struct u8ib_i *ibuf, struct u8ib_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 u8ib_deinit_ms(struct u8ib_i *ibuf, u8 step)
- {
- MS_BEG(step);
- MS_EM;
- MS_SP { ibuf->f->deinit(ibuf->buf); }
- MS_SP { mem_dealloc(ibuf->buf); }
- }
- //==============================================================================
- // Advance
- //==============================================================================
- __dllexp void u8ib_ia(struct u8ib_i *ibuf, u32 size)
- {
- ibuf->f->ia(ibuf->buf, size);
- }
- __dllexp void u8ib_oa(struct u8ib_i *ibuf, u32 size)
- {
- ibuf->f->oa(ibuf->buf, size);
- }
- //==============================================================================
- // Count
- //==============================================================================
- __dllexp u32 u8ib_igc(struct u8ib_i *ibuf)
- {
- return ibuf->f->igc(ibuf->buf);
- }
- __dllexp u32 u8ib_ogc(struct u8ib_i *ibuf)
- {
- return ibuf->f->ogc(ibuf->buf);
- }
- //==============================================================================
- // Contiguous count and pointer
- //==============================================================================
- __dllexp u32 u8ib_igcc(struct u8ib_i *ibuf)
- {
- return ibuf->f->igcc(ibuf->buf);
- }
- __dllexp u8 *u8ib_igcp(struct u8ib_i *ibuf)
- {
- return ibuf->f->igcp(ibuf->buf);
- }
- __dllexp u32 u8ib_ogcc(struct u8ib_i *ibuf)
- {
- return ibuf->f->ogcc(ibuf->buf);
- }
- __dllexp u8 *u8ib_ogcp(struct u8ib_i *ibuf)
- {
- return ibuf->f->ogcp(ibuf->buf);
- }
- //==============================================================================
- // Peeking
- //==============================================================================
- __dllexp u8 u8ib_op1(struct u8ib_i *ibuf)
- {
- return ibuf->f->op1(ibuf->buf);
- }
- __dllexp u16 u8ib_op2(struct u8ib_i *ibuf)
- {
- return ibuf->f->op2(ibuf->buf);
- }
- //==============================================================================
- // Input and output
- //==============================================================================
- __dllexp u8 u8ib_if(struct u8ib_i *ibuf, u8 (*fin)(void*, u8*, u32, u32*),
- void *arg)
- {
- return ibuf->if(ibuf->buf, fin, arg);
- }
- __dllexp u8 u8ib_of(struct u8ib_i *ibuf, u8 (*fout)(void*, u8*, u32, u32*),
- void *arg)
- {
- return ibuf->of(ibuf->buf, fout, arg);
- }
- ./gc-base-lib/1/0/src/os/unix/err.c
- //==============================================================================
- // This file is part of Gc-Base-Lib.
- // Copyright (C) 2016-2017 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/err.h>
- #include <stdio.h>
- #include <string.h>
- //==============================================================================
- // Error handling
- //==============================================================================
- __dllexp void err(void)
- {
- err_en(errno);
- }
- __dllexp void err_en(int en)
- {
- char *msg;
- char buf[256];
- msg = strerror_r(en, buf, 256);
- assert(msg != NULL);
- if (msg != NULL) // Sanity checking.
- err_msg(msg);
- }
- __dllexp void err_msg(const char *msg)
- {
- fprintf(stderr, "%s" ENDL);
- }./gc-base-lib/1/0/src/os/unix/file.c
- //==============================================================================
- // This file is part of Gc-Base-Lib.
- // Copyright (C) 2016-2017 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
- //==============================================================================
- __dllexp 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;
- }
- __dllexp void file_deinit(struct file_i *file)
- {
- close(file->fd);
- }
- //==============================================================================
- // Read and write
- //==============================================================================
- __dllexp 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;
- }
- __dllexp 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
- //==============================================================================
- __dllexp u8 file_gstats(struct file_i *file, struct file_stats *stats)
- {
- if (unlikely(fstat(file->fd, &stats->data)))
- return 1;
- return 0;
- }
- ./gc-base-lib/1/0/src/os/unix/mem.c
- //==============================================================================
- // This file is part of Gc-Base-Lib.
- // Copyright (C) 2016-2017 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
- //==============================================================================
- __dllexp void *mem_alloc(size_t size)
- {
- return malloc(size);
- }
- __dllexp void *mem_realloc(void *ptr, size_t size)
- {
- return realloc(ptr, size);
- }
- __dllexp void mem_dealloc(void *ptr)
- {
- free(ptr);
- }
- //==============================================================================
- // Utility
- //==============================================================================
- __dllexp s8 mem_comp(void *data1, void *data2, size_t size)
- {
- return memcmp(data1, data2, size);
- }
- __dllexp void mem_copy(void *dest, void *src, size_t size)
- {
- memcpy(dest, src, size);
- }
- __dllexp void mem_move(void *dest, void *src, size_t size)
- {
- memmove(dest, src, size);
- }
- __dllexp void mem_set(void *ptr, u8 data, size_t size)
- {
- memset(ptr, data, size);
- }
- ./gc-base-lib/1/0/src/os/unix/proc.c
- //==============================================================================
- // This file is part of Gc-Base-Lib.
- // Copyright (C) 2016-2017 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
- //==============================================================================
- __dllexp u8 proc_exec(void)
- {
- }
- ./gc-base-lib/1/0/src/pt/u8.c
- //==============================================================================
- // This file is part of Gc-Base-Lib.
- // Copyright (C) 2016-2017 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/u8.h>
- //==============================================================================
- // Ranges and values
- //==============================================================================
- __dllexp u8 u8_rma(u8 data, u8 *arng, u8 crng)
- {
- while (crng) {
- if (data >= *arng && data <= *(++arng))
- return 0;
- ++arng;
- --crng;
- }
- return 1;
- }
- __dllexp u8_vma(u8 data, u8 *aval, u8 cval)
- {
- while (cval) {
- if (data == *aval)
- return 0;
- ++aval;
- --cval;
- }
- return 1;
- }
- ./gc-base-lib/1/0/src/util/pars.c
- //==============================================================================
- // This file is part of Gc-Base-Lib.
- // Copyright (C) 2016-2017 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.
- //
- // This parser requires exclusive access the the buffer region provided by buf.
- // For multiple reader buffers, it's expected that a block of data will be read,
- // converted to a u8_b for the parser, and treated as a contiguous array.
- ./gc-base-lib/1/0/test/conf/strerror_r-1.c
- //==============================================================================
- // This file is part of Gc-Base-Lib.
- // Copyright (C) 2016-2017 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/err.h>
- #include <string.h>
- //==============================================================================
- // Handle invalid "errno"
- //==============================================================================
- // Ideally, this kind of test would be loaded by "dlopen()", used and then
- // unloaded.
- int main(void)
- {
- int aen[] = {INT_MIN, -ERR_ENMAX, -1, ERR_ENMAX, INT_MAX};
- char *msg;
- char buf[256];
- for (i = 0; i < 5; ++i) {
- // The manual page for "strerror()" states that the function can return
- // "NULL" on some systems if it encounters an unknown error number.
- //
- // This test verifies that "strerror_r()" does not return "NULL" if it
- // encounters an unknown error number. It does not, however, confirm
- // that the system actually has an implementation of "strerror()" that
- // is problematic. In the future, dependency tracking for tests should
- // be added to ensure that the number of unnecessary tests being run is
- // kept to a minimum.
- msg = strerror_r(aen[i], buf, 256);
- if (msg != NULL)
- continue;
- fprintf(stderr,
- "Test failed: \"strerror_r()\" - Handle invalid \"errno\"." ENDL);
- return 1;
- }
- return 0;
- }./gc-base-lib/2/0/inc/gc/aiobk.h
- 3//==============================================================================
- // This file is part of Gc-Base-Lib.
- // Kernel asynchronous, unbuffered I/O for block devices and files
- // Copyright (C) 2016-2017 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/base.h>
- #include <linux/aio_abi.h>
- //==============================================================================
- // General
- //==============================================================================
- struct aiobk_i {
- aio_context_t ctx;
- };
- struct aiobk_c {
- u16 cev;
- };./gc-base-lib/2/0/src/ct/it.c
- ./gc-base-lib/2/0/src/ct/tavl.c
- ./gc-base-lib/2/0/src/ct/trbll.c
- ./gc-base-lib/2/0/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.
- ./gc-base-lib/2/0/src/os/linux/aiobk.c
- //==============================================================================
- // This file is part of Gc-Base-Lib.
- // Kernel asynchronous, unbuffered I/O for block devices and files
- // Copyright (C) 2016-2017 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/macro/wrap_unix.h>
- #include <gc/aiobk.h>
- #include <sys/syscall.h>
- //==============================================================================
- // Initialization and deinitialization
- //==============================================================================
- __dllexp u8 aiobk_init(struct aiobk_i *aiobk, struct aiobk_c *conf)
- {
- aiobk->ctx = 0; // Required by the kernel.
- WRAP_UNIX(io_setup(conf->cev, &aiobk->ctx));
- }
- __dllexp void aiobk_deinit(struct aiobk_i *aiobk)
- WRAP_UNIX_NR(io_destroy(aiobk->ctx));./gc-base-lib/2/0/src/os/linux/this_dir.txt
- linux specific things like signalfd, timerfd, kernel aio go in this directory
- ./gc-base-lib/2/0/src/os/unix/cnd.c
- ./gc-base-lib/2/0/src/os/unix/cnd_attr.c
- ./gc-base-lib/2/0/src/os/unix/mtx.c
- ./gc-base-lib/2/0/src/os/unix/mtx_attr.c
- ./gc-base-lib/2/0/src/os/unix/pcnd.c
- ./gc-base-lib/2/0/src/os/unix/pmtx.c
- ./gc-base-lib/2/0/src/os/unix/thrd.c
- ./gc-base-lib/2/0/src/svc/atq.c
- ./gc-base-lib/2/0/src/svc/tpool_a.c
- ./gc-base-lib/backup_location.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')
- ./_script/upload-pastebin.sh
- cd /home/agorecki/dev
- 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: '
- url=$(python2 ./_script/intrn/upload-pastebin.py `cat _script/intrn/dev-key`)
- echo $url
- rm upload-data.txt
- echo -n `date` >> gc-base-lib/backup_location.txt
- echo ": $url" >> gc-base-lib/backup_location.txt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement