Skip to content

Commit 6b07f02

Browse files
committed
Merge branch 'devel'
2 parents fc47b87 + b731a5c commit 6b07f02

File tree

117 files changed

+1963
-511
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+1963
-511
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# SPDX-License-Identifier: GPL-2.0-or-later
22
CMakeFiles/
3+
Testing/
34
generated/
45
CMakeCache.txt
56
CTestTestfile.cmake

CMakeLists.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#
66

77
cmake_minimum_required(VERSION 3.12)
8-
project(bfdev VERSION 1.0.4 LANGUAGES C)
8+
project(bfdev VERSION 1.0.5 LANGUAGES C)
99

1010
include(GNUInstallDirs)
1111
include(CheckIncludeFiles)
@@ -36,6 +36,15 @@ include(scripts/commit.cmake)
3636

3737
commit_hash(BFDEV_COMMITID)
3838
commit_branch(BFDEV_BRANCH)
39+
string(TIMESTAMP BFDEV_BUILD_TIME "%A %B %d %H:%M:%S UTC %Y" UTC)
40+
41+
string(APPEND BFDEV_RELEASE
42+
"${PROJECT_NAME}-${BFDEV_NAME} "
43+
"${BFDEV_VERSION}.${BFDEV_ARCH} "
44+
"${BFDEV_COMMITID}-${BFDEV_BRANCH} "
45+
"(${CMAKE_C_COMPILER_ID} ${CMAKE_C_COMPILER_VERSION} ${CMAKE_HOST_SYSTEM_NAME}) "
46+
"${BFDEV_BUILD_TIME}"
47+
)
3948

4049
option(BFDEV_DEVEL "Enable development mode" OFF)
4150
option(BFDEV_STRICT "Enable strict compilation" ON)

cmake/config.h.in

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,10 @@ BFDEV_BEGIN_DECLS
1919
#define BFDEV_VERSION_TWEAK ${PROJECT_VERSION_TWEAK}
2020
#define BFDEV_EXTREVERSION ${BFDEV_EXTREVERSION}
2121

22-
#define BFDEV_ARCH ${BFDEV_ARCH}
2322
#define BFDEV_NAME ${BFDEV_NAME}
23+
#define BFDEV_ARCH ${BFDEV_ARCH}
2424
#define BFDEV_VERSION ${BFDEV_VERSION}
25-
26-
#define BFDEV_COMMITID ${BFDEV_COMMITID}
27-
#define BFDEV_BRANCH ${BFDEV_BRANCH}
25+
#define BFDEV_RELEASE "${BFDEV_RELEASE}"
2826

2927
#cmakedefine BFDEV_DEBUG_LIST
3028
#cmakedefine BFDEV_DEBUG_SLIST
@@ -43,6 +41,18 @@ BFDEV_BEGIN_DECLS
4341
(patch) <= BFDEV_VERSION_PATCH)) \
4442
)
4543

44+
static inline const char *
45+
bfdev_version(void)
46+
{
47+
return __bfdev_stringify(BFDEV_VERSION);
48+
}
49+
50+
static inline const char *
51+
bfdev_release(void)
52+
{
53+
return BFDEV_RELEASE;
54+
}
55+
4656
static inline int
4757
bfdev_version_major(void)
4858
{
@@ -63,4 +73,4 @@ bfdev_version_patch(void)
6373

6474
BFDEV_END_DECLS
6575

66-
#endif /*_BFDEV_CONFIG_H_*/
76+
#endif /* _BFDEV_CONFIG_H_ */

examples/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ add_subdirectory(btree)
1616
add_subdirectory(cache)
1717
add_subdirectory(circle)
1818
add_subdirectory(crc)
19+
add_subdirectory(crypto)
1920
add_subdirectory(fifo)
2021
add_subdirectory(fsm)
2122
add_subdirectory(guards)

examples/action/simple.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ test_action(void *pdata)
1717
return 0;
1818
}
1919

20-
int main(int argc, char **argv)
20+
int
21+
main(int argc, char **argv)
2122
{
2223
BFDEV_DEFINE_ACTION(action, test_action, NULL);
2324
int retval;

examples/allocator/simple.c

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ test_alloc(size_t size, void *pdata)
1212
return malloc(size);
1313
}
1414

15+
static void *
16+
test_zalloc(size_t size, void *pdata)
17+
{
18+
return calloc(1, size);
19+
}
20+
1521
static void *
1622
test_realloc(void *block, size_t resize, void *pdata)
1723
{
@@ -24,30 +30,31 @@ test_free(void *block, void *pdata)
2430
return free((void *)block);
2531
}
2632

27-
BFDEV_DEFINE_ALLOC(
33+
BFDEV_DEFINE_ALLOC_OPS(
2834
test_ops,
29-
test_alloc,
30-
test_realloc,
31-
test_free,
32-
NULL
35+
test_alloc, test_zalloc,
36+
test_realloc, test_free
3337
);
3438

35-
int main(int argc, char const *argv[])
39+
int
40+
main(int argc, char const *argv[])
3641
{
42+
BFDEV_DEFINE_ALLOC(test, &test_ops, NULL);
3743
int *block;
3844

39-
block = bfdev_malloc(&test_ops, sizeof(*block));
45+
block = bfdev_malloc(&test, sizeof(*block));
4046
if (!block)
4147
return 1;
42-
bfdev_free(&test_ops, block);
48+
bfdev_free(&test, block);
4349

44-
block = bfdev_zalloc(&test_ops, sizeof(*block));
50+
block = bfdev_zalloc(&test, sizeof(*block));
4551
if (!block)
4652
return 1;
47-
block = bfdev_realloc(&test_ops, block, sizeof(*block) * 2);
53+
54+
block = bfdev_realloc(&test, block, sizeof(*block) * 2);
4855
if (!block)
4956
return 1;
50-
bfdev_free(&test_ops, block);
57+
bfdev_free(&test, block);
5158

5259
return 0;
5360
}

examples/arc4/bandwidth.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
#define TEST_LOOP 3
1919
#define TEST_KEY 64
2020

21-
int main(int argc, const char *argv[])
21+
int
22+
main(int argc, const char *argv[])
2223
{
2324
bfdev_arc4_ctx_t sctx, dctx;
2425
unsigned int count, loop;

examples/array/simple.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
#define TEST_SIZE 64
1313
BFDEV_DEFINE_ARRAY(test_array, NULL, TEST_SIZE);
1414

15-
int main(int argc, const char *argv[])
15+
int
16+
main(int argc, const char *argv[])
1617
{
1718
unsigned int count;
1819
void *array;

examples/ascii85/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# SPDX-License-Identifier: GPL-2.0-or-later
22
/ascii85-bandwidth
3+
/ascii85

examples/ascii85/bandwidth.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
#define TEST_SIZE BFDEV_SZ_1MiB
1818
#define TEST_LOOP 3
1919

20-
int main(int argc, char const *argv[])
20+
int
21+
main(int argc, char const *argv[])
2122
{
2223
unsigned int count, loop;
2324
uint8_t *dbuff, *sbuff;

examples/base32/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# SPDX-License-Identifier: GPL-2.0-or-later
22
/base32-bandwidth
3+
/base32

examples/base32/bandwidth.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
#define TEST_SIZE BFDEV_SZ_1MiB
1818
#define TEST_LOOP 3
1919

20-
int main(int argc, char const *argv[])
20+
int
21+
main(int argc, char const *argv[])
2122
{
2223
unsigned int count, loop;
2324
uint8_t *dbuff, *sbuff;

examples/base64/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# SPDX-License-Identifier: GPL-2.0-or-later
22
/base64-bandwidth
3+
/base64

examples/base64/bandwidth.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
#define TEST_SIZE BFDEV_SZ_1MiB
1818
#define TEST_LOOP 3
1919

20-
int main(int argc, char const *argv[])
20+
int
21+
main(int argc, char const *argv[])
2122
{
2223
unsigned int count, loop;
2324
uint8_t *dbuff, *sbuff;

examples/bfdev/version.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,9 @@
66
#include <stdio.h>
77
#include <bfdev/config.h>
88

9-
int main(int argc, const char *argv[])
9+
int
10+
main(int argc, const char *argv[])
1011
{
11-
printf("arch: %s\n", __bfdev_stringify(BFDEV_ARCH));
12-
printf("name: %s\n", __bfdev_stringify(BFDEV_NAME));
13-
printf("version: %s\n", __bfdev_stringify(BFDEV_VERSION));
14-
printf("commitid: %s\n", __bfdev_stringify(BFDEV_COMMITID));
15-
printf("branch: %s\n", __bfdev_stringify(BFDEV_BRANCH));
12+
puts(bfdev_release());
1613
return 0;
1714
}

examples/bloom/simple.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ bloom_hash(unsigned int func, const void *key, void *pdata)
3535
return hash;
3636
}
3737

38-
int main(int argc, const char *argv[])
38+
int
39+
main(int argc, const char *argv[])
3940
{
4041
bfdev_bloom_t *bloom;
4142
char buffer[TEST_SIZE][32];

examples/btree/benchmark.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ bench_ops = {
3939
.find = bfdev_btree_key_find,
4040
};
4141

42-
int main(int argc, const char *argv[])
42+
int
43+
main(int argc, const char *argv[])
4344
{
4445
struct bench_node *node;
4546
unsigned int count;

examples/btree/selftest.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ test_testing(struct test_node *nodes)
178178
return 0;
179179
}
180180

181-
int main(int argc, const char *argv[])
181+
int
182+
main(int argc, const char *argv[])
182183
{
183184
struct test_node *bdata;
184185
int retval;

examples/cache/simple.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ cache_test(const char *name)
6565
return 0;
6666
}
6767

68-
int main(int argc, const char *argv[])
68+
int
69+
main(int argc, const char *argv[])
6970
{
7071
int retval;
7172

examples/circle/atomic.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ fifo_production(void *unused)
4848
return NULL;
4949
}
5050

51-
int main(int argc, const char *argv[])
51+
int
52+
main(int argc, const char *argv[])
5253
{
5354
unsigned int index;
5455
pthread_t thread;

examples/crc/bandwidth.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ for (count = 0; count < TEST_LOOP; ++count) { \
2929
); \
3030
}
3131

32-
int main(int argc, char const *argv[])
32+
int
33+
main(int argc, char const *argv[])
3334
{
3435
unsigned int count, loop;
3536
uint8_t *buff;

examples/crypto/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# SPDX-License-Identifier: GPL-2.0-or-later
2+
/crypto-bandwidth
3+
/crypto

examples/crypto/CMakeLists.txt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# SPDX-License-Identifier: GPL-2.0-or-later
2+
#
3+
# Copyright(c) 2023 John Sanpe <[email protected]>
4+
#
5+
6+
add_executable(crypto-bandwidth bandwidth.c)
7+
target_link_libraries(crypto-bandwidth bfdev)
8+
add_test(crypto-bandwidth crypto-bandwidth)
9+
10+
add_executable(crypto utils.c)
11+
target_link_libraries(crypto bfdev)
12+
13+
add_test(sha1 crypto "helloworld")
14+
add_test(sha224 crypto -l "helloworld")
15+
add_test(sha256 crypto -e "helloworld")
16+
add_test(md5 crypto -m "helloworld")
17+
18+
if(${CMAKE_PROJECT_NAME} STREQUAL "bfdev")
19+
install(FILES
20+
bandwidth.c
21+
utils.c
22+
DESTINATION
23+
${CMAKE_INSTALL_DOCDIR}/examples/crypto
24+
)
25+
26+
install(TARGETS
27+
crypto
28+
crypto-bandwidth
29+
DESTINATION
30+
${CMAKE_INSTALL_DOCDIR}/bin
31+
)
32+
endif()

0 commit comments

Comments
 (0)