repo_name stringlengths 6 97 | path stringlengths 3 341 | text stringlengths 8 1.02M |
|---|---|---|
dandycheung/baulk | lib/archive/zstd/compress/zstd_fast.c | <filename>lib/archive/zstd/compress/zstd_fast.c<gh_stars>10-100
/*
* Copyright (c) <NAME>, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under both the BSD-style license (found in the
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
* in the COPYING file in t... |
dandycheung/baulk | lib/archive/zlib/slide_hash_simd.h | /* slide_hash_simd.h
*
* Copyright 2022 The Chromium Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the Chromium source repository LICENSE file.
*/
#ifndef SLIDE_HASH_SIMD_H
#define SLIDE_HASH_SIMD_H
#include "deflate.h"
#ifndef INLINE
#if defin... |
dandycheung/baulk | lib/archive/liblzma/lz/lz_encoder_mf.c | ///////////////////////////////////////////////////////////////////////////////
//
/// \file lz_encoder_mf.c
/// \brief Match finders
///
// Authors: <NAME>
// <NAME>
//
// This file has been put into the public domain.
// You can do whatever you want with this file.
//
///////////////////... |
dandycheung/baulk | lib/archive/ppmd/Ppmd8.h | /* Ppmd8.h -- Ppmd8 (PPMdI) compression codec
2021-04-13 : <NAME> : Public domain
This code is based on:
PPMd var.I (2002): <NAME> : Public domain
Carryless rangecoder (1999): <NAME> : Public domain */
#ifndef __PPMD8_H
#define __PPMD8_H
#include "Ppmd.h"
EXTERN_C_BEGIN
#define PPMD8_MIN_ORDER 2
#... |
NurdTurd/c-learning | lib/my_zero_char_array.c | /*
** EPITECH PROJECT, 2019
** my_zero_char_array
** File description:
**
*/
void my_zero_char_array(char *arr, int length)
{
for (int i = 0; i < length; i++)
arr[i] = 0;
}
|
NurdTurd/c-learning | lib/my_putstr.c | int my_putstr(char *str)
{
int i = 0;
while (str[i] != '\0') {
my_putchar(str[i]);
}
}
|
NurdTurd/c-learning | lib/my_macro_abs.c | <filename>lib/my_macro_abs.c
/*
** EPITECH PROJECT, 2019
** my_macro_abs.h
** File description:
**
*/
#include <stdio.h>
#include "include/my_macro_abs.h"
int main(void)
{
printf("%d", ABS(-10));
}
|
NurdTurd/c-learning | lib/my_strcat.c | <filename>lib/my_strcat.c
/*
** EPITECH PROJECT, 2019
** my_strcat
** File description:
**
*/
char *my_strcat(char *dest, char const *src)
{
return;
}
|
NurdTurd/c-learning | lib/my_params_to_array.c | <filename>lib/my_params_to_array.c<gh_stars>0
/*
** EPITECH PROJECT, 2019
** my_params_to_array
** File description:
**
*/
struct info_param *my_params_to_array(int ac, char **av)
{
int length;
char *str;
char *copy;
char **word_array;
}
|
NurdTurd/c-learning | lib/my_compute_factorial_it.c | <reponame>NurdTurd/c-learning
/*
** EPITECH PROJECT, 2019
** my_compute_factorial_it
** File description:
** returns the factorial of the number given
*/
int my_putchar(char c)
{
write(1, &c, 1);
}
int my_compute_factoriel_it(int nb)
{
int resultat = 1;
if (nb < 0 || nb > 12) {
return (0);
}
... |
NurdTurd/c-learning | lib/do_up.c | /*
** EPITECH PROJECT, 2019
** do-op
** File description:
**
*/
#include <stdio.h>
void my_putchar(char c)
{
write(1, &c, 1);
}
int my_put_nbr(int nb)
{
int modulo;
if (nb < 0) {
my_putchar('-');
nb = nb * (-1);
}
if (nb >= 0) {
... |
NurdTurd/c-learning | lib/my_isneg.c | <filename>lib/my_isneg.c
/*
** EPITECH PROJECT, 2019
** my_isneg
** File description:
**
*/
int my_isneg(int n)
{
int x = 0;
if (n < x) {
my_putchar('N');
my_putchar('\n');
} else {
my_putchar('P');
my_putchar('\n');
}
}
|
NurdTurd/c-learning | examples/merge-sort.c | #include<stdlib.h>
#include<stdio.h>
// Merge Function
void merge(int arr[], int l, int m, int r) {
int i, j, k;
int n1 = m - l + 1;
int n2 = r - m;
int L[n1], R[n2];
for (i = 0; i < n1; i++)
L[i] = arr[l + i];
for (j = 0; j < n2; j++)
R[j] = arr[m + 1 + j];
i = 0;
j = 0;
k = l;
while (i <... |
NurdTurd/c-learning | lib/my_strcmp.c | <gh_stars>0
/*
** EPITECH PROJECT, 2019
** my_strcmp
** File description:
** Reproduce the behavior of the strcmp
*/
int my_strcmp(char const *s1, char const *s2)
{
int i;
for (i = 0; s1[i] == s2[i]; i++)
if (s2[i] == '\0')
return 0;
return s1[i] - s2[i];
}
|
NurdTurd/c-learning | lib/my_getnbr.c | /*
** EPITECH PROJECT, 2019
** CPool_Day04_2019
** File description:
** my_getnbr.c
*/
#include <stddef.h>
int my_getnbr(char const *str)
{
int i = -1;
int neg = 1;
long int number = 0;
if (str == NULL)
return 0;
while (str[++i] != '\0' && number == 0) {
if (str[i] == '-')
... |
NurdTurd/c-learning | lib/my_print_params.c | <filename>lib/my_print_params.c
/*
** EPITECH PROJECT, 2019
** my_print_params
** File description:
**
*/
int main(int argc, char
|
NurdTurd/c-learning | lib/my_put_nbr.c | /*
** EPITECH PROJECT, 2019
** my_put_nbr
** File description:
**
*/
int my_put_nbr(int nb)
{
int mod;
if (nb < 0) {
my_putchar('-');
nb = nb * (-1);
}
if (nb >= 0) {
if (nb >= 10) {
mod = (nb % 10);
nb = (nb - mod) / 10;
my_put_nbr(nb);
... |
NurdTurd/c-learning | examples/print-ascii-table.c | //Program to print ASCII table.
#include <stdio.h>
int main()
{
unsigned char count;
for(count=32; count< 255; count+=1)
{
printf(" %3d - %c",count,count);
if(count % 6==0)
printf("\n");
}
return 0;
}
|
NurdTurd/c-learning | lib/my_compute_factorial_rec.c | /*
** EPITECH PROJECT, 2019
** my_compute_factorial_rec
** File description:
**
*/
int my_compute_factorial_rec(int nb)
{
int f;
if (nb == 0)
return (1);
if (nb < 0)
return (0);
f = nb * my_compute_factorial_rec(nb - 1);
return (f);
}
|
NurdTurd/c-learning | lib/my_revstr.c | <gh_stars>0
/*
** EPITECH PROJECT, 2019
** my_revstr
** File description:
** Reverse string given
*/
void my_swap2(char *a, char *b)
{
char t;
t = *b;
*b = *a;
*a = t;
}
char *my_revstr(char *str)
{
int i = 0;
char x = 0;
char y = 0;
while (str[i] != '\0') {
i++;
}
y... |
NurdTurd/c-learning | lib/my_putchar.c | <reponame>NurdTurd/c-learning
int my_putchar(char c)
{
write(1, &c, 1);
}
|
LaudateCorpus1/otp | erts/emulator/nifs/common/prim_net_nif.c | /*
* %CopyrightBegin%
*
* Copyright Ericsson AB 2018-2022. All Rights Reserved.
*
* 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
*
... |
LaudateCorpus1/otp | erts/emulator/beam/erl_fun.c | /*
* %CopyrightBegin%
*
* Copyright Ericsson AB 2000-2021. All Rights Reserved.
*
* 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
*
... |
squaretwo/react-native-applovin-event-tracker | ios/RNApplovinEventTracker.h | <gh_stars>0
//
// RNApplovinEventTracker.h
//
// Created by <NAME> on 7/25/18.
// Copyright © 2018 SquareTwo. All rights reserved.
//
#import <React/RCTBridgeModule.h>
@interface RNApplovinEventTracker : NSObject <RCTBridgeModule>
@end
|
von8/temperature-prediction | factorial.c | #include<stdio.h>
int main(){
int t=1;
int i;
for(i=2;i<=5;){
t=t*i;
i=i+1;
}
printf("t=%d\n",t);
}
|
von8/temperature-prediction | compare2bum.c | #include<stdio.h>
int main(){
int max(int x, int y);
int a, b, c;
printf("Please input the first num:");
scanf("%d", &a);
printf("Please input the second num:");
scanf("%d", &b);
c = max(a, b);
printf("max=%d\n",c);
}
int max(int x, int y){
int z;
if(x>y)z=x;
else z=y;
r... |
von8/temperature-prediction | rootingProcedure.c | #include<stdio.h>
#include<math.h>
void main(){
float a,b,c,disc,x1,x2,p,q;
scanf("a=%f,b=%f,c=%f",&a,&b,&c);
disc=b*b-4*a*c;
p=-b/(2*a);
q=sqrt(disc)/(2*a);
x1=p+q;x2=p-q;
printf("x1=%5.2f\nx2=%5.2f\n",x1,x2);
}
|
von8/temperature-prediction | reversion.c | #include<stdio.h>
void main(){
void inv(int x[], int n);
int i, a[10]={3,7,9,11,0,6,7,5,4,2};
printf("The original array:\n");
for(i=0;i<10;i++)
printf("%d",a[i]);
printf("\n");
inv(a, 10);
printf("The array has been inverted:\n");
for(i=0;i<10;i++)
printf("%d",a[i]);
... |
von8/temperature-prediction | pointerReversion.c | #include<stdio.h>
void main(){
void inv(int *x, int n);
int i, a[10]={3,7,9,11,0,6,7,5,4,2};
int *p;
printf("The original array:\n");
for(i=0;i<10;i++)
printf("%d",a[i]);
printf("\n");
p=a;
inv(p, 10);
printf("The array has been inverted:\n");
for(i=0;i<10;i++)
pr... |
von8/temperature-prediction | pointer.c | #include<stdio.h>
void main(){
void swap(int *p1, int *p2);
int a, b;
int *pointer_1, *pointer_2;
scanf("%d, %d", &a, &b);
pointer_1 = &a; pointer_2 = &b;
if(a<b)swap(pointer_1, pointer_2);
printf("\n%d, %d\n",a,b);
}
void swap(int *p1, int *p2){
int temp;
temp= *p1;
*p1 = *p2;
... |
von8/temperature-prediction | pointerArray.c | <filename>pointerArray.c
#include<stdio.h>
void main(){
int a[10];
int *p;
for(p=a;p<(a+10);p++)
scanf("%d",p);
printf("\n");
p=a;
for(int i=0;i<10;i++)
printf("%d",*p++);
printf("\n");
}
|
von8/temperature-prediction | hello.c | #include<stdio.h>
int main(){
int fahr, celsius;
int lower, upper, step;
lower = 0; /*温度表的下限*/
upper = 160; /*温度表的上限*/
step = 20; /*步长*/
fahr = lower;
while(fahr<=upper){
celsius = 5*(fahr - 32)/9;
printf("%d\t%d\n", fahr, celsius);
fahr = fahr + step;
}
ret... |
von8/temperature-prediction | pointerOrder.c | #include<stdio.h>
void main(){
void exchange(int *q1, int *q2, int *q3);
int a, b, c, *p1, *p2, *p3;
scanf("%d,%d,%d", &a, &b, &c);
p1=&a, p2=&b, p3=&c;
exchange(p1,p2,p3);
printf("\n%d,%d,%d\n",a,b,c);
}
void exchange(int *q1, int *q2, int *q3){
void swap(int *pt1, int *pt2);
if(*q1<*q... |
josehu07/hux-kernel | src/common/port.h | /**
* Common I/O ports inline assembly utilities (in At&T syntax).
*/
#ifndef PORT_H
#define PORT_H
#include <stdint.h>
void outb(uint16_t port, uint8_t val);
void outw(uint16_t port, uint16_t val);
void outl(uint16_t port, uint32_t val);
void outsl(uint16_t port, const void *addr, uint32_t cnt);
uint8_t inb... |
josehu07/hux-kernel | user/lib/malloc.h | <reponame>josehu07/hux-kernel
/**
* User Heap Memory "Next-Fit" Allocator.
*/
#ifndef MALLOC_H
#define MALLOC_H
#include <stdint.h>
#include <stdbool.h>
/** Hardcoded export of the page size and some helper macros. */
#define PAGE_SIZE 4096
#define USER_BASE 0x20000000
#define HEAP_BASE (USER_BASE + 0x00100000... |
josehu07/hux-kernel | src/memory/paging.h | <filename>src/memory/paging.h
/**
* Setting up and switching to paging mode.
*/
#ifndef PAGING_H
#define PAGING_H
#include <stdint.h>
#include <stdbool.h>
/** Assume 4KiB pages, not support any other sizes. */
#define PAGE_SIZE 4096
#define PTES_PER_PAGE 1024
#define PDES_PER_PAGE 1024
/** Number of physical... |
josehu07/hux-kernel | user/tests/memtest.c | /**
* User test program - file system operations.
*/
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include "../lib/debug.h"
#include "../lib/printf.h"
#include "../lib/syscall.h"
#include "../lib/malloc.h"
void
main(int argc, char *argv[])
{
(void) argc; // Unused.
(void) argv;
... |
josehu07/hux-kernel | src/common/bitmap.c | <filename>src/common/bitmap.c
/**
* Bitmap data structure used in paging, file system, etc.
*/
#include <stdint.h>
#include <stdbool.h>
#include "bitmap.h"
#include "debug.h"
#include "string.h"
#include "spinlock.h"
/** Set a slot as used. */
inline void
bitmap_set(bitmap_t *bitmap, uint32_t slot_no)
{
asse... |
josehu07/hux-kernel | src/common/parklock.c | <gh_stars>10-100
/**
* Lock implementation that blocks the calling process on `acquire()` if
* the lock is locked. Can only be used under process context.
*/
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include "parklock.h"
#include "spinlock.h"
#include "../process/process.h"
#include "../proce... |
josehu07/hux-kernel | src/filesys/exec.h | /**
* Implementation of the `exec()` syscall on ELF-32 file.
*/
#ifndef EXEC_H
#define EXEC_H
#include <stdbool.h>
#include "file.h"
/** Maximum number of arguments allowed in `argv` list. */
#define MAX_EXEC_ARGS 32
bool exec_program(mem_inode_t *inode, char *filename, char **argv);
#endif
|
josehu07/hux-kernel | src/common/intstate.c | /**
* Interrupt enable/disable routines. Mimics xv6.
*/
#include <stdbool.h>
#include "intstate.h"
#include "debug.h"
#include "../process/scheduler.h"
/** Check if interrupts are enabled. */
inline bool
interrupt_enabled(void)
{
uint32_t eflags;
asm volatile ( "pushfl; popl %0" : "=r" (eflags) : );
... |
josehu07/hux-kernel | src/process/scheduler.h | /**
* CPU scheduler and context switching routines.
*
* Hux only aims to support a single CPU.
*/
#ifndef SCHEDULER_H
#define SCHEDULER_H
#include "process.h"
#include "../interrupt/syscall.h"
/** Per-CPU state (we only have a single CPU). */
struct cpu_state {
/** No ID field because only supporting sin... |
josehu07/hux-kernel | src/process/scheduler.c | /**
* CPU scheduler and context switching routines.
*
* Hux only aims to support a single CPU.
*/
#include <stddef.h>
#include "scheduler.h"
#include "process.h"
#include "../common/string.h"
#include "../common/debug.h"
#include "../common/intstate.h"
#include "../device/timer.h"
#include "../memory/gdt.h"
#... |
josehu07/hux-kernel | user/tests/filetest.c | /**
* User test program - file system operations.
*/
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include "../lib/debug.h"
#include "../lib/printf.h"
#include "../lib/syscall.h"
void
main(int argc, char *argv[])
{
(void) argc; // Unused.
(void) argv;
char dirname[128] = "temp... |
josehu07/hux-kernel | user/tests/schedtest.c | <gh_stars>10-100
/**
* User test program - weighted scheduling.
*/
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include "../lib/debug.h"
#include "../lib/printf.h"
#include "../lib/syscall.h"
static void
_test_child_workload(void)
{
int32_t res = 0;
for (int32_t i = 12345; i < 57896; ++i... |
josehu07/hux-kernel | src/interrupt/syscall.h | /**
* System call-related definitions and handler wrappers.
*/
#ifndef SYSCALL_H
#define SYSCALL_H
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#include "isr.h"
/** Syscall trap gate registerd at a vacant ISR number. */
#define INT_NO_SYSCALL 64 /** == 0x40 */
/** List of known syscall numbe... |
josehu07/hux-kernel | src/memory/sysmem.c | /**
* Syscalls related to user memory allocation.
*/
#include <stdint.h>
#include "sysmem.h"
#include "paging.h"
#include "../common/debug.h"
#include "../common/string.h"
#include "../interrupt/syscall.h"
#include "../process/scheduler.h"
/** int32_t setheap(uint32_t new_top); */
int32_t
syscall_setheap(void... |
josehu07/hux-kernel | src/device/timer.h | <filename>src/device/timer.h
/**
* Programmable interval timer (PIT) in square wave generator mode to
* serve as the system timer.
*/
#ifndef TIMER_H
#define TIMER_H
#include <stdint.h>
#include "../common/spinlock.h"
/** Timer interrupt frequency in Hz. */
#define TIMER_FREQ_HZ 100
/** Extern the global ti... |
josehu07/hux-kernel | src/process/sysproc.h | /**
* Syscalls related to process state & operations.
*/
#ifndef SYSPROC_H
#define SYSPROC_H
#include <stdint.h>
int32_t syscall_getpid();
int32_t syscall_fork();
int32_t syscall_exit();
int32_t syscall_sleep();
int32_t syscall_wait();
int32_t syscall_kill();
#endif
|
josehu07/hux-kernel | src/common/spinlock.h | <reponame>josehu07/hux-kernel
/**
* Spinlock implementation (synonym to `cli_push()`/`cli_pop()` pairs
* in single-CPU Hux).
*/
#ifndef SPINLOCK_H
#define SPINLOCK_H
#include <stdint.h>
#include <stdbool.h>
/** Simple spinlock structure. */
struct spinlock {
uint32_t locked; /** 0 unlocked, 1 locked, ch... |
josehu07/hux-kernel | src/common/bitmap.h | <filename>src/common/bitmap.h
/**
* Bitmap data structure used in paging, file system, etc.
*/
#ifndef BITMAP_H
#define BITMAP_H
#include <stdint.h>
#include <stdbool.h>
#include "../common/spinlock.h"
/** Bitmap is simply a contiguous array of bits. */
struct bitmap {
uint8_t *bits; /** Must ensure z... |
josehu07/hux-kernel | src/device/keyboard.c | /**
* PS/2 keyboard input support.
*/
#include <stdint.h>
#include <stdbool.h>
#include "keyboard.h"
#include "../common/port.h"
#include "../common/printf.h"
#include "../common/debug.h"
#include "../common/string.h"
#include "../common/spinlock.h"
#include "../display/vga.h"
#include "../display/terminal.h"
#... |
josehu07/hux-kernel | src/memory/gdt.c | /**
* Global descriptor table (GDT) related.
*/
#include <stdint.h>
#include <stddef.h>
#include "gdt.h"
#include "../common/debug.h"
#include "../process/process.h"
/**
* The GDT table. We maintain 6 entries:
* 0. a null entry;
* 1. kernel mode code segment;
* 2. kernel mode data segment;
* 3. us... |
josehu07/hux-kernel | src/interrupt/idt.c | /**
* Interrupt descriptor table (IDT) related.
*/
#include <stdint.h>
#include "idt.h"
#include "syscall.h"
#include "../common/string.h"
#include "../common/port.h"
#include "../memory/gdt.h"
/**
* The IDT table. Should contain 256 gate entries.
* - 0 - 31: reserved by x86 CPU for various exceptions
*... |
josehu07/hux-kernel | src/device/keyboard.h | /**
* PS/2 keyboard input support.
*/
#ifndef KEYBOARD_H
#define KEYBOARD_H
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
/** A partial set of special keys on US QWERTY keyboard. */
enum keyboard_meta_key {
KEY_NULL, // Dummy placeholder for empty key
KEY_ESC, // Escape
KEY_BACK... |
josehu07/hux-kernel | src/device/sysdev.c | /**
* Syscalls related to communication with external devices other than
* the VGA terminal display.
*/
#include <stdint.h>
#include "sysdev.h"
#include "timer.h"
#include "keyboard.h"
#include "../common/spinlock.h"
#include "../interrupt/syscall.h"
/** int32_t uptime(void); */
int32_t
syscall_uptime(void)
{... |
josehu07/hux-kernel | src/memory/kheap.h | <reponame>josehu07/hux-kernel
/**
* Kernel Heap Memory "Next-Fit" Allocator.
*/
#ifndef KHEAP_H
#define KHEAP_H
#include <stdint.h>
#include <stdbool.h>
#include "slabs.h"
/** The region between `kheap_curr` and slab allocators is free heap. */
#define KHEAP_MAX PAGE_SLAB_MIN
/** Random magic number to prote... |
josehu07/hux-kernel | src/memory/gdt.h | /**
* Global descriptor table (GDT) related.
*/
#ifndef GDT_H
#define GDT_H
#include <stdint.h>
#include "../process/process.h"
#include "../process/scheduler.h"
/**
* GDT entry format.
* Check out https://wiki.osdev.org/Global_Descriptor_Table
* for detailed anatomy of fields.
*/
struct gdt_entry {
ui... |
josehu07/hux-kernel | src/kernel.c | <gh_stars>10-100
/**
* The Hux kernel entry point.
*/
/** Check correct cross compiling. */
#if !defined(__i386__)
#error "The Hux kernel needs to be compiled with an 'ix86-elf' compiler"
#endif
#include "boot/multiboot.h"
#include "boot/elf.h"
#include "common/printf.h"
#include "common/string.h"
#include "comm... |
josehu07/hux-kernel | user/lib/debug.h | /**
* Common debugging message macros.
*/
#ifndef DEBUG_H
#define DEBUG_H
#include "printf.h"
/** Panicking macro. */
#define panic(fmt, args...) do { \
cprintf(VGA_COLOR_MAGENTA, "PANIC: " fmt "\n", \
... |
josehu07/hux-kernel | user/put.c | <gh_stars>10-100
/**
* Command line utility - put string into file.
*
* Due to limited shell cmdline parsing capability, strings containing
* whitespaces are not supported yet.
*/
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include "lib/syscall.h"
#include "lib/printf.h"
#include "lib/debug.h"... |
josehu07/hux-kernel | src/memory/slabs.h | /**
* Simple SLAB allocators for fixed-granularity kernel objects.
*/
#ifndef SLABS_H
#define SLABS_H
#include <stdint.h>
#include "paging.h"
/** Reserve kheap top 4MiB for the page slabs. */
#define PAGE_SLAB_MAX KMEM_MAX
#define PAGE_SLAB_MIN (KMEM_MAX - 0x00400000)
/** Node of a SLAB free-list. */
struct ... |
josehu07/hux-kernel | user/shell.c | <reponame>josehu07/hux-kernel
/**
* Basic command line shell.
*/
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include "lib/syscall.h"
#include "lib/printf.h"
#include "lib/debug.h"
#include "lib/string.h"
#include "lib/types.h"
#define CWD_BUF_SIZE 256
#define LINE_BUF_SIZE 256
#define MAX_EXEC... |
josehu07/hux-kernel | src/memory/sysmem.h | <filename>src/memory/sysmem.h
/**
* Syscalls related to user memory allocation.
*/
#ifndef SYSMEM_H
#define SYSMEM_H
#include <stdint.h>
int32_t syscall_setheap();
#endif
|
josehu07/hux-kernel | user/lib/syscall.h | <filename>user/lib/syscall.h<gh_stars>10-100
/**
* User program system calls library.
*
* For more documentation on syscall functions signature, please see:
* https://github.com/josehu07/hux-kernel/wiki/16.-Essential-System-Calls, and
* https://github.com/josehu07/hux-kernel/wiki/22.-File‐Related-Syscalls
*/
#i... |
josehu07/hux-kernel | user/cat.c | <reponame>josehu07/hux-kernel
/**
* Command line utility - dump file content.
*/
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include "lib/syscall.h"
#include "lib/printf.h"
#include "lib/debug.h"
#include "lib/string.h"
#define DUMP_BUF_LEN 128
static char dump_buf[DUMP_BUF_LEN];
static void
... |
josehu07/hux-kernel | src/process/sysproc.c | /**
* Syscalls related to process state & operations.
*/
#include <stdint.h>
#include "sysproc.h"
#include "../common/printf.h"
#include "../common/debug.h"
#include "../device/timer.h"
#include "../interrupt/syscall.h"
#include "../process/process.h"
#include "../process/scheduler.h"
/** int32_t getpid(void... |
josehu07/hux-kernel | src/device/idedisk.c | /**
* Parallel ATA (IDE) hard disk driver.
* Assumes only port I/O (PIO) mode without DMA for now.
*/
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#include "idedisk.h"
#include "../common/port.h"
#include "../common/debug.h"
#include "../common/string.h"
#include "../common/spinlock.h"
#include ... |
josehu07/hux-kernel | src/interrupt/idt.h | /**
* Interrupt descriptor table (IDT) related.
*/
#ifndef IDT_H
#define IDT_H
#include <stdint.h>
/**
* IDT gate entry format.
* Check out https://wiki.osdev.org/IDT for detailed anatomy
* of fields.
*/
struct idt_gate {
uint16_t base_lo; /** Base 0:15. */
uint16_t selector; /** Segment selector... |
josehu07/hux-kernel | src/device/idedisk.h | /**
* Parallel ATA (IDE) hard disk driver.
* Assumes only port I/O (PIO) mode without DMA for now.
*/
#ifndef IDEDISK_H
#define IDEDISK_H
#include <stdint.h>
#include <stdbool.h>
#include "../filesys/block.h"
/** Hard disk sector size is 512 bytes. */
#define IDE_SECTOR_SIZE 512
/**
* Default I/O ports tha... |
josehu07/hux-kernel | src/common/intstate.h | <reponame>josehu07/hux-kernel<filename>src/common/intstate.h
/**
* Interrupt enable/disable routines. Mimics xv6.
*/
#ifndef INTSTATE_H
#define INTSTATE_H
#include <stdbool.h>
bool interrupt_enabled(void);
void cli_push(void);
void cli_pop(void);
#endif
|
josehu07/hux-kernel | src/boot/elf.h | /**
* ELF 32-bit format related structures.
* See http://www.cs.cmu.edu/afs/cs/academic/class/15213-f00/docs/elf.pdf
*/
#ifndef ELF_H
#define ELF_H
#include <stdint.h>
/** ELF file header. */
struct elf_file_header {
uint32_t magic; /** In little-endian on x86. */
uint8_t ident[12]; /** Re... |
josehu07/hux-kernel | user/ls.c | <reponame>josehu07/hux-kernel
/**
* Command line utility - list directory.
*/
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include "lib/syscall.h"
#include "lib/printf.h"
#include "lib/debug.h"
#include "lib/string.h"
#define CONCAT_BUF_SIZE 300
static char *
_get_filename(char *path)
{
in... |
josehu07/hux-kernel | src/device/sysdev.h | <gh_stars>10-100
/**
* Syscalls related to communication with external devices other than
* the VGA terminal display.
*/
#ifndef SYSDEV_H
#define SYSDEV_H
#include <stdint.h>
int32_t syscall_uptime();
int32_t syscall_kbdstr();
#endif
|
josehu07/hux-kernel | src/common/parklock.h | <filename>src/common/parklock.h<gh_stars>10-100
/**
* Lock implementation that blocks the calling process on `acquire()` if
* the lock is locked. Can only be used under process context.
*/
#ifndef PARKLOCK_H
#define PARKLOCK_H
#include <stdint.h>
#include <stdbool.h>
#include "spinlock.h"
/** Parking lock str... |
josehu07/hux-kernel | src/filesys/vsfs.c | /**
* Very simple file system (VSFS) data structures & Layout.
*
* This part borrows code heavily from xv6.
*/
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include "vsfs.h"
#include "block.h"
#include "file.h"
#include "sysfile.h"
#include "exec.h"
#include "../common/debug.h"
#include "../comm... |
josehu07/hux-kernel | src/common/port.c | /**
* Common I/O ports inline assembly utilities (in At&T syntax).
*/
#include "port.h"
/** Output 8 bits to an I/O port. */
inline void
outb(uint16_t port, uint8_t val)
{
asm volatile ( "outb %0, %1" : : "a" (val), "d" (port) );
}
/** Output 16 bits to an I/O port. */
inline void
outw(uint16_t port, uint16_... |
josehu07/hux-kernel | src/device/timer.c | <gh_stars>10-100
/**
* Programmable interval timer (PIT) in square wave generator mode to
* serve as the system timer.
*/
#include <stdint.h>
#include "timer.h"
#include "../common/port.h"
#include "../common/printf.h"
#include "../common/debug.h"
#include "../common/spinlock.h"
#include "../interrupt/isr.h"
... |
josehu07/hux-kernel | src/common/string.c | <gh_stars>10-100
/**
* Common string utilities.
*/
#include <stddef.h>
#include "string.h"
/**
* Copies the byte C into the first COUNT bytes pointed to by DST.
* Returns a copy of the pointer DST.
*/
void *
memset(void *dst, unsigned char c, size_t count)
{
unsigned char *dst_copy = (unsigned char *) dst... |
josehu07/hux-kernel | src/process/layout.h | <filename>src/process/layout.h
/**
* Virtual address space layout of a user process.
*
* Each process has an address space of size 1GiB, so the valid virtual
* addresses a process could issue range from `0x00000000` to `0x40000000`.
*
* - The kernel's virtual address space of size 512MiB is mapped to the
* ... |
josehu07/hux-kernel | src/display/terminal.c | <filename>src/display/terminal.c<gh_stars>10-100
/**
* Terminal display control.
*
* All functions called outside must have `terminal_lock` held already
* (`printf()` does that).
*/
#include <stddef.h>
#include <stdint.h>
#include "terminal.h"
#include "vga.h"
#include "../common/string.h"
#include "../common/... |
josehu07/hux-kernel | src/filesys/sysfile.h | /**
* Syscalls related to process state & operations.
*/
#ifndef SYSFILE_H
#define SYSFILE_H
#include <stdint.h>
/** Flags for `open()`. */
#define OPEN_RD 0x1
#define OPEN_WR 0x2
/** Flags for `create()`. */
#define CREATE_FILE 0x1
#define CREATE_DIR 0x2
/** For the `fstat()` syscall. */
struct file_stat {... |
josehu07/hux-kernel | src/process/process.c | <gh_stars>10-100
/**
* Providing the abstraction of processes.
*/
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include "process.h"
#include "layout.h"
#include "../common/debug.h"
#include "../common/string.h"
#include "../common/spinlock.h"
#include "../device/timer.h"
#include "../interrupt/i... |
josehu07/hux-kernel | user/rm.c | /**
* Command line utility - remove file or directory.
*/
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include "lib/syscall.h"
#include "lib/printf.h"
#include "lib/debug.h"
#include "lib/string.h"
static bool
_dir_is_empty(int8_t fd)
{
/** Empty dir only has '.' and '..'. */
size_t coun... |
josehu07/hux-kernel | src/filesys/file.c | <gh_stars>10-100
/**
* In-memory structures and operations on open files.
*/
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include "file.h"
#include "block.h"
#include "vsfs.h"
#include "sysfile.h"
#include "../common/debug.h"
#include "../common/string.h"
#include "../common/spinlock.h"
#include ... |
josehu07/hux-kernel | src/filesys/exec.c | /**
* Implementation of the `exec()` syscall on ELF-32 file.
*/
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#include "exec.h"
#include "file.h"
#include "vsfs.h"
#include "../boot/elf.h"
#include "../common/debug.h"
#include "../common/string.h"
#include "../memory/paging.h"
#include "../memory... |
josehu07/hux-kernel | src/display/vga.h | /**
* VGA text mode specifications.
*/
#ifndef VGA_H
#define VGA_H
#include <stdint.h>
/** Hardcoded 4-bit color codes. */
enum vga_color {
VGA_COLOR_BLACK = 0,
VGA_COLOR_BLUE = 1,
VGA_COLOR_GREEN = 2,
VGA_COLOR_CYAN = 3,
VGA_COLOR_RED = 4,
VGA... |
josehu07/hux-kernel | src/interrupt/isr.h | /**
* Interrupt service routines (ISR) handler implementation.
*/
#ifndef ISR_H
#define ISR_H
#include <stdint.h>
/**
* Interrupt state specification, which will be followed by `isr-stub.s`
* before calling `isr_handler` below.
*/
struct interrupt_state {
uint32_t ds;
uint32_t edi, esi, ebp, useless,... |
josehu07/hux-kernel | src/display/terminal.h | /**
* Terminal display control.
*/
#ifndef TERMINAL_H
#define TERMINAL_H
#include <stddef.h>
#include "vga.h"
#include "../common/spinlock.h"
/** Extern to `printf.c` and other places of calling `terminal_`. */
extern spinlock_t terminal_lock;
/**
* Default to black background + light grey foreground.
* F... |
josehu07/hux-kernel | src/memory/paging.c | <reponame>josehu07/hux-kernel<gh_stars>10-100
/**
* Setting up and switching to paging mode.
*/
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#include "paging.h"
#include "../common/debug.h"
#include "../common/string.h"
#include "../common/spinlock.h"
#include "../common/bitmap.h"
#include "../in... |
josehu07/hux-kernel | user/lib/printf.h | /**
* Formatted printing user library.
*
* Format specifier := %[special][width][.precision][length]<type>. Only
* limited features are provided (documented in the wiki page).
*
* The final string CANNOT exceed 1024 bytes for every single invocation.
*/
#ifndef PRINTF_H
#define PRINTF_H
#include <stdint.h>
#... |
josehu07/hux-kernel | src/display/sysdisp.c | <gh_stars>10-100
/**
* Syscalls related to terminal printing.
*/
#include <stdint.h>
#include "sysdisp.h"
#include "vga.h"
#include "../common/printf.h"
#include "../interrupt/syscall.h"
/** void tprint(uint32_t color, char *str); */
int32_t
syscall_tprint(void)
{
uint32_t color;
char *str;
if (!s... |
josehu07/hux-kernel | user/tests/proctest.c | <gh_stars>10-100
/**
* User test program - file system operations.
*/
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include "../lib/debug.h"
#include "../lib/printf.h"
#include "../lib/syscall.h"
void
main(int argc, char *argv[])
{
(void) argc; // Unused.
(void) argv;
int32_t ... |
josehu07/hux-kernel | user/mk.c | <reponame>josehu07/hux-kernel
/**
* Command line utility - create file or directory.
*/
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include "lib/syscall.h"
#include "lib/printf.h"
#include "lib/debug.h"
#include "lib/string.h"
static void
_create_file(char *path, bool is_dir)
{
/** If path ... |
josehu07/hux-kernel | src/memory/slabs.c | /**
* Simple SLAB allocators for fixed-granularity kernel objects.
*/
#include <stdint.h>
#include <stddef.h>
#include "slabs.h"
#include "paging.h"
#include "../common/debug.h"
#include "../common/string.h"
#include "../common/spinlock.h"
/** Page-granularity SLAB free-list. */
static uint32_t page_slab_btm;
s... |
josehu07/hux-kernel | src/common/spinlock.c | /**
* Spinlock implementation (synonym to `cli_push()`/`cli_pop()` pairs
* in single-CPU Hux).
*/
#include <stdint.h>
#include <stdbool.h>
#include "spinlock.h"
#include "intstate.h"
#include "debug.h"
/** Returns true if the lock is currently locked. */
bool
spinlock_locked(spinlock_t *lock)
{
cli_push();
... |
josehu07/hux-kernel | src/filesys/sysfile.c | /**
* Syscalls related to process state & operations.
*/
#include <stdint.h>
#include <stdbool.h>
#include "sysfile.h"
#include "vsfs.h"
#include "file.h"
#include "exec.h"
#include "../common/debug.h"
#include "../common/string.h"
#include "../interrupt/syscall.h"
/** int32_t open(char *path, uint32_t mode); ... |
josehu07/hux-kernel | src/filesys/block.h | /**
* Block-level I/O general request layer.
*/
#ifndef BLOCK_H
#define BLOCK_H
#include <stdint.h>
#include <stdbool.h>
/** All block requests are of size 1024 bytes. */
#define BLOCK_SIZE 1024
/** Helper macros on addresses and block alignments. */
#define ADDR_BLOCK_OFFSET(addr) ((addr) & 0x000003FF)
#defi... |
josehu07/hux-kernel | src/process/process.h | /**
* Providing the abstraction of processes.
*/
#ifndef PROCESS_H
#define PROCESS_H
#include <stdint.h>
#include <stdbool.h>
#include "../common/spinlock.h"
#include "../common/parklock.h"
#include "../interrupt/isr.h"
#include "../memory/paging.h"
#include "../filesys/block.h"
#include "../filesys/file.h"
... |
josehu07/hux-kernel | src/display/sysdisp.h | /**
* Syscalls related to terminal printing.
*/
#ifndef SYSDISP_H
#define SYSDISP_H
#include <stdint.h>
int32_t syscall_tprint();
#endif
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.