util.h

来自「超强国际象棋引擎」· C头文件 代码 · 共 95 行

H
95
字号
// util.h

#ifndef UTIL_H

#define UTIL_H

// includes

#include <cstdio>

// constants

#undef FALSE
#define FALSE 0

#undef TRUE
#define TRUE 1

#ifdef _MSC_VER
#define S64_FORMAT "%I64d"
#define U64_FORMAT "%016I64X"

#else
#define S64_FORMAT "%lld"
#define U64_FORMAT "%016llX"

#endif

// macros

#ifdef _MSC_VER
#define S64(u) (u##i64)
#define U64(u) (u##ui64)

#else
#define S64(u) (u##LL)
#define U64(u) (u##ULL)

#endif

// types

typedef signed char sint8;
typedef unsigned char uint8;

typedef signed short sint16;
typedef unsigned short uint16;

typedef signed int sint32;
typedef unsigned int uint32;

#ifdef _MSC_VER

typedef signed __int64 sint64;
typedef unsigned __int64 uint64;

#else

typedef signed long long int sint64;
typedef unsigned long long int uint64;

#endif

struct my_timer_t
    {
    double start_real;
    double start_cpu;
    double elapsed_real;
    double elapsed_cpu;
    bool running;
    };

// functions

extern void util_init();
extern void random_init();
extern int random(int n);
extern sint64 atoll(const char string []);
extern void send(const char format [], ...);
extern void show_version();
extern bool file_read_line(FILE *file, char string [], int size);
extern bool string_empty(const char string []);
extern bool string_equals(const char string_1 [], const char string_2 []);
extern char *strdup(const char string []);
extern void string_set(const char ** variable, const char string []);
extern void timer_reset(my_timer_t *timer);
extern void timer_start(my_timer_t *timer);
extern void timer_stop(my_timer_t *timer);
extern double timer_elapsed_real(const my_timer_t *timer);
extern double timer_elapsed_cpu(const my_timer_t *timer);

#endif // !defined UTIL_H

// end of util.h

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?