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
60 changes: 60 additions & 0 deletions .github/workflows/ubuntu-aarch64-gcc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: build default on ubuntu aarch64 gcc

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

env:
BUILD_TYPE: Release
LD_LIBRARY_PATH: /usr/aarch64-linux-gnu/lib

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 qemu-user-binfmt \
gcc gcc-aarch64-linux-gnu

- 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=aarch64-linux-gnu-gcc \
-D HOST_C_COMPILER=gcc \
-D BFDEV_STRICT=ON \
-D BFDEV_EXAMPLES=ON \
-D BFDEV_TESTSUITE=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

- name: ctest
working-directory: ${{github.workspace}}/build
run: |
sudo ln -s /usr/aarch64-linux-gnu/lib/ld-linux-aarch64.so.1 /lib
ctest -C ${{env.BUILD_TYPE}} -V
60 changes: 60 additions & 0 deletions .github/workflows/ubuntu-armv7-gcc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: build default on ubuntu armv7 gcc

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

env:
BUILD_TYPE: Release
LD_LIBRARY_PATH: /usr/arm-linux-gnueabihf/lib

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 qemu-user-binfmt \
gcc gcc-arm-linux-gnueabihf

- 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=arm-linux-gnueabihf-gcc \
-D HOST_C_COMPILER=gcc \
-D BFDEV_STRICT=ON \
-D BFDEV_EXAMPLES=ON \
-D BFDEV_TESTSUITE=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

- name: ctest
working-directory: ${{github.workspace}}/build
run: |
sudo ln -s /usr/arm-linux-gnueabihf/lib/ld-linux-armhf.so.3 /lib
ctest -C ${{env.BUILD_TYPE}} -V
60 changes: 60 additions & 0 deletions .github/workflows/ubuntu-mips-gcc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: build default on ubuntu mips gcc

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

env:
BUILD_TYPE: Release
LD_LIBRARY_PATH: /usr/mips-linux-gnu/lib

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 qemu-user-binfmt \
gcc gcc-mips-linux-gnu

- 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=mips-linux-gnu-gcc \
-D HOST_C_COMPILER=gcc \
-D BFDEV_STRICT=ON \
-D BFDEV_EXAMPLES=ON \
-D BFDEV_TESTSUITE=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

- name: ctest
working-directory: ${{github.workspace}}/build
run: |
sudo ln -s /usr/mips-linux-gnu/lib/ld.so.1 /lib
ctest -C ${{env.BUILD_TYPE}} -V
60 changes: 60 additions & 0 deletions .github/workflows/ubuntu-mips64-gcc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: build default on ubuntu mips64 gcc

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

env:
BUILD_TYPE: Release
LD_LIBRARY_PATH: /usr/mips64-linux-gnuabi64/lib

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 qemu-user-binfmt \
gcc gcc-mips64-linux-gnuabi64

- 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=mips64-linux-gnuabi64-gcc \
-D HOST_C_COMPILER=gcc \
-D BFDEV_STRICT=ON \
-D BFDEV_EXAMPLES=ON \
-D BFDEV_TESTSUITE=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

- name: ctest
working-directory: ${{github.workspace}}/build
run: |
sudo ln -s /usr/mips64-linux-gnuabi64/lib/ld.so.1 /lib64
ctest -C ${{env.BUILD_TYPE}} -V
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@ bfdev is a high-performance, aesthetically pleasing, and portable infrastructure

## Continuous Integration Status

| Status (master) | Status (devel) | Description |
| :----------------------------------------------------------: | :----------------------------------------------------------: | :----------------------------------: |
| [![build status](https://github.com/openbfdev/bfdev/actions/workflows/ubuntu-gcc.yml/badge.svg?branch=master)](https://github.com/openbfdev/bfdev/actions/workflows/ubuntu-gcc.yml?query=branch%3Amaster) | [![build status](https://github.com/openbfdev/bfdev/actions/workflows/ubuntu-gcc.yml/badge.svg?branch=devel)](https://github.com/openbfdev/bfdev/actions/workflows/ubuntu-gcc.yml?query=branch%3Adevel) | Build default config on Ubuntu gcc |
| [![build status](https://github.com/openbfdev/bfdev/actions/workflows/ubuntu-clang.yml/badge.svg?branch=master)](https://github.com/openbfdev/bfdev/actions/workflows/ubuntu-clang.yml?query=branch%3Amaster) | [![build status](https://github.com/openbfdev/bfdev/actions/workflows/ubuntu-clang.yml/badge.svg?branch=devel)](https://github.com/openbfdev/bfdev/actions/workflows/ubuntu-clang.yml?query=branch%3Adevel) | Build default config on Ubuntu clang |
| [![build status](https://github.com/openbfdev/bfdev/actions/workflows/macos.yml/badge.svg?branch=master)](https://github.com/openbfdev/bfdev/actions/workflows/macos.yml?query=branch%3Amaster) | [![build status](https://github.com/openbfdev/bfdev/actions/workflows/macos.yml/badge.svg?branch=devel)](https://github.com/openbfdev/bfdev/actions/workflows/macos.yml?query=branch%3Adevel) | Build default config on Macos |
| [![build status](https://github.com/openbfdev/bfdev/actions/workflows/windows.yml/badge.svg?branch=master)](https://github.com/openbfdev/bfdev/actions/workflows/windows.yml?query=branch%3Amaster) | [![build status](https://github.com/openbfdev/bfdev/actions/workflows/windows.yml/badge.svg?branch=devel)](https://github.com/openbfdev/bfdev/actions/workflows/windows.yml?query=branch%3Adevel) | Build default config on Windows |
| [![build status](https://github.com/openbfdev/bfdev/actions/workflows/codeql.yml/badge.svg?branch=master)](https://github.com/openbfdev/bfdev/actions/workflows/codeql.yml?query=branch%3Amaster) | [![build status](https://github.com/openbfdev/bfdev/actions/workflows/codeql.yml/badge.svg?branch=devel)](https://github.com/openbfdev/bfdev/actions/workflows/codeql.yml?query=branch%3Adevel) | Code analyse on codeql |
| Status (master) | Status (devel) | Description |
| :-------------: | :------------: | :---------: |
| [![build status](https://github.com/openbfdev/bfdev/actions/workflows/ubuntu-gcc.yml/badge.svg?branch=master)](https://github.com/openbfdev/bfdev/actions/workflows/ubuntu-gcc.yml?query=branch%3Amaster) | [![build status](https://github.com/openbfdev/bfdev/actions/workflows/ubuntu-gcc.yml/badge.svg?branch=devel)](https://github.com/openbfdev/bfdev/actions/workflows/ubuntu-gcc.yml?query=branch%3Adevel) | Build default config on Ubuntu GCC |
| [![build status](https://github.com/openbfdev/bfdev/actions/workflows/ubuntu-clang.yml/badge.svg?branch=master)](https://github.com/openbfdev/bfdev/actions/workflows/ubuntu-clang.yml?query=branch%3Amaster) | [![build status](https://github.com/openbfdev/bfdev/actions/workflows/ubuntu-clang.yml/badge.svg?branch=devel)](https://github.com/openbfdev/bfdev/actions/workflows/ubuntu-clang.yml?query=branch%3Adevel) | Build default config on Ubuntu Clang |
| [![build status](https://github.com/openbfdev/bfdev/actions/workflows/macos.yml/badge.svg?branch=master)](https://github.com/openbfdev/bfdev/actions/workflows/macos.yml?query=branch%3Amaster) | [![build status](https://github.com/openbfdev/bfdev/actions/workflows/macos.yml/badge.svg?branch=devel)](https://github.com/openbfdev/bfdev/actions/workflows/macos.yml?query=branch%3Adevel) | Build default config on Macos |
| [![build status](https://github.com/openbfdev/bfdev/actions/workflows/windows.yml/badge.svg?branch=master)](https://github.com/openbfdev/bfdev/actions/workflows/windows.yml?query=branch%3Amaster) | [![build status](https://github.com/openbfdev/bfdev/actions/workflows/windows.yml/badge.svg?branch=devel)](https://github.com/openbfdev/bfdev/actions/workflows/windows.yml?query=branch%3Adevel) | Build default config on Windows |
| [![build status](https://github.com/openbfdev/bfdev/actions/workflows/ubuntu-armv7-gcc.yml/badge.svg?branch=master)](https://github.com/openbfdev/bfdev/actions/workflows/ubuntu-armv7-gcc.yml?query=branch%3Amaster) | [![build status](https://github.com/openbfdev/bfdev/actions/workflows/ubuntu-armv7-gcc.yml/badge.svg?branch=devel)](https://github.com/openbfdev/bfdev/actions/workflows/ubuntu-armv7-gcc.yml?query=branch%3Adevel) | Cross build ARMv7 default on Ubuntu GCC |
| [![build status](https://github.com/openbfdev/bfdev/actions/workflows/ubuntu-aarch64-gcc.yml/badge.svg?branch=master)](https://github.com/openbfdev/bfdev/actions/workflows/ubuntu-aarch64-gcc.yml?query=branch%3Amaster) | [![build status](https://github.com/openbfdev/bfdev/actions/workflows/ubuntu-aarch64-gcc.yml/badge.svg?branch=devel)](https://github.com/openbfdev/bfdev/actions/workflows/ubuntu-aarch64-gcc.yml?query=branch%3Adevel) | Cross build AArch64 default on Ubuntu GCC |
| [![build status](https://github.com/openbfdev/bfdev/actions/workflows/ubuntu-mips-gcc.yml/badge.svg?branch=master)](https://github.com/openbfdev/bfdev/actions/workflows/ubuntu-mips-gcc.yml?query=branch%3Amaster) | [![build status](https://github.com/openbfdev/bfdev/actions/workflows/ubuntu-mips-gcc.yml/badge.svg?branch=devel)](https://github.com/openbfdev/bfdev/actions/workflows/ubuntu-mips-gcc.yml?query=branch%3Adevel) | Cross build MIPS default on Ubuntu GCC |
| [![build status](https://github.com/openbfdev/bfdev/actions/workflows/ubuntu-mips64-gcc.yml/badge.svg?branch=master)](https://github.com/openbfdev/bfdev/actions/workflows/ubuntu-mips64-gcc.yml?query=branch%3Amaster) | [![build status](https://github.com/openbfdev/bfdev/actions/workflows/ubuntu-mips64-gcc.yml/badge.svg?branch=devel)](https://github.com/openbfdev/bfdev/actions/workflows/ubuntu-mips64-gcc.yml?query=branch%3Adevel) | Cross build MIPS64 default on Ubuntu GCC |
| [![build status](https://github.com/openbfdev/bfdev/actions/workflows/codeql.yml/badge.svg?branch=master)](https://github.com/openbfdev/bfdev/actions/workflows/codeql.yml?query=branch%3Amaster) | [![build status](https://github.com/openbfdev/bfdev/actions/workflows/codeql.yml/badge.svg?branch=devel)](https://github.com/openbfdev/bfdev/actions/workflows/codeql.yml?query=branch%3Adevel) | Code analyse on codeql |

## Why Choose

Expand Down
23 changes: 13 additions & 10 deletions include/bfdev/bitmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ BFDEV_BEGIN_DECLS
bfdev_align_check(bits, BFDEV_BITMAP_ALIGN) \
)

#define bfdev_bitmap_size(nbits) \
BFDEV_BITS_DIV_U8(bfdev_align_high(nbits, BFDEV_BITS_PER_LONG))

static __bfdev_always_inline bfdev_bool
bfdev_bitmap_empty(const unsigned long *src, unsigned int bits)
{
Expand All @@ -45,7 +48,7 @@ bfdev_bitmap_empty(const unsigned long *src, unsigned int bits)
if (!bfdev_bitmap_const_aligned(bits))
return bfdev_find_first_bit(src, bits) >= bits;

return !bfdev_memdiff(src, BFDEV_UINT8_MIN, bits / BFDEV_BITS_PER_BYTE);
return !bfdev_memdiff(src, BFDEV_UINT8_MIN, BFDEV_BITS_DIV_U8(bits));
}

static __bfdev_always_inline bfdev_bool
Expand All @@ -57,7 +60,7 @@ bfdev_bitmap_full(const unsigned long *src, unsigned int bits)
if (!bfdev_bitmap_const_aligned(bits))
return bfdev_find_first_zero(src, bits) >= bits;

return !bfdev_memdiff(src, BFDEV_UINT8_MAX, bits / BFDEV_BITS_PER_BYTE);
return !bfdev_memdiff(src, BFDEV_UINT8_MAX, BFDEV_BITS_DIV_U8(bits));
}

static __bfdev_always_inline bfdev_bool
Expand All @@ -70,7 +73,7 @@ bfdev_bitmap_equal(const unsigned long *src1, const unsigned long *src2,
if (!bfdev_bitmap_const_aligned(bits))
return bfdev_bitmap_comp_equal(src1, src2, bits);

return bfdev_memcmp(src1, src2, bits / BFDEV_BITS_PER_BYTE);
return bfdev_memcmp(src1, src2, BFDEV_BITS_DIV_U8(bits));
}

static __bfdev_always_inline bfdev_bool
Expand Down Expand Up @@ -202,8 +205,8 @@ bfdev_bitmap_set(unsigned long *bitmap, unsigned int start, unsigned int bits)
!bfdev_bitmap_const_aligned(bits))
return bfdev_bitmap_comp_set(bitmap, start, bits);

offset = start / BFDEV_BITS_PER_BYTE;
size = bits / BFDEV_BITS_PER_BYTE;
offset = BFDEV_BITS_DIV_U8(start);
size = BFDEV_BITS_DIV_U8(bits);

bfdev_memset((char *)bitmap + offset, 0xff, size);
}
Expand All @@ -220,8 +223,8 @@ bfdev_bitmap_clr(unsigned long *bitmap, unsigned int start, unsigned int bits)
!bfdev_bitmap_const_aligned(bits))
return bfdev_bitmap_comp_clr(bitmap, start, bits);

offset = start / BFDEV_BITS_PER_BYTE;
size = bits / BFDEV_BITS_PER_BYTE;
offset = BFDEV_BITS_DIV_U8(start);
size = BFDEV_BITS_DIV_U8(bits);

bfdev_memset((char *)bitmap + offset, 0, size);
}
Expand All @@ -236,7 +239,7 @@ bfdev_bitmap_zero(unsigned long *bitmap, unsigned int bits)
return;
}

length = BFDEV_BITS_TO_U8(bits);
length = bfdev_bitmap_size(bits);
bfdev_memset(bitmap, 0, length);
}

Expand All @@ -250,7 +253,7 @@ bfdev_bitmap_fill(unsigned long *bitmap, unsigned int bits)
return;
}

length = BFDEV_BITS_TO_U8(bits);
length = bfdev_bitmap_size(bits);
bfdev_memset(bitmap, BFDEV_UINT8_MAX, length);
}

Expand All @@ -264,7 +267,7 @@ bfdev_bitmap_copy(unsigned long *dest, unsigned long *src, unsigned int bits)
return;
}

length = BFDEV_BITS_TO_U8(bits);
length = bfdev_bitmap_size(bits);
bfdev_memcpy(dest, src, length);
}

Expand Down
Loading
Loading