Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .github/workflows/ubuntu-generic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: build generic on ubuntu gcc

on:
repository_dispatch:
workflow_dispatch:
push:
pull_request:
schedule:
- cron: '0 */2 * * *'

env:
BUILD_TYPE: Release

jobs:
build:
name: Test on ${{matrix.os}}
runs-on: ${{matrix.os}}
strategy:
matrix:
os: [ubuntu-22.04]

steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: install dependencies
run: |
sudo apt update
sudo apt install cmake make gcc ccache

- name: configure cmake
run: |
cmake -B ${{github.workspace}}/build \
-D CMAKE_INSTALL_PREFIX=${{github.workspace}}/build/install \
-D CMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \
-D CMAKE_C_COMPILER=/usr/lib/ccache/gcc \
-D CMAKE_SYSTEM_NAME=Generic -Wno-dev \
-D BFDEV_DEVEL=ON

- name: make
run: |
cmake --build ${{github.workspace}}/build \
--config ${{env.BUILD_TYPE}}

- name: install
run: |
cmake --build ${{github.workspace}}/build \
--config ${{env.BUILD_TYPE}} -- install
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ cmake_minimum_required(VERSION 3.12)
project(bfdev VERSION 1.0.6 LANGUAGES C)

include(GNUInstallDirs)
include(CheckIncludeFiles)
include(CheckIncludeFile)
include(CheckSymbolExists)
include(CheckTypeSize)

set(BFDEV_NAME sirius)
set(BFDEV_VERSION ${PROJECT_VERSION})
Expand All @@ -23,6 +25,7 @@ set(BFDEV_ARCH generic)
set(BFDEV_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
set(BFDEV_HEADER_PATH ${PROJECT_SOURCE_DIR}/include)
set(BFDEV_SOURCE_PATH ${PROJECT_SOURCE_DIR}/src)
set(BFDEV_PORT_PATH ${PROJECT_SOURCE_DIR}/port)
set(BFDEV_DOCUMENT_PATH ${PROJECT_SOURCE_DIR}/docs)
set(BFDEV_GENERATED_PATH ${PROJECT_BINARY_DIR}/generated)
set(BFDEV_EXPORT_PATH ${PROJECT_BINARY_DIR}/export)
Expand Down
2 changes: 2 additions & 0 deletions build.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ if(BFDEV_STRICT)
)
endif()

include(scripts/check.cmake)
include(scripts/sanitize.cmake)
include(scripts/asm-generic.cmake)

Expand Down Expand Up @@ -65,6 +66,7 @@ set(BFDEV_INCLUDE_DIRS
include_directories(${BFDEV_INCLUDE_DIRS})
include(${BFDEV_ARCH_PATH}/build.cmake)
include(${BFDEV_SOURCE_PATH}/build.cmake)
include(${BFDEV_PORT_PATH}/build.cmake)

set(BFDEV_LIBRARY_HEADER
${BFDEV_HEADER}
Expand Down
1 change: 1 addition & 0 deletions examples/ascii85/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <bfdev/log.h>
#include <bfdev/errname.h>
Expand Down
1 change: 1 addition & 0 deletions examples/base32/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <bfdev/log.h>
#include <bfdev/errname.h>
Expand Down
1 change: 1 addition & 0 deletions examples/base64/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <bfdev/log.h>
#include <bfdev/errname.h>
Expand Down
1 change: 1 addition & 0 deletions examples/bloom/simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdint.h>
#include <errno.h>
#include <err.h>
Expand Down
1 change: 1 addition & 0 deletions examples/btree/selftest.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
Expand Down
1 change: 1 addition & 0 deletions examples/cache/simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <time.h>
#include <err.h>
#include <bfdev/cache.h>
Expand Down
1 change: 1 addition & 0 deletions examples/crypto/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <bfdev/log.h>
#include <bfdev/errname.h>
#include <bfdev/sha1.h>
Expand Down
1 change: 1 addition & 0 deletions examples/fsm/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include <bfdev/fsm.h>

enum {
Expand Down
1 change: 1 addition & 0 deletions examples/glob/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#define MODULE_NAME "bfdev-glob"
#define bfdev_log_fmt(fmt) MODULE_NAME ": " fmt

#include <stdbool.h>
#include <bfdev/log.h>
#include <bfdev/glob.h>

Expand Down
1 change: 1 addition & 0 deletions examples/prandom/simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#define MODULE_NAME "prandom-simple"
#define bfdev_log_fmt(fmt) MODULE_NAME ": " fmt

#include <stdint.h>
#include <time.h>
#include <bfdev/log.h>
#include <bfdev/prandom.h>
Expand Down
1 change: 1 addition & 0 deletions examples/ratelimit/simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#define MODULE_NAME "ratelimit-simple"
#define bfdev_log_fmt(fmt) MODULE_NAME ": " fmt

#include <stdbool.h>
#include <time.h>
#include <unistd.h>
#include <bfdev/log.h>
Expand Down
1 change: 1 addition & 0 deletions examples/time.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#define _EXAMPLES_TIME_H_

#include <stdio.h>
#include <stdint.h>
#include <time.h>
#include <unistd.h>
#include <sys/time.h>
Expand Down
1 change: 1 addition & 0 deletions examples/tokenbucket/simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#define MODULE_NAME "tokenbucket-simple"
#define bfdev_log_fmt(fmt) MODULE_NAME ": " fmt

#include <stdbool.h>
#include <time.h>
#include <unistd.h>
#include <bfdev/log.h>
Expand Down
2 changes: 0 additions & 2 deletions include/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
#include <bfdev/types.h>
#include <bfdev/stdarg.h>
#include <bfdev/stddef.h>
#include <bfdev/stdio.h>
#include <bfdev/stdlib.h>

#include <bfdev/align.h>
#include <bfdev/alloca.h>
Expand Down
2 changes: 1 addition & 1 deletion include/bfdev/action.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ bfdev_action_update(bfdev_action_t *action, const void *data)
static inline void
bfdev_action_clear(bfdev_action_t *action)
{
action->func = NULL;
action->func = BFDEV_NULL;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions include/bfdev/align.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ BFDEV_BEGIN_DECLS
* @align: check alignment size.
*/
#define bfdev_align_ptr_check(ptr, align) ( \
bfdev_align_check((uintptr_t)(ptr), align) \
bfdev_align_check((bfdev_uintptr_t)(ptr), align) \
)

/**
Expand Down Expand Up @@ -57,7 +57,7 @@ BFDEV_BEGIN_DECLS
* @align: alignment size.
*/
#define bfdev_align_ptr_low(ptr, align) ({ \
(typeof(ptr))bfdev_align_low((uintptr_t)(ptr), align); \
(typeof(ptr))bfdev_align_low((bfdev_uintptr_t)(ptr), align); \
})

/**
Expand All @@ -66,7 +66,7 @@ BFDEV_BEGIN_DECLS
* @align: alignment size.
*/
#define bfdev_align_ptr_high(ptr, align) ({ \
(typeof(ptr))bfdev_align_high((uintptr_t)(ptr), align); \
(typeof(ptr))bfdev_align_high((bfdev_uintptr_t)(ptr), align); \
})

#define bfdev_align_low_adj(value, align) ({ \
Expand Down
13 changes: 7 additions & 6 deletions include/bfdev/allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,14 @@ bfdev_alloc_ops_init(bfdev_alloc_ops_t *ops,
}

extern __bfdev_malloc void *
bfdev_malloc(const bfdev_alloc_t *alloc, size_t size);
bfdev_malloc(const bfdev_alloc_t *alloc, bfdev_size_t size);

extern __bfdev_malloc void *
bfdev_zalloc(const bfdev_alloc_t *alloc, size_t size);
bfdev_zalloc(const bfdev_alloc_t *alloc, bfdev_size_t size);

extern __bfdev_malloc void *
bfdev_realloc(const bfdev_alloc_t *alloc, const void *block, size_t resize);
bfdev_realloc(const bfdev_alloc_t *alloc, const void *block,
bfdev_size_t resize);

extern void
bfdev_free(const bfdev_alloc_t *alloc, const void *block);
Expand All @@ -94,7 +95,7 @@ bfdev_free(const bfdev_alloc_t *alloc, const void *block);
*/
static __bfdev_always_inline __bfdev_malloc void *
bfdev_malloc_array(const bfdev_alloc_t *alloc,
size_t nr, size_t size)
bfdev_size_t nr, bfdev_size_t size)
{
return bfdev_malloc(alloc, size * nr);
}
Expand All @@ -106,7 +107,7 @@ bfdev_malloc_array(const bfdev_alloc_t *alloc,
*/
static __bfdev_always_inline __bfdev_malloc void *
bfdev_zalloc_array(const bfdev_alloc_t *alloc,
size_t nr, size_t size)
bfdev_size_t nr, bfdev_size_t size)
{
return bfdev_zalloc(alloc, size * nr);
}
Expand All @@ -119,7 +120,7 @@ bfdev_zalloc_array(const bfdev_alloc_t *alloc,
*/
static __bfdev_always_inline __bfdev_malloc void *
bfdev_realloc_array(const bfdev_alloc_t *alloc,
void *block, size_t nr, size_t size)
void *block, bfdev_size_t nr, bfdev_size_t size)
{
return bfdev_realloc(alloc, block, size * nr);
}
Expand Down
9 changes: 5 additions & 4 deletions include/bfdev/allocpool.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ typedef struct bfdev_allocpool bfdev_allocpool_t;

struct bfdev_allocpool {
void *block;
size_t size;
uintptr_t last;
bfdev_size_t size;
bfdev_uintptr_t last;
unsigned long count;
};

Expand All @@ -38,7 +38,7 @@ struct bfdev_allocpool {
* @size: mempool array size.
*/
static inline void
bfdev_allocpool_init(bfdev_allocpool_t *pool, void *block, size_t size)
bfdev_allocpool_init(bfdev_allocpool_t *pool, void *block, bfdev_size_t size)
{
*pool = BFDEV_ALLOCPOOL_INIT(block, size);
}
Expand All @@ -61,7 +61,8 @@ bfdev_allocpool_reset(bfdev_allocpool_t *pool)
* @align: align to allocation.
*/
extern __bfdev_malloc void *
bfdev_allocpool_alloc(bfdev_allocpool_t *pool, size_t size, size_t align);
bfdev_allocpool_alloc(bfdev_allocpool_t *pool, bfdev_size_t size,
bfdev_size_t align);

/**
* bfdev_allocpool_free() - Allocation mempool free.
Expand Down
10 changes: 5 additions & 5 deletions include/bfdev/arc4.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ BFDEV_BEGIN_DECLS
typedef struct bfdev_arc4_ctx bfdev_arc4_ctx_t;

struct bfdev_arc4_ctx {
uint8_t box[BFDEV_ARC4_KSIZE];
uint8_t proa;
uint8_t prob;
bfdev_u8 box[BFDEV_ARC4_KSIZE];
bfdev_u8 proa;
bfdev_u8 prob;
};

extern void
bfdev_arc4_trans(bfdev_arc4_ctx_t *ctx, void *buff,
const void *data, size_t size);
const void *data, bfdev_size_t size);

extern void
bfdev_arc4_setkey(bfdev_arc4_ctx_t *ctx,
const uint8_t *key, unsigned int klen);
const bfdev_u8 *key, unsigned int klen);

BFDEV_END_DECLS

Expand Down
11 changes: 6 additions & 5 deletions include/bfdev/array.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ struct bfdev_array {
const bfdev_alloc_t *alloc;
unsigned long capacity;
unsigned long index;
size_t cells;
bfdev_size_t cells;
void *data;
};

Expand All @@ -54,7 +54,8 @@ struct bfdev_array {
* @cells: the size per elements.
*/
static inline void
bfdev_array_init(bfdev_array_t *array, const bfdev_alloc_t *alloc, size_t cells)
bfdev_array_init(bfdev_array_t *array, const bfdev_alloc_t *alloc,
bfdev_size_t cells)
{
*array = BFDEV_ARRAY_INIT(alloc, cells);
}
Expand Down Expand Up @@ -92,7 +93,7 @@ bfdev_array_index(const bfdev_array_t *array)
* Returns the total size of elements stored in
* the array container.
*/
static inline size_t
static inline bfdev_size_t
bfdev_array_size(const bfdev_array_t *array)
{
return array->cells * array->index;
Expand All @@ -106,7 +107,7 @@ bfdev_array_size(const bfdev_array_t *array)
* Return the address offset of the object indexed
* by @index in the array.
*/
static inline uintptr_t
static inline bfdev_uintptr_t
bfdev_array_offset(const bfdev_array_t *array, unsigned long index)
{
return array->cells * index;
Expand All @@ -124,7 +125,7 @@ static inline void *
bfdev_array_data(const bfdev_array_t *array, unsigned long index)
{
if (bfdev_unlikely(index >= array->index))
return NULL;
return BFDEV_NULL;

return array->data + bfdev_array_offset(array, index);
}
Expand Down
Loading
Loading