This repository has been archived by the owner on Mar 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
/
util.h
65 lines (57 loc) · 1.6 KB
/
util.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//
// util.h
// cdos
//
// Created by Andre Zay on 17.12.2017.
// Copyright © 2017 Andre Zay. All rights reserved.
//
#ifndef util_h
#define util_h
#include <assert.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <stdint.h>
#include <stdint.h>
#define SIZE_BYTES 0
#define SIZE_KB 1
#define SIZE_MB 2
#define SIZE_GB 3
#define SIZE_TB 4
//For rand_cwmc
#define PHI 0x9e3779b9
typedef struct _slist_node{ /*node*/
struct _slist_node *next;
char* val;
}_node;
typedef struct _list{ /*header*/
uint64_t length;
_node* first;
_node* last;
} slist;
int randport(void);
char randchar(void);
char* randstring(size_t sz);
int randrange(int start, int end);
const char* getarg(const char arg[2], const char* argv[], int argc);
bool checkarg(const char arg[2], const char* argv[], int argc);
bool checklarg(const char* arg, const char* argv[], int argc);
char* readfile(char* filename);
const char* getlarg(const char* arg, const char* argv[], int argc);
void sleep_ms(int milliseconds);
char* dtoa(double x);
char* bytes2mb(int64_t bcount);
char* bytes2any(int64_t bcount,uint8_t type);
char* metrics2str(uint8_t type);
uint8_t str2metrics(char* metrics);
const char* sgetlarg(const char *arg, const char* argv[], int argc,const char* _default);
const char* sgetarg(const char arg[2], const char* argv[], int argc,const char* _default);
bool is_root(void);
slist* create_slist(void);
void add_slist(slist* this,char* x);
void free_slist(slist *this);
_node* nth_slist(slist* this,uint64_t n);
void init_rand(uint32_t x);
uint32_t rand_cmwc(void);
#endif /* util_h */