Skip to content

Commit 717a40b

Browse files
authored
Merge pull request #7 from zombocoder/feature/freebsd-support
Add FreeBSD build support
2 parents 7a8c314 + 047993f commit 717a40b

4 files changed

Lines changed: 25 additions & 9 deletions

File tree

README.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ A high-performance, single-file container format for storing files and directori
1515
- **Optional compression** - ZSTD compression with intelligent content analysis
1616
- **Optional encryption** - ChaCha20-Poly1305 AEAD with Argon2id key derivation
1717
- **Integrity validation** - CRC32C checksums with hardware acceleration
18-
- **Cross-platform** - Works on Linux, macOS, and other Unix systems
18+
- **Cross-platform** - Works on Linux, macOS, FreeBSD, and other Unix systems
1919
- **Crash-safe writes** - Atomic container creation with index at EOF
2020
- **Memory efficient** - Optimized for large containers and small memory footprint
2121

@@ -53,6 +53,7 @@ cmake --build build
5353
**Optional dependencies:**
5454
- ZSTD library for compression support
5555
- libsodium for encryption support
56+
- pkg-config (or pkgconf on FreeBSD) for dependency detection
5657

5758
### Build from source
5859

@@ -72,6 +73,20 @@ cmake --build build
7273
sudo cmake --install build --prefix /usr/local
7374
```
7475

76+
**FreeBSD-specific setup:**
77+
78+
```bash
79+
# Install dependencies
80+
sudo pkg install cmake pkgconf libzstd libsodium
81+
82+
# Build (uses gmake wrapper)
83+
make
84+
85+
# Or use cmake directly
86+
cmake -B build -DCMAKE_BUILD_TYPE=Release -DBFC_WITH_ZSTD=ON -DBFC_WITH_SODIUM=ON
87+
make -C build
88+
```
89+
7590
### Build options
7691

7792
```bash
@@ -618,9 +633,9 @@ limitations under the License.
618633
- Initial release
619634
- Complete CLI tool with create, list, extract, info, verify commands
620635
- C library with full read/write API
621-
- Hardware-accelerated CRC32C
636+
- Hardware-accelerated CRC32C (SSE4.2 on x86_64)
622637
- Comprehensive test suite
623-
- Cross-platform support (Linux, macOS)
638+
- Cross-platform support (Linux, macOS, FreeBSD)
624639
- Performance optimizations
625640
- Security hardening
626641

benchmarks/benchmark_encrypt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ static int benchmark_encrypted_containers(void) {
344344

345345
// Set decryption password if needed
346346
if (scenarios[sc].use_encryption) {
347-
result = bfc_set_encryption_password(reader, "benchmark_pass", 14);
347+
result = bfc_reader_set_encryption_password(reader, "benchmark_pass", 14);
348348
if (result != BFC_OK) {
349349
printf("Failed to set decryption password: %d\n", result);
350350
bfc_close_read(reader);

src/lib/CMakeLists.txt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,10 @@ set(BFC_LIB_HEADERS
3636
add_library(bfc STATIC ${BFC_LIB_SOURCES})
3737
add_library(bfc_shared SHARED ${BFC_LIB_SOURCES})
3838

39-
# Enable SSE4.2 for CRC32C hardware support on x86_64
40-
if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64")
41-
set_source_files_properties(bfc_crc32c.c PROPERTIES
42-
COMPILE_FLAGS "-msse4.2"
43-
)
39+
# Enable SSE4.2 and CRC32 for hardware support on x86_64
40+
if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64|amd64")
41+
target_compile_options(bfc PRIVATE -msse4.2 -mcrc32)
42+
target_compile_options(bfc_shared PRIVATE -msse4.2 -mcrc32)
4443
endif()
4544

4645
# Set properties for both libraries

src/lib/bfc_os.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,8 @@ int bfc_os_advise_nocache(FILE* file) {
305305
return BFC_E_INVAL;
306306
int fd = fileno(file);
307307
posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED);
308+
#else
309+
(void) file; // Suppress unused parameter warning
308310
#endif
309311
return BFC_OK;
310312
}

0 commit comments

Comments
 (0)