repo_name
stringlengths
5
122
path
stringlengths
3
232
text
stringlengths
6
1.05M
Kristopher38/LuaCPU
hardware/hps_0.h
#ifndef _ALTERA_HPS_0_H_ #define _ALTERA_HPS_0_H_ /* * This file was automatically generated by the swinfo2header utility. * * Created from SOPC Builder system 'soc_system' in * file 'C:/altera/13.1/embedded/HPS_LED_HEX/LED_HEX_hardware/soc_system.sopcinfo'. */ /* * This file contains macros for mod...
Kristopher38/LuaCPU
software/lua_on_nios2_bsp/HAL/src/alt_fs_reg.c
<gh_stars>100-1000 /****************************************************************************** * * * License Agreement * * ...
Kristopher38/LuaCPU
software/lua_on_nios2_bsp/HAL/inc/priv/alt_file.h
#ifndef __ALT_FILE_H__ #define __ALT_FILE_H__ /****************************************************************************** * * * License Agreement * * ...
Kristopher38/LuaCPU
software/lua_on_nios2_bsp/HAL/src/alt_main.c
/****************************************************************************** * * * License Agreement * * * ...
Kristopher38/LuaCPU
software/lua_on_nios2_bsp/HAL/src/alt_irq_handler.c
/****************************************************************************** * * * License Agreement * * * ...
Kristopher38/LuaCPU
software/lua_on_nios2/lua/lstring.h
<filename>software/lua_on_nios2/lua/lstring.h /* ** $Id: lstring.h,v 1.61.1.1 2017/04/19 17:20:42 roberto Exp $ ** String table (keep all strings handled by Lua) ** See Copyright Notice in lua.h */ #ifndef lstring_h #define lstring_h #include "lgc.h" #include "lobject.h" #include "lstate.h" #define sizelstring(l) ...
Kristopher38/LuaCPU
software/lua_on_nios2_bsp/HAL/inc/sys/alt_warning.h
<filename>software/lua_on_nios2_bsp/HAL/inc/sys/alt_warning.h #ifndef __WARNING_H__ #define __WARNING_H__ /****************************************************************************** * * * License Agreement ...
Kristopher38/LuaCPU
software/lua_on_nios2_bsp/drivers/src/altera_avalon_jtag_uart_write.c
<reponame>Kristopher38/LuaCPU /****************************************************************************** * * * License Agreement * * ...
Kristopher38/LuaCPU
software/lua_on_nios2_bsp/system.h
<gh_stars>0 /* * system.h - SOPC Builder system and BSP software package information * * Machine generated for CPU 'nios2_gen2_0' in SOPC Builder design 'soc_system' * SOPC Builder design path: /home/kris/luacpu/hardware/soc_system.sopcinfo * * Generated: Wed Feb 16 22:25:28 CET 2022 */ /* * DO NOT MODIFY THIS...
Kristopher38/LuaCPU
software/lua_on_nios2/lua/lprefix.h
<filename>software/lua_on_nios2/lua/lprefix.h /* ** $Id: lprefix.h,v 1.2.1.1 2017/04/19 17:20:42 roberto Exp $ ** Definitions for Lua code that must come before any other header file ** See Copyright Notice in lua.h */ #ifndef lprefix_h #define lprefix_h /* ** Allows POSIX/XSI stuff */ #if !defined(LUA_USE_C89) /* {...
Kristopher38/LuaCPU
software/lua_on_nios2/lua/testes/libs/lib11.c
#include "lua.h" /* function from lib1.c */ int lib1_export (lua_State *L); LUAMOD_API int luaopen_lib11 (lua_State *L) { return lib1_export(L); }
Kristopher38/LuaCPU
software/lua_on_nios2_bsp/HAL/src/alt_iic_isr_register.c
<reponame>Kristopher38/LuaCPU /****************************************************************************** * * * License Agreement * * ...
Kristopher38/LuaCPU
software/lua_on_nios2/lua/cpusim.h
<reponame>Kristopher38/LuaCPU #ifndef h_cpusim #define h_cpusim #include <iostream> #include <queue> #include <verilated.h> #include "obj_dir/Vlua_cpu.h" #include "verilated_vcd_c.h" class SDRAMController; extern Vlua_cpu* cpu; extern SDRAMController* sdram; extern VerilatedVcdC* tfp; extern uint32_t luacpu_simula...
Kristopher38/LuaCPU
software/lua_on_nios2_bsp/HAL/src/alt_usleep.c
<gh_stars>100-1000 /* * Copyright (c) 2003 Altera Corporation, San Jose, California, USA. * All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to * deal in the Software without restrictio...
Kristopher38/LuaCPU
software/lua_on_nios2/lua/obj_dir/Vlua_cpu.h
<reponame>Kristopher38/LuaCPU // Verilated -*- C++ -*- // DESCRIPTION: Verilator output: Primary model header // // This header should be included by all source files instantiating the design. // The class here is then constructed to instantiate the design. // See the Verilator manual for examples. #ifndef VERILATED_V...
Kristopher38/LuaCPU
software/lua_on_nios2_bsp/HAL/inc/priv/alt_alarm.h
#ifndef __ALT_PRIV_ALARM_H__ #define __ALT_PRIV_ALARM_H__ /****************************************************************************** * * * License Agreement * * ...
Kristopher38/LuaCPU
software/lua_on_nios2_bsp/HAL/src/alt_remap_uncached.c
/****************************************************************************** * * * License Agreement * * * ...
Kristopher38/LuaCPU
software/lua_on_nios2_bsp/drivers/src/altera_avalon_sysid_qsys.c
<reponame>Kristopher38/LuaCPU /****************************************************************************** * * * License Agreement * * ...
Kristopher38/LuaCPU
software/lua_on_nios2_bsp/drivers/inc/altera_avalon_jtag_uart_regs.h
<reponame>Kristopher38/LuaCPU /****************************************************************************** * * * License Agreement * * ...
Kristopher38/LuaCPU
software/lua_on_nios2_bsp/HAL/src/alt_sbrk.c
<gh_stars>100-1000 /****************************************************************************** * * * License Agreement * * ...
Kristopher38/LuaCPU
software/lua_on_nios2_bsp/HAL/src/alt_uncached_malloc.c
<filename>software/lua_on_nios2_bsp/HAL/src/alt_uncached_malloc.c /****************************************************************************** * * * License Agreement * * ...
dltech/laminator-nemo
lib/tm1637.h
<reponame>dltech/laminator-nemo<gh_stars>0 #ifndef H_TM1637 #define H_TM1637 /* * printf for TM1637 display-driver based 7-segment displays * connected to STM32. * * Copyright 2021 <NAME> <<EMAIL>> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in complian...
dltech/laminator-nemo
fw/main.c
#include "mystmbackend.h" #include "printf7.h" #include "freq_dr.h" #include "ds18b20.h" volatile int32_t temp = 0; volatile uint32_t cnts = 0; int main(void) { delay_ms(10); clkInit(); tmInit(); dsInit(); initPwm(); while(1){ temp = tempBlocking(); if(temp == -1) { myprintf("err"); } else { mypri...
dltech/laminator-nemo
lib/cmsis_sin.c
<gh_stars>0 #include "cmsis_sin.h" const uint32_t sinTable_q31[FAST_MATH_TABLE_SIZE + 1] = { 0x00000000, 0x01921D20, 0x03242ABF, 0x04B6195D, 0x0647D97C, 0x07D95B9E, 0x096A9049, 0x0AFB6805, 0x0C8BD35E, 0x0E1BC2E4, 0x0FAB272B, 0x1139F0CF, 0x12C8106F, 0x145576B1, 0x15E21445, 0x176DD9DE, 0x18F8B83C, 0x1A82A026, ...
dltech/laminator-nemo
lib/ds18b20.h
#ifndef H_DS18B20 #define H_DS18B20 /* * stm32 usart based ds18b20 lib * * Copyright 2021 <NAME> <<EMAIL>> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.o...
dltech/laminator-nemo
lib/tm1637.c
<gh_stars>0 /* * printf for TM1637 display-driver based 7-segment displays * connected to STM32. * * Copyright 2021 <NAME> <<EMAIL>> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at *...
dltech/laminator-nemo
lib/printf7.h
<filename>lib/printf7.h #ifndef H_DISPLAY #define H_DISPLAY #include <stdint.h> #include "tm1637.h" // schematic depended (not necessarily segment A fits byte 0) #define SEGA (1 << 0) #define SEGB (1 << 2) #define SEGC (1 << 4) #define SEGD (1 << 6) #define SEGE (1 << 7) #define SEGF (1 << 1) #define SEGG (1 <...
dltech/laminator-nemo
lib/freq_dr.h
#ifndef H_FREQDR #define H_FREQDR #define SIN_RESOL_HP 16 #define DIR_OFFS 5 #define PINL 6 #define PINR 7 #define SYSCLK 48000000 #define PSC 16 #define ARR(out_clk) SYSCLK / PSC / SIN_RESOL_HP / out_clk #define forward_dir 0 #define reverse_dir 1 void setSpd(uint32_t hz, uint8_t reverse)...
dltech/laminator-nemo
lib/ds18b20.c
/* * stm32 timer based ds18b20 lib * Copyright 2021 <NAME> <<EMAIL>> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless re...
dltech/laminator-nemo
lib/printf7.c
#include <stdint.h> #include <stdio.h> #include <stdarg.h> #include <string.h> #include "printf7.h" #include "tm1637.h" //volatile uint8_t dispBuffer[DIGITS] = {0, 0, 0}; uint32_t alphabet(char s); void myprintf(char *format, ... ) { char buffer[DIGITS*4]; uint8_t dispBuffer[DIGITS]; va_list args; va...
dltech/laminator-nemo
lib/cmsis_sin.h
<filename>lib/cmsis_sin.h #ifndef H_SIN #define H_SIN #include <inttypes.h> #define FAST_MATH_TABLE_SIZE 512 #define FAST_MATH_Q31_SHIFT (32 - 10) #define BASEQ31 2147483648 /* This is ripped out sin function from CMSIS library input and output are in q31 format */ uint32_t arm_sin_q31(uint32_t x); #endif
dltech/laminator-nemo
lib/mystmbackend.c
<filename>lib/mystmbackend.c<gh_stars>0 #include "mystmbackend.h" #include "../libopencm3/include/libopencm3/stm32/i2c.h" #include "../libopencm3/include/libopencm3/stm32/rcc.h" #include "../libopencm3/include/libopencm3/stm32/gpio.h" void clkInit() { // не знаю зачем, на всякий случай RCC_CR |= RCC_CR_HSION...
dltech/laminator-nemo
lib/mystmbackend.h
<filename>lib/mystmbackend.h #ifndef H_MYSTM #define H_MYSTM #include "inttypes.h" #define SCL 9 #define SDA 10 #define I2C_ADD_NE_ADD 0x00 #define TIMEOUT_CLKS 10000 void clkInit(void); void rough_delay_us(uint16_t us); void delay_ms(uint16_t ms); void delay_s(uint16_t s); void f0I2cInit(void); void f0I2cSend(u...
dltech/laminator-nemo
lib/buttons.c
#include <stdlib.h> #include <stdio.h> #include <stdint.h> #include "../libopencm3/include/libopencm3/stm32/rcc.h" #include "../libopencm3/include/libopencm3/stm32/exti.h" #include "../libopencm3/include/libopencm3/stm32/gpio.h" #include "../libopencm3/include/libopencm3/stm32/timer.h" #include "../libopencm3/include/l...
dltech/laminator-nemo
lib/freq_dr.c
#include "../libopencm3/include/libopencm3/stm32/rcc.h" #include "../libopencm3/include/libopencm3/stm32/gpio.h" #include "../libopencm3/include/libopencm3/stm32/timer.h" #include "../libopencm3/include/libopencm3/stm32/dma.h" #include "freq_dr.h" #include "cmsis_sin.h" volatile uint32_t positive[SIN_RESOL_HP*2]; vola...
dltech/laminator-nemo
lib/buttons.h
<reponame>dltech/laminator-nemo<gh_stars>0 #ifndef H_BUTTONS #define H_BUTTONS #define BUTTON_PORT GPIOA #define BUTTON_READ GPIOA_IDR #define SET_PIN GPIO9 #define CHOOSE_PIN GPIO10 void buttonsInit(void); void checkButtonResetTimer(void); void startButtonsCheck(void); #endif
gigimushroom/DatabaseBackendEngine
src/include/logging/log_recovery.h
<reponame>gigimushroom/DatabaseBackendEngine<filename>src/include/logging/log_recovery.h /** * recovery_manager.h * Read log file from disk, redo and undo */ #pragma once #include <algorithm> #include <mutex> #include <unordered_map> #include "buffer/buffer_pool_manager.h" #include "concurrency/lock_manager.h" #in...
gigimushroom/DatabaseBackendEngine
src/include/table/table_heap.h
/** * table_heap.h * * doubly-linked list of heap pages */ #pragma once #include "buffer/buffer_pool_manager.h" #include "logging/log_manager.h" #include "page/table_page.h" #include "table/table_iterator.h" #include "table/tuple.h" namespace cmudb { class TableHeap { friend class TableIterator; public: ~T...
gigimushroom/DatabaseBackendEngine
src/include/page/table_page.h
<gh_stars>10-100 /** * table_page.h * * Slotted page format: * --------------------------------------- * | HEADER | ... FREE SPACES ... | TUPLES | * --------------------------------------- * ^ * free space pointer * * Header format (size in byte): * ...
gigimushroom/DatabaseBackendEngine
src/include/page/b_plus_tree_page.h
<filename>src/include/page/b_plus_tree_page.h<gh_stars>10-100 /** * b_plus_tree_page.h * * Both internal and leaf page are inherited from this page. * * It actually serves as a header part for each B+ tree page and * contains information shared by both leaf page and internal page. * * Header format (size in byt...
gigimushroom/DatabaseBackendEngine
src/include/disk/disk_manager.h
<reponame>gigimushroom/DatabaseBackendEngine<gh_stars>10-100 /** * disk_manager.h * * Disk manager takes care of the allocation and deallocation of pages within a * database. It also performs read and write of pages to and from disk, and * provides a logical file layer within the context of a database management ...
gigimushroom/DatabaseBackendEngine
src/include/common/rwmutex.h
<filename>src/include/common/rwmutex.h /** * rwmutex.h * * Reader-Writer lock */ #pragma once #include <climits> #include <condition_variable> #include <mutex> namespace cmudb { class RWMutex { typedef std::mutex mutex_t; typedef std::condition_variable cond_t; static const uint32_t max_readers_ = UINT_MA...
gigimushroom/DatabaseBackendEngine
src/include/hash/extendible_hash.h
<reponame>gigimushroom/DatabaseBackendEngine<filename>src/include/hash/extendible_hash.h /* * extendible_hash.h : implementation of in-memory hash table using extendible * hashing * * Functionality: The buffer pool manager must maintain a page table to be able * to quickly map a PageId to its corresponding memory ...
gigimushroom/DatabaseBackendEngine
src/include/type/numeric_type.h
<gh_stars>10-100 /** * numeric_type.h */ #pragma once #include <cmath> #include "type/value.h" namespace cmudb { // A numeric value is an abstract type representing a number. Numerics can be // either integral or non-integral (decimal), but must provide arithmetic // operations on its value. class NumericType : pub...
gigimushroom/DatabaseBackendEngine
src/include/index/index_iterator.h
<filename>src/include/index/index_iterator.h<gh_stars>10-100 /** * index_iterator.h * For range scan of b+ tree */ #pragma once #include "page/b_plus_tree_leaf_page.h" #include "buffer/buffer_pool_manager.h" //#include "common/logger.h" namespace cmudb { #define INDEXITERATOR_TYPE ...
gigimushroom/DatabaseBackendEngine
src/include/concurrency/lock_manager.h
/** * lock_manager.h * * Tuple level lock manager, use wait-die to prevent deadlocks */ #pragma once #include <condition_variable> #include <list> #include <memory> #include <mutex> #include <unordered_map> #include <unordered_set> #include "common/rid.h" #include "concurrency/transaction.h" namespace cmudb { ...
gigimushroom/DatabaseBackendEngine
src/include/concurrency/transaction_manager.h
<filename>src/include/concurrency/transaction_manager.h /** * transaction_manager.h * */ #pragma once #include <atomic> #include <unordered_set> #include "common/config.h" #include "concurrency/lock_manager.h" #include "logging/log_manager.h" namespace cmudb { class TransactionManager { public: TransactionManag...
gigimushroom/DatabaseBackendEngine
test/include/logging/common.h
/** * common.h */ #pragma once #include <chrono> #include <cstdio> #include <cstdlib> #include <sys/time.h> #include "table/tuple.h" namespace cmudb { // use a fixed schema to construct a random tuple Tuple ConstructTuple(Schema *schema) { std::vector<Value> values; Value v(TypeId::INVALID); struct timeva...
sksdlin/GroupChatClientDesktop
src/global.h
<gh_stars>0 #include <QString> #include <QTcpSocket> #include <QByteArray> #include <QWebSocket> #ifndef GLOBAL_H #define GLOBAL_H extern QString USERNAME; extern QWebSocket *SOCKET; extern QString DATA; #endif // GLOBAL_H
sksdlin/GroupChatClientDesktop
src/adminchat.h
#ifndef ADMINCHAT_H #define ADMINCHAT_H #include <QMainWindow> #include "global.h" namespace Ui { class AdminChat; } class AdminChat : public QMainWindow { Q_OBJECT public: explicit AdminChat(QWidget *parent = 0); void loadAllBlocked(); void loadAllUnBlocked(); QVector<QString> comaEndedStr(QSt...
sksdlin/GroupChatClientDesktop
src/regex.h
#ifndef REGEX_H #define REGEX_H #include<QRegExp> class RegEx { //QRegExp regX; public: RegEx(); bool regEmail (QString ); bool regUserName (QString ); bool regDob (QString ); bool regName (QString ); }; #endif // REGEX_H
sksdlin/GroupChatClientDesktop
src/forgotpassword.h
#ifndef FORGOTPASSWORD_H #define FORGOTPASSWORD_H #include <QDialog> namespace Ui { class ForgotPassword; } class ForgotPassword : public QDialog { Q_OBJECT public: explicit ForgotPassword(QWidget *parent = 0); QVector<QString> commaEndedStr(QString Str); QString hashSha1(QString hashIt); ~For...
sksdlin/GroupChatClientDesktop
src/regwindow.h
#ifndef REGWINDOW_H #define REGWINDOW_H #include <QWidget> #include <QMainWindow> #include "regex.h" #include "global.h" #include <QCryptographicHash> namespace Ui { class RegWindow; } class RegWindow : public QMainWindow { Q_OBJECT public: explicit RegWindow(QWidget *parent = 0); QString hashSha1(QStri...
sksdlin/GroupChatClientDesktop
src/loginwindow.h
<gh_stars>0 #ifndef LOGINWINDOW_H #define LOGINWINDOW_H #include <QMainWindow> #include <QWidget> #include <QTcpSocket> #include <regex> #include <QCryptographicHash> #include <QSslError> namespace Ui { class LoginWindow; } class LoginWindow : public QMainWindow { Q_OBJECT public: explicit LoginWindow(QWidge...
sksdlin/GroupChatClientDesktop
src/chat.h
<filename>src/chat.h<gh_stars>0 #ifndef CHAT_H #define CHAT_H #include <QMainWindow> #include <QTcpSocket> #include <QHostAddress> #include <string> #include <QDataStream> namespace Ui { class Chat; } class Chat : public QMainWindow { Q_OBJECT public: explicit Chat(QWidget *parent = 0); void closeEven...
tealminivan/FinalProject
kernel/generated_pybind.h
//#include <pybind11/pybind11.h> //#include "dlpack.h" //#include "kernel.h" //#include "csr.h" //namespace py = pybind11; inline void export_kernel(py::module &m) { m.def("spmm", [](graph_t& graph, py::capsule& input, py::capsule& output) { array2d_t<float> input_array = capsule_to_array2d(i...
tealminivan/FinalProject
kernel/kernel.h
#pragma once #include "csr.h" #include "op.h" extern int THD_COUNT; void invoke_spmm(graph_t& graph, array2d_t<float> & input, array2d_t<float> & output);
tealminivan/FinalProject
kernel/op.h
<reponame>tealminivan/FinalProject // // Created by yidong on 8/31/20. // #pragma once #include <string> #include <cstring> enum op_t { eSUM = 0, eMAX, eMIN, eSUB, eMUL, eDIV, }; //1D tensor template <class T> struct array1d_t { T* data_ptr; int64_t col_count; bool alloc; T&...
tealminivan/FinalProject
kernel/csr.h
<reponame>tealminivan/FinalProject #pragma once #include "stdint.h" using namespace std; #ifdef B64 typedef uint64_t vid_t; #elif B32 typedef uint32_t vid_t; #endif typedef float val_t; struct neighbor_t { vid_t dst; val_t weight; }; class csr_t { public: vid_t v_count; //This is actual vcount in a g...
khoih-prog/RTL8720_TimerInterrupt
src_h/RTL8720_TimerInterrupt.h
<filename>src_h/RTL8720_TimerInterrupt.h /**************************************************************************************************************************** RTL8720_TimerInterrupt.h For RTL8720DN, RTL8722DM and RTL8722CSM boards Written by <NAME> Built by Khoi Hoang https://github.com/khoih-prog/RTL8...
lusm554/operating-system-concepts
src/chapter-3/what_the_output.c
<reponame>lusm554/operating-system-concepts #include <stdio.h> #include <sys/types.h> #include <unistd.h> int value = 5; int main(void) { pid_t pid; pid = fork(); printf("pid - %u\n", pid); if (pid == 0) { // child value += 15; return 0; } if (pid > 0) { // parent wait(NULL); printf("num...
lusm554/operating-system-concepts
src/chapter-3/Programming-Problems/pid_manager.c
#include <stdio.h> #include <stdlib.h> #define MIN_PID 300 #define MAX_PID 5000 #define SIZE MAX_PID - MIN_PID int alloc_map(void); int alloc_pid(void); void release_pid(int pid); int bitmap[SIZE] = {0}; int main(void) { alloc_map(); printf("%zu\n", sizeof bitmap); for (int i = 0; i < 5; i++) { int t = ...
lusm554/operating-system-concepts
src/chapter-3/Programming-Problems/time_ver_2.c
<filename>src/chapter-3/Programming-Problems/time_ver_2.c<gh_stars>0 #include <stdio.h> #include <string.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <sys/time.h> #include <sys/wait.h> #define SIZE 128 #define READ_END 0 #define WRITE_END 1 int elapsed(struct timeval *start, struct timev...
lusm554/operating-system-concepts
src/chapter-4/Programming-Problems/fibonacci.c
<filename>src/chapter-4/Programming-Problems/fibonacci.c #include <stdio.h> #include <stdlib.h> #include <pthread.h> void *runner(void *param); int *arr; int main(int argc, char **argv) { if (argc != 2) return 1; char *count = argv[1]; arr = malloc(sizeof(*arr) * atoi(count)); pthread_t tid; pthread_attr...
lusm554/operating-system-concepts
src/chapter-3/Programming-Problems/cp.c
#include <stdio.h> #include <errno.h> #include <sys/wait.h> #include <unistd.h> #include <stdlib.h> #include <string.h> #define READ_END 0 #define WRITE_END 1 int main(int argc, void **argv) { if (argc != 3) return 1; char *src = argv[1]; char *dest = argv[2]; FILE *fp_read; FILE *fp_write; int fd[2]; ...
lusm554/operating-system-concepts
src/chapter-3/Programming-Problems/SHM-Collatz-conjecture.c
<reponame>lusm554/operating-system-concepts<filename>src/chapter-3/Programming-Problems/SHM-Collatz-conjecture.c<gh_stars>0 #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <fcntl.h> #include <limits.h> #include <errno.h> #include <sys/types.h> #include <sys/wait.h> #include <sys/stat.h> #include <sy...
lusm554/operating-system-concepts
src/chapter-3/Programming-Problems/Collatz-conjecture.c
<filename>src/chapter-3/Programming-Problems/Collatz-conjecture.c #include <stdio.h> #include <sys/types.h> #include <unistd.h> #include <stdlib.h> #include <limits.h> #include <errno.h> #include <wait.h> long to_num(char *str); int main(int argc, char **argv) { if (argc != 2) return 1; long num; if ((num ...
lusm554/operating-system-concepts
src/chapter-4/Programming-Problems/calculate-statistical-values.c
<filename>src/chapter-4/Programming-Problems/calculate-statistical-values.c<gh_stars>0 #include <stdio.h> #include <stdlib.h> #include <pthread.h> void *get_avg(void *raw_args); void *get_max(void *raw_args); void *get_min(void *raw_args); int MAX; int MIN; int AVG; struct arg_struct { int *arr; int len; } *args...
lusm554/operating-system-concepts
src/chapter-3/producer.c
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <fcntl.h> #include <sys/shm.h> #include <sys/stat.h> #include <unistd.h> // for avoid warning for truncate #include <sys/mman.h> int main(void) { /* the size (in bytes) of shared memory object */ const int SIZE = 4096; /* name of the shared mem...
lusm554/operating-system-concepts
src/chapter-3/consumer-producer-problem.c
<filename>src/chapter-3/consumer-producer-problem.c #include <stdio.h> #include <stdlib.h> #include <string.h> #include <fcntl.h> #include <sys/shm.h> #include <sys/stat.h> #include <sys/mman.h> #include <unistd.h> void write_shm(void); void read_shm(void); int main(void) { write_shm(); read_shm(); return 0; }...
lusm554/operating-system-concepts
src/chapter-3/Programming-Problems/zombie-process.c
#include <stdio.h> #include <sys/types.h> #include <unistd.h> #include <stdlib.h> int main(void) { pid_t pid; pid = fork(); if (pid < 0) { // error return 1; } if (pid == 0) { // child process exit(0); } if (pid > 0) { // parent process // sleep 20 seconds time_t end_time = time(NULL) ...
lusm554/operating-system-concepts
src/chapter-2/Linux-Kernel-Modules/simple.c
#include <linux/init.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/hash.h> // GOLDEN_RATIO_PRIME #include <linux/gcd.h> // gcd #include <asm/param.h> // HZ #include <linux/jiffies.h> // jiffies unsigned long int JIFFIES_AT_INIT; /* This function is called when the module is loaded. */ int sim...
lusm554/operating-system-concepts
src/chapter-3/Programming-Projects/unix-shell.c
<gh_stars>0 #include <stdio.h> #include <unistd.h> #include <errno.h> // errno #include <string.h> #include <stdlib.h> #include <sys/wait.h> #define MAX_LINE 256 /* The max length of command */ #define MAX_TOKEN 64 #define TOK_DELIM " \t\r\n\a" /* * errno * * Value: Description: * 0 No error * EDOM...
lusm554/operating-system-concepts
src/chapter-2/Linux-Kernel-Modules/seconds.c
<filename>src/chapter-2/Linux-Kernel-Modules/seconds.c #include <linux/init.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/proc_fs.h> #include <linux/uaccess.h> #include <linux/jiffies.h> // seconds #include <asm/param.h> // HZ #define BUFFER_SIZE 128 #define PROC_NAME "seconds" unsigned long ...
lusm554/operating-system-concepts
src/chapter-3/Programming-Problems/time_ver_1.c
#include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <string.h> #include <fcntl.h> #include <sys/time.h> #include <sys/types.h> #include <sys/wait.h> #include <sys/stat.h> #include <sys/mman.h> #define SIZE sizeof(long long int) * 2 // two nums #define NAME "/time_counter" int elapsed(struct timeval *s...
lusm554/operating-system-concepts
src/chapter-4/multithreaded-sum.c
<gh_stars>0 #include <stdio.h> #include <pthread.h> #include <stdlib.h> // This data is shared by the thread(s) int sum; // Threads call this function void *runner(void *param); int main(int argc, char **argv) { char *number_to_sum = argv[1]; pthread_t tid; // the thread identifier pthread_attr_t attr; // set o...
lusm554/operating-system-concepts
src/chapter-4/Programming-Projects/sudoku-solution-validator.c
#include <stdio.h> int main(void) { int solution_to_9x9_puzzle[9][9] = { {6, 2, 4, 5, 3, 9, 1, 8, 7}, {5, 1, 9, 7, 2, 8, 6, 3, 4}, {8, 3, 7, 6, 1, 4, 2, 9, 5}, {1, 4, 3, 8, 6, 5, 7, 2, 9}, {9, 5, 8, 2, 4, 7, 3, 6, 1}, {7, 6, 2, 3, 9, 1, 4 ,5, 8}, {3, 7, 1, 9, 5, 6, 8, 4, 2}, {4, 9, 6,...
lusm554/operating-system-concepts
src/chapter-3/Programming-Problems/quote-of-the-day.c
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <errno.h> #include <string.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <netdb.h> #include <arpa/inet.h> #include <sys/wait.h> #include <signal.h> #include <time.h> #define PORT "6017" #define BACKLOG 5 // how man...
lusm554/operating-system-concepts
src/chapter-4/Programming-Problems/prime_nums.c
<filename>src/chapter-4/Programming-Problems/prime_nums.c #include <stdio.h> #include <stdlib.h> #include <pthread.h> void *runner(void *param); int main(int argc, char **argv) { if (argc != 2) return 1; char *limit = argv[1]; pthread_t tid; pthread_attr_t attr; pthread_attr_init(&attr); pthread_creat...
lusm554/operating-system-concepts
src/chapter-3/Programming-Problems/reverse-case-pipe.c
#include <stdio.h> #include <sys/types.h> #include <string.h> #include <unistd.h> #include <sys/wait.h> #define SIZE 25 #define READ_END 0 #define WRITE_END 1 void read_pipe(int *fd, char *read_msg); void write_pipe(int *fd, char *write_msg); int main(int argc, char **argv) { // parent buf char write_msg_p[SIZE...
lusm554/operating-system-concepts
src/chapter-2/Programming-Problems/FileCopy.c
#include <stdio.h> #include <unistd.h> /* Write cp program using either the POSIX or Windows API. Be sure to include all necessary error checking, including ensuring that the source file exists. Input: 1. source file 2. destination file */ #define ENOENT 64 // machine is not on the network (args < 2) #define EPER...
barikang/npk
libnpk/external/tea/tea.h
/* TEA code from http://www.ftp.cl.cam.ac.uk/ftp/papers/djw-rmn/djw-rmn-tea.html */ void tea_encode(unsigned char* v, int* k); void tea_decode(unsigned char* v, int* k); void tea_encode_buffer(unsigned char* in_buffer, off_t in_size, int* key, int cipherRemains); void tea_decode_buffer(unsigned char* in_buffer, off_t...
barikang/npk
libnpk/tests/testutil.h
/* testutil.h from haje01's GX library */ #ifndef __TESTUTIL_H__ #define __TESTUTIL_H__ #include <iostream> #include <fcntl.h> #if defined( WIN32 ) #include <io.h> #pragma warning ( disable : 4819 ) #pragma warning ( disable : 4996 ) #else #include <stdio.h> #include <unistd.h> #include <string.h> #include <stdlib.h> ...
barikang/npk
npk/cli/helper_bstrcmp.h
<reponame>barikang/npk<filename>npk/cli/helper_bstrcmp.h /* created by <EMAIL> */ // msdos-like wildcard comparator bool b_strcmp( const char* s, const char* d, bool casesensitive = true ) { bool asterisk = false; int sPos = 0, dPos = 0; if( !s || !d ) return false; while(1) { if( s[sPos] ...
barikang/npk
libnpk/external/tea/tea.c
<gh_stars>10-100 #include <sys/types.h> #include <stddef.h> #ifdef NPK_DEV void tea_encode(unsigned char* c, int* k) { unsigned int y, z, sum=0, delta=0x9e3779b9, n=32; y = c[0] | c[1] << 8 | c[2] << 16 | c[3] << 24; z = c[4] | c[5] << 8 | c[6] << 16 | c[7] << 24; while (n-->0) { sum += delta;...
barikang/npk
libnpk/external/xxtea/xxtea.c
#include <sys/types.h> #include <stddef.h> #define DELTA 0x9e3779b9 #define MX (((z>>5^y<<2) + (y>>3^z<<4)) ^ ((sum^y) + (k[(p&3)^e] ^ z))) #ifdef NPK_DEV void xxtea_encode(unsigned char* c, int* k) { unsigned int n = 2; unsigned int v[2]; unsigned int y, z, sum; unsigned int p, rounds, e; v[0] =...
barikang/npk
libnpk/include/npk_base.h
/* npk - neat package system See README for copyright and license information. base type and definitions of npk */ #include <stddef.h> #include "npk_conf.h" #ifndef _NPK_BASE_H_ #define _NPK_BASE_H_ // Type typedef int NPK_RESULT; typedef void* NPK_...
barikang/npk
libnpk/include/npk.h
<reponame>barikang/npk /* npk - neat package system See README for copyright and license information. */ #ifndef _NPK_H_ #define _NPK_H_ #include "npk_conf.h" #include "npk_base.h" #include "npk_error.h" #ifdef __cplusplus extern "C" { #endif extern NPK_API int g_npkError; extern NPK_API int g_useCritica...
barikang/npk
libnpk/include/npk_dev.h
<reponame>barikang/npk /* npk - neat package system See README for copyright and license information. header for npk development mode */ #ifndef _NPK_DEV_H_ #define _NPK_DEV_H_ #include "npk_conf.h" #include "npk_base.h" #include "npk_error.h" #ifdef NPK_PLATFORM_WINDOWS #include <windows.h> #endif #d...
barikang/npk
libnpk/include/npk_error.h
/* npk - neat package system See README for copyright and license information. npk error code */ #ifndef _NPK_ERROR_H_ #define _NPK_ERROR_H_ // Success #define NPK_SUCCESS 1 // Error #define NPK_ERROR 0 #defin...
barikang/npk
npk/cli/helper_dirent.c
/* Implementation of POSIX directory browsing functions and types for Win32. Author: <NAME> (<EMAIL>, <EMAIL>) History: Created March 1997. Updated June 2003. Rights: See end of file. */ #include "helper_dirent.h" #include <errno.h> #include <io.h> /* _findfirst and _findnext set errno iff they re...
barikang/npk
libnpk/external/xxtea/xxtea.h
<reponame>barikang/npk /* Corrected Block TEA code from http://en.wikipedia.org/wiki/XXTEA */ void xxtea_encode(unsigned char* v, int* k); void xxtea_decode(unsigned char* v, int* k); void xxtea_encode_buffer(unsigned char* in_buffer, off_t in_size, int* key, int cipherRemains); void xxtea_decode_buffer(unsigned char...
barikang/npk
libnpk/src/npk.c
/* npk - neat package system See README for copyright and license information. */ #include <stdio.h> #include <stdlib.h> #include <time.h> #include <sys/stat.h> #include "npk.h" #include "npk_dev.h" #ifdef NPK_PLATFORM_MACOS #include <strings.h> #else #include <string.h> #endif #include "../external/tea/tea...
barikang/npk
libnpk/src/npk_common.c
<filename>libnpk/src/npk_common.c /* npk - neat package system See README for copyright and license information. */ #include <stdio.h> #include <stdlib.h> #include <stdarg.h> #include <time.h> #include <errno.h> #include <fcntl.h> #include <string.h> #include <sys/types.h> #include <sys/stat.h> #include "npk...
barikang/npk
libnpk/src/npk_dev.c
/* npk - neat package system See README for copyright and license information. */ #include <stdio.h> #include <stdlib.h> #include <stdarg.h> #include <time.h> #include <errno.h> #include <fcntl.h> #include <string.h> #include <sys/types.h> #include <sys/stat.h> #include "npk.h" #include "npk_dev.h" #ifdef N...
Pavel-Innokentevich-Galanin/BrSTU-4-sem_Operating-Systems-and-System-Programming
lab4/src/example/app/main.c
#include <unistd.h> #include <sys/types.h> #include <stdio.h> #include <stdlib.h> int main() { pid_t pid; printf("Порождение процесса 1 PID = %d PPID = %d\n", getppid(), getppid()); // Порождение второго процесса if ( (pid = fork()) == -1 ) printf("Ошибка!\n"); else if (pid == 0) { ...
Pavel-Innokentevich-Galanin/BrSTU-4-sem_Operating-Systems-and-System-Programming
lab5/src/example2/src/main.c
#include <sys/types.h> #include <fcntl.h> #include <stdio.h> int main() { int fd; size_t sizeRead, sizeWrite; char string[255]; /* Считываем данные из стандартного потока ввода */ sizeRead = read(0, string, 255); if (sizeRead <= 0) { printf("Can\'t read.\n"); return(-1); } ...
Pavel-Innokentevich-Galanin/BrSTU-4-sem_Operating-Systems-and-System-Programming
lab5/src/option5-part3/src/main.c
//библиотеки #include <unistd.h> //read() #include <stdio.h> //printf() #include <stdlib.h> //calloc(), realloc(), free() #include <string.h> //strcpy(), strlen(), strcat() //прототипы struct WordNode { char* word; struct WordNode* left; struct WordNode* right; }; struct WordNode* WordNode__Constructor(...
Pavel-Innokentevich-Galanin/BrSTU-4-sem_Operating-Systems-and-System-Programming
lab4/src/option5/app/main.c
<gh_stars>0 #include <unistd.h> #include <sys/types.h> #include <stdio.h> #include <stdlib.h> // 0112233 // 1234567 // if0 // if1 // if2 // if4 // if5 // if3 // if6 // if7 int main() { pid_t pid; // print 0 printf("start pr 0 PID = %d PPID = %d\n", getpid()...
Pavel-Innokentevich-Galanin/BrSTU-4-sem_Operating-Systems-and-System-Programming
lab7/src/option5/two.c
#include <unistd.h> #include <stdio.h> //printf() #include <stdlib.h> //rand() #include <sys/types.h> #include <sys/ipc.h> #include <sys/shm.h> #include <fcntl.h> #include <semaphore.h> #include <pthread.h> #include <time.h> //time(), localetime() int get_random(int x1, int x2); void print_r...