repo_name
stringlengths
5
122
path
stringlengths
3
232
text
stringlengths
6
1.05M
RabbitBio/RabbitBM
src/barcodePositionMap.h
<reponame>RabbitBio/RabbitBM #ifndef BARCODEPOSITIONMAP_H #define BARCODEPOSITIONMAP_H #include <string> #include <cstring> #include "fastqreader.h" #include "read.h" #include "util.h" #include "options.h" #include "chipMaskHDF5.h" #include "bloomFilter.h" #include <unordered_map> //#include "robin_hood...
RabbitBio/RabbitBM
src/chipMaskHDF5.h
<reponame>RabbitBio/RabbitBM #ifndef CHIPMASKHDF5_H #define CHIPMASKHDF5_H #include <iostream> #include <hdf5.h> #include <unordered_map> #include "common.h" #include <libdeflate.h> //#include "robin_hood.h" #include "util.h" #include "bloomFilter.h" #define RANK 3 #define CDIM0 1537 #define CDIM1 1537 #define DATAS...
RabbitBio/RabbitBM
common/system.h
<reponame>RabbitBio/RabbitBM #ifndef SYSTEM_H #define SYSTEM_H #include <cstdlib> #include <exception> #include <system_error> #include <string> namespace utils { namespace system { namespace except { void throw_syserr(const std::string& what) { int errcode = errno; errno = 0; switch (errcode) { ...
RabbitBio/RabbitBM
libdeflatePugz.h
/* * libdeflate.h - public header for libdeflate */ #ifndef LIBDEFLATE_H #define LIBDEFLATE_H #define LIBDEFLATE_VERSION_MAJOR 0 #define LIBDEFLATE_VERSION_MINOR 8 #define LIBDEFLATE_VERSION_STRING "0.8" #include <cstddef> #include <cstdint> /* =====================================================================...
RabbitBio/RabbitBM
src/FastqStream.h
<gh_stars>0 /* This file is a part of DSRC software distributed under GNU GPL 2 licence. The homepage of the DSRC project is http://sun.aei.polsl.pl/dsrc Authors: <NAME> and <NAME> Version: 2.00 */ /* This file is modified by SDU HPC lab for RabbitQC project. Last modified: JULY2019 */ ...
manparvesh/regx.h
src/regx.h
<filename>src/regx.h<gh_stars>0 /********************************************************* * Created by manparvesh on 7/6/18. *********************************************************/ #ifndef REGX_H_REGX_H #define REGX_H_REGX_H #include <stdbool.h> /** * Search for a regex pattern in the text * */ bool...
manparvesh/regx.h
src/regx.c
/********************************************************* * Created by manparvesh on 7/6/18. *********************************************************/ #include <stdlib.h> #include <string.h> #include "regx.h" /********************************************************* * Private methods declaratio...
manparvesh/regx.h
tests/test.c
/********************************************************* * Created by manparvesh on 7/6/18. *********************************************************/ #include <assert.h> #include "regx.h" int main(){ char *pattern = ".*"; char *text = "abcdfseirjhewo34434jj"; assert(search(pattern, text)); ...
DiplexSoftfork/Skyrcoin
src/chainparamsseeds.h
#ifndef BITCOIN_CHAINPARAMSSEEDS_H #define BITCOIN_CHAINPARAMSSEEDS_H /** * List of fixed seed nodes for the bitcoin network * AUTOGENERATED by contrib/seeds/generate-seeds.py * * Each line contains a 16-byte IPv6 address and a port. * IPv4 as well as onion addresses are wrapped inside an IPv6 address accordingly....
calcmogul/sysid
sysid-application/src/main/native/include/sysid/generation/HardwareType.h
<reponame>calcmogul/sysid // Copyright (c) FIRST and other WPILib contributors. // Open Source Software; you can modify and/or share it under the terms of // the WPILib BSD license file in the root directory of this project. #pragma once #include <array> #include <string_view> namespace sysid { /** * Stores informa...
calcmogul/sysid
sysid-application/src/main/native/include/sysid/analysis/AngularDriveSim.h
<gh_stars>10-100 // Copyright (c) FIRST and other WPILib contributors. // Open Source Software; you can modify and/or share it under the terms of // the WPILib BSD license file in the root directory of this project. #pragma once #include <Eigen/Core> #include <units/time.h> #include <units/voltage.h> namespace sysid...
G33kDude/tinycomputer
src/assembler/macros.h
#pragma once #include <string> #include <vector> #include <map> #include <cstring> // strlen #include "lines.h" #define MACRO_START "!@" #define MACRO_END "!" #define MACRO_REF "@" namespace macros { struct macro { std::string name; std::vector<lines::line> repl; }; using macros = std::map<std::string,macro>;...
G33kDude/tinycomputer
src/assembler/assemble.h
#pragma once #include <algorithm> #include <array> #include <vector> #include "lines.h" #include "labels.h" #define ASM_BIT_PTR 1 << 2 #define ASM_TYPE_LITRL 1 << 0 #define ASM_TYPE_RWRAM 1 << 1 #define ASM_TYPE_RORAM 1 << 2 #define ASM_TYPE_LABEL 1 << 3 namespace assemble { using instruction = std::array<unsigne...
G33kDude/tinycomputer
src/assembler/labels.h
#pragma once #include <map> #include "lines.h" namespace labels { using labels = std::map<std::string, int>; lines::lines find_labels(lines::lines &input_lines, labels &found_labels); }
G33kDude/tinycomputer
src/assembler/lines.h
<gh_stars>1-10 #pragma once #include <iostream> #include <vector> #include <string> #define COMMENT_CHAR "#" #define WHITESPACE " \t" namespace lines { struct line { int number; std::string text; }; void trim_line(line &input); using lines = std::vector<line>; lines lines_from_cin(); lines clean_lines(line...
joshbainbridge/morphogenetic-sim
include/RenderThread.h
<filename>include/RenderThread.h #ifndef _RENDERTHREAD_H_ #define _RENDERTHREAD_H_ #include <boost/thread.hpp> #include <boost/shared_ptr.hpp> #include <Scene.h> #include <Settings.h> #include <Image.h> #include <TaskStack.h> #include <Task.h> #include <IntegratorInterface.h> #include <RandomGener...
joshbainbridge/morphogenetic-sim
include/IntegratorInterface.h
#ifndef _INTEGRATORINTERFACE_H_ #define _INTEGRATORINTERFACE_H_ #include <boost/shared_ptr.hpp> #include <Scene.h> #include <RandomGenerator.h> #include <Common.h> class IntegratorInterface { public: IntegratorInterface() : m_current_depth(0), m_limit_depth(0), m_absorption(0.f) {;} virtual ~...
joshbainbridge/morphogenetic-sim
include/Aabb.h
<gh_stars>1-10 #ifndef _AABB_H_ #define _AABB_H_ #include <Common.h> class Aabb { public: Aabb() : m_min(Vector3f(0.f, 0.f, 0.f)), m_max(Vector3f(0.f, 0.f, 0.f)) {;} Aabb(const Vector3f _min, const Vector3f _max) : m_min(_min), m_max(_max) {;} inline Vector3f min() const {return m_min;} inl...
joshbainbridge/morphogenetic-sim
include/Settings.h
#ifndef _SETTINGS_H_ #define _SETTINGS_H_ struct Settings { Settings() : resolution_x(0) , resolution_y(0) , bucket_size(0) , frame_number(0) , samples(0) , depth(0) , absorption(0.f) {;} int resolution_x; int resolution_y; int bucket_size; i...
joshbainbridge/morphogenetic-sim
include/TaskStack.h
<gh_stars>1-10 #ifndef _TASKSTACK_H_ #define _TASKSTACK_H_ #include <vector> #include <boost/thread.hpp> #include <Task.h> class TaskStack { public: TaskStack() : m_count(0) , m_total(0) , m_percentage(1.f) {;} void addTask(const Task _task); int takeTask(Task *_ta...
joshbainbridge/morphogenetic-sim
include/HierarchicalAggregate.h
#ifndef _HIERARCHICALAGGREGATE_H_ #define _HIERARCHICALAGGREGATE_H_ // Currently just looping over all primitives in list #endif
joshbainbridge/morphogenetic-sim
include/Common.h
<reponame>joshbainbridge/morphogenetic-sim<filename>include/Common.h #ifndef _COMMON_H_ #define _COMMON_H_ #include <cfloat> #include <cmath> #include <Eigen/Core> #include <Eigen/Geometry> //Common defines constants and linear algebraic types used through out the project //Algebraic types are based on...
joshbainbridge/morphogenetic-sim
include/Scene.h
<reponame>joshbainbridge/morphogenetic-sim #ifndef _SCENE_H_ #define _SCENE_H_ #include <vector> #include <boost/shared_ptr.hpp> #include <CameraInterface.h> #include <LightInterface.h> #include <Primitive.h> #include <ShapeInterface.h> #include <Transmission.h> class Scene { public: inlin...
joshbainbridge/morphogenetic-sim
include/Transmission.h
<gh_stars>1-10 #ifndef _TRANSMISSION_H_ #define _TRANSMISSION_H_ #include <boost/shared_ptr.hpp> #include <Common.h> #include <Material.h> struct Transmission { Transmission() : distance(M_INFINITY) {;} Vector3f position; Vector3f normal; float distance; boost::shared_ptr<Material> m...
joshbainbridge/morphogenetic-sim
include/QuadLight.h
<gh_stars>1-10 #ifndef _QUADLIGHT_H_ #define _QUADLIGHT_H_ #include <LightInterface.h> #include <RandomGenerator.h> class QuadLight : public LightInterface { public: QuadLight() : LightInterface() {;} inline void illumination(const Colour3f &_illum){m_illum = _illum;} Colour3f illumination(co...
joshbainbridge/morphogenetic-sim
include/RandomGenerator.h
#ifndef _RANDOMGENERATOR_H_ #define _RANDOMGENERATOR_H_ #include <boost/random.hpp> class RandomGenerator { public: float getValue(); private: boost::mt19937 m_generator; boost::uniform_real<float> m_uniform_dist; }; #endif
joshbainbridge/morphogenetic-sim
include/Image.h
#ifndef _IMAGE_H_ #define _IMAGE_H_ #include <vector> #include <boost/thread.hpp> #include <Pixel.h> #include <Transmission.h> #include <Task.h> #include <Common.h> class Image { public: Image() : m_resolution_x(0), m_resolution_y(0) {;} void resolution(const int _resolution_x, const int...
joshbainbridge/morphogenetic-sim
include/LightInterface.h
<filename>include/LightInterface.h #ifndef _LIGHTINTERFACE_H_ #define _LIGHTINTERFACE_H_ #include <Common.h> #include <RandomGenerator.h> class LightInterface { public: LightInterface() : m_illum(Vector3f(1.f, 1.f, 1.f)) , m_origin(Vector3f(0.f, 0.f, 0.f)) , m_dir(Vector3f(0.f, 0.f, ...
joshbainbridge/morphogenetic-sim
include/TissueShape.h
<gh_stars>1-10 #ifndef _TISSUESHAPE_H_ #define _TISSUESHAPE_H_ #include <vector> #include <boost/shared_ptr.hpp> #include <boost/random.hpp> #include <Common.h> #include <CellShape.h> #include <ShapeInterface.h> #include <RandomGenerator.h> class TissueShape : public ShapeInterface { public: ...
joshbainbridge/morphogenetic-sim
include/Engine.h
#ifndef _ENGINE_H_ #define _ENGINE_H_ #include <vector> #include <string> #include <boost/shared_ptr.hpp> #include <Scene.h> #include <Settings.h> #include <Image.h> #include <TaskStack.h> #include <RenderThread.h> #include <IntegratorInterface.h> class Engine { public: Engine(); ...
joshbainbridge/morphogenetic-sim
include/Task.h
<gh_stars>1-10 #ifndef _TASK_H_ #define _TASK_H_ struct Task { Task() : pixel_x(0) , pixel_y(0) , width(0) , height(0) , samples(0) {;} int pixel_x; int pixel_y; int width; int height; int samples; }; #endif
joshbainbridge/morphogenetic-sim
include/PlanarLightAbstract.h
<reponame>joshbainbridge/morphogenetic-sim<filename>include/PlanarLightAbstract.h #ifndef _PLANARLIGHTABSTRACT_H_ #define _PLANARLIGHTABSTRACT_H_ //Currently Implementing both planar lights directly #endif
joshbainbridge/morphogenetic-sim
include/LambertBsdf.h
#ifndef _LAMBERTBSDF_H_ #define _LAMBERTBSDF_H_ #include <Common.h> #include <RandomGenerator.h> #include <BsdfInterface.h> class LambertBsdf : public BsdfInterface { public: Vector3f sample(const Vector3f &_incident, const Vector3f &_normal, RandomGenerator &_random_generator) const; float ...
joshbainbridge/morphogenetic-sim
include/Material.h
<reponame>joshbainbridge/morphogenetic-sim<gh_stars>1-10 #ifndef _MATERIAL_H_ #define _MATERIAL_H_ #include <boost/shared_ptr.hpp> #include <Common.h> #include <BsdfInterface.h> #include <RandomGenerator.h> class Material { public: Material(boost::shared_ptr< BsdfInterface > _bsdf); inline C...
joshbainbridge/morphogenetic-sim
include/CellShape.h
#ifndef _CELLSHAPE_H_ #define _CELLSHAPE_H_ #include <vector> #include <boost/shared_ptr.hpp> #include <Common.h> #include <SphereShape.h> #include <RandomGenerator.h> class CellShape : public SphereShape { public: CellShape(int _identifier) : SphereShape() , m_nutrition(0.f) ...
joshbainbridge/morphogenetic-sim
include/SphereShape.h
<filename>include/SphereShape.h #ifndef _SPHERESHAPE_H_ #define _SPHERESHAPE_H_ #include <ShapeInterface.h> #include <Common.h> #include <Transmission.h> class SphereShape : public ShapeInterface { public: SphereShape() : m_pos(Vector3f(0.f, 0.f, 0.f)), m_rad(1.f) {;} inline Vector3f position()...
joshbainbridge/morphogenetic-sim
include/CameraInterface.h
#ifndef _CAMERAINTERFACE_H_ #define _CAMERAINTERFACE_H_ #include <Common.h> #include <RandomGenerator.h> class CameraInterface { public: virtual ~CameraInterface() {} inline Vector3f direction() const {return m_dir;} inline Vector3f origin() const {return m_origin;} inline Vector3f up() c...
joshbainbridge/morphogenetic-sim
include/GeometricCamera.h
<reponame>joshbainbridge/morphogenetic-sim #ifndef _GEOMETRICCAMERA_H_ #define _GEOMETRICCAMERA_H_ #include <Common.h> #include <CameraInterface.h> #include <RandomGenerator.h> class GeometricCamera : public CameraInterface { public: GeometricCamera(); inline float aperture() const {return m_ap...
joshbainbridge/morphogenetic-sim
include/ShapeInterface.h
#ifndef _SHAPEINTERFACE_H_ #define _SHAPEINTERFACE_H_ #include <Common.h> #include <Transmission.h> class ShapeInterface { public: virtual ~ShapeInterface() {} virtual bool intersect(const Ray3f _ray, Transmission *_output) const =0; virtual Vector3f position() const =0; virtual Vector3f...
joshbainbridge/morphogenetic-sim
include/Primitive.h
#ifndef _PRIMITIVE_H_ #define _PRIMITIVE_H_ #include <vector> #include <boost/shared_ptr.hpp> #include <Common.h> #include <Material.h> #include <ShapeInterface.h> #include <Transmission.h> #include <Aabb.h> class Primitive { public: Primitive(boost::shared_ptr<ShapeInterface> _shape, boos...
joshbainbridge/morphogenetic-sim
include/BsdfInterface.h
<gh_stars>1-10 #ifndef _BSDFINTERFACE_H_ #define _BSDFINTERFACE_H_ #include <Common.h> #include <RandomGenerator.h> class BsdfInterface { public: virtual ~BsdfInterface() {} virtual Vector3f sample(const Vector3f &_incident, const Vector3f &_normal, RandomGenerator &_random_generator) const =...
joshbainbridge/morphogenetic-sim
include/PathtraceIntegrator.h
#ifndef _PATHTRACEINTEGRATOR_H_ #define _PATHTRACEINTEGRATOR_H_ #include <boost/shared_ptr.hpp> #include <IntegratorInterface.h> #include <Scene.h> #include <RandomGenerator.h> #include <Common.h> class PathtraceIntegrator : public IntegratorInterface { public: PathtraceIntegrator() : Integrato...
joshbainbridge/morphogenetic-sim
include/Pixel.h
#ifndef _PIXEL_H_ #define _PIXEL_H_ #include <vector> #include <Common.h> #include <Transmission.h> class Pixel { public: Colour3f pixelColour() const; void addSample(const Colour3f _sample); Colour3f getSample(const int _index) const; private: std::vector< Colour3f > m_samples; };...
Ramjonchhen/hacktoberfest2021-1
C/LinkedList/Circular Singly Linked List Operations.c
#include <stdio.h> #include <stdlib.h> #include <stdio.h> #include <stdlib.h> struct node { int data; struct node* next; }; struct node* head = NULL ; struct node* tail = NULL ; int count = 0; void display() { struct node* display = head; if( head == NULL ) { printf("\nThe Linked List is e...
jodyhagins/WJHEventTap
WJHEventTap/NSDictionary+WJHEventTap.h
<gh_stars>0 // // NSDictionary+WJHEventTap.h // WJHEventTap // // Copyright (c) 2015 <NAME>. All rights reserved. // #import <Foundation/Foundation.h> @interface NSDictionary (WJHEventTap) /** Creates a dictionary object containing the specified CGEventTapInformation structure. @param tapInfo the value for the...
jodyhagins/WJHEventTap
WJHEventTap/WJHEventTapDelegate.h
<reponame>jodyhagins/WJHEventTap<gh_stars>0 // // WJHEventTapDelegate.h // WJHEventTap // // Created by <NAME> on 9/17/15. // Copyright (c) 2015 <NAME>. All rights reserved. // #import <Foundation/Foundation.h> @class WJHEventTap; #pragma mark - WJHEventTapDelegate Protocol /** Protocol to be implemented by an...
jodyhagins/WJHEventTap
WJHEventTap/NSValue+WJHEventTap.h
<gh_stars>0 // // NSValue+WJHEventTap.h // WJHEventTap // // Copyright (c) 2015 <NAME>. All rights reserved. // #import <Foundation/Foundation.h> @interface NSValue (WJHEventTap) /** Creates a value object containing the specified CGEventTapInformation structure. @param tapInfo the value for the new object @...
jodyhagins/WJHEventTap
WJHEventTap/WJHEventTap.h
// // WJHEventTap.h // WJHEventTap // // Copyright (c) 2015 <NAME>. All rights reserved. // #import <Foundation/Foundation.h> #import <WJHEventTap/WJHEventTapDelegate.h> #import <WJHEventTap/NSDictionary+WJHEventTap.h> #import <WJHEventTap/NSValue+WJHEventTap.h> extern double WJHEventTapVersionNumber(); extern uns...
gkwityn/Advent-of-Code-2021
day_3/part1/day3_pt1.c
<filename>day_3/part1/day3_pt1.c #include <stdlib.h> #include <stdio.h> #include <string.h> #define BIT_LENGTH 13 void build_gamma_epsilon(char *gamma, char *epsilon, int *ones, int *zeros){ for(int i = 0; i <= BIT_LENGTH; i++){ if(i == BIT_LENGTH){ gamma[i] = '\0'; ...
gkwityn/Advent-of-Code-2021
day_1/part1/day1_pt1.c
<reponame>gkwityn/Advent-of-Code-2021<filename>day_1/part1/day1_pt1.c #include <stdlib.h> #include <stdio.h> #define N_INPUT 2000 int main(int argc, char const *argv[]) { int depth_readings[N_INPUT]; int data; int count = 0; FILE *fp; fp = fopen("sonar_sweep.txt", "r"); if(fp == NULL){ ...
gkwityn/Advent-of-Code-2021
day_2/part2/day2_pt2.c
/* forward X increases the horizontal position by X units. down X increases the depth by X units. up X decreases the depth by X units. down X increases your aim by X units. up X decreases your aim by X units. forward X does two things: It increases your horizontal position by X units. It increases your depth by y...
gkwityn/Advent-of-Code-2021
day_1/part2/day1_pt2.c
#include <stdio.h> #include <stdlib.h> #define N_INPUT 2000 void cmp_arrays(int* prev, int* current, int* count){ int prev_sum = 0; int curr_sum = 0; for(int i = 0; i < 3; i++){ prev_sum += prev[i]; curr_sum += current[i]; } if(prev_sum < curr_sum ){ *count = *count + 1; ...
gkwityn/Advent-of-Code-2021
day_2/part1/day2_pt1.c
#include <stdio.h> #include <string.h> int main(int argc, char const *argv[]) { int horizontal = 0; int depth = 0; char buff[8]; int x_unites; // forward X increases the horizontal position by X units. // down X increases the depth by X units. // up X decreases the depth by X units. F...
gkwityn/Advent-of-Code-2021
day_3/part2/day3_pt2.c
#include <stdlib.h> #include <stdio.h> #include <string.h> #define BIT_LENGTH 13 #define N_INPUT 1000 //------------------------------------------------------------------------------- void build_gamma_epsilon(char *gamma, char *epsilon, int *ones, int *zeros){ for(int i = 0; i < BIT_LENGTH-1; i++){ if...
akalend/sophiaDb
src/config.c
<filename>src/config.c #include "main.h" #include "ini.h" #include "mc.h" extern void parse(const char* fname, conf_t *server_ctx); int parser(void* pctx, const char* section, const char* name, const char* value) { conf_t* ctx = (conf_t*) pctx; static datatype_t *p = NULL; datatype_t *tmp = NULL; int ...
akalend/sophiaDb
src/mc.c
#include "mc.h" #ifndef __sophiadb_mc__ #define __sophiadb_mc__ #endif #ifdef __sophiadb_mc__ #include <sophia.h> #include <sys/stat.h> #include <sys/time.h> #include <ev.h> #define BUFSIZE 512 //TODO nax... extern FILE *flog; extern int max_clients; extern fd_ctx *clients; extern int is_finish; extern...
akalend/sophiaDb
src/main.h
#ifndef __mymc_main__ #define __mymc_main__ #endif #ifdef __mymc_main__ #include <unistd.h> #include <fcntl.h> #include <ev.h> #include <sys/socket.h> #include <netinet/in.h> #include <sys/un.h> #include <stdlib.h> #include <errno.h> #include <stdint.h> #include <ctype.h> #include <signal.h> #include <sys/resource....
akalend/sophiaDb
src/io_buffer.h
<filename>src/io_buffer.h #pragma once #include <stdint.h> typedef unsigned bsize_t; typedef int bssize_t; #define IBUFFER_EOF 1 #define IBUFFER_STATIC 2 /** Input buffer */ struct ibuffer { union { char *c_data; /**< buffer data as character array */ uint8_t *u_data; /**< buffer data as array of bytes */ ...
akalend/sophiaDb
src/mc.h
#ifndef __sophiadb_mch__ #define __sophiadb_mch__ #endif #ifdef __sophiadb_mch__ #include "main.h" #include <sys/socket.h> #define set_client_timeout(io,t_o) clients[(io)->fd].timeout = ev_now(EV_A) + t_o #define reset_client_timeout(io) clients[(io)->fd].timeout = 0 #define TIMEOUT_CHECK_INTERVAL 10 #define TIME_C...
akalend/sophiaDb
src/io_buffer.c
<reponame>akalend/sophiaDb #include "io_buffer.h" #include <unistd.h> #include <fcntl.h> #include <stdlib.h> #include <string.h> #include <errno.h> #define DISCARD_THRESHOLD 1024 /** Initialize input buffer structure. * @param $b input buffer. * @param $pool pool for memory allocation. * @param $initsize initia...
akalend/sophiaDb
src/main.c
<gh_stars>1-10 /* выпилить лог, заменить на суслог */ #include "main.h" #include "mc.h" #include "ini.h" #include <sophia.h> #include <sys/time.h> #include <libgen.h> #include <netdb.h> #ifdef PREFIX #define CONFIGFILE PREFIX"/conf/config.ini" #else #define CONFIGFILE "config.ini" #endif #define MYMC_VERSION...
marce-ldv/swiftCache
CacheManager/CacheManager.h
// // CacheManager.h // CacheManager // // Created by <NAME> on 22/04/2020. // Copyright © 2020 <NAME>. All rights reserved. // #import <Foundation/Foundation.h> //! Project version number for CacheManager. FOUNDATION_EXPORT double CacheManagerVersionNumber; //! Project version string for CacheManager. FOUNDATIO...
zedshaw/earing
tests/repl_tests.c
#include <cut/2.6/cut.h> void __CUT__repl_test( void ) { ASSERT( 1, "Any non-zero value must always pass an ASSERT." ); }
zedshaw/earing
src/module.c
#include "module.h" #include <assert.h> #include <stdio.h> #include <stdint.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include "directives.h" #include "grammar.h" #include <string.h> #include "error.h" #include <gc/gc.h> #include <gc/cord.h> Module *Module_create(const char *name, size_t max_...
zedshaw/earing
src/allocator_ops.h
int inst_size_of(Module *state, Token *type, array_t *args); int inst_alloc(Module *state, Token *type, array_t *args); int inst_realloc(Module *state, Token *type, array_t *args); int inst_free(Module *state, Token *type, array_t *args); int inst_collect(Module *state, Token *type, array_t *args);
zedshaw/earing
src/error.c
#include "error.h" #include <stdarg.h> #include <gc/cord.h> static void print_location(Module *state) { if(state) { printf("%s:%d: ", state->module_name, state->curline); if(state->current) { CORD_printf("in function %r, ", state->current->name); } } } void error(Module *st...
zedshaw/earing
src/token.h
<gh_stars>1-10 #ifndef token_h #define token_h #include "array.h" #include <gc/cord.h> struct Module; struct Token; /** * This is attached to operation tokens and is called later to do the actual byte code * generation. */ typedef int (*f_inst_call)(struct Module *state, struct Token *type, array_t *params); /*...
zedshaw/earing
src/allocator_ops.c
<reponame>zedshaw/earing /* these are included directly into src/ops.c */ #include "allocator.h" int inst_size_of(Module *state, Token *type, array_t *params) { if(type) { if(array_length(params) != 1) die(state, "sizeof requires 1 parameter for a type."); } else { if(array_length(...
zedshaw/earing
src/function.c
#include "module.h" #include "directives.h" #include "grammar.h" #include "error.h" #include "array.h" #include "hash.h" #include <gc/gc.h> #include <gc/cord.h> #include <assert.h> Function *Function_find(Module *state, CORD name) { hnode_t *hn = hash_lookup(state->functions, name); return hn ? hnode_get(hn) ...
zedshaw/earing
src/array.c
<reponame>zedshaw/earing #include "array.h" #include <gc/gc.h> #include <assert.h> array_t *array_create(size_t size) { array_t *ary = GC_MALLOC(sizeof(array_t) + size * sizeof(void *)); ary->size = size; ary->end = 0; return ary; } size_t array_add(array_t *ary, void *el) { assert(ary != NULL ...
zedshaw/earing
src/ops.c
#include "module.h" #include "allocator_ops.c" int inst_addr(Module *state, Token *type, array_t *params) { if(array_length(params) != 3) die(state, "addr requires 3 parameters."); if(!type) die(state, "addr requires type of: ['i', 'ui', 'l', 'ul', 'p', 'f', 'd']."); switch(type->value) { ...
zedshaw/earing
src/types.c
#include "types.h" #include <assert.h> const char *OpType_strings[] = { "int", "uint", "long", "ulong", "ptr", "float", "double", "void", "char", "uchar", "short", "ushort" }; const char *OpType_to_str(OpType type) { assert(type >= 0 && type < 12 && "Invalid OpType_code"); return OpType_strings[type...
zedshaw/earing
tests/token_tests.c
#include <cut/2.6/cut.h> #include "token.h" #include "ops.h" #include "grammar.h" #include <gc.h> #include <string.h> #include <gc/cord.h> void __CUT__Token_createBringup(void) { GC_INIT(); } void __CUT__Token_create( void ) { CORD data = CORD_from_char_star("100"); Token *tk = Token_creat...
zedshaw/earing
src/repl.c
<gh_stars>1-10 #include <stdio.h> #include "repl.h" #include <string.h> #include <stdlib.h> #include <gc/gc.h> void repl_init(complete_function func) { // does nothing until I can figure out how to portably use readline } char *repl_prompt() { char *line = GC_MALLOC(1024 * sizeof(char)); printf(">>> "); ...
zedshaw/earing
src/token.c
<reponame>zedshaw/earing<filename>src/token.c<gh_stars>1-10 #include "token.h" #include <stdlib.h> #include "grammar.h" #include <assert.h> #include <string.h> #include <gc/gc.h> Token *Token_create(int id, CORD data, f_inst_call call) { Token *tk = GC_MALLOC(sizeof(Token)); tk->id = id; tk->data = data...
zedshaw/earing
tests/struct_tests.c
<filename>tests/struct_tests.c #include <cut/2.6/cut.h> #include "struct.h" #include <gc.h> #include <stdio.h> void __CUT__StructAlign_create( void ) { StructAlign sa = StructAlign_create(); ASSERT(!StructAlign_indeterminate(sa), "Indeterminate structure alignment."); ASSERT(!StructAlign_multiple_cases(sa...
zedshaw/earing
src/lexer.c
<filename>src/lexer.c #line 1 "src/lexer.rl" /** <NAME> -- A weird assembler. Copyright 2008. */ #include "module.h" #include "grammar.h" #include "tokenize.h" #include "grammar.c" #include "ops.h" #include "error.h" #include "allocator.h" #line 187 "src/lexer.rl" #line 19 "src/lexer.c" static const int lexer_...
zedshaw/earing
tests/array_tests.c
<reponame>zedshaw/earing #include <cut/2.6/cut.h> #include "array.h" #include <gc.h> #define ARRAY_BASE_SIZE 10 void __CUT__array_Bringup(void) { GC_INIT(); } void __CUT__array_create( void ) { array_t *ary = array_create(ARRAY_BASE_SIZE); ASSERT(ary != NULL, "Must create an array." ); ASSERT(ary->s...
zedshaw/earing
src/struct.h
<reponame>zedshaw/earing #ifndef struct_h #define struct_h typedef struct StructAlign { int is_packed; int is_two; int is_four; int is_eight; int is_largest; int size; int extent; } StructAlign; StructAlign StructAlign_create(void); int StructAlign_indeterminate(StructAlign sa); int Struct...
zedshaw/earing
src/gen.c
#include "module.h" #include "label.h" #include "function.h" #include "grammar.h" #include "error.h" #include "hash.h" #include <gc/gc.h> #include <assert.h> // because of the way GNU lightning is designed we have to keep ALL of the // code generation tasks in the same file. Since the function management is // here w...
zedshaw/earing
src/struct.c
<reponame>zedshaw/earing<filename>src/struct.c /* * This program attempts to determine struct layout rules for the compiler * in use. It is only approximate, of course. It looks for: * packed (no gaps) * aligned on 4 bytes * aligned on 8 bytes * aligned on sizeof(largest member) * Suggestions for further i...
zedshaw/earing
tests/hash_tests.c
#include "hash.h" #include <stdio.h> #include <ctype.h> #include <stdarg.h> #include <cut/2.6/cut.h> #include <stdlib.h> #include <string.h> typedef char input_t[256]; static int tokenize(char *string, ...) { char **tokptr; va_list arglist; int tokcount = 0; va_start(arglist, string); tokptr = v...
zedshaw/earing
src/array.h
#ifndef array_h #define array_h #include <stdlib.h> typedef struct array_t { size_t size; size_t end; void *data[]; } array_t; array_t *array_create(); void *array_pop(array_t *ary); size_t array_add(array_t *ary, void *el); array_t *array_extend(array_t *ary, size_t by); array_t *array_clamp(array_...
zedshaw/earing
src/repl.h
<gh_stars>1-10 #ifndef repl_h #define repl_h typedef char **(*complete_function)(const char *string, int start, int end); void repl_init(complete_function func); char *repl_prompt(); #endif
zedshaw/earing
tests/allocator_tests.c
<gh_stars>1-10 #include <cut/2.6/cut.h> #include "allocator.h" #include <gc.h> void __CUT_allocator_Bringup(void) { GC_INIT(); } void __CUT__Allocator_expression( void ) { Token alloc = {.value = 100L}; Token *res = Allocator_expression(NULL, &alloc); ASSERT(res != NULL, "Failed to run allocator expr...
zedshaw/earing
src/tst.h
#ifndef tst_h #define tst_h #include <stdlib.h> typedef struct tst_t { char splitchar; struct tst_t *low; struct tst_t *equal; struct tst_t *high; void *value; } tst_t; typedef struct tst_collect_t { size_t length; void **values; } tst_collect_t; typedef void (*tst_traverse_cb)(void ...
zedshaw/earing
src/dis.c
#include <udis86.h> #include "module.h" #include "sglib.h" void dis_code_bytes(Function *func, ud_t *ud_obj) { ud_set_input_buffer(ud_obj, func->code, func->code_len); printf("function %s(", func->name); int count; SGLIB_SORTED_LIST_MAP_ON_ELEMENTS(FunctionParam, func->params, i, next, { prin...
zedshaw/earing
tests/dict_tests.c
#include "dict.h" #include <stdio.h> #include <ctype.h> #include <stdarg.h> #include <cut/2.6/cut.h> #include <stdlib.h> #include <string.h> typedef char input_t[256]; static int tokenize(char *string, ...) { char **tokptr; va_list arglist; int tokcount = 0; va_start(arglist, string); tokptr = v...
zedshaw/earing
src/ops.h
#ifndef ops_h #define ops_h #include "module.h" #include "array.h" #include "allocator_ops.h" int inst_addr(Module *state, Token *type, array_t *params); int inst_addi(Module *state, Token *type, array_t *params); int inst_addxr(Module *state, Token *type, array_t *params); int inst_addxi(Module *state, Token *type...
zedshaw/earing
src/earing.c
<reponame>zedshaw/earing<gh_stars>1-10 #include <stdio.h> #include <stdlib.h> #include <assert.h> #include <sys/mman.h> #include <sys/types.h> #include <sys/wait.h> #include <sys/stat.h> #include <unistd.h> #include <fcntl.h> #include <sys/time.h> #include "directives.h" #include "module.h" #include "util.h" #include "...
zedshaw/earing
src/util.h
#ifndef util_h #define util_h char *mmap_file(const char *fname, size_t *length); void run_function(Module *state, const char *named); #endif
zedshaw/earing
src/label.h
#ifndef label_h #define label_h #include "function.h" #include <gc/cord.h> typedef struct Label { jit_insn *ref; CORD name; int realized; array_t *back_refs; } Label; Label *Label_find_or_create(Function *func, Token *ident); Token *Label_expression(Function *func, Token *tk); void Label_statement...
zedshaw/earing
src/grammar.c
/* Driver template for the LEMON parser generator. ** The author disclaims copyright to this source code. */ /* First off, code is include which follows the "include" declaration ** in the input file. */ #include <stdio.h> #line 3 "grammar.y" #include <assert.h> #include <stdio.h> #include <gc/gc.h> #include ...
zedshaw/earing
src/directives.h
#ifndef directives_h #define directives_h #include "module.h" typedef struct Directive { int len; CORD name; Module_directive_cb call; Module_directive_cb destroy; } Directive; void Module_register_default_directives(Module *state); void *Library_search(Module *state, Token *module, Token *name); #...
zedshaw/earing
src/allocator.h
#ifndef allocator_h #define allocator_h #include "token.h" #include "module.h" Token *Allocator_expression(Module *state, Token *tk); void *Allocator_malloc(int size); void *Allocator_realloc(void *mem, int new_size); void Allocator_free(void *mem); void Allocator_collect(); #endif
zedshaw/earing
src/function.h
#ifndef function_h #define function_h #include <lightning.h> #include <gc/cord.h> #include "types.h" #include "array.h" #include "hash.h" #include "token.h" struct Module; typedef struct FunctionParam { int index; CORD name; OpType type; } FunctionParam; typedef struct Function { jit_insn *code; ...
zedshaw/earing
tests/util_tests.c
#include <cut/2.6/cut.h> void __CUT__util_test( void ) { ASSERT( 1, "Any non-zero value must always pass an ASSERT." ); }
zedshaw/earing
tests/types_tests.c
<filename>tests/types_tests.c #include "types.h" #include <cut/2.6/cut.h> void __CUT__OpType_to_str_test(void) { const char *name = OpType_to_str(OpType_i); ASSERT(name != NULL, "Bad OpType."); ASSERT(name == "int", "Wrong one for int."); name = Opttype_to_str(OpType_c); ASSERT(name != NULL, "Bad ...
zedshaw/earing
src/tst.c
#include <stdlib.h> #include "tst.h" #include <stdio.h> #include <assert.h> #include <gc/gc.h> static void tst_collect_build(void *value, tst_collect_t *results) { if(results->length < 100) { results->values[results->length++] = value; } } tst_collect_t tst_collect(tst_t *root, const char *s, int len)...
zedshaw/earing
tests/module_tests.c
#include <cut/2.6/cut.h> /* A pointless module -- tests nothing useful, will never fail. * This nonetheless shows the basic form of tests. */ void __CUT__module1( void ) { ASSERT( 1, "Any non-zero value must always pass an ASSERT." ); } /* A more complex test, consisting of a bringup, a takedown, * a...