diff options
author | David Robillard <d@drobilla.net> | 2024-11-15 08:53:26 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2024-11-15 08:53:26 -0500 |
commit | c79edf4df9909bdb1313e74bb9cc7c8ea7936dcb (patch) | |
tree | a9a6642536eeb5860ae6c1eaaa74ba523385d7c8 /include | |
parent | 336aad280221ce643255032e948acccc27e7204f (diff) | |
download | zix-c79edf4df9909bdb1313e74bb9cc7c8ea7936dcb.tar.gz zix-c79edf4df9909bdb1313e74bb9cc7c8ea7936dcb.tar.bz2 zix-c79edf4df9909bdb1313e74bb9cc7c8ea7936dcb.zip |
Update clang-format configuration
Diffstat (limited to 'include')
-rw-r--r-- | include/zix/allocator.h | 15 | ||||
-rw-r--r-- | include/zix/attributes.h | 15 | ||||
-rw-r--r-- | include/zix/btree.h | 47 | ||||
-rw-r--r-- | include/zix/bump_allocator.h | 3 | ||||
-rw-r--r-- | include/zix/digest.h | 18 | ||||
-rw-r--r-- | include/zix/filesystem.h | 58 | ||||
-rw-r--r-- | include/zix/hash.h | 49 | ||||
-rw-r--r-- | include/zix/path.h | 70 | ||||
-rw-r--r-- | include/zix/ring.h | 44 | ||||
-rw-r--r-- | include/zix/sem.h | 18 | ||||
-rw-r--r-- | include/zix/status.h | 3 | ||||
-rw-r--r-- | include/zix/string_view.h | 18 | ||||
-rw-r--r-- | include/zix/thread.h | 6 | ||||
-rw-r--r-- | include/zix/tree.h | 46 |
14 files changed, 130 insertions, 280 deletions
diff --git a/include/zix/allocator.h b/include/zix/allocator.h index bace039..6c9a61d 100644 --- a/include/zix/allocator.h +++ b/include/zix/allocator.h @@ -103,13 +103,11 @@ struct ZixAllocatorImpl { }; /// Return the default allocator which simply uses the system allocator -ZIX_CONST_API -ZixAllocator* ZIX_NONNULL +ZIX_CONST_API ZixAllocator* ZIX_NONNULL zix_default_allocator(void); /// Convenience wrapper that defers to malloc() if allocator is null -ZIX_MALLOC_FUNC -static inline void* ZIX_ALLOCATED +ZIX_MALLOC_FUNC static inline void* ZIX_ALLOCATED zix_malloc(ZixAllocator* const ZIX_NULLABLE allocator, const size_t size) { ZixAllocator* const actual = allocator ? allocator : zix_default_allocator(); @@ -118,8 +116,7 @@ zix_malloc(ZixAllocator* const ZIX_NULLABLE allocator, const size_t size) } /// Convenience wrapper that defers to calloc() if allocator is null -ZIX_MALLOC_FUNC -static inline void* ZIX_ALLOCATED +ZIX_MALLOC_FUNC static inline void* ZIX_ALLOCATED zix_calloc(ZixAllocator* const ZIX_NULLABLE allocator, const size_t nmemb, const size_t size) @@ -130,8 +127,7 @@ zix_calloc(ZixAllocator* const ZIX_NULLABLE allocator, } /// Convenience wrapper that defers to realloc() if allocator is null -ZIX_NODISCARD -static inline void* ZIX_ALLOCATED +ZIX_NODISCARD static inline void* ZIX_ALLOCATED zix_realloc(ZixAllocator* const ZIX_NULLABLE allocator, void* const ZIX_NULLABLE ptr, const size_t size) @@ -152,8 +148,7 @@ zix_free(ZixAllocator* const ZIX_NULLABLE allocator, } /// Convenience wrapper that defers to the system allocator if allocator is null -ZIX_MALLOC_FUNC -static inline void* ZIX_ALLOCATED +ZIX_MALLOC_FUNC static inline void* ZIX_ALLOCATED zix_aligned_alloc(ZixAllocator* const ZIX_NULLABLE allocator, const size_t alignment, const size_t size) diff --git a/include/zix/attributes.h b/include/zix/attributes.h index 249e6a6..f92f2b0 100644 --- a/include/zix/attributes.h +++ b/include/zix/attributes.h @@ -48,22 +48,13 @@ #endif /// A pure function in the public API that only reads memory -#define ZIX_PURE_API \ - ZIX_API \ - ZIX_PURE_FUNC \ - ZIX_NODISCARD +#define ZIX_PURE_API ZIX_API ZIX_PURE_FUNC ZIX_NODISCARD /// A const function in the public API that is pure and only reads parameters -#define ZIX_CONST_API \ - ZIX_API \ - ZIX_CONST_FUNC \ - ZIX_NODISCARD +#define ZIX_CONST_API ZIX_API ZIX_CONST_FUNC ZIX_NODISCARD /// A malloc function in the public API that returns allocated memory -#define ZIX_MALLOC_API \ - ZIX_API \ - ZIX_MALLOC_FUNC \ - ZIX_NODISCARD +#define ZIX_MALLOC_API ZIX_API ZIX_MALLOC_FUNC ZIX_NODISCARD // Printf-like format functions #ifdef __GNUC__ diff --git a/include/zix/btree.h b/include/zix/btree.h index ddade81..de9f788 100644 --- a/include/zix/btree.h +++ b/include/zix/btree.h @@ -59,9 +59,7 @@ typedef void (*ZixBTreeDestroyFunc)(void* ZIX_UNSPECIFIED ptr, Searching can be done with a custom comparator that supports wildcards, see zix_btree_lower_bound() for details. */ -ZIX_API -ZIX_NODISCARD -ZixBTree* ZIX_ALLOCATED +ZIX_API ZIX_NODISCARD ZixBTree* ZIX_ALLOCATED zix_btree_new(ZixAllocator* ZIX_NULLABLE allocator, ZixBTreeCompareFunc ZIX_NONNULL cmp, const void* ZIX_UNSPECIFIED cmp_data); @@ -76,8 +74,7 @@ zix_btree_new(ZixAllocator* ZIX_NULLABLE allocator, @param destroy_data Opaque user data pointer to pass to `destroy`. */ -ZIX_API -void +ZIX_API void zix_btree_free(ZixBTree* ZIX_NULLABLE t, ZixBTreeDestroyFunc ZIX_NULLABLE destroy, const void* ZIX_NULLABLE destroy_data); @@ -92,15 +89,13 @@ zix_btree_free(ZixBTree* ZIX_NULLABLE t, @param destroy_data Opaque user data pointer to pass to `destroy`. */ -ZIX_API -void +ZIX_API void zix_btree_clear(ZixBTree* ZIX_NONNULL t, ZixBTreeDestroyFunc ZIX_NULLABLE destroy, const void* ZIX_NULLABLE destroy_data); /// Return the number of elements in `t` -ZIX_PURE_API -size_t +ZIX_PURE_API size_t zix_btree_size(const ZixBTree* ZIX_NONNULL t); /** @@ -135,42 +130,34 @@ static const ZixBTreeIter zix_btree_end_iter = { }; /// Return the data at the given position in the tree -ZIX_PURE_API -void* ZIX_UNSPECIFIED +ZIX_PURE_API void* ZIX_UNSPECIFIED zix_btree_get(ZixBTreeIter ti); /// Return an iterator to the first (smallest) element in `t` -ZIX_PURE_API -ZixBTreeIter +ZIX_PURE_API ZixBTreeIter zix_btree_begin(const ZixBTree* ZIX_NONNULL t); /// Return an iterator to the end of `t` (one past the last element) -ZIX_CONST_API -ZixBTreeIter +ZIX_CONST_API ZixBTreeIter zix_btree_end(const ZixBTree* ZIX_NULLABLE t); /// Return true iff `lhs` is equal to `rhs` -ZIX_CONST_API -bool +ZIX_CONST_API bool zix_btree_iter_equals(ZixBTreeIter lhs, ZixBTreeIter rhs); /// Return true iff `i` is an iterator at the end of a tree -ZIX_NODISCARD -static inline bool +ZIX_NODISCARD static inline bool zix_btree_iter_is_end(const ZixBTreeIter i) { return i.level == 0 && !i.nodes[0]; } /// Increment `i` to point to the next element in the tree -ZIX_API -ZixStatus +ZIX_API ZixStatus zix_btree_iter_increment(ZixBTreeIter* ZIX_NONNULL i); /// Return an iterator one past `iter` -ZIX_API -ZIX_NODISCARD -ZixBTreeIter +ZIX_API ZIX_NODISCARD ZixBTreeIter zix_btree_iter_next(ZixBTreeIter iter); /** @@ -185,8 +172,7 @@ zix_btree_iter_next(ZixBTreeIter iter); @return #ZIX_STATUS_SUCCESS on success, #ZIX_STATUS_EXISTS, or #ZIX_STATUS_NO_MEM. */ -ZIX_API -ZixStatus +ZIX_API ZixStatus zix_btree_insert(ZixBTree* ZIX_NONNULL t, void* ZIX_UNSPECIFIED e); /** @@ -203,8 +189,7 @@ zix_btree_insert(ZixBTree* ZIX_NONNULL t, void* ZIX_UNSPECIFIED e); @return #ZIX_STATUS_SUCCESS on success, or #ZIX_STATUS_NOT_FOUND. */ -ZIX_API -ZixStatus +ZIX_API ZixStatus zix_btree_remove(ZixBTree* ZIX_NONNULL t, const void* ZIX_UNSPECIFIED e, void* ZIX_UNSPECIFIED* ZIX_NONNULL out, @@ -223,8 +208,7 @@ zix_btree_remove(ZixBTree* ZIX_NONNULL t, @return #ZIX_STATUS_SUCCESS on success, or #ZIX_STATUS_NOT_FOUND. */ -ZIX_API -ZixStatus +ZIX_API ZixStatus zix_btree_find(const ZixBTree* ZIX_NONNULL t, const void* ZIX_UNSPECIFIED e, ZixBTreeIter* ZIX_NONNULL ti); @@ -245,8 +229,7 @@ zix_btree_find(const ZixBTree* ZIX_NONNULL t, @return #ZIX_STATUS_SUCCESS. */ -ZIX_API -ZixStatus +ZIX_API ZixStatus zix_btree_lower_bound(const ZixBTree* ZIX_NONNULL t, ZixBTreeCompareFunc ZIX_NULLABLE compare_key, const void* ZIX_NULLABLE compare_key_data, diff --git a/include/zix/bump_allocator.h b/include/zix/bump_allocator.h index c69de92..ecb2383 100644 --- a/include/zix/bump_allocator.h +++ b/include/zix/bump_allocator.h @@ -52,8 +52,7 @@ typedef struct { } ZixBumpAllocator; /// Return a bump allocator that works within a provided buffer -ZIX_API -ZixBumpAllocator +ZIX_API ZixBumpAllocator zix_bump_allocator(size_t capacity, void* ZIX_NONNULL buffer); /** diff --git a/include/zix/digest.h b/include/zix/digest.h index deffaf0..3b23c3f 100644 --- a/include/zix/digest.h +++ b/include/zix/digest.h @@ -29,8 +29,7 @@ ZIX_BEGIN_DECLS This can be used for any size or alignment. */ -ZIX_PURE_API -uint32_t +ZIX_PURE_API uint32_t zix_digest32(uint32_t seed, const void* ZIX_NONNULL buf, size_t len); /** @@ -39,8 +38,7 @@ zix_digest32(uint32_t seed, const void* ZIX_NONNULL buf, size_t len); Both the buffer and size must be aligned to 32 bits. For data that fits these requirements, this is equivalent to, but faster than, zix_digest32(). */ -ZIX_PURE_API -uint32_t +ZIX_PURE_API uint32_t zix_digest32_aligned(uint32_t seed, const void* ZIX_NONNULL buf, size_t len); /** @@ -48,8 +46,7 @@ zix_digest32_aligned(uint32_t seed, const void* ZIX_NONNULL buf, size_t len); This can be used for any size or alignment. */ -ZIX_PURE_API -uint64_t +ZIX_PURE_API uint64_t zix_digest64(uint64_t seed, const void* ZIX_NONNULL buf, size_t len); /** @@ -58,8 +55,7 @@ zix_digest64(uint64_t seed, const void* ZIX_NONNULL buf, size_t len); Both the buffer and size must be aligned to 64 bits. For data that fits these requirements, this is equivalent to, but faster than, zix_digest64(). */ -ZIX_PURE_API -uint64_t +ZIX_PURE_API uint64_t zix_digest64_aligned(uint64_t seed, const void* ZIX_NONNULL buf, size_t len); /** @@ -70,8 +66,7 @@ zix_digest64_aligned(uint64_t seed, const void* ZIX_NONNULL buf, size_t len); Internally, this simply dispatches to zix_digest32() or zix_digest64() as appropriate. */ -ZIX_PURE_API -size_t +ZIX_PURE_API size_t zix_digest(size_t seed, const void* ZIX_NONNULL buf, size_t len); /** @@ -84,8 +79,7 @@ zix_digest(size_t seed, const void* ZIX_NONNULL buf, size_t len); Internally, this simply dispatches to zix_digest32_aligned() or zix_digest64_aligned() as appropriate. */ -ZIX_PURE_API -size_t +ZIX_PURE_API size_t zix_digest_aligned(size_t seed, const void* ZIX_NONNULL buf, size_t len); /** diff --git a/include/zix/filesystem.h b/include/zix/filesystem.h index 221e165..878cd93 100644 --- a/include/zix/filesystem.h +++ b/include/zix/filesystem.h @@ -51,8 +51,7 @@ typedef uint32_t ZixCopyOptions; @param options Options to control the kind of copy and error conditions. @return #ZIX_STATUS_SUCCESS if `dst` was successfully created, or an error. */ -ZIX_API -ZixStatus +ZIX_API ZixStatus zix_copy_file(ZixAllocator* ZIX_NULLABLE allocator, const char* ZIX_NONNULL src, const char* ZIX_NONNULL dst, @@ -64,8 +63,7 @@ zix_copy_file(ZixAllocator* ZIX_NULLABLE allocator, @return #ZIX_STATUS_SUCCESS if `dir_path` was successfully created, or an error. */ -ZIX_API -ZixStatus +ZIX_API ZixStatus zix_create_directory(const char* ZIX_NONNULL dir_path); /** @@ -77,8 +75,7 @@ zix_create_directory(const char* ZIX_NONNULL dir_path); @return #ZIX_STATUS_SUCCESS if `dir_path` was successfully created, or an error. */ -ZIX_API -ZixStatus +ZIX_API ZixStatus zix_create_directory_like(const char* ZIX_NONNULL dir_path, const char* ZIX_NONNULL existing_path); @@ -92,8 +89,7 @@ zix_create_directory_like(const char* ZIX_NONNULL dir_path, @return #ZIX_STATUS_SUCCESS if all directories in `dir_path` were successfully created (or already existed), or an error. */ -ZIX_API -ZixStatus +ZIX_API ZixStatus zix_create_directories(ZixAllocator* ZIX_NULLABLE allocator, const char* ZIX_NONNULL dir_path); @@ -102,8 +98,7 @@ zix_create_directories(ZixAllocator* ZIX_NULLABLE allocator, @return #ZIX_STATUS_SUCCESS, or an error. */ -ZIX_API -ZixStatus +ZIX_API ZixStatus zix_create_hard_link(const char* ZIX_NONNULL target_path, const char* ZIX_NONNULL link_path); @@ -116,8 +111,7 @@ zix_create_hard_link(const char* ZIX_NONNULL target_path, @return #ZIX_STATUS_SUCCESS, or an error. */ -ZIX_API -ZixStatus +ZIX_API ZixStatus zix_create_symlink(const char* ZIX_NONNULL target_path, const char* ZIX_NONNULL link_path); @@ -129,8 +123,7 @@ zix_create_symlink(const char* ZIX_NONNULL target_path, @return #ZIX_STATUS_SUCCESS, or an error. */ -ZIX_API -ZixStatus +ZIX_API ZixStatus zix_create_directory_symlink(const char* ZIX_NONNULL target_path, const char* ZIX_NONNULL link_path); @@ -146,14 +139,12 @@ zix_create_directory_symlink(const char* ZIX_NONNULL target_path, @return The path of the created directory, or null. */ -ZIX_MALLOC_API -char* ZIX_NULLABLE +ZIX_MALLOC_API char* ZIX_NULLABLE zix_create_temporary_directory(ZixAllocator* ZIX_NULLABLE allocator, const char* ZIX_NONNULL path_pattern); /// Remove the file or empty directory at `path` -ZIX_API -ZixStatus +ZIX_API ZixStatus zix_remove(const char* ZIX_NONNULL path); /** @@ -173,8 +164,7 @@ zix_remove(const char* ZIX_NONNULL path); parameter is always the directory path passed to this function, the `name` parameter is the name of the directory entry (not its full path). */ -ZIX_API -void +ZIX_API void zix_dir_for_each(const char* ZIX_NONNULL path, void* ZIX_NULLABLE data, void (*ZIX_NONNULL f)(const char* ZIX_NONNULL path, @@ -193,9 +183,7 @@ zix_dir_for_each(const char* ZIX_NONNULL path, @return True if the two files have byte-for-byte identical contents. */ -ZIX_API -ZIX_NODISCARD -bool +ZIX_API ZIX_NODISCARD bool zix_file_equals(ZixAllocator* ZIX_NULLABLE allocator, const char* ZIX_NONNULL a_path, const char* ZIX_NONNULL b_path); @@ -228,8 +216,7 @@ zix_file_equals(ZixAllocator* ZIX_NULLABLE allocator, @return A new canonical version of `path`, or null if it doesn't exist. */ -ZIX_MALLOC_API -char* ZIX_NULLABLE +ZIX_MALLOC_API char* ZIX_NULLABLE zix_canonical_path(ZixAllocator* ZIX_NULLABLE allocator, const char* ZIX_NULLABLE path); @@ -256,8 +243,7 @@ typedef enum { @param mode Lock mode. @return #ZIX_STATUS_SUCCESS if the file was locked, or an error. */ -ZIX_API -ZixStatus +ZIX_API ZixStatus zix_file_lock(FILE* ZIX_NONNULL file, ZixFileLockMode mode); /** @@ -267,8 +253,7 @@ zix_file_lock(FILE* ZIX_NONNULL file, ZixFileLockMode mode); @param mode Lock mode. @return #ZIX_STATUS_SUCCESS if the file was unlocked, or an error. */ -ZIX_API -ZixStatus +ZIX_API ZixStatus zix_file_unlock(FILE* ZIX_NONNULL file, ZixFileLockMode mode); /** @@ -309,8 +294,7 @@ typedef enum { /** Return the type of a file or directory, resolving symlinks. */ -ZIX_API -ZixFileType +ZIX_API ZixFileType zix_file_type(const char* ZIX_NONNULL path); /** @@ -319,8 +303,7 @@ zix_file_type(const char* ZIX_NONNULL path); On Windows, a directory symlink (actually a "reparse point") always appears as a directory. */ -ZIX_API -ZixFileType +ZIX_API ZixFileType zix_symlink_type(const char* ZIX_NONNULL path); /** @@ -332,8 +315,7 @@ zix_symlink_type(const char* ZIX_NONNULL path); @return A non-negative size in bytes, or -1 on error. */ -ZIX_API -ZixFileOffset +ZIX_API ZixFileOffset zix_file_size(const char* ZIX_NONNULL path); /** @@ -347,8 +329,7 @@ zix_file_size(const char* ZIX_NONNULL path); @param allocator Allocator used for the returned path. */ -ZIX_MALLOC_API -char* ZIX_ALLOCATED +ZIX_MALLOC_API char* ZIX_ALLOCATED zix_current_path(ZixAllocator* ZIX_NULLABLE allocator); /** @@ -358,8 +339,7 @@ zix_current_path(ZixAllocator* ZIX_NULLABLE allocator); @return A new path to a temporary directory, or null on error. */ -ZIX_MALLOC_API -char* ZIX_ALLOCATED +ZIX_MALLOC_API char* ZIX_ALLOCATED zix_temp_directory_path(ZixAllocator* ZIX_NULLABLE allocator); /** diff --git a/include/zix/hash.h b/include/zix/hash.h index 6cd2271..9447cd7 100644 --- a/include/zix/hash.h +++ b/include/zix/hash.h @@ -102,22 +102,18 @@ typedef bool (*ZixKeyEqualFunc)(const ZixHashKey* ZIX_NONNULL a, @param hash_func The key hashing function. @param equal_func A function to test keys for equality. */ -ZIX_API -ZIX_NODISCARD -ZixHash* ZIX_ALLOCATED +ZIX_API ZIX_NODISCARD ZixHash* ZIX_ALLOCATED zix_hash_new(ZixAllocator* ZIX_NULLABLE allocator, ZixKeyFunc ZIX_NONNULL key_func, ZixHashFunc ZIX_NONNULL hash_func, ZixKeyEqualFunc ZIX_NONNULL equal_func); /// Free `hash` -ZIX_API -void +ZIX_API void zix_hash_free(ZixHash* ZIX_NULLABLE hash); /// Return the number of elements in the hash -ZIX_PURE_API -size_t +ZIX_PURE_API size_t zix_hash_size(const ZixHash* ZIX_NONNULL hash); /** @@ -135,23 +131,19 @@ zix_hash_size(const ZixHash* ZIX_NONNULL hash); typedef size_t ZixHashIter; /// Return an iterator to the first record in a hash, or the end if it is empty -ZIX_PURE_API -ZixHashIter +ZIX_PURE_API ZixHashIter zix_hash_begin(const ZixHash* ZIX_NONNULL hash); /// Return an iterator one past the last possible record in a hash -ZIX_PURE_API -ZixHashIter +ZIX_PURE_API ZixHashIter zix_hash_end(const ZixHash* ZIX_NONNULL hash); /// Return the record pointed to by an iterator -ZIX_PURE_API -ZixHashRecord* ZIX_NULLABLE +ZIX_PURE_API ZixHashRecord* ZIX_NULLABLE zix_hash_get(const ZixHash* ZIX_NONNULL hash, ZixHashIter i); /// Return an iterator that has been advanced to the next record in a hash -ZIX_PURE_API -ZixHashIter +ZIX_PURE_API ZixHashIter zix_hash_next(const ZixHash* ZIX_NONNULL hash, ZixHashIter i); /** @@ -189,8 +181,7 @@ typedef struct { record with this key using zix_hash_insert_at() until the hash table is modified (which invalidates the position). */ -ZIX_API -ZixHashInsertPlan +ZIX_API ZixHashInsertPlan zix_hash_plan_insert(const ZixHash* ZIX_NONNULL hash, const ZixHashKey* ZIX_NONNULL key); @@ -214,8 +205,7 @@ zix_hash_plan_insert(const ZixHash* ZIX_NONNULL hash, be inserted, and the predicate must return true only if the key it is called with (the first argument) matches the key to be inserted. */ -ZIX_API -ZixHashInsertPlan +ZIX_API ZixHashInsertPlan zix_hash_plan_insert_prehashed(const ZixHash* ZIX_NONNULL hash, ZixHashCode code, ZixKeyMatchFunc ZIX_NONNULL predicate, @@ -228,8 +218,7 @@ zix_hash_plan_insert_prehashed(const ZixHash* ZIX_NONNULL hash, can be used to insert a new record, or to access the existing matching record. */ -ZIX_PURE_API -ZixHashRecord* ZIX_NULLABLE +ZIX_PURE_API ZixHashRecord* ZIX_NULLABLE zix_hash_record_at(const ZixHash* ZIX_NONNULL hash, ZixHashInsertPlan position); /** @@ -249,8 +238,7 @@ zix_hash_record_at(const ZixHash* ZIX_NONNULL hash, ZixHashInsertPlan position); @return ZIX_STATUS_SUCCESS, ZIX_STATUS_EXISTS if a record already exists at this position, or ZIX_STATUS_NO_MEM if growing the hash table failed. */ -ZIX_API -ZixStatus +ZIX_API ZixStatus zix_hash_insert_at(ZixHash* ZIX_NONNULL hash, ZixHashInsertPlan position, ZixHashRecord* ZIX_NONNULL record); @@ -269,8 +257,7 @@ zix_hash_insert_at(ZixHash* ZIX_NONNULL hash, @return ZIX_STATUS_SUCCESS, ZIX_STATUS_EXISTS, or ZIX_STATUS_NO_MEM. */ -ZIX_API -ZixStatus +ZIX_API ZixStatus zix_hash_insert(ZixHash* ZIX_NONNULL hash, ZixHashRecord* ZIX_NONNULL record); /** @@ -287,8 +274,7 @@ zix_hash_insert(ZixHash* ZIX_NONNULL hash, ZixHashRecord* ZIX_NONNULL record); @return ZIX_STATUS_SUCCES or ZIX_STATUS_BAD_ARG if `i` does not point at a removable record. */ -ZIX_API -ZixStatus +ZIX_API ZixStatus zix_hash_erase(ZixHash* ZIX_NONNULL hash, ZixHashIter i, ZixHashRecord* ZIX_NULLABLE* ZIX_NONNULL removed); @@ -301,8 +287,7 @@ zix_hash_erase(ZixHash* ZIX_NONNULL hash, @param removed Set to the removed record, or null. @return ZIX_STATUS_SUCCES or ZIX_STATUS_NOT_FOUND. */ -ZIX_API -ZixStatus +ZIX_API ZixStatus zix_hash_remove(ZixHash* ZIX_NONNULL hash, const ZixHashKey* ZIX_NONNULL key, ZixHashRecord* ZIX_NULLABLE* ZIX_NONNULL removed); @@ -323,8 +308,7 @@ zix_hash_remove(ZixHash* ZIX_NONNULL hash, @return An iterator to the matching record, or the end iterator if no such record exists. */ -ZIX_API -ZixHashIter +ZIX_API ZixHashIter zix_hash_find(const ZixHash* ZIX_NONNULL hash, const ZixHashKey* ZIX_NONNULL key); @@ -340,8 +324,7 @@ zix_hash_find(const ZixHash* ZIX_NONNULL hash, @return A pointer to the matching record, of null if no such record exists. */ -ZIX_API -ZixHashRecord* ZIX_NULLABLE +ZIX_API ZixHashRecord* ZIX_NULLABLE zix_hash_find_record(const ZixHash* ZIX_NONNULL hash, const ZixHashKey* ZIX_NONNULL key); diff --git a/include/zix/path.h b/include/zix/path.h index 22c8202..3fed43a 100644 --- a/include/zix/path.h +++ b/include/zix/path.h @@ -35,9 +35,7 @@ ZIX_BEGIN_DECLS */ /// Join path `a` and path `b` with a single directory separator between them -ZIX_API -ZIX_NODISCARD -char* ZIX_ALLOCATED +ZIX_API ZIX_NODISCARD char* ZIX_ALLOCATED zix_path_join(ZixAllocator* ZIX_NULLABLE allocator, const char* ZIX_NULLABLE a, const char* ZIX_NULLABLE b); @@ -55,9 +53,7 @@ zix_path_join(ZixAllocator* ZIX_NULLABLE allocator, converted to the preferred separator (backslash on Windows, slash everywhere else). */ -ZIX_API -ZIX_NODISCARD -char* ZIX_ALLOCATED +ZIX_API ZIX_NODISCARD char* ZIX_ALLOCATED zix_path_preferred(ZixAllocator* ZIX_NULLABLE allocator, const char* ZIX_NONNULL path); @@ -72,9 +68,7 @@ zix_path_preferred(ZixAllocator* ZIX_NULLABLE allocator, like case normalization or symbolic link dereferencing. For that, use zix_canonical_path(). */ -ZIX_API -ZIX_NODISCARD -char* ZIX_ALLOCATED +ZIX_API ZIX_NODISCARD char* ZIX_ALLOCATED zix_path_lexically_normal(ZixAllocator* ZIX_NULLABLE allocator, const char* ZIX_NONNULL path); @@ -85,9 +79,7 @@ zix_path_lexically_normal(ZixAllocator* ZIX_NULLABLE allocator, equivalent path relative to `base` is returned (which may contain up-references). */ -ZIX_API -ZIX_NODISCARD -char* ZIX_ALLOCATED +ZIX_API ZIX_NODISCARD char* ZIX_ALLOCATED zix_path_lexically_relative(ZixAllocator* ZIX_NULLABLE allocator, const char* ZIX_NONNULL path, const char* ZIX_NONNULL base); @@ -99,13 +91,11 @@ zix_path_lexically_relative(ZixAllocator* ZIX_NULLABLE allocator, */ /// Return the root name of `path` like "C:", or null -ZIX_PURE_WIN_API -ZixStringView +ZIX_PURE_WIN_API ZixStringView zix_path_root_name(const char* ZIX_NONNULL path); /// Return the root directory of `path` like "/" or "\", or null -ZIX_PURE_API -ZixStringView +ZIX_PURE_API ZixStringView zix_path_root_directory(const char* ZIX_NONNULL path); /** @@ -121,8 +111,7 @@ zix_path_root_directory(const char* ZIX_NONNULL path); @return The newly allocated root path of `path`, or null if it has no root or allocation failed. */ -ZIX_PURE_API -ZixStringView +ZIX_PURE_API ZixStringView zix_path_root_path(const char* ZIX_NONNULL path); /** @@ -131,8 +120,7 @@ zix_path_root_path(const char* ZIX_NONNULL path); If the path has no relative path (because it is empty or a root path), this returns null. */ -ZIX_PURE_API -ZixStringView +ZIX_PURE_API ZixStringView zix_path_relative_path(const char* ZIX_NONNULL path); /** @@ -151,8 +139,7 @@ zix_path_relative_path(const char* ZIX_NONNULL path); @return The newly allocated path to the parent of `path`, or null if it has no parent or allocation failed. */ -ZIX_PURE_API -ZixStringView +ZIX_PURE_API ZixStringView zix_path_parent_path(const char* ZIX_NONNULL path); /** @@ -161,8 +148,7 @@ zix_path_parent_path(const char* ZIX_NONNULL path); The filename is the name after the last directory separator. If the path has no filename, this returns null. */ -ZIX_PURE_API -ZixStringView +ZIX_PURE_API ZixStringView zix_path_filename(const char* ZIX_NONNULL path); /** @@ -171,8 +157,7 @@ zix_path_filename(const char* ZIX_NONNULL path); The "stem" is the filename without the extension, that is, everything up to the last "." if "." is not the first character. */ -ZIX_PURE_API -ZixStringView +ZIX_PURE_API ZixStringView zix_path_stem(const char* ZIX_NONNULL path); /** @@ -181,8 +166,7 @@ zix_path_stem(const char* ZIX_NONNULL path); The "extension" is everything past the last "." in the filename, if "." is not the first character. */ -ZIX_PURE_API -ZixStringView +ZIX_PURE_API ZixStringView zix_path_extension(const char* ZIX_NONNULL path); /** @@ -192,53 +176,43 @@ zix_path_extension(const char* ZIX_NONNULL path); */ /// Return true if `path` has a root path like "/" or "C:\" -ZIX_PURE_API -bool +ZIX_PURE_API bool zix_path_has_root_path(const char* ZIX_NULLABLE path); /// Return true if `path` has a root name like "C:" -ZIX_PURE_WIN_API -bool +ZIX_PURE_WIN_API bool zix_path_has_root_name(const char* ZIX_NULLABLE path); /// Return true if `path` has a root directory like "/" or "\" -ZIX_PURE_API -bool +ZIX_PURE_API bool zix_path_has_root_directory(const char* ZIX_NULLABLE path); /// Return true if `path` has a relative path "dir/file.txt" -ZIX_PURE_API -bool +ZIX_PURE_API bool zix_path_has_relative_path(const char* ZIX_NULLABLE path); /// Return true if `path` has a parent path like "dir/" -ZIX_PURE_API -bool +ZIX_PURE_API bool zix_path_has_parent_path(const char* ZIX_NULLABLE path); /// Return true if `path` has a filename like "file.txt" -ZIX_PURE_API -bool +ZIX_PURE_API bool zix_path_has_filename(const char* ZIX_NULLABLE path); /// Return true if `path` has a stem like "file" -ZIX_PURE_API -bool +ZIX_PURE_API bool zix_path_has_stem(const char* ZIX_NULLABLE path); /// Return true if `path` has an extension like ".txt" -ZIX_PURE_API -bool +ZIX_PURE_API bool zix_path_has_extension(const char* ZIX_NULLABLE path); /// Return true if `path` is an absolute path -ZIX_PURE_API -bool +ZIX_PURE_API bool zix_path_is_absolute(const char* ZIX_NULLABLE path); /// Return true if `path` is a relative path -ZIX_PURE_API -bool +ZIX_PURE_API bool zix_path_is_relative(const char* ZIX_NULLABLE path); /** diff --git a/include/zix/ring.h b/include/zix/ring.h index db72f41..6829016 100644 --- a/include/zix/ring.h +++ b/include/zix/ring.h @@ -40,14 +40,11 @@ typedef struct ZixRingImpl ZixRing; At most `size` - 1 bytes may be stored in the ring at once. */ -ZIX_API -ZIX_NODISCARD -ZixRing* ZIX_ALLOCATED +ZIX_API ZIX_NODISCARD ZixRing* ZIX_ALLOCATED zix_ring_new(ZixAllocator* ZIX_NULLABLE allocator, uint32_t size); /// Destroy a ring -ZIX_API -void +ZIX_API void zix_ring_free(ZixRing* ZIX_NULLABLE ring); /** @@ -57,8 +54,7 @@ zix_ring_free(ZixRing* ZIX_NULLABLE ring); after zix_ring_new() to lock all ring memory to avoid page faults while using the ring. */ -ZIX_API -ZixStatus +ZIX_API ZixStatus zix_ring_mlock(ZixRing* ZIX_NONNULL ring); /** @@ -67,8 +63,7 @@ zix_ring_mlock(ZixRing* ZIX_NONNULL ring); This function is NOT thread-safe, it may only be called when there is no reader or writer. */ -ZIX_API -void +ZIX_API void zix_ring_reset(ZixRing* ZIX_NONNULL ring); /** @@ -77,8 +72,7 @@ zix_ring_reset(ZixRing* ZIX_NONNULL ring); This function returns a constant for any given ring, and may (but usually shouldn't) be called anywhere. */ -ZIX_PURE_API -uint32_t +ZIX_PURE_API uint32_t zix_ring_capacity(const ZixRing* ZIX_NONNULL ring); /** @@ -89,23 +83,19 @@ zix_ring_capacity(const ZixRing* ZIX_NONNULL ring); */ /// Return the number of bytes available for reading -ZIX_PURE_API -uint32_t +ZIX_PURE_API uint32_t zix_ring_read_space(const ZixRing* ZIX_NONNULL ring); /// Read from the ring without advancing the read head -ZIX_API -uint32_t +ZIX_API uint32_t zix_ring_peek(ZixRing* ZIX_NONNULL ring, void* ZIX_NONNULL dst, uint32_t size); /// Read from the ring and advance the read head -ZIX_API -uint32_t +ZIX_API uint32_t zix_ring_read(ZixRing* ZIX_NONNULL ring, void* ZIX_NONNULL dst, uint32_t size); /// Advance the read head, ignoring any data -ZIX_API -uint32_t +ZIX_API uint32_t zix_ring_skip(ZixRing* ZIX_NONNULL ring, uint32_t size); /** @@ -130,13 +120,11 @@ typedef struct { } ZixRingTransaction; /// Return the number of bytes available for writing -ZIX_PURE_API -uint32_t +ZIX_PURE_API uint32_t zix_ring_write_space(const ZixRing* ZIX_NONNULL ring); /// Write data to the ring -ZIX_API -uint32_t +ZIX_API uint32_t zix_ring_write(ZixRing* ZIX_NONNULL ring, const void* ZIX_NONNULL src, uint32_t size); @@ -155,9 +143,7 @@ zix_ring_write(ZixRing* ZIX_NONNULL ring, @param ring The ring to write data to. @return A new empty transaction. */ -ZIX_API -ZIX_NODISCARD -ZixRingTransaction +ZIX_API ZIX_NODISCARD ZixRingTransaction zix_ring_begin_write(ZixRing* ZIX_NONNULL ring); /** @@ -178,8 +164,7 @@ zix_ring_begin_write(ZixRing* ZIX_NONNULL ring); @param size Length of data to write in bytes. @return #ZIX_STATUS_NO_MEM or #ZIX_STATUS_SUCCESS. */ -ZIX_API -ZixStatus +ZIX_API ZixStatus zix_ring_amend_write(ZixRing* ZIX_NONNULL ring, ZixRingTransaction* ZIX_NONNULL tx, const void* ZIX_NONNULL src, @@ -198,8 +183,7 @@ zix_ring_amend_write(ZixRing* ZIX_NONNULL ring, @param tx The active transaction, from zix_ring_begin_write(). @return #ZIX_STATUS_SUCCESS. */ -ZIX_API -ZixStatus +ZIX_API ZixStatus zix_ring_commit_write(ZixRing* ZIX_NONNULL ring, const ZixRingTransaction* ZIX_NONNULL tx); diff --git a/include/zix/sem.h b/include/zix/sem.h index 42dd6c3..545aa8a 100644 --- a/include/zix/sem.h +++ b/include/zix/sem.h @@ -49,8 +49,7 @@ typedef struct ZixSemImpl ZixSem; @return #ZIX_STATUS_SUCCESS, or an unlikely error. */ -ZIX_API -ZixStatus +ZIX_API ZixStatus zix_sem_init(ZixSem* ZIX_NONNULL sem, unsigned initial); /** @@ -58,8 +57,7 @@ zix_sem_init(ZixSem* ZIX_NONNULL sem, unsigned initial); @return #ZIX_STATUS_SUCCESS, or an error. */ -ZIX_API -ZixStatus +ZIX_API ZixStatus zix_sem_destroy(ZixSem* ZIX_NONNULL sem); /** @@ -71,8 +69,7 @@ zix_sem_destroy(ZixSem* ZIX_NONNULL sem); if the maximum possible value would have been exceeded, or #ZIX_STATUS_BAD_ARG if `sem` is invalid. */ -ZIX_API -ZixStatus +ZIX_API ZixStatus zix_sem_post(ZixSem* ZIX_NONNULL sem); /** @@ -83,8 +80,7 @@ zix_sem_post(ZixSem* ZIX_NONNULL sem); @return #ZIX_STATUS_SUCCESS if `sem` was decremented, or #ZIX_STATUS_BAD_ARG if `sem` is invalid. */ -ZIX_API -ZixStatus +ZIX_API ZixStatus zix_sem_wait(ZixSem* ZIX_NONNULL sem); /** @@ -94,8 +90,7 @@ zix_sem_wait(ZixSem* ZIX_NONNULL sem); #ZIX_STATUS_UNAVAILABLE if it was already zero, or #ZIX_STATUS_BAD_ARG if `sem` is invalid. */ -ZIX_API -ZixStatus +ZIX_API ZixStatus zix_sem_try_wait(ZixSem* ZIX_NONNULL sem); /** @@ -108,8 +103,7 @@ zix_sem_try_wait(ZixSem* ZIX_NONNULL sem); the system does not support timed waits, or #ZIX_STATUS_BAD_ARG if `sem` is invalid. */ -ZIX_API -ZixStatus +ZIX_API ZixStatus zix_sem_timed_wait(ZixSem* ZIX_NONNULL sem, uint32_t seconds, uint32_t nanoseconds); diff --git a/include/zix/status.h b/include/zix/status.h index 47aede8..fce27bc 100644 --- a/include/zix/status.h +++ b/include/zix/status.h @@ -38,8 +38,7 @@ typedef enum { The returned string is always one sentence, with an uppercase first character, and no trailing period. */ -ZIX_CONST_API -const char* +ZIX_CONST_API const char* zix_strerror(ZixStatus status); /** diff --git a/include/zix/string_view.h b/include/zix/string_view.h index cfd478d..d6f39c5 100644 --- a/include/zix/string_view.h +++ b/include/zix/string_view.h @@ -40,9 +40,7 @@ typedef struct { // clang-format on /// Return a view of an empty string -ZIX_ALWAYS_INLINE_FUNC -ZIX_CONST_FUNC -static inline ZixStringView +ZIX_ALWAYS_INLINE_FUNC ZIX_CONST_FUNC static inline ZixStringView zix_empty_string(void) { const ZixStringView view = {"", 0U}; @@ -62,9 +60,7 @@ zix_empty_string(void) @param len Length of the substring in bytes, not including the trailing null terminator if present. */ -ZIX_ALWAYS_INLINE_FUNC -ZIX_CONST_FUNC -static inline ZixStringView +ZIX_ALWAYS_INLINE_FUNC ZIX_CONST_FUNC static inline ZixStringView zix_substring(const char* const ZIX_NONNULL str, const size_t len) { const ZixStringView view = {str, len}; @@ -78,9 +74,7 @@ zix_substring(const char* const ZIX_NONNULL str, const size_t len) @param str Pointer to the start of a null-terminated C string, or null. */ -ZIX_ALWAYS_INLINE_FUNC -ZIX_PURE_FUNC -static inline ZixStringView +ZIX_ALWAYS_INLINE_FUNC ZIX_PURE_FUNC static inline ZixStringView // NOLINTNEXTLINE(clang-diagnostic-unused-function) zix_string(const char* const ZIX_NULLABLE str) { @@ -90,8 +84,7 @@ zix_string(const char* const ZIX_NULLABLE str) /** Copy a string view into a newly allocated null-terminated string. */ -ZIX_MALLOC_API -char* ZIX_ALLOCATED +ZIX_MALLOC_API char* ZIX_ALLOCATED zix_string_view_copy(ZixAllocator* ZIX_NULLABLE allocator, ZixStringView view); /** @@ -101,8 +94,7 @@ zix_string_view_copy(ZixAllocator* ZIX_NULLABLE allocator, ZixStringView view); has fast paths for when the operands have different lengths, or point to the same string data. */ -ZIX_PURE_API -bool +ZIX_PURE_API bool zix_string_view_equals(ZixStringView lhs, ZixStringView rhs); /** diff --git a/include/zix/thread.h b/include/zix/thread.h index 2493ed3..dc9804c 100644 --- a/include/zix/thread.h +++ b/include/zix/thread.h @@ -62,8 +62,7 @@ typedef ZixThreadResult(ZIX_THREAD_FUNC* ZixThreadFunc)(void*); @return #ZIX_STATUS_SUCCESS on success, or #ZIX_STATUS_ERROR. */ -ZIX_API -ZixStatus +ZIX_API ZixStatus zix_thread_create(ZixThread* thread, size_t stack_size, ZixThreadFunc function, @@ -74,8 +73,7 @@ zix_thread_create(ZixThread* thread, @return #ZIX_STATUS_SUCCESS on success, or #ZIX_STATUS_ERROR. */ -ZIX_API -ZixStatus +ZIX_API ZixStatus zix_thread_join(ZixThread thread); /** diff --git a/include/zix/tree.h b/include/zix/tree.h index b51fa72..60bfe6c 100644 --- a/include/zix/tree.h +++ b/include/zix/tree.h @@ -37,9 +37,7 @@ typedef void (*ZixTreeDestroyFunc)(void* ZIX_UNSPECIFIED ptr, const void* ZIX_UNSPECIFIED user_data); /// Create a new (empty) tree -ZIX_API -ZIX_NODISCARD -ZixTree* ZIX_ALLOCATED +ZIX_API ZIX_NODISCARD ZixTree* ZIX_ALLOCATED zix_tree_new(ZixAllocator* ZIX_NULLABLE allocator, bool allow_duplicates, ZixTreeCompareFunc ZIX_NONNULL cmp, @@ -48,13 +46,11 @@ zix_tree_new(ZixAllocator* ZIX_NULLABLE allocator, const void* ZIX_NULLABLE destroy_user_data); /// Free `t` -ZIX_API -void +ZIX_API void zix_tree_free(ZixTree* ZIX_NULLABLE t); /// Return the number of elements in `t` -ZIX_PURE_API -size_t +ZIX_PURE_API size_t zix_tree_size(const ZixTree* ZIX_NONNULL t); /** @@ -67,48 +63,39 @@ zix_tree_size(const ZixTree* ZIX_NONNULL t); typedef struct ZixTreeNodeImpl ZixTreeIter; /// Return the data associated with the given tree item -ZIX_PURE_API -void* ZIX_UNSPECIFIED +ZIX_PURE_API void* ZIX_UNSPECIFIED zix_tree_get(const ZixTreeIter* ZIX_NULLABLE ti); /// Return an iterator to the first (smallest) element in `t` -ZIX_PURE_API -ZixTreeIter* ZIX_NULLABLE +ZIX_PURE_API ZixTreeIter* ZIX_NULLABLE zix_tree_begin(ZixTree* ZIX_NONNULL t); /// Return an iterator the the element one past the last element in `t` -ZIX_CONST_API -ZixTreeIter* ZIX_NULLABLE +ZIX_CONST_API ZixTreeIter* ZIX_NULLABLE zix_tree_end(ZixTree* ZIX_NONNULL t); /// Return true iff `i` is an iterator to the end of its tree -ZIX_CONST_API -bool +ZIX_CONST_API bool zix_tree_iter_is_end(const ZixTreeIter* ZIX_NULLABLE i); /// Return an iterator to the last (largest) element in `t` -ZIX_PURE_API -ZixTreeIter* ZIX_NULLABLE +ZIX_PURE_API ZixTreeIter* ZIX_NULLABLE zix_tree_rbegin(ZixTree* ZIX_NONNULL t); /// Return an iterator the the element one before the first element in `t` -ZIX_CONST_API -ZixTreeIter* ZIX_NULLABLE +ZIX_CONST_API ZixTreeIter* ZIX_NULLABLE zix_tree_rend(ZixTree* ZIX_NONNULL t); /// Return true iff `i` is an iterator to the reverse end of its tree -ZIX_CONST_API -bool +ZIX_CONST_API bool zix_tree_iter_is_rend(const ZixTreeIter* ZIX_NULLABLE i); /// Return an iterator that points to the element one past `i` -ZIX_PURE_API -ZixTreeIter* ZIX_NULLABLE +ZIX_PURE_API ZixTreeIter* ZIX_NULLABLE zix_tree_iter_next(ZixTreeIter* ZIX_NULLABLE i); /// Return an iterator that points to the element one before `i` -ZIX_PURE_API -ZixTreeIter* ZIX_NULLABLE +ZIX_PURE_API ZixTreeIter* ZIX_NULLABLE zix_tree_iter_prev(ZixTreeIter* ZIX_NULLABLE i); /** @@ -118,15 +105,13 @@ zix_tree_iter_prev(ZixTreeIter* ZIX_NULLABLE i); */ /// Insert the element `e` into `t` and point `ti` at the new element -ZIX_API -ZixStatus +ZIX_API ZixStatus zix_tree_insert(ZixTree* ZIX_NONNULL t, void* ZIX_UNSPECIFIED e, ZixTreeIter* ZIX_NULLABLE* ZIX_NULLABLE ti); /// Remove the item pointed at by `ti` from `t` -ZIX_API -ZixStatus +ZIX_API ZixStatus zix_tree_remove(ZixTree* ZIX_NONNULL t, ZixTreeIter* ZIX_NONNULL ti); /** @@ -140,8 +125,7 @@ zix_tree_remove(ZixTree* ZIX_NONNULL t, ZixTreeIter* ZIX_NONNULL ti); If no such item exists, `ti` is set to NULL. */ -ZIX_API -ZixStatus +ZIX_API ZixStatus zix_tree_find(const ZixTree* ZIX_NONNULL t, const void* ZIX_UNSPECIFIED e, ZixTreeIter* ZIX_NULLABLE* ZIX_NONNULL ti); |