before next stage

This commit is contained in:
eason
2023-12-20 18:54:24 +08:00
commit c6f08be676
38 changed files with 183324 additions and 0 deletions

13
include/clock.h Normal file
View File

@ -0,0 +1,13 @@
#define clock_start usize freq=0;\
u64 begin=rdtsc_64bits();
#define clock_end u64 end=rdtsc_64bits(); \
printf(" execute cycle(s) %llu, %zu operation(s) take place!\n",end-begin,freq);
#define record_start u64 r_begin=rdtsc_64bits();
#define record_end(x) output_csv(x,r_begin);
// #define record_start ;
// #define record_end(x) ;
unsigned long long int rdtsc_64bits();
void output_csv(char * filename,unsigned long long int old);

22
include/hashmap.h Normal file
View File

@ -0,0 +1,22 @@
#include <stdbool.h>
#include "rust.h"
#define B 100
struct Entries{
void* key;
void* val;
};
struct Entry{
usize size;
usize cap;
struct Entries* list;
};
struct HashMap{
struct Entry entry[B];
usize (*hasher)(void *);
bool (*eq)(void *,void *);
};
void hash_new(struct HashMap* map,usize (*hasher)(void *), bool (*eq)(void *,void *));
void hash_insert(struct HashMap* map,void* key,void* val);
void* hash_get(struct HashMap* map,void* key);
void* hash_pop(struct HashMap* map,void* key);

13
include/linklist.h Normal file
View File

@ -0,0 +1,13 @@
#include "rust.h"
struct Node{
void* val;
__INTPTR_TYPE__ xor_;
};
struct Node* xor_new(void * val);
struct Node* xor_next(struct Node* previous,struct Node* current);
struct Node* xor_insert_front(struct Node* head,void* val);
struct Node* xor_insert_mid(struct Node* previous,struct Node* current,void * val);
void * xor_remove(struct Node * previous,struct Node* current);
usize xor_count(struct Node* head);

13
include/rust.h Normal file
View File

@ -0,0 +1,13 @@
#include <stdlib.h>
#define u8 unsigned char
#define u16 unsigned short int
#define u32 unsigned int
#define u64 unsigned long int
#define i8 char
#define i16 short int
#define i32 int
#define i64 long int
#define usize size_t
void panic(char * msg);
void log_warn(char * msg);

26
include/state.h Normal file
View File

@ -0,0 +1,26 @@
#include "rust.h"
struct HashMap;
union Submask
{
u8 mask[4];
u32 raw;
};
struct SizedSubmask
{
union Submask mask;
usize len;
};
usize display_submask(struct SizedSubmask *mask);
usize display_ip(struct SizedSubmask *mask);
void parse_submask(char* cstr, struct SizedSubmask *mask);
struct SizedSubmask* clone_submask(struct SizedSubmask *mask);
bool reduce_submask(struct SizedSubmask* source);
struct State{
struct Node* head;
struct HashMap* hashmap;
};

2
include/v1.h Normal file
View File

@ -0,0 +1,2 @@
void input(struct State* state);
void length_distribution(struct State* state);

3
include/v2.h Normal file
View File

@ -0,0 +1,3 @@
#include "state.h"
void segment(struct State* state);

3
include/v3.h Normal file
View File

@ -0,0 +1,3 @@
void prefix_insert(struct State* state);
void prefix_delete(struct State* state);
void search(struct State* state);