switch to s8...s64 and u8...u64 integer notation
This commit is contained in:
@@ -30,6 +30,11 @@
|
|||||||
ERROR_64_BYTES_WORDSIZE_ONLY
|
ERROR_64_BYTES_WORDSIZE_ONLY
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
typedef int64_t s64;
|
||||||
|
typedef int32_t s32;
|
||||||
|
typedef int16_t s16;
|
||||||
|
typedef int8_t s8;
|
||||||
|
|
||||||
typedef uint64_t u64;
|
typedef uint64_t u64;
|
||||||
typedef uint32_t u32;
|
typedef uint32_t u32;
|
||||||
typedef uint16_t u16;
|
typedef uint16_t u16;
|
||||||
|
@@ -82,12 +82,12 @@ typedef unsigned char castle_t;
|
|||||||
|
|
||||||
/* bitboard
|
/* bitboard
|
||||||
*/
|
*/
|
||||||
typedef uint64_t bitboard_t;
|
typedef u64 bitboard_t;
|
||||||
|
|
||||||
|
|
||||||
/* eval type
|
/* eval type
|
||||||
*/
|
*/
|
||||||
typedef int64_t eval_t;
|
typedef u64 eval_t;
|
||||||
|
|
||||||
/* forward typedefs
|
/* forward typedefs
|
||||||
*/
|
*/
|
||||||
|
16
src/debug.c
16
src/debug.c
@@ -19,17 +19,17 @@
|
|||||||
#define NANOSEC 1000000000 /* nano sec in sec */
|
#define NANOSEC 1000000000 /* nano sec in sec */
|
||||||
#define MILLISEC 1000000 /* milli sec in sec */
|
#define MILLISEC 1000000 /* milli sec in sec */
|
||||||
|
|
||||||
static int64_t timer_start; /* in nanosecond */
|
static s64 timer_start; /* in nanosecond */
|
||||||
static uint32_t debug_level=0;
|
static u32 debug_level=0;
|
||||||
|
|
||||||
void debug_level_set(uint32_t level)
|
void debug_level_set(u32 level)
|
||||||
{
|
{
|
||||||
debug_level = level;;
|
debug_level = level;;
|
||||||
|
|
||||||
log(0, "debug level set to %u\n", level);
|
log(0, "debug level set to %u\n", level);
|
||||||
}
|
}
|
||||||
|
|
||||||
void debug_init(uint32_t level)
|
void debug_init(u32 level)
|
||||||
{
|
{
|
||||||
struct timespec timer;
|
struct timespec timer;
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ void debug_init(uint32_t level)
|
|||||||
log(0, "timer started.\n");
|
log(0, "timer started.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
inline static int64_t timer_elapsed()
|
inline static s64 timer_elapsed()
|
||||||
{
|
{
|
||||||
struct timespec timer;
|
struct timespec timer;
|
||||||
|
|
||||||
@@ -58,8 +58,8 @@ inline static int64_t timer_elapsed()
|
|||||||
* @src : source file/func name (or NULL)
|
* @src : source file/func name (or NULL)
|
||||||
* @line : line number
|
* @line : line number
|
||||||
*/
|
*/
|
||||||
void debug(uint32_t level, bool timestamp, uint32_t indent, const char *src,
|
void debug(u32 level, bool timestamp, u32 indent, const char *src,
|
||||||
uint32_t line, const char *fmt, ...)
|
u32 line, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
if (level > debug_level)
|
if (level > debug_level)
|
||||||
return;
|
return;
|
||||||
@@ -70,7 +70,7 @@ void debug(uint32_t level, bool timestamp, uint32_t indent, const char *src,
|
|||||||
printf("%*s", 2*(indent-1), "");
|
printf("%*s", 2*(indent-1), "");
|
||||||
|
|
||||||
if (timestamp) {
|
if (timestamp) {
|
||||||
int64_t diff = timer_elapsed();
|
s64 diff = timer_elapsed();
|
||||||
printf("%ld.%03ld ", diff/NANOSEC, (diff/1000000)%1000);
|
printf("%ld.%03ld ", diff/NANOSEC, (diff/1000000)%1000);
|
||||||
printf("%010ld ", diff);
|
printf("%010ld ", diff);
|
||||||
}
|
}
|
||||||
|
12
src/debug.h
12
src/debug.h
@@ -17,11 +17,13 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
void debug_init(uint32_t level);
|
#include "bits.h"
|
||||||
void debug_level_set(uint32_t level);
|
|
||||||
void debug_devel_set(uint32_t level);
|
void debug_init(u32 level);
|
||||||
void debug(uint32_t level, bool timestamp, uint32_t indent,
|
void debug_level_set(u32 level);
|
||||||
const char *src, uint32_t line, const char *, ...);
|
void debug_devel_set(u32 level);
|
||||||
|
void debug(u32 level, bool timestamp, u32 indent,
|
||||||
|
const char *src, u32 line, const char *, ...);
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
|
||||||
|
@@ -34,7 +34,7 @@ typedef struct piece_list_s {
|
|||||||
piece_t piece;
|
piece_t piece;
|
||||||
square_t square;
|
square_t square;
|
||||||
short castle;
|
short castle;
|
||||||
int64_t value;
|
s64 value;
|
||||||
struct list_head list;
|
struct list_head list;
|
||||||
} piece_list_t;
|
} piece_list_t;
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ extern struct piece_details {
|
|||||||
char *symbol_w;
|
char *symbol_w;
|
||||||
char *symbol_b; /* used for game notation */
|
char *symbol_b; /* used for game notation */
|
||||||
char *name;
|
char *name;
|
||||||
int64_t value;
|
s64 value;
|
||||||
} piece_details[];
|
} piece_details[];
|
||||||
|
|
||||||
#define P_NAME(p) piece_details[E_PIECE(p)].name
|
#define P_NAME(p) piece_details[E_PIECE(p)].name
|
||||||
|
13
src/pool.c
13
src/pool.c
@@ -23,6 +23,7 @@
|
|||||||
#include "list.h"
|
#include "list.h"
|
||||||
#include "pool.h"
|
#include "pool.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
#include "bits.h"
|
||||||
|
|
||||||
void pool_stats(pool_t *pool)
|
void pool_stats(pool_t *pool)
|
||||||
{
|
{
|
||||||
@@ -35,7 +36,7 @@ void pool_stats(pool_t *pool)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pool_t *pool_init(const char *name, uint32_t growsize, size_t eltsize)
|
pool_t *pool_init(const char *name, u32 growsize, size_t eltsize)
|
||||||
{
|
{
|
||||||
pool_t *pool;
|
pool_t *pool;
|
||||||
|
|
||||||
@@ -57,7 +58,7 @@ pool_t *pool_init(const char *name, uint32_t growsize, size_t eltsize)
|
|||||||
return pool;
|
return pool;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t _pool_add(pool_t *pool, struct list_head *elt)
|
static u32 _pool_add(pool_t *pool, struct list_head *elt)
|
||||||
{
|
{
|
||||||
# ifdef DEBUG_POOL
|
# ifdef DEBUG_POOL
|
||||||
log_f(10, "pool=%p &head=%p elt=%p off1=%lu off2=%lu\n",
|
log_f(10, "pool=%p &head=%p elt=%p off1=%lu off2=%lu\n",
|
||||||
@@ -72,7 +73,7 @@ static uint32_t _pool_add(pool_t *pool, struct list_head *elt)
|
|||||||
return ++pool->available;
|
return ++pool->available;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t pool_add(pool_t *pool, void *elt)
|
u32 pool_add(pool_t *pool, void *elt)
|
||||||
{
|
{
|
||||||
return _pool_add(pool, elt);
|
return _pool_add(pool, elt);
|
||||||
}
|
}
|
||||||
@@ -92,7 +93,7 @@ void *pool_get(pool_t *pool)
|
|||||||
if (!pool->available) {
|
if (!pool->available) {
|
||||||
void *alloc = malloc(pool->eltsize * pool->growsize);
|
void *alloc = malloc(pool->eltsize * pool->growsize);
|
||||||
void *cur;
|
void *cur;
|
||||||
uint32_t i;
|
u32 i;
|
||||||
# ifdef DEBUG_POOL
|
# ifdef DEBUG_POOL
|
||||||
log_f(1, "[%s]: growing pool from %u to %u elements.\n",
|
log_f(1, "[%s]: growing pool from %u to %u elements.\n",
|
||||||
pool->name,
|
pool->name,
|
||||||
@@ -125,7 +126,7 @@ void *pool_get(pool_t *pool)
|
|||||||
|
|
||||||
#ifdef BIN_pool
|
#ifdef BIN_pool
|
||||||
struct d {
|
struct d {
|
||||||
uint16_t data1;
|
u16 data1;
|
||||||
char c;
|
char c;
|
||||||
struct list_head list;
|
struct list_head list;
|
||||||
};
|
};
|
||||||
@@ -137,7 +138,7 @@ int main(int ac, char**av)
|
|||||||
pool_t *pool;
|
pool_t *pool;
|
||||||
int total;
|
int total;
|
||||||
int action=0;
|
int action=0;
|
||||||
uint16_t icur=0;
|
u16 icur=0;
|
||||||
char ccur='z';
|
char ccur='z';
|
||||||
struct d *elt;
|
struct d *elt;
|
||||||
|
|
||||||
|
11
src/pool.h
11
src/pool.h
@@ -17,19 +17,20 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
|
#include "bits.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char *name;
|
char *name;
|
||||||
uint32_t available;
|
u32 available;
|
||||||
uint32_t allocated;
|
u32 allocated;
|
||||||
uint32_t growsize;
|
u32 growsize;
|
||||||
size_t eltsize;
|
size_t eltsize;
|
||||||
struct list_head head;
|
struct list_head head;
|
||||||
} pool_t;
|
} pool_t;
|
||||||
|
|
||||||
void pool_stats(pool_t *pool);
|
void pool_stats(pool_t *pool);
|
||||||
pool_t *pool_init(const char *name, uint32_t grow, size_t size);
|
pool_t *pool_init(const char *name, u32 grow, size_t size);
|
||||||
void *pool_get(pool_t *pool);
|
void *pool_get(pool_t *pool);
|
||||||
uint32_t pool_add(pool_t *pool, void *elt);
|
u32 pool_add(pool_t *pool, void *elt);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user