Latest commit

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

types.h

typedefu8;
typedefi8;
typedefu16;
typedefi16;
typedefu32;
typedefi32;
typedefu64;
typedefi64;
typedefusize; //typedef unsigned long long size_ttypedefisize; //typedef long long ptrdiff_ttypedefintptr;
typedefuintptr;
typedeff32;
typedeff64;
typedefRune;
typedefb8;
typedefb16;
typedefb32;
#defineCM_RUNE_INVALID#defineCM_RUNE_MAX #define CM_RUNE_BOM #defineCM_RUNE_EOF#defineU8_MIN#defineU8_MAX#defineI8_MIN#defineI8_MAX#defineU16_MIN#defineU16_MAX#defineI16_MIN#defineI16_MAX#defineU32_MIN#defineU32_MAX#defineI32_MIN#defineI32_MAX#defineU64_MIN#defineU64_MAX#defineI64_MIN#defineI64_MAX#defineUSIZE_MIX #define USIZE_MAX
#defineISIZE_MIX#defineISIZE_MAX#defineF32_MIN#defineF32_MAX#defineF64_MIN#defineF64_MAX

arch.h

/*  * Arch  */#defineCM_ARCH_64#defineCM_ARCH_32/*  * Endian  */#defineCM_ENDIAN_ORDER#defineCM_BIG_ENDIAN#defineCM_LITTLE_ENDIAN/* * OS */#defineCM_WINDOWS#defineCM_OS_WINDOWS#defineCM_SYS_WINDOWS#defineCM_OSX#defineCM_OS_OSX#defineCM_SYS_OSX#defineCM_UNIX#defineCM_OS_UNIX#defineCM_SYS_UNIX#defineCM_LINUX#defineCM_OS_LINUX#defineCM_SYS_LINUX#defineCM_FREEBSD#defineCM_OS_FREEBSD#defineCM_SYS_FREEBSD/* * Compiler */#defineCM_COMPILER_MSVC#defineCM_COMPILER_GCC#defineCM_COMPILER_CLANG/* * CPU */#defineCM_CPU_X86#defineCM_CPU_PPC#defineCM_CPU_ARM#defineCM_CPU_MIPS#defineCM_CACHE_LINE_SIZE

assert.h

#defineCM_STATIC_ASSERT(cond) #define CM_STATIC_ASSERT1(cond, line)
#defineCM_STATIC_ASSERT2(cond, line)
#defineCM_STATIC_ASSERT3(cond, msg)

affinity.h

  • Struct
/* * cmAffinity */typedefstructcmAffinity{
b32is_accurate;
isizecore_count;
isizethread_count;
usizecore_masks[CM_WIN32_MAX_THREADS];
} cmAffinity;
  • Function
/* */voidcm_affinity_init (cmAffinity*a);
/* */voidcm_affinity_destroy (cmAffinity*a);
/* */b32cm_affinity_set (cmAffinity*a, isizecore, isizethread);
/* */isizecm_affinity_thread_count_for_core (cmAffinity*a, isizecore);

atomics.h

  • Struct
/* * cmAtomic32 */typedefstructcmAtomic32 { i32volatilevalue; } cmAtomic32;
/* * cmAtomic64 */typedefstructcmAtomic64 {
i64volatilevalue; } cmAtomic64;
/* * cmAtomicPtr */typedefstructcmAtomicPtr { void*volatilevalue;
} cmAtomicPtr;
  • Function
/* * atomic32 */i32cm_atomic32_load (cmAtomic32constvolatile*a);
voidcm_atomic32_store (cmAtomic32volatile*a, i32value);
i32cm_atomic32_compare_exchange (cmAtomic32volatile*a, i32expected, i32desired);
i32cm_atomic32_exchanged (cmAtomic32volatile*a, i32desired);
i32cm_atomic32_fetch_add (cmAtomic32volatile*a, i32operand);
i32cm_atomic32_fetch_and (cmAtomic32volatile*a, i32operand);
i32cm_atomic32_fetch_or (cmAtomic32volatile*a, i32operand);
b32cm_atomic32_spin_lock (cmAtomic32volatile*a, isizetime_out);
voidcm_atomic32_spin_unlock (cmAtomic32volatile*a);
b32cm_atomic32_try_acquire_lock (cmAtomic32volatile*a);
/* * atomic64 */i64cm_atomic64_load (cmAtomic64constvolatile*a);
voidcm_atomic64_store (cmAtomic64volatile*a, i64value);
i64cm_atomic64_compare_exchange (cmAtomic64volatile*a, i64expected, i64desired);
i64cm_atomic64_exchanged (cmAtomic64volatile*a, i64desired);
i64cm_atomic64_fetch_add (cmAtomic64volatile*a, i64operand);
i64cm_atomic64_fetch_and (cmAtomic64volatile*a, i64operand);
i64cm_atomic64_fetch_or (cmAtomic64volatile*a, i64operand);
b32cm_atomic64_spin_lock (cmAtomic64volatile*a, isizetime_out);
voidcm_atomic64_spin_unlock (cmAtomic64volatile*a);
b32cm_atomic64_try_acquire_lock (cmAtomic64volatile*a);
/* * atomicptr */void*cm_atomic_ptr_load (cmAtomicPtrconstvolatile*a);
voidcm_atomic_ptr_store (cmAtomicPtrvolatile*a, void*value);
void*cm_atomic_ptr_compare_exchange (cmAtomicPtrvolatile*a, void*expected, void*desired);
void*cm_atomic_ptr_exchanged (cmAtomicPtrvolatile*a, void*desired);
void*cm_atomic_ptr_fetch_add (cmAtomicPtrvolatile*a, void*operand);
void*cm_atomic_ptr_fetch_and (cmAtomicPtrvolatile*a, void*operand);
void*cm_atomic_ptr_fetch_or (cmAtomicPtrvolatile*a, void*operand);
b32cm_atomic_ptr_spin_lock (cmAtomicPtrvolatile*a, isizetime_out);
voidcm_atomic_ptr_spin_unlock (cmAtomicPtrvolatile*a);
b32cm_atomic_ptr_try_acquire_lock (cmAtomicPtrvolatile*a);

buffer.h

  • Struct
/* * cmBufferHeader */typedefstructcmBufferHeader {
isizecount;
isizecapacity;
} cmBufferHeader;
  • Function
/* * ประกาศตัวแปร Ex. cmBuffer(i32) buffer; */cmBuffer(Type);
/* * จำนวน */isizecm_buffer_count (cmBufferHeader*bfh);
/* * ความจุ */isizecm_buffer_capacity (cmBufferHeader*bfh);
/* * ค่าเริ่มต้น */void*cm_buffer_init (x, allocator, cap);
/* * เลิกใช้งาน */voidcm_buffer_free (x, allocator);
/* * เพิ่มข้อมูล(1 รายการ) */voidcm_buffer_append (x, item);
/* * เพิ่มข้อมูล(มากกว่า 1 รายการ) */voidcm_buffer_appendv (x, items, item_count);
/* * นำข้อมูลออก */voidcm_buffer_pop (x);
/* * ล้างข้อมูล */cm_buffer_clear (x)

char.h

  • Function
/* * แปลงตัวอักษรเป็นพิมพ์เล็ก */charcm_char_to_lower (charc);
/* * แปลงตัวอักษรเป็นพิมพ์ใหญ่ */charcm_char_to_upper (charc);
/* * ตรวจสอบช่องว่าง */b32cm_char_is_space (charc);
/* * ตรวจสอบตัวเลข */b32cm_char_is_digit (charc);
/* * ตรวจสอบตัวเลขที่เป็นฐาน16 (hex) */b32cm_char_is_hex_digit (charc);
/* *  */b32cm_char_is_alpha (charc);
/* * ตรวจสอบว่าเป็นตัวเลขหรือตัวอักษร */b32cm_char_is_alphanumeric (charc);
/* * แปลงตัวอักษร */i32cm_digit_to_int (charc);
/* * แปลงตัวอักษรฐาน16(hex)เป็นตัวเลขจำนวนเต็ม */i32cm_hex_digit_to_int (charc);
/* * แปลงตัวอักษรเป็นพิมพ์เล็ก */voidcm_str_to_lower(char*str);
/* * แปลงตัวอักษรเป็นพิมพ์ใหญ่ */voidcm_str_to_upper(char*str);
/* * จำนวนข้อความ */isizecm_strlen (charconst*str);
/* *  */isizecm_strnlen(charconst*str, isizemax_len);
/* * เปรียบเทียบข้อความ */i32cm_strcmp (charconst*s1, charconst*s2);
/* *  */i32cm_strncmp(charconst*s1, charconst*s2, isizelen);
/* * ก๊อบปี้ข้อความ */char*cm_strcpy (char*dest, charconst*source);
/* *  */char*cm_strncpy(char*dest, charconst*source, isizelen);
/* *  */isizecm_strlcpy(char*dest, charconst*source, isizelen);
/* *  */char*cm_strrev (char*str);
/* *  */charconst*cm_strtok(char*output, charconst*src, charconst*delimit);
/* *  */b32cm_str_has_prefix(charconst*str, charconst*prefix);
/* *  */b32cm_str_has_suffix(charconst*str, charconst*suffix);
/* *  */charconst*cm_char_first_occurence(charconst*str, charc);
/* *  */charconst*cm_char_last_occurence (charconst*str, charc);
/* *  */voidcm_str_concat(char*dest, isizedest_len, charconst*src_a, isizesrc_a_len, charconst*src_b, isizesrc_b_len);
/* *  */u64cm_str_to_u64(charconst*str, char**end_ptr, i32base);
/* *  */i64cm_str_to_i64(charconst*str, char**end_ptr, i32base);
/* *  */f32cm_str_to_f32(charconst*str, char**end_ptr);
/* *  */f64cm_str_to_f64(charconst*str, char**end_ptr);
/* *  */voidcm_i64_to_str(i64value, char*string, i32base);
/* *  */voidcm_u64_to_str(u64value, char*string, i32base);

debug.h

#defineCM_DEBUG_TRAP()
#defineCM_ASSERT_MSG(cond, msg, ...)
#defineCM_ASSERT(cond)
#defineCM_ASSERT_NOT_NULL(ptr)
#defineCM_PANIC(msg, ...)
  • Function
//voidcm_assert_handler(charconst*prefix, charconst*condition, charconst*file, i32line, charconst*msg, ...);

defer.h

#defineCM_DEFER_1(x, y)
#defineCM_DEFER_2(x, y)
#defineCM_DEFER_3(x)
  • Function
/*ตัวอย่างcmMutex m;cm_mutex_init(&m);{	cm_mutex_lock(&m);	defer (cm_mutex_unlock(&m));	...}*/voiddefer(code);

dll.h

#defineCM_DLL_EXPORT#defineCM_DLL_IMPORT#defineCM_DEF#defineCM_SHARED_LIB_BUILD#defineCM_SHARED_LIB_USE#defineCM_C_API
  • Struct
typedefvoid*cmDllHandle;
typedefvoid (*cmDllProc)(void);
  • Function
/* * Ex. cmDllHandle handle = cm_dll_load("opengl32.dll"); */cmDllHandlecm_dll_load (charconst*filepath);
/* * Ex. cm_dll_unload(handle); */voidcm_dll_unload (cmDllHandledll);
/* * Ex. * cmDllHandle xinput_library = cm_dll_load("xinput9_1_0.dll"); * cmXInputGetStateProc *get_state = cast(cmXInputGetStateProc *)cm_dll_proc_address(xinput_library, "XInputGetState"); * cmXInputGetStateProc *set_state = cast(cmXInputSetStateProc *)cm_dll_proc_address(xinput_library, "XInputSetState"); */cmDllProccm_dll_proc_address (cmDllHandledll, charconst*proc_name);

dynarray.h

#defineCM_ARRAY_GROW_FORMULA(x)
#defineCM_ARRAY_HEADER(x)
  • Struct
/* * cmArrayHeader */typedefstructcmArrayHeader {
cmAllocatorallocator;
isizecount;
isizecapacity;
} cmArrayHeader;
  • Function
/* * ประกาศตัวแปร Ex. cmArray(i32) array; */cmArray(Type);
/* */cmAllocatorcm_array_allocator(x);
/* */isizecm_array_count(x);
/* */isizecm_array_capacity(x);
/* */voidcm_array_init_reserve(x, allocator_, cap);
/* */voidcm_array_init(x, allocator);
/* */voidcm_array_free(x);
/* */voidcm_array_set_capacity(x, capacity);
/* */void*cm__array_set_capacity(void*array, isizecapacity, isizeelement_size);
/* */voidcm_array_grow(x, min_capacity) ;
/* */voidcm_array_append(x, item);
/* */voidcm_array_appendv(x, items, item_count);
/* */voidcm_array_pop(x);
/* */voidcm_array_clear(x);
/* */voidcm_array_resize(x, new_count);
/* */voidcm_array_reserve(x, new_capacity);

extern.h

#defineCM_EXTERN#defineCM_BEGIN_EXTERN#defineCM_END_EXTERN

fences.h

  • Function
/* */voidcm_yield_thread(void);
/* */voidcm_mfence (void);
/* */voidcm_sfence (void);
/* */voidcm_lfence (void);

file.h

  • Struct
/* */typedefu32cmFileMode;
/* */typedefenumcmFileModeFlag {
cmFileMode_Read,
cmFileMode_Write,
cmFileMode_Append,
cmFileMode_Rw,
cmFileMode_Modes ,
} cmFileModeFlag;
/* */typedefenumcmSeekWhenceType {
cmSeekWhence_Begin,
cmSeekWhence_Current,
cmSeekWhence_End,
} cmSeekWhenceType;
/* */typedefenumcmFileError {
cmFileError_None,
cmFileError_Invalid,
cmFileError_InvalidFilename,
cmFileError_Exists,
cmFileError_NotExists,
cmFileError_Permission,
cmFileError_TruncationFailure,
} cmFileError;
/* */typedefunioncmFileDescriptor {
void*p;
intptri;
uintptru;
} cmFileDescriptor;
/* */typedefstructcmFileOperationscmFileOperations;
/* */typedefCM_FILE_OPEN_PROC(cmFileOpenProc);
/* */typedefCM_FILE_READ_AT_PROC(cmFileReadProc);
/* */typedefCM_FILE_WRITE_AT_PROC(cmFileWriteProc);
/* */typedefCM_FILE_SEEK_PROC(cmFileSeekProc);
/* */typedefCM_FILE_CLOSE_PROC(cmFileCloseProc)
/* */structcmFileOperations {
cmFileReadProc*read_at;
cmFileWriteProc*write_at;
cmFileSeekProc*seek;
cmFileCloseProc*close;
};
/* */externcmFileOperationsconstcmDefaultFileOperations;
/* */typedefu64cmFileTime;
/* */typedefstructcmFile {
cmFileOperationsops;
cmFileDescriptorfd;
charconst*filename;
cmFileTimelast_write_time;
// gbDirInfo * dir_info; // TODO(bill): Get directory info
} cmFile;
/* */typedefenumcmFileStandardType {
cmFileStandard_Input,
cmFileStandard_Output,
cmFileStandard_Error,
cmFileStandard_Count,
} cmFileStandardType;
/* */typedefstructcmFileContents {
cmAllocatorallocator;
void*data;
isizesize;
} cmFileContents;
/* */#defineCM_PATH_SEPARATOR
  • Function
/* */cmFile*constcm_file_get_standard (cmFileStandardTypestd);
/* */cmFileErrorcm_file_create (cmFile*file, charconst*filename);
/* */cmFileErrorcm_file_open_mode (cmFile*file, cmFileModemode, charconst*filename);
/* */cmFileErrorcm_file_new (cmFile*file, cmFileDescriptorfd, cmFileOperationsops, charconst*filename);
/* */b32cm_file_read_at_check (cmFile*file, void*buffer, isizesize, i64offset, isize*bytes_read);
/* */b32cm_file_write_at_check(cmFile*file, voidconst*buffer, isizesize, i64offset, isize*bytes_written);
/* */b32cm_file_read_at (cmFile*file, void*buffer, isizesize, i64offset);
/* */b32cm_file_write_at (cmFile*file, voidconst*buffer, isizesize, i64offset);
/* */i64cm_file_seek (cmFile*file, i64offset);
/* */i64cm_file_seek_to_end (cmFile*file);
/* */i64cm_file_skip (cmFile*file, i64bytes);
/* */i64cm_file_tell (cmFile*file);
/* */cmFileErrorcm_file_close (cmFile*file);
/* */b32cm_file_read (cmFile*file, void*buffer, isizesize);
/* */b32cm_file_write (cmFile*file, voidconst*buffer, isizesize);
/* */i64cm_file_size (cmFile*file);
/* */charconst*cm_file_name (cmFile*file);
/* */cmFileErrorcm_file_truncate (cmFile*file, i64size);
/* */b32cm_file_has_changed (cmFile*file);
/* */cmFileContentscm_file_read_contents(cmAllocatora, b32zero_terminate, charconst*filepath);
/* */voidcm_file_free_contents(cmFileContents*fc);
/* */b32cm_file_exists (charconst*filepath);
/* */cmFileTimecm_file_last_write_time(charconst*filepath);
/* */b32cm_file_copy (charconst*existing_filename, charconst*new_filename, b32fail_if_exists);
/* */b32cm_file_move (charconst*existing_filename, charconst*new_filename);
/* */b32cm_file_remove (charconst*filename);
/* */b32cm_path_is_absolute (charconst*path);
/* */b32cm_path_is_relative (charconst*path);
/* */b32cm_path_is_root (charconst*path);
/* */charconst*cm_path_base_name (charconst*path);
/* */charconst*cm_path_extension (charconst*path);
/* */char*cm_path_get_full_name(cmAllocatora, charconst*path);

hash.h

  • Function
/* */u32cm_adler32(voidconst*data, isizelen);
/* */u32cm_crc32(voidconst*data, isizelen);
/* */u64cm_crc64(voidconst*data, isizelen);
/* */u32cm_fnv32 (voidconst*data, isizelen);
/* */u64cm_fnv64 (voidconst*data, isizelen);
/* */u32cm_fnv32a(voidconst*data, isizelen);
/* */u64cm_fnv64a(voidconst*data, isizelen);
/* */u32cm_murmur32(voidconst*data, isizelen);
/* */u64cm_murmur64(voidconst*data, isizelen);
/* */u32cm_murmur32_seed(voidconst*data, isizelen, u32seed);
/* */u64cm_murmur64_seed(voidconst*data, isizelen, u64seed);

hashtable.h

#defineCM_TABLE(PREFIX, NAME, FUNC, VALUE)
#defineCM_TABLE_DECLARE(PREFIX, NAME, FUNC, VALUE)
#defineCM_TABLE_DEFINE(NAME, FUNC, VALUE)
  • Struct
/* * cmHashTableFindResult */typedefstructcmHashTableFindResult {
isizehash_index;
isizeentry_prev;
isizeentry_index;
} cmHashTableFindResult;

header.h

#define_CRT_SECURE_NO_WARNINGS#define_GNU_SOURCE#define_LARGEFILE64_SOURCE#defineWIN32_LEAN_AND_MEAN #define WIN32_MEAN_AND_LEAN #defineVC_EXTRALEAN#defineNOMINMAX

memory.h

#defineCM_DEFAULT_MEMORY_ALIGNMENT#defineCM_DEFAULT_ALLOCATOR_FLAGS
  • Struct
/* * cmVirtualMemory */typedefstructcmVirtualMemory {
void*data;
isizesize;
} cmVirtualMemory;
/* * cmVirtualMemory */typedefenumcmAllocationType {
cmAllocation_Alloc,
cmAllocation_Free,
cmAllocation_FreeAll,
cmAllocation_Resize,
} cmAllocationType;
/* * cmAllocator */typedefstructcmAllocator {
cmAllocatorProc*proc;
void*data;
} cmAllocator;
/* * cmAllocatorFlag */typedefenumcmAllocatorFlag {
cmAllocatorFlag_ClearToZero ,
} cmAllocatorFlag;
/* * cmArena */typedefstructcmArena {
cmAllocatorbacking;
void*physical_start;
isizetotal_size;
isizetotal_allocated;
isizetemp_count;
} cmArena;
  • Function
/* */b32cm_is_power_of_two (isizex);
/* */void*cm_align_forward (void*ptr, isizealignment);
/* */void*cm_pointer_add (void*ptr, isizebytes);
/* */void*cm_pointer_sub (void*ptr, isizebytes);
/* */voidconst*cm_pointer_add_const (voidconst*ptr, isizebytes);
/* */voidconst*cm_pointer_sub_const (voidconst*ptr, isizebytes);
/* */isizecm_pointer_diff (voidconst*begin, voidconst*end);
/* */voidcm_zero_size (void*ptr, isizesize);
/* */voidcm_zero_item (void*t)
/* */voidcm_zero_array (void*a, count)
/* */void*cm_memcopy (void*dest, voidconst*source, isizesize);
/* */void*cm_memmove (void*dest, voidconst*source, isizesize);
/* */void*cm_memset (void*data, u8byte_value, isizesize);
/* */i32cm_memcompare (voidconst*s1, voidconst*s2, isizesize);
/* */voidcm_memswap (void*i, void*j, isizesize);
/* */voidconst*cm_memchr (voidconst*data, u8byte_value, isizesize);
/* */voidconst*cm_memrchr (voidconst*data, u8byte_value, isizesize);
/* */cm_memcopy_array (dst, src, count);
/* */cm_memmove_array (dst, src, count) /* */cmVirtualMemorycm_virtual_memory (void*data, isizesize);
/* */cmVirtualMemorycm_vm_alloc (void*addr, isizesize);
/* */b32cm_vm_free (cmVirtualMemoryvm);
/* */cmVirtualMemorycm_vm_trim (cmVirtualMemoryvm, isizelead_size, isizesize);
/* */b32cm_vm_purge (cmVirtualMemoryvm);
/* */isizecm_virtual_memory_page_size (isize*alignment_out);
/* */void*cm_alloc_align (cmAllocatora, isizesize, isizealignment);
/* */void*cm_alloc (cmAllocatora, isizesize);
/* */voidcm_free (cmAllocatora, void*ptr);
/* */voidcm_free_all (cmAllocatora);
/* */void*cm_resize (cmAllocatora, void*ptr, isizeold_size, isizenew_size);
/* */void*cm_resize_align (cmAllocatora, void*ptr, isizeold_size, isizenew_size, isizealignment);
/* */void*cm_alloc_copy (cmAllocatora, voidconst*src, isizesize);
/* */void*cm_alloc_copy_align (cmAllocatora, voidconst*src, isizesize, isizealignment);
/* */char*cm_alloc_str (cmAllocatora, charconst*str);
/* */char*cm_alloc_str_len (cmAllocatora, charconst*str, isizelen);
/* */cm_alloc_item (allocator_, Type)
/* */cm_alloc_array (allocator_, Type, count)
/* */void*gb_default_resize_align (cmAllocatora, void*ptr, isizeold_size, isizenew_size, isizealignment);
/* */cmAllocatorcm_heap_allocator (void);
/* */cm_malloc(sz);
/* */cm_mfree(ptr);
/* */voidcm_arena_init_from_memory (cmArena*arena, void*start, isizesize);
/* */voidcm_arena_init_from_allocator (cmArena*arena, cmAllocatorbacking, isizesize);
/* */voidcm_arena_init_sub (cmArena*arena, cmArena*parent_arena, isizesize);
/* */voidcm_arena_free (cmArena*arena);
/* */isizecm_arena_alignment_of (cmArena*arena, isizealignment);
/* */isizecm_arena_size_remaining (cmArena*arena, isizealignment);
/* */voidcm_arena_check (cmArena*arena);
/* */cmAllocatorcm_arena_allocator (cmArena*arena);

math.h

#defineCM_MATH_INFINITYF#defineCM_MATH_NANF#defineCM_MATH_PZEROF#defineCM_MATH_NZEROF#defineCM_MATH_INFINITY#defineCM_MATH_NAN#defineCM_MATH_PZERO#defineCM_MATH_NZERO#defineCM_MATH_INFINITYL#defineCM_MATH_NANL#defineCM_MATH_PZEROL#defineCM_MATH_NZEROL#defineCM_SIZEOF_CHAR#defineCM_SIZEOF_BYTE#defineCM_SIZEOF_INT#defineCM_SIZEOF_INTP#defineCM_SIZEOF_UINTP#defineCM_SIZEOF_HALF#defineCM_SIZEOF_LONG#defineCM_SIZEOF_LONGLONG#defineCM_SIZEOF_DOUBLE#defineCM_SIZEOF_LONGDOUBLE#defineCM_SIZEOF_DATETIME#defineCM_SIZEOF_TIMEDELTA#defineCM_CHAR_BIT#defineCM_BYTE_FMT#defineCM_UBYTE_FMT#defineCM_SHORT_FMT#defineCM_USHORT_FMT#defineCM_INT_FMT#defineCM_UINT_FMT#defineCM_LONG_FMT#defineCM_ULONG_FMT#defineCM_HALF_FMT#defineCM_FLOAT_FMT#defineCM_DOUBLE_FMT#defineCM_LONGLONG_FMT#defineCM_ULONGLONG_FMT#defineCM_LONGLONG_SUFFIX(x)
#defineCM_ULONGLONG_SUFFIX(x)
#definecm_isnan(x)
#definecm_isfinite(x)
#definecm_isinf(x)
#defineCM_EXTRACT_WORDS(ix0,ix1,d)
#defineCM_GET_HIGH_WORD(i,d)
#defineCM_GET_LOW_WORD(i,d)
#defineCM_SET_HIGH_WORD(d,v)
#defineCM_SET_LOW_WORD(d,v)
#defineCM_INSERT_WORDS(d,ix0,ix1)
#defineCM_MATH_E#defineCM_MATH_LOG2E#defineCM_MATH_LOG10E#defineCM_MATH_LOGE2#defineCM_MATH_LOGE10#defineCM_MATH_PI#defineCM_MATH_PI_2 #define CM_MATH_PI_4
#defineCM_MATH_1_PI#defineCM_MATH_2_PI#defineCM_MATH_EULER#defineCM_MATH_SQRT2#defineCM_MATH_SQRT1_2#defineCM_MATH_Ef#defineCM_MATH_LOG2Ef#defineCM_MATH_LOG10Ef#defineCM_MATH_LOGE2f#defineCM_MATH_LOGE10f#defineCM_MATH_PIf#defineCM_MATH_PI_2f#defineCM_MATH_PI_4f#defineCM_MATH_1_PIf#defineCM_MATH_2_PIf#defineCM_MATH_EULERf#defineCM_MATH_SQRT2f#defineCM_MATH_SQRT1_2f#defineCM_MATH_El#defineCM_MATH_LOG2El#defineCM_MATH_LOG10El#defineCM_MATH_LOGE2l#defineCM_MATH_LOGE10l#defineCM_MATH_PIl#defineCM_MATH_PI_2l#defineCM_MATH_PI_4l#defineCM_MATH_1_PIl#defineCM_MATH_2_PIl#defineCM_MATH_EULERl#defineCM_MATH_SQRT2l#defineCM_MATH_SQRT1_2l#definecm_math_degrees#definecm_math_degreesf#definecm_math_degreesl#definecm_math_radians#definecm_math_radiansf#definecm_math_radiansl
  • Function
/* * Integer functions. *//* */u32cm_math_gcdu(u32a, u32b);
/* */u32cm_math_lcmu(u32a, u32b);
/* */ulcm_math_gcdul(ula, ulb);
/* */ulcm_math_lcmul(ula, ulb);
/* */ullcm_math_gcdull(ulla, ullb);
/* */ullcm_math_lcmull(ulla, ullb);
/* */u32cm_math_gcd(u32a, u32b);
/* */u32cm_math_lcm(u32a, u32b);
/* */ilcm_math_gcdl(ila, ilb);
/* */ilcm_math_lcml(ila, ilb);
/* */illcm_math_gcdll(illa, illb);
/* */illcm_math_lcmll(illa, illb);
/* */ubytecm_math_rshiftuhh(ubytea, ubyteb);
/* */ubytecm_math_lshiftuhh(ubytea, ubyteb);
/* */u16cm_math_rshiftuh(u16a, u16b);
/* */u16cm_math_lshiftuh(u16a, u16b);
/* */u32cm_math_rshiftu(u32a, u32b);
/* */u32cm_math_lshiftu(u32a, u32b);
/* */ulcm_math_rshiftul(ula, ulb);
/* */ulcm_math_lshiftul(ula, ulb);
/* */ullcm_math_rshiftull(ulla, ullb);
/* */ullcm_math_lshiftull(ulla, ullb);
/* */ibytecm_math_rshifthh(ibytea, ibyteb);
/* */ibytecm_math_lshifthh(ibytea, ibyteb);
/* */i16cm_math_rshifth(i16a, i16b);
/* */i16cm_math_lshifth(i16a, i16b);
/* */i32cm_math_rshift(i32a, i32b);
/* */i32cm_math_lshift(i32a, i32b);
/* */ilcm_math_rshiftl(ila, ilb);
/* */ilcm_math_lshiftl(ila, ilb);
/* */illcm_math_rshiftll(illa, illb);
/* */illcm_math_lshiftll(illa, illb);
/* * float C99 math functions *//* */f32cm_math_sinf(f32x);
/* */f32cm_math_cosf(f32x);
/* */f32cm_math_tanf(f32x);
/* */f32cm_math_sinhf(f32x);
/* */f32cm_math_coshf(f32x);
/* */f32cm_math_tanhf(f32x);
/* */f32cm_math_fabsf(f32x);
/* */f32cm_math_floorf(f32x);
/* */f32cm_math_ceilf(f32x);
/* */f32cm_math_rintf(f32x);
/* */f32cm_math_truncf(f32x);
/* */f32cm_math_sqrtf(f32x);
/* */f32cm_math_cbrtf(f32x);
/* */f32cm_math_log10f(f32x);
/* */f32cm_math_logf(f32x);
/* */f32cm_math_expf(f32x);
/* */f32cm_math_expm1f(f32x);
/* */f32cm_math_asinf(f32x);
/* */f32cm_math_acosf(f32x);
/* */f32cm_math_atanf(f32x);
/* */f32cm_math_asinhf(f32x);
/* */f32cm_math_acoshf(f32x);
/* */f32cm_math_atanhf(f32x);
/* */f32cm_math_log1pf(f32x);
/* */f32cm_math_exp2f(f32x);
/* */f32cm_math_log2f(f32x);
/* */f32cm_math_atan2f(f32x, f32y);
/* */f32cm_math_hypotf(f32x, f32y);
/* */f32cm_math_powf(f32x, f32y);
/* */f32cm_math_fmodf(f32x, f32y);
/* */f32cm_math_modff(f32x, f32*y);
/* */f32cm_math_frexpf(f32x, i32*y);
/* */f32cm_math_ldexpf(f32x, i32y);
/* */f32cm_math_copysignf(f32x, f32y);
/* */f32cm_math_nextafterf(f32x, f32y);
/* */f32cm_math_spacingf(f32x);
/* * long double C99 math functions *//* */fldcm_math_sinl(fldx);
/* */fldcm_math_cosl(fldx);
/* */fldcm_math_tanl(fldx);
/* */fldcm_math_sinhl(fldx);
/* */fldcm_math_coshl(fldx);
/* */fldcm_math_tanhl(fldx);
/* */fldcm_math_fabsl(fldx);
/* */fldcm_math_floorl(fldx);
/* */fldcm_math_ceill(fldx);
/* */fldcm_math_rintl(fldx);
/* */fldcm_math_truncl(fldx);
/* */fldcm_math_sqrtl(fldx);
/* */fldcm_math_cbrtl(fldx);
/* */fldcm_math_log10l(fldx);
/* */fldcm_math_logl(fldx);
/* */fldcm_math_expl(fldx);
/* */fldcm_math_expm1l(fldx);
/* */fldcm_math_asinl(fldx);
/* */fldcm_math_acosl(fldx);
/* */fldcm_math_atanl(fldx);
/* */fldcm_math_asinhl(fldx);
/* */fldcm_math_acoshl(fldx);
/* */fldcm_math_atanhl(fldx);
/* */fldcm_math_log1pl(fldx);
/* */fldcm_math_exp2l(fldx);
/* */fldcm_math_log2l(fldx);
/* */fldcm_math_atan2l(fldx, fldy);
/* */fldcm_math_hypotl(fldx, fldy);
/* */fldcm_math_powl(fldx, fldy);
/* */fldcm_math_fmodl(fldx, fldy);
/* */fldcm_math_modfl(fldx, fld*y);
/* */fldcm_math_frexpl(fldx, int*y);
/* */fldcm_math_ldexpl(fldx, inty);
/* */fldcm_math_copysignl(fldx, fldy);
/* */fldcm_math_nextafterl(fldx, fldy);
/* */fldcm_math_spacingl(fldx);
/* * Non standard functions *//* */f64cm_math_deg2rad(f64x);
/* */f64cm_math_rad2deg(f64x);
/* */f64cm_math_logaddexp(f64x, f64y);
/* */f64cm_math_logaddexp2(f64x, f64y);
/* */f64cm_math_divmod(f64x, f64y, f64*modulus);
/* */f64cm_math_heaviside(f64x, f64h0);
/* */f32cm_math_deg2radf(f32x);
/* */f32cm_math_rad2degf(f32x);
/* */f32cm_math_logaddexpf(f32x, f32y);
/* */f32cm_math_logaddexp2f(f32x, f32y);
/* */f32cm_math_divmodf(f32x, f32y, f32*modulus);
/* */f32cm_math_heavisidef(f32x, f32h0);
/* */fldcm_math_deg2radl(fldx);
/* */fldcm_math_rad2degl(fldx);
/* */fldcm_math_logaddexpl(fldx, fldy);
/* */fldcm_math_logaddexp2l(fldx, fldy);
/* */fldcm_math_divmodl(fldx, fldy, fld*modulus);
/* */fldcm_math_heavisidel(fldx, fldh0);
/* * Complex declarations *//* */inlinec64cm_math_cpack(f64x, f64y);
/* */inlinec32cm_math_cpackf(f32x, f32y);
/* */inlinecldcm_math_cpackl(fldx, fldy);
/* */inlinef64cm_math_creal(c64z);
/* */inlinef64cm_math_cimag(c64z);
/* */inlinef32cm_math_crealf(c32z);
/* */inlinef32cm_math_cimagf(c32z);
/* */inlinefldcm_math_creall(cldz);
/* */inlinefldcm_math_cimagl(cldz);
/* * Double precision complex functions *//* */f64cm_math_cabs(c64z);
/* */f64cm_math_carg(c64z);
/* */c64cm_math_cexp(c64z);
/* */c64cm_math_clog(c64z);
/* */c64cm_math_cpow(c64x, c64y);
/* */c64cm_math_csqrt(c64z);
/* */c64cm_math_ccos(c64z);
/* */c64cm_math_csin(c64z);
/* */c64cm_math_ctan(c64z);
/* */c64cm_math_ccosh(c64z);
/* */c64cm_math_csinh(c64z);
/* */c64cm_math_ctanh(c64z);
/* */c64cm_math_cacos(c64z);
/* */c64cm_math_casin(c64z);
/* */c64cm_math_catan(c64z);
/* */c64cm_math_cacosh(c64z);
/* */c64cm_math_casinh(c64z);
/* */c64cm_math_catanh(c64z);
/* * Single precision complex functions *//* */f32cm_math_cabsf(c32z);
/* */f32cm_math_cargf(c32z);
/* */c32cm_math_cexpf(c32z);
/* */c32cm_math_clogf(c32z);
/* */c32cm_math_cpowf(c32x, c32y);
/* */c32cm_math_csqrtf(c32z);
/* */c32cm_math_ccosf(c32z);
/* */c32cm_math_csinf(c32z);
/* */c32cm_math_ctanf(c32z);
/* */c32cm_math_ccoshf(c32z);
/* */c32cm_math_csinhf(c32z);
/* */c32cm_math_ctanhf(c32z);
/* */c32cm_math_cacosf(c32z);
/* */c32cm_math_casinf(c32z);
/* */c32cm_math_catanf(c32z);
/* */c32cm_math_cacoshf(c32z);
/* */c32cm_math_casinhf(c32z);
/* */c32cm_math_catanhf(c32z);
/* * Extended precision complex functions *//* */fldcm_math_cabsl(cldz);
/* */fldcm_math_cargl(cldz);
/* */cldcm_math_cexpl(cldz);
/* */cldcm_math_clogl(cldz);
/* */cldcm_math_cpowl(cldx, cldy);
/* */cldcm_math_csqrtl(cldz);
/* */cldcm_math_ccosl(cldz);
/* */cldcm_math_csinl(cldz);
/* */cldcm_math_ctanl(cldz);
/* */cldcm_math_ccoshl(cldz);
/* */cldcm_math_csinhl(cldz);
/* */cldcm_math_ctanhl(cldz);
/* */cldcm_math_cacosl(cldz);
/* */cldcm_math_casinl(cldz);
/* */cldcm_math_catanl(cldz);
/* */cldcm_math_cacoshl(cldz);
/* */cldcm_math_casinhl(cldz);
/* */cldcm_math_catanhl(cldz);

misc.h

  • Function
/* */voidcm_exit (u32code);
/* */voidcm_yield (void);
/* */voidcm_set_env (charconst*name, charconst*value);
/* */voidcm_unset_env (charconst*name);
/* */u16cm_endian_swap16 (u16i);
/* */u32cm_endian_swap32 (u32i);
/* */u64cm_endian_swap64 (u64i);
/* */isizecm_count_set_bits (u64mask);

mutex.h

  • Struct
/* * Windows */typedefstructcmMutex {
CRITICAL_SECTIONwin32_critical_section;
} cmMutex;
/* * Unix & Linux */typedefstructcmMutex {
pthread_mutex_tpthread_mutex;
pthread_mutexattr_tpthread_mutexattr;
} cmMutex;
  • Function
/* */voidcm_mutex_init (cmMutex*m);
/* */voidcm_mutex_destroy (cmMutex*m);
/* */voidcm_mutex_lock (cmMutex*m);
/* */b32cm_mutex_try_lock (cmMutex*m);
/* */voidcm_mutex_unlock (cmMutex*m);

print.h

  • Function
/* */isizecm_printf (charconst*fmt, ...) CM_PRINTF_ARGS(1);
/* */isizecm_printf_va (charconst*fmt, va_listva);
/* */isizecm_printf_err (charconst*fmt, ...) CM_PRINTF_ARGS(1);
/* */isizecm_printf_err_va (charconst*fmt, va_listva);
/* */isizecm_fprintf (cmFile*f, charconst*fmt, ...) CM_PRINTF_ARGS(2);
/* */isizecm_fprintf_va (cmFile*f, charconst*fmt, va_listva);
/* */char*cm_bprintf (charconst*fmt, ...) CM_PRINTF_ARGS(1);
/* */char*cm_bprintf_va (charconst*fmt, va_listva);
/* */isizecm_snprintf (char*str, isizen, charconst*fmt, ...) CM_PRINTF_ARGS(3);

random.h

  • Struct
/* */typedefstructcmRandom {
u32offsets[8];
u32value;
} cmRandom;
  • Function
/* */voidcm_random_init (cmRandom*r);
/* */u32cm_random_gen_u32 (cmRandom*r);
/* */u32cm_random_gen_u32_unique (cmRandom*r);
/* */u64cm_random_gen_u64 (cmRandom*r);
/* */isizecm_random_gen_isize (cmRandom*r);
/* */i64cm_random_range_i64 (cmRandom*r, i64lower_inc, i64higher_inc);
/* */isizecm_random_range_isize (cmRandom*r, isizelower_inc, isizehigher_inc);
/* */f64cm_random_range_f64 (cmRandom*r, f64lower_inc, f64higher_inc);

semaphore.h

  • Struct
/* * Window */typedefstructcmSemaphore { void*win32_handle;} cmSemaphore;
/* * OSX */typedefstructcmSemaphore { semaphore_tosx_handle; } cmSemaphore;
/* * Unix */typedefstructcmSemaphore { sem_tunix_handle; } cmSemaphore;
  • Function
/* */voidcm_semaphore_init (cmSemaphore*s);
/* */voidcm_semaphore_destroy (cmSemaphore*s);
/* */voidcm_semaphore_post (cmSemaphore*s, i32count);
/* */voidcm_semaphore_release (cmSemaphore*s);
/* */voidcm_semaphore_wait (cmSemaphore*s);

sortsearch.h

  • Function
/* */int (*cm_i16_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */int (*cm_i32_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */int (*cm_i64_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */int (*cm_isize_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */int (*cm_str_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */int (*cm_f32_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */int (*cm_f64_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */cm_sort_array(array, count, compare_proc) ;
/* */voidcm_sort(void*base, isizecount, isizesize, cmCompareProccompare_proc);
/* */cm_radix_sort(Type);
/* */voidcm_radix_sort_u8 (u8*items, u8*temp, isizecount);
/* */voidcm_radix_sort_u16 (u16*items, u16*temp, isizecount);
/* */voidcm_radix_sort_u32 (u32*items, u32*temp, isizecount);
/* */voidcm_radix_sort_u64 (u64*items, u64*temp, isizecount);
/* */cm_binary_search_array(array, count, key, compare_proc);
/* */isizecm_binary_search(voidconst*base, isizecount, isizesize, voidconst*key, cmCompareProccompare_proc);
/* */cm_shuffle_array(array, count);
/* */voidcm_shuffle(void*base, isizecount, isizesize);
/* */cm_reverse_array(array, count);
/* */voidcm_reverse(void*base, isizecount, isizesize);

string.h

  • Struct
/* */typedefchar*cmString;
/* */typedefstructcmStringHeader {
cmAllocatorallocator;
isizelength;
isizecapacity;
} cmStringHeader;
  • Function
/* */cmStringcm_string_make_reserve (cmAllocatora, isizecapacity);
/* */cmStringcm_string_make (cmAllocatora, charconst*str);
/* */cmStringcm_string_make_length (cmAllocatora, voidconst*str, isizenum_bytes);
/* */voidcm_string_free (cmStringstr);
/* */cmStringcm_string_duplicate (cmAllocatora, cmStringconststr);
/* */isizecm_string_length (cmStringconststr);
/* */isizecm_string_capacity (cmStringconststr);
/* */isizecm_string_available_space(cmStringconststr);
/* */voidcm_string_clear (cmStringstr);
/* */cmStringcm_string_append (cmStringstr, cmStringconstother);
/* */cmStringcm_string_append_length (cmStringstr, voidconst*other, isizenum_bytes);
/* */cmStringcm_string_appendc (cmStringstr, charconst*other);
/* */cmStringcm_string_append_rune (cmStringstr, Runer);
/* */cmStringcm_string_append_fmt (cmStringstr, charconst*fmt, ...);
/* */cmStringcm_string_set (cmStringstr, charconst*cstr);
/* */cmStringcm_string_make_space_for (cmStringstr, isizeadd_len);
/* */isizecm_string_allocation_size(cmStringconststr);
/* */b32cm_string_are_equal (cmStringconstlhs, cmStringconstrhs);
/* */cmStringcm_string_trim (cmStringstr, charconst*cut_set);
/* */cmStringcm_string_trim_space (cmStringstr);

thread.h

  • Struct
/* * Window */typedefstructcmThread {
void*win32_handle;
cmThreadProc*proc;
void*user_data;
isizeuser_index;
isizevolatilereturn_value;
cmSemaphoresemaphore;
isizestack_size;
b32volatileis_running;
} cmThread;
/* * Posix */typedefstructcmThread {
pthread_tposix_handle;
cmThreadProc*proc;
void*user_data;
isizeuser_index;
isizevolatilereturn_value;
cmSemaphoresemaphore;
isizestack_size;
b32volatileis_running;
} cmThread;
/* */typedefstructcmSync {
i32target; // Target Number of threadsi32current; // Threads to hiti32waiting; // Threads waitingcmMutexstart;
cmMutexmutex;
cmSemaphorerelease;
} cmSync;
  • Function
/* */voidcm_thread_init (cmThread*t);
/* */voidcm_thread_destroy (cmThread*t);
/* */voidcm_thread_start (cmThread*t, cmThreadProc*proc, void*data);
/* */voidcm_thread_start_with_stack (cmThread*t, cmThreadProc*proc, void*data, isizestack_size);
/* */voidcm_thread_join (cmThread*t);
/* */b32cm_thread_is_running (cmThreadconst*t);
/* */u32cm_thread_current_id (void);
/* */voidcm_thread_set_name (cmThread*t, charconst*name);
/* */voidcm_sync_init (cmSync*s);
/* */voidcm_sync_destroy (cmSync*s);
/* */voidcm_sync_set_target (cmSync*s, i32count);
/* */voidcm_sync_release (cmSync*s);
/* */i32cm_sync_reach (cmSync*s);
/* */voidcm_sync_reach_and_wait (cmSync*s);

time.h

  • Function
/* */u64cm_rdtsc (void);
/* */f64cm_time_now (void);
/* */u64cm_utc_time_now(void);
/* */voidcm_sleep_ms (u32ms);

utf8.h

  • Function
/* */isizecm_utf8_strlen (u8const*str);
/* */isizecm_utf8_strnlen(u8const*str, isizemax_len);
/* */u16*cm_utf8_to_ucs2 (u16*buffer, isizelen, u8const*str);
/* */u8*cm_ucs2_to_utf8 (u8*buffer, isizelen, u16const*str);
/* */u16*cm_utf8_to_ucs2_buf (u8const*str);
/* */u8*cm_ucs2_to_utf8_buf (u16const*str);
/* */isizecm_utf8_decode (u8const*str, isizestr_len, Rune*codepoint);
/* */isizecm_utf8_codepoint_size (u8const*str, isizestr_len);
/* */isizecm_utf8_encode_rune (u8buf[4], Runer);

utils.h

#defineNULL#defineinline#definecm_restrict#definecm_inline#definecm_no_inline#definecm_thread_local#definecast(Type)
#definecm_size_of(x)
#definecm_count_of(x)
#definecm_offset_of(Type, element)
#definecm_align_of(Type)
#definecm_swap(Type, a, b)
#definecm_global#definecm_internal#definecm_local_persist#definecm_unused(x)
#definevprtcast(x)
#definevoidcast(x)
#defineCM_BIT(x)
#defineCM_MIN(a, b)
#defineCM_MAX(a, b)
#defineCM_MIN3(a, b, c)
#defineCM_MAX3(a, b, c)
#defineCM_CLAMP(x, lower, upper)
#defineCM_CLAMP01(x)
#defineCM_IS_BETWEEN(x, lower, upper)
#defineCM_ABS(x)
#defineCM_MASK_SET(var, set, mask)
#defineCM_PRINTF_ARGS(FMT)

About

c/c++ marcro and utility

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

Latest commit

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

types.h

typedefu8;
typedefi8;
typedefu16;
typedefi16;
typedefu32;
typedefi32;
typedefu64;
typedefi64;
typedefusize; //typedef unsigned long long size_ttypedefisize; //typedef long long ptrdiff_ttypedefintptr;
typedefuintptr;
typedeff32;
typedeff64;
typedefRune;
typedefb8;
typedefb16;
typedefb32;
#defineCM_RUNE_INVALID#defineCM_RUNE_MAX #define CM_RUNE_BOM #defineCM_RUNE_EOF#defineU8_MIN#defineU8_MAX#defineI8_MIN#defineI8_MAX#defineU16_MIN#defineU16_MAX#defineI16_MIN#defineI16_MAX#defineU32_MIN#defineU32_MAX#defineI32_MIN#defineI32_MAX#defineU64_MIN#defineU64_MAX#defineI64_MIN#defineI64_MAX#defineUSIZE_MIX #define USIZE_MAX
#defineISIZE_MIX#defineISIZE_MAX#defineF32_MIN#defineF32_MAX#defineF64_MIN#defineF64_MAX

arch.h

/*  * Arch  */#defineCM_ARCH_64#defineCM_ARCH_32/*  * Endian  */#defineCM_ENDIAN_ORDER#defineCM_BIG_ENDIAN#defineCM_LITTLE_ENDIAN/* * OS */#defineCM_WINDOWS#defineCM_OS_WINDOWS#defineCM_SYS_WINDOWS#defineCM_OSX#defineCM_OS_OSX#defineCM_SYS_OSX#defineCM_UNIX#defineCM_OS_UNIX#defineCM_SYS_UNIX#defineCM_LINUX#defineCM_OS_LINUX#defineCM_SYS_LINUX#defineCM_FREEBSD#defineCM_OS_FREEBSD#defineCM_SYS_FREEBSD/* * Compiler */#defineCM_COMPILER_MSVC#defineCM_COMPILER_GCC#defineCM_COMPILER_CLANG/* * CPU */#defineCM_CPU_X86#defineCM_CPU_PPC#defineCM_CPU_ARM#defineCM_CPU_MIPS#defineCM_CACHE_LINE_SIZE

assert.h

#defineCM_STATIC_ASSERT(cond) #define CM_STATIC_ASSERT1(cond, line)
#defineCM_STATIC_ASSERT2(cond, line)
#defineCM_STATIC_ASSERT3(cond, msg)

affinity.h

  • Struct
/* * cmAffinity */typedefstructcmAffinity{
b32is_accurate;
isizecore_count;
isizethread_count;
usizecore_masks[CM_WIN32_MAX_THREADS];
} cmAffinity;
  • Function
/* */voidcm_affinity_init (cmAffinity*a);
/* */voidcm_affinity_destroy (cmAffinity*a);
/* */b32cm_affinity_set (cmAffinity*a, isizecore, isizethread);
/* */isizecm_affinity_thread_count_for_core (cmAffinity*a, isizecore);

atomics.h

  • Struct
/* * cmAtomic32 */typedefstructcmAtomic32 { i32volatilevalue; } cmAtomic32;
/* * cmAtomic64 */typedefstructcmAtomic64 {
i64volatilevalue; } cmAtomic64;
/* * cmAtomicPtr */typedefstructcmAtomicPtr { void*volatilevalue;
} cmAtomicPtr;
  • Function
/* * atomic32 */i32cm_atomic32_load (cmAtomic32constvolatile*a);
voidcm_atomic32_store (cmAtomic32volatile*a, i32value);
i32cm_atomic32_compare_exchange (cmAtomic32volatile*a, i32expected, i32desired);
i32cm_atomic32_exchanged (cmAtomic32volatile*a, i32desired);
i32cm_atomic32_fetch_add (cmAtomic32volatile*a, i32operand);
i32cm_atomic32_fetch_and (cmAtomic32volatile*a, i32operand);
i32cm_atomic32_fetch_or (cmAtomic32volatile*a, i32operand);
b32cm_atomic32_spin_lock (cmAtomic32volatile*a, isizetime_out);
voidcm_atomic32_spin_unlock (cmAtomic32volatile*a);
b32cm_atomic32_try_acquire_lock (cmAtomic32volatile*a);
/* * atomic64 */i64cm_atomic64_load (cmAtomic64constvolatile*a);
voidcm_atomic64_store (cmAtomic64volatile*a, i64value);
i64cm_atomic64_compare_exchange (cmAtomic64volatile*a, i64expected, i64desired);
i64cm_atomic64_exchanged (cmAtomic64volatile*a, i64desired);
i64cm_atomic64_fetch_add (cmAtomic64volatile*a, i64operand);
i64cm_atomic64_fetch_and (cmAtomic64volatile*a, i64operand);
i64cm_atomic64_fetch_or (cmAtomic64volatile*a, i64operand);
b32cm_atomic64_spin_lock (cmAtomic64volatile*a, isizetime_out);
voidcm_atomic64_spin_unlock (cmAtomic64volatile*a);
b32cm_atomic64_try_acquire_lock (cmAtomic64volatile*a);
/* * atomicptr */void*cm_atomic_ptr_load (cmAtomicPtrconstvolatile*a);
voidcm_atomic_ptr_store (cmAtomicPtrvolatile*a, void*value);
void*cm_atomic_ptr_compare_exchange (cmAtomicPtrvolatile*a, void*expected, void*desired);
void*cm_atomic_ptr_exchanged (cmAtomicPtrvolatile*a, void*desired);
void*cm_atomic_ptr_fetch_add (cmAtomicPtrvolatile*a, void*operand);
void*cm_atomic_ptr_fetch_and (cmAtomicPtrvolatile*a, void*operand);
void*cm_atomic_ptr_fetch_or (cmAtomicPtrvolatile*a, void*operand);
b32cm_atomic_ptr_spin_lock (cmAtomicPtrvolatile*a, isizetime_out);
voidcm_atomic_ptr_spin_unlock (cmAtomicPtrvolatile*a);
b32cm_atomic_ptr_try_acquire_lock (cmAtomicPtrvolatile*a);

buffer.h

  • Struct
/* * cmBufferHeader */typedefstructcmBufferHeader {
isizecount;
isizecapacity;
} cmBufferHeader;
  • Function
/* * ประกาศตัวแปร Ex. cmBuffer(i32) buffer; */cmBuffer(Type);
/* * จำนวน */isizecm_buffer_count (cmBufferHeader*bfh);
/* * ความจุ */isizecm_buffer_capacity (cmBufferHeader*bfh);
/* * ค่าเริ่มต้น */void*cm_buffer_init (x, allocator, cap);
/* * เลิกใช้งาน */voidcm_buffer_free (x, allocator);
/* * เพิ่มข้อมูล(1 รายการ) */voidcm_buffer_append (x, item);
/* * เพิ่มข้อมูล(มากกว่า 1 รายการ) */voidcm_buffer_appendv (x, items, item_count);
/* * นำข้อมูลออก */voidcm_buffer_pop (x);
/* * ล้างข้อมูล */cm_buffer_clear (x)

char.h

  • Function
/* * แปลงตัวอักษรเป็นพิมพ์เล็ก */charcm_char_to_lower (charc);
/* * แปลงตัวอักษรเป็นพิมพ์ใหญ่ */charcm_char_to_upper (charc);
/* * ตรวจสอบช่องว่าง */b32cm_char_is_space (charc);
/* * ตรวจสอบตัวเลข */b32cm_char_is_digit (charc);
/* * ตรวจสอบตัวเลขที่เป็นฐาน16 (hex) */b32cm_char_is_hex_digit (charc);
/* *  */b32cm_char_is_alpha (charc);
/* * ตรวจสอบว่าเป็นตัวเลขหรือตัวอักษร */b32cm_char_is_alphanumeric (charc);
/* * แปลงตัวอักษร */i32cm_digit_to_int (charc);
/* * แปลงตัวอักษรฐาน16(hex)เป็นตัวเลขจำนวนเต็ม */i32cm_hex_digit_to_int (charc);
/* * แปลงตัวอักษรเป็นพิมพ์เล็ก */voidcm_str_to_lower(char*str);
/* * แปลงตัวอักษรเป็นพิมพ์ใหญ่ */voidcm_str_to_upper(char*str);
/* * จำนวนข้อความ */isizecm_strlen (charconst*str);
/* *  */isizecm_strnlen(charconst*str, isizemax_len);
/* * เปรียบเทียบข้อความ */i32cm_strcmp (charconst*s1, charconst*s2);
/* *  */i32cm_strncmp(charconst*s1, charconst*s2, isizelen);
/* * ก๊อบปี้ข้อความ */char*cm_strcpy (char*dest, charconst*source);
/* *  */char*cm_strncpy(char*dest, charconst*source, isizelen);
/* *  */isizecm_strlcpy(char*dest, charconst*source, isizelen);
/* *  */char*cm_strrev (char*str);
/* *  */charconst*cm_strtok(char*output, charconst*src, charconst*delimit);
/* *  */b32cm_str_has_prefix(charconst*str, charconst*prefix);
/* *  */b32cm_str_has_suffix(charconst*str, charconst*suffix);
/* *  */charconst*cm_char_first_occurence(charconst*str, charc);
/* *  */charconst*cm_char_last_occurence (charconst*str, charc);
/* *  */voidcm_str_concat(char*dest, isizedest_len, charconst*src_a, isizesrc_a_len, charconst*src_b, isizesrc_b_len);
/* *  */u64cm_str_to_u64(charconst*str, char**end_ptr, i32base);
/* *  */i64cm_str_to_i64(charconst*str, char**end_ptr, i32base);
/* *  */f32cm_str_to_f32(charconst*str, char**end_ptr);
/* *  */f64cm_str_to_f64(charconst*str, char**end_ptr);
/* *  */voidcm_i64_to_str(i64value, char*string, i32base);
/* *  */voidcm_u64_to_str(u64value, char*string, i32base);

debug.h

#defineCM_DEBUG_TRAP()
#defineCM_ASSERT_MSG(cond, msg, ...)
#defineCM_ASSERT(cond)
#defineCM_ASSERT_NOT_NULL(ptr)
#defineCM_PANIC(msg, ...)
  • Function
//voidcm_assert_handler(charconst*prefix, charconst*condition, charconst*file, i32line, charconst*msg, ...);

defer.h

#defineCM_DEFER_1(x, y)
#defineCM_DEFER_2(x, y)
#defineCM_DEFER_3(x)
  • Function
/*ตัวอย่างcmMutex m;cm_mutex_init(&m);{	cm_mutex_lock(&m);	defer (cm_mutex_unlock(&m));	...}*/voiddefer(code);

dll.h

#defineCM_DLL_EXPORT#defineCM_DLL_IMPORT#defineCM_DEF#defineCM_SHARED_LIB_BUILD#defineCM_SHARED_LIB_USE#defineCM_C_API
  • Struct
typedefvoid*cmDllHandle;
typedefvoid (*cmDllProc)(void);
  • Function
/* * Ex. cmDllHandle handle = cm_dll_load("opengl32.dll"); */cmDllHandlecm_dll_load (charconst*filepath);
/* * Ex. cm_dll_unload(handle); */voidcm_dll_unload (cmDllHandledll);
/* * Ex. * cmDllHandle xinput_library = cm_dll_load("xinput9_1_0.dll"); * cmXInputGetStateProc *get_state = cast(cmXInputGetStateProc *)cm_dll_proc_address(xinput_library, "XInputGetState"); * cmXInputGetStateProc *set_state = cast(cmXInputSetStateProc *)cm_dll_proc_address(xinput_library, "XInputSetState"); */cmDllProccm_dll_proc_address (cmDllHandledll, charconst*proc_name);

dynarray.h

#defineCM_ARRAY_GROW_FORMULA(x)
#defineCM_ARRAY_HEADER(x)
  • Struct
/* * cmArrayHeader */typedefstructcmArrayHeader {
cmAllocatorallocator;
isizecount;
isizecapacity;
} cmArrayHeader;
  • Function
/* * ประกาศตัวแปร Ex. cmArray(i32) array; */cmArray(Type);
/* */cmAllocatorcm_array_allocator(x);
/* */isizecm_array_count(x);
/* */isizecm_array_capacity(x);
/* */voidcm_array_init_reserve(x, allocator_, cap);
/* */voidcm_array_init(x, allocator);
/* */voidcm_array_free(x);
/* */voidcm_array_set_capacity(x, capacity);
/* */void*cm__array_set_capacity(void*array, isizecapacity, isizeelement_size);
/* */voidcm_array_grow(x, min_capacity) ;
/* */voidcm_array_append(x, item);
/* */voidcm_array_appendv(x, items, item_count);
/* */voidcm_array_pop(x);
/* */voidcm_array_clear(x);
/* */voidcm_array_resize(x, new_count);
/* */voidcm_array_reserve(x, new_capacity);

extern.h

#defineCM_EXTERN#defineCM_BEGIN_EXTERN#defineCM_END_EXTERN

fences.h

  • Function
/* */voidcm_yield_thread(void);
/* */voidcm_mfence (void);
/* */voidcm_sfence (void);
/* */voidcm_lfence (void);

file.h

  • Struct
/* */typedefu32cmFileMode;
/* */typedefenumcmFileModeFlag {
cmFileMode_Read,
cmFileMode_Write,
cmFileMode_Append,
cmFileMode_Rw,
cmFileMode_Modes ,
} cmFileModeFlag;
/* */typedefenumcmSeekWhenceType {
cmSeekWhence_Begin,
cmSeekWhence_Current,
cmSeekWhence_End,
} cmSeekWhenceType;
/* */typedefenumcmFileError {
cmFileError_None,
cmFileError_Invalid,
cmFileError_InvalidFilename,
cmFileError_Exists,
cmFileError_NotExists,
cmFileError_Permission,
cmFileError_TruncationFailure,
} cmFileError;
/* */typedefunioncmFileDescriptor {
void*p;
intptri;
uintptru;
} cmFileDescriptor;
/* */typedefstructcmFileOperationscmFileOperations;
/* */typedefCM_FILE_OPEN_PROC(cmFileOpenProc);
/* */typedefCM_FILE_READ_AT_PROC(cmFileReadProc);
/* */typedefCM_FILE_WRITE_AT_PROC(cmFileWriteProc);
/* */typedefCM_FILE_SEEK_PROC(cmFileSeekProc);
/* */typedefCM_FILE_CLOSE_PROC(cmFileCloseProc)
/* */structcmFileOperations {
cmFileReadProc*read_at;
cmFileWriteProc*write_at;
cmFileSeekProc*seek;
cmFileCloseProc*close;
};
/* */externcmFileOperationsconstcmDefaultFileOperations;
/* */typedefu64cmFileTime;
/* */typedefstructcmFile {
cmFileOperationsops;
cmFileDescriptorfd;
charconst*filename;
cmFileTimelast_write_time;
// gbDirInfo * dir_info; // TODO(bill): Get directory info
} cmFile;
/* */typedefenumcmFileStandardType {
cmFileStandard_Input,
cmFileStandard_Output,
cmFileStandard_Error,
cmFileStandard_Count,
} cmFileStandardType;
/* */typedefstructcmFileContents {
cmAllocatorallocator;
void*data;
isizesize;
} cmFileContents;
/* */#defineCM_PATH_SEPARATOR
  • Function
/* */cmFile*constcm_file_get_standard (cmFileStandardTypestd);
/* */cmFileErrorcm_file_create (cmFile*file, charconst*filename);
/* */cmFileErrorcm_file_open_mode (cmFile*file, cmFileModemode, charconst*filename);
/* */cmFileErrorcm_file_new (cmFile*file, cmFileDescriptorfd, cmFileOperationsops, charconst*filename);
/* */b32cm_file_read_at_check (cmFile*file, void*buffer, isizesize, i64offset, isize*bytes_read);
/* */b32cm_file_write_at_check(cmFile*file, voidconst*buffer, isizesize, i64offset, isize*bytes_written);
/* */b32cm_file_read_at (cmFile*file, void*buffer, isizesize, i64offset);
/* */b32cm_file_write_at (cmFile*file, voidconst*buffer, isizesize, i64offset);
/* */i64cm_file_seek (cmFile*file, i64offset);
/* */i64cm_file_seek_to_end (cmFile*file);
/* */i64cm_file_skip (cmFile*file, i64bytes);
/* */i64cm_file_tell (cmFile*file);
/* */cmFileErrorcm_file_close (cmFile*file);
/* */b32cm_file_read (cmFile*file, void*buffer, isizesize);
/* */b32cm_file_write (cmFile*file, voidconst*buffer, isizesize);
/* */i64cm_file_size (cmFile*file);
/* */charconst*cm_file_name (cmFile*file);
/* */cmFileErrorcm_file_truncate (cmFile*file, i64size);
/* */b32cm_file_has_changed (cmFile*file);
/* */cmFileContentscm_file_read_contents(cmAllocatora, b32zero_terminate, charconst*filepath);
/* */voidcm_file_free_contents(cmFileContents*fc);
/* */b32cm_file_exists (charconst*filepath);
/* */cmFileTimecm_file_last_write_time(charconst*filepath);
/* */b32cm_file_copy (charconst*existing_filename, charconst*new_filename, b32fail_if_exists);
/* */b32cm_file_move (charconst*existing_filename, charconst*new_filename);
/* */b32cm_file_remove (charconst*filename);
/* */b32cm_path_is_absolute (charconst*path);
/* */b32cm_path_is_relative (charconst*path);
/* */b32cm_path_is_root (charconst*path);
/* */charconst*cm_path_base_name (charconst*path);
/* */charconst*cm_path_extension (charconst*path);
/* */char*cm_path_get_full_name(cmAllocatora, charconst*path);

hash.h

  • Function
/* */u32cm_adler32(voidconst*data, isizelen);
/* */u32cm_crc32(voidconst*data, isizelen);
/* */u64cm_crc64(voidconst*data, isizelen);
/* */u32cm_fnv32 (voidconst*data, isizelen);
/* */u64cm_fnv64 (voidconst*data, isizelen);
/* */u32cm_fnv32a(voidconst*data, isizelen);
/* */u64cm_fnv64a(voidconst*data, isizelen);
/* */u32cm_murmur32(voidconst*data, isizelen);
/* */u64cm_murmur64(voidconst*data, isizelen);
/* */u32cm_murmur32_seed(voidconst*data, isizelen, u32seed);
/* */u64cm_murmur64_seed(voidconst*data, isizelen, u64seed);

hashtable.h

#defineCM_TABLE(PREFIX, NAME, FUNC, VALUE)
#defineCM_TABLE_DECLARE(PREFIX, NAME, FUNC, VALUE)
#defineCM_TABLE_DEFINE(NAME, FUNC, VALUE)
  • Struct
/* * cmHashTableFindResult */typedefstructcmHashTableFindResult {
isizehash_index;
isizeentry_prev;
isizeentry_index;
} cmHashTableFindResult;

header.h

#define_CRT_SECURE_NO_WARNINGS#define_GNU_SOURCE#define_LARGEFILE64_SOURCE#defineWIN32_LEAN_AND_MEAN #define WIN32_MEAN_AND_LEAN #defineVC_EXTRALEAN#defineNOMINMAX

memory.h

#defineCM_DEFAULT_MEMORY_ALIGNMENT#defineCM_DEFAULT_ALLOCATOR_FLAGS
  • Struct
/* * cmVirtualMemory */typedefstructcmVirtualMemory {
void*data;
isizesize;
} cmVirtualMemory;
/* * cmVirtualMemory */typedefenumcmAllocationType {
cmAllocation_Alloc,
cmAllocation_Free,
cmAllocation_FreeAll,
cmAllocation_Resize,
} cmAllocationType;
/* * cmAllocator */typedefstructcmAllocator {
cmAllocatorProc*proc;
void*data;
} cmAllocator;
/* * cmAllocatorFlag */typedefenumcmAllocatorFlag {
cmAllocatorFlag_ClearToZero ,
} cmAllocatorFlag;
/* * cmArena */typedefstructcmArena {
cmAllocatorbacking;
void*physical_start;
isizetotal_size;
isizetotal_allocated;
isizetemp_count;
} cmArena;
  • Function
/* */b32cm_is_power_of_two (isizex);
/* */void*cm_align_forward (void*ptr, isizealignment);
/* */void*cm_pointer_add (void*ptr, isizebytes);
/* */void*cm_pointer_sub (void*ptr, isizebytes);
/* */voidconst*cm_pointer_add_const (voidconst*ptr, isizebytes);
/* */voidconst*cm_pointer_sub_const (voidconst*ptr, isizebytes);
/* */isizecm_pointer_diff (voidconst*begin, voidconst*end);
/* */voidcm_zero_size (void*ptr, isizesize);
/* */voidcm_zero_item (void*t)
/* */voidcm_zero_array (void*a, count)
/* */void*cm_memcopy (void*dest, voidconst*source, isizesize);
/* */void*cm_memmove (void*dest, voidconst*source, isizesize);
/* */void*cm_memset (void*data, u8byte_value, isizesize);
/* */i32cm_memcompare (voidconst*s1, voidconst*s2, isizesize);
/* */voidcm_memswap (void*i, void*j, isizesize);
/* */voidconst*cm_memchr (voidconst*data, u8byte_value, isizesize);
/* */voidconst*cm_memrchr (voidconst*data, u8byte_value, isizesize);
/* */cm_memcopy_array (dst, src, count);
/* */cm_memmove_array (dst, src, count) /* */cmVirtualMemorycm_virtual_memory (void*data, isizesize);
/* */cmVirtualMemorycm_vm_alloc (void*addr, isizesize);
/* */b32cm_vm_free (cmVirtualMemoryvm);
/* */cmVirtualMemorycm_vm_trim (cmVirtualMemoryvm, isizelead_size, isizesize);
/* */b32cm_vm_purge (cmVirtualMemoryvm);
/* */isizecm_virtual_memory_page_size (isize*alignment_out);
/* */void*cm_alloc_align (cmAllocatora, isizesize, isizealignment);
/* */void*cm_alloc (cmAllocatora, isizesize);
/* */voidcm_free (cmAllocatora, void*ptr);
/* */voidcm_free_all (cmAllocatora);
/* */void*cm_resize (cmAllocatora, void*ptr, isizeold_size, isizenew_size);
/* */void*cm_resize_align (cmAllocatora, void*ptr, isizeold_size, isizenew_size, isizealignment);
/* */void*cm_alloc_copy (cmAllocatora, voidconst*src, isizesize);
/* */void*cm_alloc_copy_align (cmAllocatora, voidconst*src, isizesize, isizealignment);
/* */char*cm_alloc_str (cmAllocatora, charconst*str);
/* */char*cm_alloc_str_len (cmAllocatora, charconst*str, isizelen);
/* */cm_alloc_item (allocator_, Type)
/* */cm_alloc_array (allocator_, Type, count)
/* */void*gb_default_resize_align (cmAllocatora, void*ptr, isizeold_size, isizenew_size, isizealignment);
/* */cmAllocatorcm_heap_allocator (void);
/* */cm_malloc(sz);
/* */cm_mfree(ptr);
/* */voidcm_arena_init_from_memory (cmArena*arena, void*start, isizesize);
/* */voidcm_arena_init_from_allocator (cmArena*arena, cmAllocatorbacking, isizesize);
/* */voidcm_arena_init_sub (cmArena*arena, cmArena*parent_arena, isizesize);
/* */voidcm_arena_free (cmArena*arena);
/* */isizecm_arena_alignment_of (cmArena*arena, isizealignment);
/* */isizecm_arena_size_remaining (cmArena*arena, isizealignment);
/* */voidcm_arena_check (cmArena*arena);
/* */cmAllocatorcm_arena_allocator (cmArena*arena);

math.h

#defineCM_MATH_INFINITYF#defineCM_MATH_NANF#defineCM_MATH_PZEROF#defineCM_MATH_NZEROF#defineCM_MATH_INFINITY#defineCM_MATH_NAN#defineCM_MATH_PZERO#defineCM_MATH_NZERO#defineCM_MATH_INFINITYL#defineCM_MATH_NANL#defineCM_MATH_PZEROL#defineCM_MATH_NZEROL#defineCM_SIZEOF_CHAR#defineCM_SIZEOF_BYTE#defineCM_SIZEOF_INT#defineCM_SIZEOF_INTP#defineCM_SIZEOF_UINTP#defineCM_SIZEOF_HALF#defineCM_SIZEOF_LONG#defineCM_SIZEOF_LONGLONG#defineCM_SIZEOF_DOUBLE#defineCM_SIZEOF_LONGDOUBLE#defineCM_SIZEOF_DATETIME#defineCM_SIZEOF_TIMEDELTA#defineCM_CHAR_BIT#defineCM_BYTE_FMT#defineCM_UBYTE_FMT#defineCM_SHORT_FMT#defineCM_USHORT_FMT#defineCM_INT_FMT#defineCM_UINT_FMT#defineCM_LONG_FMT#defineCM_ULONG_FMT#defineCM_HALF_FMT#defineCM_FLOAT_FMT#defineCM_DOUBLE_FMT#defineCM_LONGLONG_FMT#defineCM_ULONGLONG_FMT#defineCM_LONGLONG_SUFFIX(x)
#defineCM_ULONGLONG_SUFFIX(x)
#definecm_isnan(x)
#definecm_isfinite(x)
#definecm_isinf(x)
#defineCM_EXTRACT_WORDS(ix0,ix1,d)
#defineCM_GET_HIGH_WORD(i,d)
#defineCM_GET_LOW_WORD(i,d)
#defineCM_SET_HIGH_WORD(d,v)
#defineCM_SET_LOW_WORD(d,v)
#defineCM_INSERT_WORDS(d,ix0,ix1)
#defineCM_MATH_E#defineCM_MATH_LOG2E#defineCM_MATH_LOG10E#defineCM_MATH_LOGE2#defineCM_MATH_LOGE10#defineCM_MATH_PI#defineCM_MATH_PI_2 #define CM_MATH_PI_4
#defineCM_MATH_1_PI#defineCM_MATH_2_PI#defineCM_MATH_EULER#defineCM_MATH_SQRT2#defineCM_MATH_SQRT1_2#defineCM_MATH_Ef#defineCM_MATH_LOG2Ef#defineCM_MATH_LOG10Ef#defineCM_MATH_LOGE2f#defineCM_MATH_LOGE10f#defineCM_MATH_PIf#defineCM_MATH_PI_2f#defineCM_MATH_PI_4f#defineCM_MATH_1_PIf#defineCM_MATH_2_PIf#defineCM_MATH_EULERf#defineCM_MATH_SQRT2f#defineCM_MATH_SQRT1_2f#defineCM_MATH_El#defineCM_MATH_LOG2El#defineCM_MATH_LOG10El#defineCM_MATH_LOGE2l#defineCM_MATH_LOGE10l#defineCM_MATH_PIl#defineCM_MATH_PI_2l#defineCM_MATH_PI_4l#defineCM_MATH_1_PIl#defineCM_MATH_2_PIl#defineCM_MATH_EULERl#defineCM_MATH_SQRT2l#defineCM_MATH_SQRT1_2l#definecm_math_degrees#definecm_math_degreesf#definecm_math_degreesl#definecm_math_radians#definecm_math_radiansf#definecm_math_radiansl
  • Function
/* * Integer functions. *//* */u32cm_math_gcdu(u32a, u32b);
/* */u32cm_math_lcmu(u32a, u32b);
/* */ulcm_math_gcdul(ula, ulb);
/* */ulcm_math_lcmul(ula, ulb);
/* */ullcm_math_gcdull(ulla, ullb);
/* */ullcm_math_lcmull(ulla, ullb);
/* */u32cm_math_gcd(u32a, u32b);
/* */u32cm_math_lcm(u32a, u32b);
/* */ilcm_math_gcdl(ila, ilb);
/* */ilcm_math_lcml(ila, ilb);
/* */illcm_math_gcdll(illa, illb);
/* */illcm_math_lcmll(illa, illb);
/* */ubytecm_math_rshiftuhh(ubytea, ubyteb);
/* */ubytecm_math_lshiftuhh(ubytea, ubyteb);
/* */u16cm_math_rshiftuh(u16a, u16b);
/* */u16cm_math_lshiftuh(u16a, u16b);
/* */u32cm_math_rshiftu(u32a, u32b);
/* */u32cm_math_lshiftu(u32a, u32b);
/* */ulcm_math_rshiftul(ula, ulb);
/* */ulcm_math_lshiftul(ula, ulb);
/* */ullcm_math_rshiftull(ulla, ullb);
/* */ullcm_math_lshiftull(ulla, ullb);
/* */ibytecm_math_rshifthh(ibytea, ibyteb);
/* */ibytecm_math_lshifthh(ibytea, ibyteb);
/* */i16cm_math_rshifth(i16a, i16b);
/* */i16cm_math_lshifth(i16a, i16b);
/* */i32cm_math_rshift(i32a, i32b);
/* */i32cm_math_lshift(i32a, i32b);
/* */ilcm_math_rshiftl(ila, ilb);
/* */ilcm_math_lshiftl(ila, ilb);
/* */illcm_math_rshiftll(illa, illb);
/* */illcm_math_lshiftll(illa, illb);
/* * float C99 math functions *//* */f32cm_math_sinf(f32x);
/* */f32cm_math_cosf(f32x);
/* */f32cm_math_tanf(f32x);
/* */f32cm_math_sinhf(f32x);
/* */f32cm_math_coshf(f32x);
/* */f32cm_math_tanhf(f32x);
/* */f32cm_math_fabsf(f32x);
/* */f32cm_math_floorf(f32x);
/* */f32cm_math_ceilf(f32x);
/* */f32cm_math_rintf(f32x);
/* */f32cm_math_truncf(f32x);
/* */f32cm_math_sqrtf(f32x);
/* */f32cm_math_cbrtf(f32x);
/* */f32cm_math_log10f(f32x);
/* */f32cm_math_logf(f32x);
/* */f32cm_math_expf(f32x);
/* */f32cm_math_expm1f(f32x);
/* */f32cm_math_asinf(f32x);
/* */f32cm_math_acosf(f32x);
/* */f32cm_math_atanf(f32x);
/* */f32cm_math_asinhf(f32x);
/* */f32cm_math_acoshf(f32x);
/* */f32cm_math_atanhf(f32x);
/* */f32cm_math_log1pf(f32x);
/* */f32cm_math_exp2f(f32x);
/* */f32cm_math_log2f(f32x);
/* */f32cm_math_atan2f(f32x, f32y);
/* */f32cm_math_hypotf(f32x, f32y);
/* */f32cm_math_powf(f32x, f32y);
/* */f32cm_math_fmodf(f32x, f32y);
/* */f32cm_math_modff(f32x, f32*y);
/* */f32cm_math_frexpf(f32x, i32*y);
/* */f32cm_math_ldexpf(f32x, i32y);
/* */f32cm_math_copysignf(f32x, f32y);
/* */f32cm_math_nextafterf(f32x, f32y);
/* */f32cm_math_spacingf(f32x);
/* * long double C99 math functions *//* */fldcm_math_sinl(fldx);
/* */fldcm_math_cosl(fldx);
/* */fldcm_math_tanl(fldx);
/* */fldcm_math_sinhl(fldx);
/* */fldcm_math_coshl(fldx);
/* */fldcm_math_tanhl(fldx);
/* */fldcm_math_fabsl(fldx);
/* */fldcm_math_floorl(fldx);
/* */fldcm_math_ceill(fldx);
/* */fldcm_math_rintl(fldx);
/* */fldcm_math_truncl(fldx);
/* */fldcm_math_sqrtl(fldx);
/* */fldcm_math_cbrtl(fldx);
/* */fldcm_math_log10l(fldx);
/* */fldcm_math_logl(fldx);
/* */fldcm_math_expl(fldx);
/* */fldcm_math_expm1l(fldx);
/* */fldcm_math_asinl(fldx);
/* */fldcm_math_acosl(fldx);
/* */fldcm_math_atanl(fldx);
/* */fldcm_math_asinhl(fldx);
/* */fldcm_math_acoshl(fldx);
/* */fldcm_math_atanhl(fldx);
/* */fldcm_math_log1pl(fldx);
/* */fldcm_math_exp2l(fldx);
/* */fldcm_math_log2l(fldx);
/* */fldcm_math_atan2l(fldx, fldy);
/* */fldcm_math_hypotl(fldx, fldy);
/* */fldcm_math_powl(fldx, fldy);
/* */fldcm_math_fmodl(fldx, fldy);
/* */fldcm_math_modfl(fldx, fld*y);
/* */fldcm_math_frexpl(fldx, int*y);
/* */fldcm_math_ldexpl(fldx, inty);
/* */fldcm_math_copysignl(fldx, fldy);
/* */fldcm_math_nextafterl(fldx, fldy);
/* */fldcm_math_spacingl(fldx);
/* * Non standard functions *//* */f64cm_math_deg2rad(f64x);
/* */f64cm_math_rad2deg(f64x);
/* */f64cm_math_logaddexp(f64x, f64y);
/* */f64cm_math_logaddexp2(f64x, f64y);
/* */f64cm_math_divmod(f64x, f64y, f64*modulus);
/* */f64cm_math_heaviside(f64x, f64h0);
/* */f32cm_math_deg2radf(f32x);
/* */f32cm_math_rad2degf(f32x);
/* */f32cm_math_logaddexpf(f32x, f32y);
/* */f32cm_math_logaddexp2f(f32x, f32y);
/* */f32cm_math_divmodf(f32x, f32y, f32*modulus);
/* */f32cm_math_heavisidef(f32x, f32h0);
/* */fldcm_math_deg2radl(fldx);
/* */fldcm_math_rad2degl(fldx);
/* */fldcm_math_logaddexpl(fldx, fldy);
/* */fldcm_math_logaddexp2l(fldx, fldy);
/* */fldcm_math_divmodl(fldx, fldy, fld*modulus);
/* */fldcm_math_heavisidel(fldx, fldh0);
/* * Complex declarations *//* */inlinec64cm_math_cpack(f64x, f64y);
/* */inlinec32cm_math_cpackf(f32x, f32y);
/* */inlinecldcm_math_cpackl(fldx, fldy);
/* */inlinef64cm_math_creal(c64z);
/* */inlinef64cm_math_cimag(c64z);
/* */inlinef32cm_math_crealf(c32z);
/* */inlinef32cm_math_cimagf(c32z);
/* */inlinefldcm_math_creall(cldz);
/* */inlinefldcm_math_cimagl(cldz);
/* * Double precision complex functions *//* */f64cm_math_cabs(c64z);
/* */f64cm_math_carg(c64z);
/* */c64cm_math_cexp(c64z);
/* */c64cm_math_clog(c64z);
/* */c64cm_math_cpow(c64x, c64y);
/* */c64cm_math_csqrt(c64z);
/* */c64cm_math_ccos(c64z);
/* */c64cm_math_csin(c64z);
/* */c64cm_math_ctan(c64z);
/* */c64cm_math_ccosh(c64z);
/* */c64cm_math_csinh(c64z);
/* */c64cm_math_ctanh(c64z);
/* */c64cm_math_cacos(c64z);
/* */c64cm_math_casin(c64z);
/* */c64cm_math_catan(c64z);
/* */c64cm_math_cacosh(c64z);
/* */c64cm_math_casinh(c64z);
/* */c64cm_math_catanh(c64z);
/* * Single precision complex functions *//* */f32cm_math_cabsf(c32z);
/* */f32cm_math_cargf(c32z);
/* */c32cm_math_cexpf(c32z);
/* */c32cm_math_clogf(c32z);
/* */c32cm_math_cpowf(c32x, c32y);
/* */c32cm_math_csqrtf(c32z);
/* */c32cm_math_ccosf(c32z);
/* */c32cm_math_csinf(c32z);
/* */c32cm_math_ctanf(c32z);
/* */c32cm_math_ccoshf(c32z);
/* */c32cm_math_csinhf(c32z);
/* */c32cm_math_ctanhf(c32z);
/* */c32cm_math_cacosf(c32z);
/* */c32cm_math_casinf(c32z);
/* */c32cm_math_catanf(c32z);
/* */c32cm_math_cacoshf(c32z);
/* */c32cm_math_casinhf(c32z);
/* */c32cm_math_catanhf(c32z);
/* * Extended precision complex functions *//* */fldcm_math_cabsl(cldz);
/* */fldcm_math_cargl(cldz);
/* */cldcm_math_cexpl(cldz);
/* */cldcm_math_clogl(cldz);
/* */cldcm_math_cpowl(cldx, cldy);
/* */cldcm_math_csqrtl(cldz);
/* */cldcm_math_ccosl(cldz);
/* */cldcm_math_csinl(cldz);
/* */cldcm_math_ctanl(cldz);
/* */cldcm_math_ccoshl(cldz);
/* */cldcm_math_csinhl(cldz);
/* */cldcm_math_ctanhl(cldz);
/* */cldcm_math_cacosl(cldz);
/* */cldcm_math_casinl(cldz);
/* */cldcm_math_catanl(cldz);
/* */cldcm_math_cacoshl(cldz);
/* */cldcm_math_casinhl(cldz);
/* */cldcm_math_catanhl(cldz);

misc.h

  • Function
/* */voidcm_exit (u32code);
/* */voidcm_yield (void);
/* */voidcm_set_env (charconst*name, charconst*value);
/* */voidcm_unset_env (charconst*name);
/* */u16cm_endian_swap16 (u16i);
/* */u32cm_endian_swap32 (u32i);
/* */u64cm_endian_swap64 (u64i);
/* */isizecm_count_set_bits (u64mask);

mutex.h

  • Struct
/* * Windows */typedefstructcmMutex {
CRITICAL_SECTIONwin32_critical_section;
} cmMutex;
/* * Unix & Linux */typedefstructcmMutex {
pthread_mutex_tpthread_mutex;
pthread_mutexattr_tpthread_mutexattr;
} cmMutex;
  • Function
/* */voidcm_mutex_init (cmMutex*m);
/* */voidcm_mutex_destroy (cmMutex*m);
/* */voidcm_mutex_lock (cmMutex*m);
/* */b32cm_mutex_try_lock (cmMutex*m);
/* */voidcm_mutex_unlock (cmMutex*m);

print.h

  • Function
/* */isizecm_printf (charconst*fmt, ...) CM_PRINTF_ARGS(1);
/* */isizecm_printf_va (charconst*fmt, va_listva);
/* */isizecm_printf_err (charconst*fmt, ...) CM_PRINTF_ARGS(1);
/* */isizecm_printf_err_va (charconst*fmt, va_listva);
/* */isizecm_fprintf (cmFile*f, charconst*fmt, ...) CM_PRINTF_ARGS(2);
/* */isizecm_fprintf_va (cmFile*f, charconst*fmt, va_listva);
/* */char*cm_bprintf (charconst*fmt, ...) CM_PRINTF_ARGS(1);
/* */char*cm_bprintf_va (charconst*fmt, va_listva);
/* */isizecm_snprintf (char*str, isizen, charconst*fmt, ...) CM_PRINTF_ARGS(3);

random.h

  • Struct
/* */typedefstructcmRandom {
u32offsets[8];
u32value;
} cmRandom;
  • Function
/* */voidcm_random_init (cmRandom*r);
/* */u32cm_random_gen_u32 (cmRandom*r);
/* */u32cm_random_gen_u32_unique (cmRandom*r);
/* */u64cm_random_gen_u64 (cmRandom*r);
/* */isizecm_random_gen_isize (cmRandom*r);
/* */i64cm_random_range_i64 (cmRandom*r, i64lower_inc, i64higher_inc);
/* */isizecm_random_range_isize (cmRandom*r, isizelower_inc, isizehigher_inc);
/* */f64cm_random_range_f64 (cmRandom*r, f64lower_inc, f64higher_inc);

semaphore.h

  • Struct
/* * Window */typedefstructcmSemaphore { void*win32_handle;} cmSemaphore;
/* * OSX */typedefstructcmSemaphore { semaphore_tosx_handle; } cmSemaphore;
/* * Unix */typedefstructcmSemaphore { sem_tunix_handle; } cmSemaphore;
  • Function
/* */voidcm_semaphore_init (cmSemaphore*s);
/* */voidcm_semaphore_destroy (cmSemaphore*s);
/* */voidcm_semaphore_post (cmSemaphore*s, i32count);
/* */voidcm_semaphore_release (cmSemaphore*s);
/* */voidcm_semaphore_wait (cmSemaphore*s);

sortsearch.h

  • Function
/* */int (*cm_i16_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */int (*cm_i32_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */int (*cm_i64_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */int (*cm_isize_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */int (*cm_str_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */int (*cm_f32_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */int (*cm_f64_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */cm_sort_array(array, count, compare_proc) ;
/* */voidcm_sort(void*base, isizecount, isizesize, cmCompareProccompare_proc);
/* */cm_radix_sort(Type);
/* */voidcm_radix_sort_u8 (u8*items, u8*temp, isizecount);
/* */voidcm_radix_sort_u16 (u16*items, u16*temp, isizecount);
/* */voidcm_radix_sort_u32 (u32*items, u32*temp, isizecount);
/* */voidcm_radix_sort_u64 (u64*items, u64*temp, isizecount);
/* */cm_binary_search_array(array, count, key, compare_proc);
/* */isizecm_binary_search(voidconst*base, isizecount, isizesize, voidconst*key, cmCompareProccompare_proc);
/* */cm_shuffle_array(array, count);
/* */voidcm_shuffle(void*base, isizecount, isizesize);
/* */cm_reverse_array(array, count);
/* */voidcm_reverse(void*base, isizecount, isizesize);

string.h

  • Struct
/* */typedefchar*cmString;
/* */typedefstructcmStringHeader {
cmAllocatorallocator;
isizelength;
isizecapacity;
} cmStringHeader;
  • Function
/* */cmStringcm_string_make_reserve (cmAllocatora, isizecapacity);
/* */cmStringcm_string_make (cmAllocatora, charconst*str);
/* */cmStringcm_string_make_length (cmAllocatora, voidconst*str, isizenum_bytes);
/* */voidcm_string_free (cmStringstr);
/* */cmStringcm_string_duplicate (cmAllocatora, cmStringconststr);
/* */isizecm_string_length (cmStringconststr);
/* */isizecm_string_capacity (cmStringconststr);
/* */isizecm_string_available_space(cmStringconststr);
/* */voidcm_string_clear (cmStringstr);
/* */cmStringcm_string_append (cmStringstr, cmStringconstother);
/* */cmStringcm_string_append_length (cmStringstr, voidconst*other, isizenum_bytes);
/* */cmStringcm_string_appendc (cmStringstr, charconst*other);
/* */cmStringcm_string_append_rune (cmStringstr, Runer);
/* */cmStringcm_string_append_fmt (cmStringstr, charconst*fmt, ...);
/* */cmStringcm_string_set (cmStringstr, charconst*cstr);
/* */cmStringcm_string_make_space_for (cmStringstr, isizeadd_len);
/* */isizecm_string_allocation_size(cmStringconststr);
/* */b32cm_string_are_equal (cmStringconstlhs, cmStringconstrhs);
/* */cmStringcm_string_trim (cmStringstr, charconst*cut_set);
/* */cmStringcm_string_trim_space (cmStringstr);

thread.h

  • Struct
/* * Window */typedefstructcmThread {
void*win32_handle;
cmThreadProc*proc;
void*user_data;
isizeuser_index;
isizevolatilereturn_value;
cmSemaphoresemaphore;
isizestack_size;
b32volatileis_running;
} cmThread;
/* * Posix */typedefstructcmThread {
pthread_tposix_handle;
cmThreadProc*proc;
void*user_data;
isizeuser_index;
isizevolatilereturn_value;
cmSemaphoresemaphore;
isizestack_size;
b32volatileis_running;
} cmThread;
/* */typedefstructcmSync {
i32target; // Target Number of threadsi32current; // Threads to hiti32waiting; // Threads waitingcmMutexstart;
cmMutexmutex;
cmSemaphorerelease;
} cmSync;
  • Function
/* */voidcm_thread_init (cmThread*t);
/* */voidcm_thread_destroy (cmThread*t);
/* */voidcm_thread_start (cmThread*t, cmThreadProc*proc, void*data);
/* */voidcm_thread_start_with_stack (cmThread*t, cmThreadProc*proc, void*data, isizestack_size);
/* */voidcm_thread_join (cmThread*t);
/* */b32cm_thread_is_running (cmThreadconst*t);
/* */u32cm_thread_current_id (void);
/* */voidcm_thread_set_name (cmThread*t, charconst*name);
/* */voidcm_sync_init (cmSync*s);
/* */voidcm_sync_destroy (cmSync*s);
/* */voidcm_sync_set_target (cmSync*s, i32count);
/* */voidcm_sync_release (cmSync*s);
/* */i32cm_sync_reach (cmSync*s);
/* */voidcm_sync_reach_and_wait (cmSync*s);

time.h

  • Function
/* */u64cm_rdtsc (void);
/* */f64cm_time_now (void);
/* */u64cm_utc_time_now(void);
/* */voidcm_sleep_ms (u32ms);

utf8.h

  • Function
/* */isizecm_utf8_strlen (u8const*str);
/* */isizecm_utf8_strnlen(u8const*str, isizemax_len);
/* */u16*cm_utf8_to_ucs2 (u16*buffer, isizelen, u8const*str);
/* */u8*cm_ucs2_to_utf8 (u8*buffer, isizelen, u16const*str);
/* */u16*cm_utf8_to_ucs2_buf (u8const*str);
/* */u8*cm_ucs2_to_utf8_buf (u16const*str);
/* */isizecm_utf8_decode (u8const*str, isizestr_len, Rune*codepoint);
/* */isizecm_utf8_codepoint_size (u8const*str, isizestr_len);
/* */isizecm_utf8_encode_rune (u8buf[4], Runer);

utils.h

#defineNULL#defineinline#definecm_restrict#definecm_inline#definecm_no_inline#definecm_thread_local#definecast(Type)
#definecm_size_of(x)
#definecm_count_of(x)
#definecm_offset_of(Type, element)
#definecm_align_of(Type)
#definecm_swap(Type, a, b)
#definecm_global#definecm_internal#definecm_local_persist#definecm_unused(x)
#definevprtcast(x)
#definevoidcast(x)
#defineCM_BIT(x)
#defineCM_MIN(a, b)
#defineCM_MAX(a, b)
#defineCM_MIN3(a, b, c)
#defineCM_MAX3(a, b, c)
#defineCM_CLAMP(x, lower, upper)
#defineCM_CLAMP01(x)
#defineCM_IS_BETWEEN(x, lower, upper)
#defineCM_ABS(x)
#defineCM_MASK_SET(var, set, mask)
#defineCM_PRINTF_ARGS(FMT)

About

c/c++ marcro and utility

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Latest commit

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

types.h

typedefu8;
typedefi8;
typedefu16;
typedefi16;
typedefu32;
typedefi32;
typedefu64;
typedefi64;
typedefusize; //typedef unsigned long long size_ttypedefisize; //typedef long long ptrdiff_ttypedefintptr;
typedefuintptr;
typedeff32;
typedeff64;
typedefRune;
typedefb8;
typedefb16;
typedefb32;
#defineCM_RUNE_INVALID#defineCM_RUNE_MAX #define CM_RUNE_BOM #defineCM_RUNE_EOF#defineU8_MIN#defineU8_MAX#defineI8_MIN#defineI8_MAX#defineU16_MIN#defineU16_MAX#defineI16_MIN#defineI16_MAX#defineU32_MIN#defineU32_MAX#defineI32_MIN#defineI32_MAX#defineU64_MIN#defineU64_MAX#defineI64_MIN#defineI64_MAX#defineUSIZE_MIX #define USIZE_MAX
#defineISIZE_MIX#defineISIZE_MAX#defineF32_MIN#defineF32_MAX#defineF64_MIN#defineF64_MAX

arch.h

/*  * Arch  */#defineCM_ARCH_64#defineCM_ARCH_32/*  * Endian  */#defineCM_ENDIAN_ORDER#defineCM_BIG_ENDIAN#defineCM_LITTLE_ENDIAN/* * OS */#defineCM_WINDOWS#defineCM_OS_WINDOWS#defineCM_SYS_WINDOWS#defineCM_OSX#defineCM_OS_OSX#defineCM_SYS_OSX#defineCM_UNIX#defineCM_OS_UNIX#defineCM_SYS_UNIX#defineCM_LINUX#defineCM_OS_LINUX#defineCM_SYS_LINUX#defineCM_FREEBSD#defineCM_OS_FREEBSD#defineCM_SYS_FREEBSD/* * Compiler */#defineCM_COMPILER_MSVC#defineCM_COMPILER_GCC#defineCM_COMPILER_CLANG/* * CPU */#defineCM_CPU_X86#defineCM_CPU_PPC#defineCM_CPU_ARM#defineCM_CPU_MIPS#defineCM_CACHE_LINE_SIZE

assert.h

#defineCM_STATIC_ASSERT(cond) #define CM_STATIC_ASSERT1(cond, line)
#defineCM_STATIC_ASSERT2(cond, line)
#defineCM_STATIC_ASSERT3(cond, msg)

affinity.h

  • Struct
/* * cmAffinity */typedefstructcmAffinity{
b32is_accurate;
isizecore_count;
isizethread_count;
usizecore_masks[CM_WIN32_MAX_THREADS];
} cmAffinity;
  • Function
/* */voidcm_affinity_init (cmAffinity*a);
/* */voidcm_affinity_destroy (cmAffinity*a);
/* */b32cm_affinity_set (cmAffinity*a, isizecore, isizethread);
/* */isizecm_affinity_thread_count_for_core (cmAffinity*a, isizecore);

atomics.h

  • Struct
/* * cmAtomic32 */typedefstructcmAtomic32 { i32volatilevalue; } cmAtomic32;
/* * cmAtomic64 */typedefstructcmAtomic64 {
i64volatilevalue; } cmAtomic64;
/* * cmAtomicPtr */typedefstructcmAtomicPtr { void*volatilevalue;
} cmAtomicPtr;
  • Function
/* * atomic32 */i32cm_atomic32_load (cmAtomic32constvolatile*a);
voidcm_atomic32_store (cmAtomic32volatile*a, i32value);
i32cm_atomic32_compare_exchange (cmAtomic32volatile*a, i32expected, i32desired);
i32cm_atomic32_exchanged (cmAtomic32volatile*a, i32desired);
i32cm_atomic32_fetch_add (cmAtomic32volatile*a, i32operand);
i32cm_atomic32_fetch_and (cmAtomic32volatile*a, i32operand);
i32cm_atomic32_fetch_or (cmAtomic32volatile*a, i32operand);
b32cm_atomic32_spin_lock (cmAtomic32volatile*a, isizetime_out);
voidcm_atomic32_spin_unlock (cmAtomic32volatile*a);
b32cm_atomic32_try_acquire_lock (cmAtomic32volatile*a);
/* * atomic64 */i64cm_atomic64_load (cmAtomic64constvolatile*a);
voidcm_atomic64_store (cmAtomic64volatile*a, i64value);
i64cm_atomic64_compare_exchange (cmAtomic64volatile*a, i64expected, i64desired);
i64cm_atomic64_exchanged (cmAtomic64volatile*a, i64desired);
i64cm_atomic64_fetch_add (cmAtomic64volatile*a, i64operand);
i64cm_atomic64_fetch_and (cmAtomic64volatile*a, i64operand);
i64cm_atomic64_fetch_or (cmAtomic64volatile*a, i64operand);
b32cm_atomic64_spin_lock (cmAtomic64volatile*a, isizetime_out);
voidcm_atomic64_spin_unlock (cmAtomic64volatile*a);
b32cm_atomic64_try_acquire_lock (cmAtomic64volatile*a);
/* * atomicptr */void*cm_atomic_ptr_load (cmAtomicPtrconstvolatile*a);
voidcm_atomic_ptr_store (cmAtomicPtrvolatile*a, void*value);
void*cm_atomic_ptr_compare_exchange (cmAtomicPtrvolatile*a, void*expected, void*desired);
void*cm_atomic_ptr_exchanged (cmAtomicPtrvolatile*a, void*desired);
void*cm_atomic_ptr_fetch_add (cmAtomicPtrvolatile*a, void*operand);
void*cm_atomic_ptr_fetch_and (cmAtomicPtrvolatile*a, void*operand);
void*cm_atomic_ptr_fetch_or (cmAtomicPtrvolatile*a, void*operand);
b32cm_atomic_ptr_spin_lock (cmAtomicPtrvolatile*a, isizetime_out);
voidcm_atomic_ptr_spin_unlock (cmAtomicPtrvolatile*a);
b32cm_atomic_ptr_try_acquire_lock (cmAtomicPtrvolatile*a);

buffer.h

  • Struct
/* * cmBufferHeader */typedefstructcmBufferHeader {
isizecount;
isizecapacity;
} cmBufferHeader;
  • Function
/* * ประกาศตัวแปร Ex. cmBuffer(i32) buffer; */cmBuffer(Type);
/* * จำนวน */isizecm_buffer_count (cmBufferHeader*bfh);
/* * ความจุ */isizecm_buffer_capacity (cmBufferHeader*bfh);
/* * ค่าเริ่มต้น */void*cm_buffer_init (x, allocator, cap);
/* * เลิกใช้งาน */voidcm_buffer_free (x, allocator);
/* * เพิ่มข้อมูล(1 รายการ) */voidcm_buffer_append (x, item);
/* * เพิ่มข้อมูล(มากกว่า 1 รายการ) */voidcm_buffer_appendv (x, items, item_count);
/* * นำข้อมูลออก */voidcm_buffer_pop (x);
/* * ล้างข้อมูล */cm_buffer_clear (x)

char.h

  • Function
/* * แปลงตัวอักษรเป็นพิมพ์เล็ก */charcm_char_to_lower (charc);
/* * แปลงตัวอักษรเป็นพิมพ์ใหญ่ */charcm_char_to_upper (charc);
/* * ตรวจสอบช่องว่าง */b32cm_char_is_space (charc);
/* * ตรวจสอบตัวเลข */b32cm_char_is_digit (charc);
/* * ตรวจสอบตัวเลขที่เป็นฐาน16 (hex) */b32cm_char_is_hex_digit (charc);
/* *  */b32cm_char_is_alpha (charc);
/* * ตรวจสอบว่าเป็นตัวเลขหรือตัวอักษร */b32cm_char_is_alphanumeric (charc);
/* * แปลงตัวอักษร */i32cm_digit_to_int (charc);
/* * แปลงตัวอักษรฐาน16(hex)เป็นตัวเลขจำนวนเต็ม */i32cm_hex_digit_to_int (charc);
/* * แปลงตัวอักษรเป็นพิมพ์เล็ก */voidcm_str_to_lower(char*str);
/* * แปลงตัวอักษรเป็นพิมพ์ใหญ่ */voidcm_str_to_upper(char*str);
/* * จำนวนข้อความ */isizecm_strlen (charconst*str);
/* *  */isizecm_strnlen(charconst*str, isizemax_len);
/* * เปรียบเทียบข้อความ */i32cm_strcmp (charconst*s1, charconst*s2);
/* *  */i32cm_strncmp(charconst*s1, charconst*s2, isizelen);
/* * ก๊อบปี้ข้อความ */char*cm_strcpy (char*dest, charconst*source);
/* *  */char*cm_strncpy(char*dest, charconst*source, isizelen);
/* *  */isizecm_strlcpy(char*dest, charconst*source, isizelen);
/* *  */char*cm_strrev (char*str);
/* *  */charconst*cm_strtok(char*output, charconst*src, charconst*delimit);
/* *  */b32cm_str_has_prefix(charconst*str, charconst*prefix);
/* *  */b32cm_str_has_suffix(charconst*str, charconst*suffix);
/* *  */charconst*cm_char_first_occurence(charconst*str, charc);
/* *  */charconst*cm_char_last_occurence (charconst*str, charc);
/* *  */voidcm_str_concat(char*dest, isizedest_len, charconst*src_a, isizesrc_a_len, charconst*src_b, isizesrc_b_len);
/* *  */u64cm_str_to_u64(charconst*str, char**end_ptr, i32base);
/* *  */i64cm_str_to_i64(charconst*str, char**end_ptr, i32base);
/* *  */f32cm_str_to_f32(charconst*str, char**end_ptr);
/* *  */f64cm_str_to_f64(charconst*str, char**end_ptr);
/* *  */voidcm_i64_to_str(i64value, char*string, i32base);
/* *  */voidcm_u64_to_str(u64value, char*string, i32base);

debug.h

#defineCM_DEBUG_TRAP()
#defineCM_ASSERT_MSG(cond, msg, ...)
#defineCM_ASSERT(cond)
#defineCM_ASSERT_NOT_NULL(ptr)
#defineCM_PANIC(msg, ...)
  • Function
//voidcm_assert_handler(charconst*prefix, charconst*condition, charconst*file, i32line, charconst*msg, ...);

defer.h

#defineCM_DEFER_1(x, y)
#defineCM_DEFER_2(x, y)
#defineCM_DEFER_3(x)
  • Function
/*ตัวอย่างcmMutex m;cm_mutex_init(&m);{	cm_mutex_lock(&m);	defer (cm_mutex_unlock(&m));	...}*/voiddefer(code);

dll.h

#defineCM_DLL_EXPORT#defineCM_DLL_IMPORT#defineCM_DEF#defineCM_SHARED_LIB_BUILD#defineCM_SHARED_LIB_USE#defineCM_C_API
  • Struct
typedefvoid*cmDllHandle;
typedefvoid (*cmDllProc)(void);
  • Function
/* * Ex. cmDllHandle handle = cm_dll_load("opengl32.dll"); */cmDllHandlecm_dll_load (charconst*filepath);
/* * Ex. cm_dll_unload(handle); */voidcm_dll_unload (cmDllHandledll);
/* * Ex. * cmDllHandle xinput_library = cm_dll_load("xinput9_1_0.dll"); * cmXInputGetStateProc *get_state = cast(cmXInputGetStateProc *)cm_dll_proc_address(xinput_library, "XInputGetState"); * cmXInputGetStateProc *set_state = cast(cmXInputSetStateProc *)cm_dll_proc_address(xinput_library, "XInputSetState"); */cmDllProccm_dll_proc_address (cmDllHandledll, charconst*proc_name);

dynarray.h

#defineCM_ARRAY_GROW_FORMULA(x)
#defineCM_ARRAY_HEADER(x)
  • Struct
/* * cmArrayHeader */typedefstructcmArrayHeader {
cmAllocatorallocator;
isizecount;
isizecapacity;
} cmArrayHeader;
  • Function
/* * ประกาศตัวแปร Ex. cmArray(i32) array; */cmArray(Type);
/* */cmAllocatorcm_array_allocator(x);
/* */isizecm_array_count(x);
/* */isizecm_array_capacity(x);
/* */voidcm_array_init_reserve(x, allocator_, cap);
/* */voidcm_array_init(x, allocator);
/* */voidcm_array_free(x);
/* */voidcm_array_set_capacity(x, capacity);
/* */void*cm__array_set_capacity(void*array, isizecapacity, isizeelement_size);
/* */voidcm_array_grow(x, min_capacity) ;
/* */voidcm_array_append(x, item);
/* */voidcm_array_appendv(x, items, item_count);
/* */voidcm_array_pop(x);
/* */voidcm_array_clear(x);
/* */voidcm_array_resize(x, new_count);
/* */voidcm_array_reserve(x, new_capacity);

extern.h

#defineCM_EXTERN#defineCM_BEGIN_EXTERN#defineCM_END_EXTERN

fences.h

  • Function
/* */voidcm_yield_thread(void);
/* */voidcm_mfence (void);
/* */voidcm_sfence (void);
/* */voidcm_lfence (void);

file.h

  • Struct
/* */typedefu32cmFileMode;
/* */typedefenumcmFileModeFlag {
cmFileMode_Read,
cmFileMode_Write,
cmFileMode_Append,
cmFileMode_Rw,
cmFileMode_Modes ,
} cmFileModeFlag;
/* */typedefenumcmSeekWhenceType {
cmSeekWhence_Begin,
cmSeekWhence_Current,
cmSeekWhence_End,
} cmSeekWhenceType;
/* */typedefenumcmFileError {
cmFileError_None,
cmFileError_Invalid,
cmFileError_InvalidFilename,
cmFileError_Exists,
cmFileError_NotExists,
cmFileError_Permission,
cmFileError_TruncationFailure,
} cmFileError;
/* */typedefunioncmFileDescriptor {
void*p;
intptri;
uintptru;
} cmFileDescriptor;
/* */typedefstructcmFileOperationscmFileOperations;
/* */typedefCM_FILE_OPEN_PROC(cmFileOpenProc);
/* */typedefCM_FILE_READ_AT_PROC(cmFileReadProc);
/* */typedefCM_FILE_WRITE_AT_PROC(cmFileWriteProc);
/* */typedefCM_FILE_SEEK_PROC(cmFileSeekProc);
/* */typedefCM_FILE_CLOSE_PROC(cmFileCloseProc)
/* */structcmFileOperations {
cmFileReadProc*read_at;
cmFileWriteProc*write_at;
cmFileSeekProc*seek;
cmFileCloseProc*close;
};
/* */externcmFileOperationsconstcmDefaultFileOperations;
/* */typedefu64cmFileTime;
/* */typedefstructcmFile {
cmFileOperationsops;
cmFileDescriptorfd;
charconst*filename;
cmFileTimelast_write_time;
// gbDirInfo * dir_info; // TODO(bill): Get directory info
} cmFile;
/* */typedefenumcmFileStandardType {
cmFileStandard_Input,
cmFileStandard_Output,
cmFileStandard_Error,
cmFileStandard_Count,
} cmFileStandardType;
/* */typedefstructcmFileContents {
cmAllocatorallocator;
void*data;
isizesize;
} cmFileContents;
/* */#defineCM_PATH_SEPARATOR
  • Function
/* */cmFile*constcm_file_get_standard (cmFileStandardTypestd);
/* */cmFileErrorcm_file_create (cmFile*file, charconst*filename);
/* */cmFileErrorcm_file_open_mode (cmFile*file, cmFileModemode, charconst*filename);
/* */cmFileErrorcm_file_new (cmFile*file, cmFileDescriptorfd, cmFileOperationsops, charconst*filename);
/* */b32cm_file_read_at_check (cmFile*file, void*buffer, isizesize, i64offset, isize*bytes_read);
/* */b32cm_file_write_at_check(cmFile*file, voidconst*buffer, isizesize, i64offset, isize*bytes_written);
/* */b32cm_file_read_at (cmFile*file, void*buffer, isizesize, i64offset);
/* */b32cm_file_write_at (cmFile*file, voidconst*buffer, isizesize, i64offset);
/* */i64cm_file_seek (cmFile*file, i64offset);
/* */i64cm_file_seek_to_end (cmFile*file);
/* */i64cm_file_skip (cmFile*file, i64bytes);
/* */i64cm_file_tell (cmFile*file);
/* */cmFileErrorcm_file_close (cmFile*file);
/* */b32cm_file_read (cmFile*file, void*buffer, isizesize);
/* */b32cm_file_write (cmFile*file, voidconst*buffer, isizesize);
/* */i64cm_file_size (cmFile*file);
/* */charconst*cm_file_name (cmFile*file);
/* */cmFileErrorcm_file_truncate (cmFile*file, i64size);
/* */b32cm_file_has_changed (cmFile*file);
/* */cmFileContentscm_file_read_contents(cmAllocatora, b32zero_terminate, charconst*filepath);
/* */voidcm_file_free_contents(cmFileContents*fc);
/* */b32cm_file_exists (charconst*filepath);
/* */cmFileTimecm_file_last_write_time(charconst*filepath);
/* */b32cm_file_copy (charconst*existing_filename, charconst*new_filename, b32fail_if_exists);
/* */b32cm_file_move (charconst*existing_filename, charconst*new_filename);
/* */b32cm_file_remove (charconst*filename);
/* */b32cm_path_is_absolute (charconst*path);
/* */b32cm_path_is_relative (charconst*path);
/* */b32cm_path_is_root (charconst*path);
/* */charconst*cm_path_base_name (charconst*path);
/* */charconst*cm_path_extension (charconst*path);
/* */char*cm_path_get_full_name(cmAllocatora, charconst*path);

hash.h

  • Function
/* */u32cm_adler32(voidconst*data, isizelen);
/* */u32cm_crc32(voidconst*data, isizelen);
/* */u64cm_crc64(voidconst*data, isizelen);
/* */u32cm_fnv32 (voidconst*data, isizelen);
/* */u64cm_fnv64 (voidconst*data, isizelen);
/* */u32cm_fnv32a(voidconst*data, isizelen);
/* */u64cm_fnv64a(voidconst*data, isizelen);
/* */u32cm_murmur32(voidconst*data, isizelen);
/* */u64cm_murmur64(voidconst*data, isizelen);
/* */u32cm_murmur32_seed(voidconst*data, isizelen, u32seed);
/* */u64cm_murmur64_seed(voidconst*data, isizelen, u64seed);

hashtable.h

#defineCM_TABLE(PREFIX, NAME, FUNC, VALUE)
#defineCM_TABLE_DECLARE(PREFIX, NAME, FUNC, VALUE)
#defineCM_TABLE_DEFINE(NAME, FUNC, VALUE)
  • Struct
/* * cmHashTableFindResult */typedefstructcmHashTableFindResult {
isizehash_index;
isizeentry_prev;
isizeentry_index;
} cmHashTableFindResult;

header.h

#define_CRT_SECURE_NO_WARNINGS#define_GNU_SOURCE#define_LARGEFILE64_SOURCE#defineWIN32_LEAN_AND_MEAN #define WIN32_MEAN_AND_LEAN #defineVC_EXTRALEAN#defineNOMINMAX

memory.h

#defineCM_DEFAULT_MEMORY_ALIGNMENT#defineCM_DEFAULT_ALLOCATOR_FLAGS
  • Struct
/* * cmVirtualMemory */typedefstructcmVirtualMemory {
void*data;
isizesize;
} cmVirtualMemory;
/* * cmVirtualMemory */typedefenumcmAllocationType {
cmAllocation_Alloc,
cmAllocation_Free,
cmAllocation_FreeAll,
cmAllocation_Resize,
} cmAllocationType;
/* * cmAllocator */typedefstructcmAllocator {
cmAllocatorProc*proc;
void*data;
} cmAllocator;
/* * cmAllocatorFlag */typedefenumcmAllocatorFlag {
cmAllocatorFlag_ClearToZero ,
} cmAllocatorFlag;
/* * cmArena */typedefstructcmArena {
cmAllocatorbacking;
void*physical_start;
isizetotal_size;
isizetotal_allocated;
isizetemp_count;
} cmArena;
  • Function
/* */b32cm_is_power_of_two (isizex);
/* */void*cm_align_forward (void*ptr, isizealignment);
/* */void*cm_pointer_add (void*ptr, isizebytes);
/* */void*cm_pointer_sub (void*ptr, isizebytes);
/* */voidconst*cm_pointer_add_const (voidconst*ptr, isizebytes);
/* */voidconst*cm_pointer_sub_const (voidconst*ptr, isizebytes);
/* */isizecm_pointer_diff (voidconst*begin, voidconst*end);
/* */voidcm_zero_size (void*ptr, isizesize);
/* */voidcm_zero_item (void*t)
/* */voidcm_zero_array (void*a, count)
/* */void*cm_memcopy (void*dest, voidconst*source, isizesize);
/* */void*cm_memmove (void*dest, voidconst*source, isizesize);
/* */void*cm_memset (void*data, u8byte_value, isizesize);
/* */i32cm_memcompare (voidconst*s1, voidconst*s2, isizesize);
/* */voidcm_memswap (void*i, void*j, isizesize);
/* */voidconst*cm_memchr (voidconst*data, u8byte_value, isizesize);
/* */voidconst*cm_memrchr (voidconst*data, u8byte_value, isizesize);
/* */cm_memcopy_array (dst, src, count);
/* */cm_memmove_array (dst, src, count) /* */cmVirtualMemorycm_virtual_memory (void*data, isizesize);
/* */cmVirtualMemorycm_vm_alloc (void*addr, isizesize);
/* */b32cm_vm_free (cmVirtualMemoryvm);
/* */cmVirtualMemorycm_vm_trim (cmVirtualMemoryvm, isizelead_size, isizesize);
/* */b32cm_vm_purge (cmVirtualMemoryvm);
/* */isizecm_virtual_memory_page_size (isize*alignment_out);
/* */void*cm_alloc_align (cmAllocatora, isizesize, isizealignment);
/* */void*cm_alloc (cmAllocatora, isizesize);
/* */voidcm_free (cmAllocatora, void*ptr);
/* */voidcm_free_all (cmAllocatora);
/* */void*cm_resize (cmAllocatora, void*ptr, isizeold_size, isizenew_size);
/* */void*cm_resize_align (cmAllocatora, void*ptr, isizeold_size, isizenew_size, isizealignment);
/* */void*cm_alloc_copy (cmAllocatora, voidconst*src, isizesize);
/* */void*cm_alloc_copy_align (cmAllocatora, voidconst*src, isizesize, isizealignment);
/* */char*cm_alloc_str (cmAllocatora, charconst*str);
/* */char*cm_alloc_str_len (cmAllocatora, charconst*str, isizelen);
/* */cm_alloc_item (allocator_, Type)
/* */cm_alloc_array (allocator_, Type, count)
/* */void*gb_default_resize_align (cmAllocatora, void*ptr, isizeold_size, isizenew_size, isizealignment);
/* */cmAllocatorcm_heap_allocator (void);
/* */cm_malloc(sz);
/* */cm_mfree(ptr);
/* */voidcm_arena_init_from_memory (cmArena*arena, void*start, isizesize);
/* */voidcm_arena_init_from_allocator (cmArena*arena, cmAllocatorbacking, isizesize);
/* */voidcm_arena_init_sub (cmArena*arena, cmArena*parent_arena, isizesize);
/* */voidcm_arena_free (cmArena*arena);
/* */isizecm_arena_alignment_of (cmArena*arena, isizealignment);
/* */isizecm_arena_size_remaining (cmArena*arena, isizealignment);
/* */voidcm_arena_check (cmArena*arena);
/* */cmAllocatorcm_arena_allocator (cmArena*arena);

math.h

#defineCM_MATH_INFINITYF#defineCM_MATH_NANF#defineCM_MATH_PZEROF#defineCM_MATH_NZEROF#defineCM_MATH_INFINITY#defineCM_MATH_NAN#defineCM_MATH_PZERO#defineCM_MATH_NZERO#defineCM_MATH_INFINITYL#defineCM_MATH_NANL#defineCM_MATH_PZEROL#defineCM_MATH_NZEROL#defineCM_SIZEOF_CHAR#defineCM_SIZEOF_BYTE#defineCM_SIZEOF_INT#defineCM_SIZEOF_INTP#defineCM_SIZEOF_UINTP#defineCM_SIZEOF_HALF#defineCM_SIZEOF_LONG#defineCM_SIZEOF_LONGLONG#defineCM_SIZEOF_DOUBLE#defineCM_SIZEOF_LONGDOUBLE#defineCM_SIZEOF_DATETIME#defineCM_SIZEOF_TIMEDELTA#defineCM_CHAR_BIT#defineCM_BYTE_FMT#defineCM_UBYTE_FMT#defineCM_SHORT_FMT#defineCM_USHORT_FMT#defineCM_INT_FMT#defineCM_UINT_FMT#defineCM_LONG_FMT#defineCM_ULONG_FMT#defineCM_HALF_FMT#defineCM_FLOAT_FMT#defineCM_DOUBLE_FMT#defineCM_LONGLONG_FMT#defineCM_ULONGLONG_FMT#defineCM_LONGLONG_SUFFIX(x)
#defineCM_ULONGLONG_SUFFIX(x)
#definecm_isnan(x)
#definecm_isfinite(x)
#definecm_isinf(x)
#defineCM_EXTRACT_WORDS(ix0,ix1,d)
#defineCM_GET_HIGH_WORD(i,d)
#defineCM_GET_LOW_WORD(i,d)
#defineCM_SET_HIGH_WORD(d,v)
#defineCM_SET_LOW_WORD(d,v)
#defineCM_INSERT_WORDS(d,ix0,ix1)
#defineCM_MATH_E#defineCM_MATH_LOG2E#defineCM_MATH_LOG10E#defineCM_MATH_LOGE2#defineCM_MATH_LOGE10#defineCM_MATH_PI#defineCM_MATH_PI_2 #define CM_MATH_PI_4
#defineCM_MATH_1_PI#defineCM_MATH_2_PI#defineCM_MATH_EULER#defineCM_MATH_SQRT2#defineCM_MATH_SQRT1_2#defineCM_MATH_Ef#defineCM_MATH_LOG2Ef#defineCM_MATH_LOG10Ef#defineCM_MATH_LOGE2f#defineCM_MATH_LOGE10f#defineCM_MATH_PIf#defineCM_MATH_PI_2f#defineCM_MATH_PI_4f#defineCM_MATH_1_PIf#defineCM_MATH_2_PIf#defineCM_MATH_EULERf#defineCM_MATH_SQRT2f#defineCM_MATH_SQRT1_2f#defineCM_MATH_El#defineCM_MATH_LOG2El#defineCM_MATH_LOG10El#defineCM_MATH_LOGE2l#defineCM_MATH_LOGE10l#defineCM_MATH_PIl#defineCM_MATH_PI_2l#defineCM_MATH_PI_4l#defineCM_MATH_1_PIl#defineCM_MATH_2_PIl#defineCM_MATH_EULERl#defineCM_MATH_SQRT2l#defineCM_MATH_SQRT1_2l#definecm_math_degrees#definecm_math_degreesf#definecm_math_degreesl#definecm_math_radians#definecm_math_radiansf#definecm_math_radiansl
  • Function
/* * Integer functions. *//* */u32cm_math_gcdu(u32a, u32b);
/* */u32cm_math_lcmu(u32a, u32b);
/* */ulcm_math_gcdul(ula, ulb);
/* */ulcm_math_lcmul(ula, ulb);
/* */ullcm_math_gcdull(ulla, ullb);
/* */ullcm_math_lcmull(ulla, ullb);
/* */u32cm_math_gcd(u32a, u32b);
/* */u32cm_math_lcm(u32a, u32b);
/* */ilcm_math_gcdl(ila, ilb);
/* */ilcm_math_lcml(ila, ilb);
/* */illcm_math_gcdll(illa, illb);
/* */illcm_math_lcmll(illa, illb);
/* */ubytecm_math_rshiftuhh(ubytea, ubyteb);
/* */ubytecm_math_lshiftuhh(ubytea, ubyteb);
/* */u16cm_math_rshiftuh(u16a, u16b);
/* */u16cm_math_lshiftuh(u16a, u16b);
/* */u32cm_math_rshiftu(u32a, u32b);
/* */u32cm_math_lshiftu(u32a, u32b);
/* */ulcm_math_rshiftul(ula, ulb);
/* */ulcm_math_lshiftul(ula, ulb);
/* */ullcm_math_rshiftull(ulla, ullb);
/* */ullcm_math_lshiftull(ulla, ullb);
/* */ibytecm_math_rshifthh(ibytea, ibyteb);
/* */ibytecm_math_lshifthh(ibytea, ibyteb);
/* */i16cm_math_rshifth(i16a, i16b);
/* */i16cm_math_lshifth(i16a, i16b);
/* */i32cm_math_rshift(i32a, i32b);
/* */i32cm_math_lshift(i32a, i32b);
/* */ilcm_math_rshiftl(ila, ilb);
/* */ilcm_math_lshiftl(ila, ilb);
/* */illcm_math_rshiftll(illa, illb);
/* */illcm_math_lshiftll(illa, illb);
/* * float C99 math functions *//* */f32cm_math_sinf(f32x);
/* */f32cm_math_cosf(f32x);
/* */f32cm_math_tanf(f32x);
/* */f32cm_math_sinhf(f32x);
/* */f32cm_math_coshf(f32x);
/* */f32cm_math_tanhf(f32x);
/* */f32cm_math_fabsf(f32x);
/* */f32cm_math_floorf(f32x);
/* */f32cm_math_ceilf(f32x);
/* */f32cm_math_rintf(f32x);
/* */f32cm_math_truncf(f32x);
/* */f32cm_math_sqrtf(f32x);
/* */f32cm_math_cbrtf(f32x);
/* */f32cm_math_log10f(f32x);
/* */f32cm_math_logf(f32x);
/* */f32cm_math_expf(f32x);
/* */f32cm_math_expm1f(f32x);
/* */f32cm_math_asinf(f32x);
/* */f32cm_math_acosf(f32x);
/* */f32cm_math_atanf(f32x);
/* */f32cm_math_asinhf(f32x);
/* */f32cm_math_acoshf(f32x);
/* */f32cm_math_atanhf(f32x);
/* */f32cm_math_log1pf(f32x);
/* */f32cm_math_exp2f(f32x);
/* */f32cm_math_log2f(f32x);
/* */f32cm_math_atan2f(f32x, f32y);
/* */f32cm_math_hypotf(f32x, f32y);
/* */f32cm_math_powf(f32x, f32y);
/* */f32cm_math_fmodf(f32x, f32y);
/* */f32cm_math_modff(f32x, f32*y);
/* */f32cm_math_frexpf(f32x, i32*y);
/* */f32cm_math_ldexpf(f32x, i32y);
/* */f32cm_math_copysignf(f32x, f32y);
/* */f32cm_math_nextafterf(f32x, f32y);
/* */f32cm_math_spacingf(f32x);
/* * long double C99 math functions *//* */fldcm_math_sinl(fldx);
/* */fldcm_math_cosl(fldx);
/* */fldcm_math_tanl(fldx);
/* */fldcm_math_sinhl(fldx);
/* */fldcm_math_coshl(fldx);
/* */fldcm_math_tanhl(fldx);
/* */fldcm_math_fabsl(fldx);
/* */fldcm_math_floorl(fldx);
/* */fldcm_math_ceill(fldx);
/* */fldcm_math_rintl(fldx);
/* */fldcm_math_truncl(fldx);
/* */fldcm_math_sqrtl(fldx);
/* */fldcm_math_cbrtl(fldx);
/* */fldcm_math_log10l(fldx);
/* */fldcm_math_logl(fldx);
/* */fldcm_math_expl(fldx);
/* */fldcm_math_expm1l(fldx);
/* */fldcm_math_asinl(fldx);
/* */fldcm_math_acosl(fldx);
/* */fldcm_math_atanl(fldx);
/* */fldcm_math_asinhl(fldx);
/* */fldcm_math_acoshl(fldx);
/* */fldcm_math_atanhl(fldx);
/* */fldcm_math_log1pl(fldx);
/* */fldcm_math_exp2l(fldx);
/* */fldcm_math_log2l(fldx);
/* */fldcm_math_atan2l(fldx, fldy);
/* */fldcm_math_hypotl(fldx, fldy);
/* */fldcm_math_powl(fldx, fldy);
/* */fldcm_math_fmodl(fldx, fldy);
/* */fldcm_math_modfl(fldx, fld*y);
/* */fldcm_math_frexpl(fldx, int*y);
/* */fldcm_math_ldexpl(fldx, inty);
/* */fldcm_math_copysignl(fldx, fldy);
/* */fldcm_math_nextafterl(fldx, fldy);
/* */fldcm_math_spacingl(fldx);
/* * Non standard functions *//* */f64cm_math_deg2rad(f64x);
/* */f64cm_math_rad2deg(f64x);
/* */f64cm_math_logaddexp(f64x, f64y);
/* */f64cm_math_logaddexp2(f64x, f64y);
/* */f64cm_math_divmod(f64x, f64y, f64*modulus);
/* */f64cm_math_heaviside(f64x, f64h0);
/* */f32cm_math_deg2radf(f32x);
/* */f32cm_math_rad2degf(f32x);
/* */f32cm_math_logaddexpf(f32x, f32y);
/* */f32cm_math_logaddexp2f(f32x, f32y);
/* */f32cm_math_divmodf(f32x, f32y, f32*modulus);
/* */f32cm_math_heavisidef(f32x, f32h0);
/* */fldcm_math_deg2radl(fldx);
/* */fldcm_math_rad2degl(fldx);
/* */fldcm_math_logaddexpl(fldx, fldy);
/* */fldcm_math_logaddexp2l(fldx, fldy);
/* */fldcm_math_divmodl(fldx, fldy, fld*modulus);
/* */fldcm_math_heavisidel(fldx, fldh0);
/* * Complex declarations *//* */inlinec64cm_math_cpack(f64x, f64y);
/* */inlinec32cm_math_cpackf(f32x, f32y);
/* */inlinecldcm_math_cpackl(fldx, fldy);
/* */inlinef64cm_math_creal(c64z);
/* */inlinef64cm_math_cimag(c64z);
/* */inlinef32cm_math_crealf(c32z);
/* */inlinef32cm_math_cimagf(c32z);
/* */inlinefldcm_math_creall(cldz);
/* */inlinefldcm_math_cimagl(cldz);
/* * Double precision complex functions *//* */f64cm_math_cabs(c64z);
/* */f64cm_math_carg(c64z);
/* */c64cm_math_cexp(c64z);
/* */c64cm_math_clog(c64z);
/* */c64cm_math_cpow(c64x, c64y);
/* */c64cm_math_csqrt(c64z);
/* */c64cm_math_ccos(c64z);
/* */c64cm_math_csin(c64z);
/* */c64cm_math_ctan(c64z);
/* */c64cm_math_ccosh(c64z);
/* */c64cm_math_csinh(c64z);
/* */c64cm_math_ctanh(c64z);
/* */c64cm_math_cacos(c64z);
/* */c64cm_math_casin(c64z);
/* */c64cm_math_catan(c64z);
/* */c64cm_math_cacosh(c64z);
/* */c64cm_math_casinh(c64z);
/* */c64cm_math_catanh(c64z);
/* * Single precision complex functions *//* */f32cm_math_cabsf(c32z);
/* */f32cm_math_cargf(c32z);
/* */c32cm_math_cexpf(c32z);
/* */c32cm_math_clogf(c32z);
/* */c32cm_math_cpowf(c32x, c32y);
/* */c32cm_math_csqrtf(c32z);
/* */c32cm_math_ccosf(c32z);
/* */c32cm_math_csinf(c32z);
/* */c32cm_math_ctanf(c32z);
/* */c32cm_math_ccoshf(c32z);
/* */c32cm_math_csinhf(c32z);
/* */c32cm_math_ctanhf(c32z);
/* */c32cm_math_cacosf(c32z);
/* */c32cm_math_casinf(c32z);
/* */c32cm_math_catanf(c32z);
/* */c32cm_math_cacoshf(c32z);
/* */c32cm_math_casinhf(c32z);
/* */c32cm_math_catanhf(c32z);
/* * Extended precision complex functions *//* */fldcm_math_cabsl(cldz);
/* */fldcm_math_cargl(cldz);
/* */cldcm_math_cexpl(cldz);
/* */cldcm_math_clogl(cldz);
/* */cldcm_math_cpowl(cldx, cldy);
/* */cldcm_math_csqrtl(cldz);
/* */cldcm_math_ccosl(cldz);
/* */cldcm_math_csinl(cldz);
/* */cldcm_math_ctanl(cldz);
/* */cldcm_math_ccoshl(cldz);
/* */cldcm_math_csinhl(cldz);
/* */cldcm_math_ctanhl(cldz);
/* */cldcm_math_cacosl(cldz);
/* */cldcm_math_casinl(cldz);
/* */cldcm_math_catanl(cldz);
/* */cldcm_math_cacoshl(cldz);
/* */cldcm_math_casinhl(cldz);
/* */cldcm_math_catanhl(cldz);

misc.h

  • Function
/* */voidcm_exit (u32code);
/* */voidcm_yield (void);
/* */voidcm_set_env (charconst*name, charconst*value);
/* */voidcm_unset_env (charconst*name);
/* */u16cm_endian_swap16 (u16i);
/* */u32cm_endian_swap32 (u32i);
/* */u64cm_endian_swap64 (u64i);
/* */isizecm_count_set_bits (u64mask);

mutex.h

  • Struct
/* * Windows */typedefstructcmMutex {
CRITICAL_SECTIONwin32_critical_section;
} cmMutex;
/* * Unix & Linux */typedefstructcmMutex {
pthread_mutex_tpthread_mutex;
pthread_mutexattr_tpthread_mutexattr;
} cmMutex;
  • Function
/* */voidcm_mutex_init (cmMutex*m);
/* */voidcm_mutex_destroy (cmMutex*m);
/* */voidcm_mutex_lock (cmMutex*m);
/* */b32cm_mutex_try_lock (cmMutex*m);
/* */voidcm_mutex_unlock (cmMutex*m);

print.h

  • Function
/* */isizecm_printf (charconst*fmt, ...) CM_PRINTF_ARGS(1);
/* */isizecm_printf_va (charconst*fmt, va_listva);
/* */isizecm_printf_err (charconst*fmt, ...) CM_PRINTF_ARGS(1);
/* */isizecm_printf_err_va (charconst*fmt, va_listva);
/* */isizecm_fprintf (cmFile*f, charconst*fmt, ...) CM_PRINTF_ARGS(2);
/* */isizecm_fprintf_va (cmFile*f, charconst*fmt, va_listva);
/* */char*cm_bprintf (charconst*fmt, ...) CM_PRINTF_ARGS(1);
/* */char*cm_bprintf_va (charconst*fmt, va_listva);
/* */isizecm_snprintf (char*str, isizen, charconst*fmt, ...) CM_PRINTF_ARGS(3);

random.h

  • Struct
/* */typedefstructcmRandom {
u32offsets[8];
u32value;
} cmRandom;
  • Function
/* */voidcm_random_init (cmRandom*r);
/* */u32cm_random_gen_u32 (cmRandom*r);
/* */u32cm_random_gen_u32_unique (cmRandom*r);
/* */u64cm_random_gen_u64 (cmRandom*r);
/* */isizecm_random_gen_isize (cmRandom*r);
/* */i64cm_random_range_i64 (cmRandom*r, i64lower_inc, i64higher_inc);
/* */isizecm_random_range_isize (cmRandom*r, isizelower_inc, isizehigher_inc);
/* */f64cm_random_range_f64 (cmRandom*r, f64lower_inc, f64higher_inc);

semaphore.h

  • Struct
/* * Window */typedefstructcmSemaphore { void*win32_handle;} cmSemaphore;
/* * OSX */typedefstructcmSemaphore { semaphore_tosx_handle; } cmSemaphore;
/* * Unix */typedefstructcmSemaphore { sem_tunix_handle; } cmSemaphore;
  • Function
/* */voidcm_semaphore_init (cmSemaphore*s);
/* */voidcm_semaphore_destroy (cmSemaphore*s);
/* */voidcm_semaphore_post (cmSemaphore*s, i32count);
/* */voidcm_semaphore_release (cmSemaphore*s);
/* */voidcm_semaphore_wait (cmSemaphore*s);

sortsearch.h

  • Function
/* */int (*cm_i16_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */int (*cm_i32_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */int (*cm_i64_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */int (*cm_isize_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */int (*cm_str_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */int (*cm_f32_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */int (*cm_f64_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */cm_sort_array(array, count, compare_proc) ;
/* */voidcm_sort(void*base, isizecount, isizesize, cmCompareProccompare_proc);
/* */cm_radix_sort(Type);
/* */voidcm_radix_sort_u8 (u8*items, u8*temp, isizecount);
/* */voidcm_radix_sort_u16 (u16*items, u16*temp, isizecount);
/* */voidcm_radix_sort_u32 (u32*items, u32*temp, isizecount);
/* */voidcm_radix_sort_u64 (u64*items, u64*temp, isizecount);
/* */cm_binary_search_array(array, count, key, compare_proc);
/* */isizecm_binary_search(voidconst*base, isizecount, isizesize, voidconst*key, cmCompareProccompare_proc);
/* */cm_shuffle_array(array, count);
/* */voidcm_shuffle(void*base, isizecount, isizesize);
/* */cm_reverse_array(array, count);
/* */voidcm_reverse(void*base, isizecount, isizesize);

string.h

  • Struct
/* */typedefchar*cmString;
/* */typedefstructcmStringHeader {
cmAllocatorallocator;
isizelength;
isizecapacity;
} cmStringHeader;
  • Function
/* */cmStringcm_string_make_reserve (cmAllocatora, isizecapacity);
/* */cmStringcm_string_make (cmAllocatora, charconst*str);
/* */cmStringcm_string_make_length (cmAllocatora, voidconst*str, isizenum_bytes);
/* */voidcm_string_free (cmStringstr);
/* */cmStringcm_string_duplicate (cmAllocatora, cmStringconststr);
/* */isizecm_string_length (cmStringconststr);
/* */isizecm_string_capacity (cmStringconststr);
/* */isizecm_string_available_space(cmStringconststr);
/* */voidcm_string_clear (cmStringstr);
/* */cmStringcm_string_append (cmStringstr, cmStringconstother);
/* */cmStringcm_string_append_length (cmStringstr, voidconst*other, isizenum_bytes);
/* */cmStringcm_string_appendc (cmStringstr, charconst*other);
/* */cmStringcm_string_append_rune (cmStringstr, Runer);
/* */cmStringcm_string_append_fmt (cmStringstr, charconst*fmt, ...);
/* */cmStringcm_string_set (cmStringstr, charconst*cstr);
/* */cmStringcm_string_make_space_for (cmStringstr, isizeadd_len);
/* */isizecm_string_allocation_size(cmStringconststr);
/* */b32cm_string_are_equal (cmStringconstlhs, cmStringconstrhs);
/* */cmStringcm_string_trim (cmStringstr, charconst*cut_set);
/* */cmStringcm_string_trim_space (cmStringstr);

thread.h

  • Struct
/* * Window */typedefstructcmThread {
void*win32_handle;
cmThreadProc*proc;
void*user_data;
isizeuser_index;
isizevolatilereturn_value;
cmSemaphoresemaphore;
isizestack_size;
b32volatileis_running;
} cmThread;
/* * Posix */typedefstructcmThread {
pthread_tposix_handle;
cmThreadProc*proc;
void*user_data;
isizeuser_index;
isizevolatilereturn_value;
cmSemaphoresemaphore;
isizestack_size;
b32volatileis_running;
} cmThread;
/* */typedefstructcmSync {
i32target; // Target Number of threadsi32current; // Threads to hiti32waiting; // Threads waitingcmMutexstart;
cmMutexmutex;
cmSemaphorerelease;
} cmSync;
  • Function
/* */voidcm_thread_init (cmThread*t);
/* */voidcm_thread_destroy (cmThread*t);
/* */voidcm_thread_start (cmThread*t, cmThreadProc*proc, void*data);
/* */voidcm_thread_start_with_stack (cmThread*t, cmThreadProc*proc, void*data, isizestack_size);
/* */voidcm_thread_join (cmThread*t);
/* */b32cm_thread_is_running (cmThreadconst*t);
/* */u32cm_thread_current_id (void);
/* */voidcm_thread_set_name (cmThread*t, charconst*name);
/* */voidcm_sync_init (cmSync*s);
/* */voidcm_sync_destroy (cmSync*s);
/* */voidcm_sync_set_target (cmSync*s, i32count);
/* */voidcm_sync_release (cmSync*s);
/* */i32cm_sync_reach (cmSync*s);
/* */voidcm_sync_reach_and_wait (cmSync*s);

time.h

  • Function
/* */u64cm_rdtsc (void);
/* */f64cm_time_now (void);
/* */u64cm_utc_time_now(void);
/* */voidcm_sleep_ms (u32ms);

utf8.h

  • Function
/* */isizecm_utf8_strlen (u8const*str);
/* */isizecm_utf8_strnlen(u8const*str, isizemax_len);
/* */u16*cm_utf8_to_ucs2 (u16*buffer, isizelen, u8const*str);
/* */u8*cm_ucs2_to_utf8 (u8*buffer, isizelen, u16const*str);
/* */u16*cm_utf8_to_ucs2_buf (u8const*str);
/* */u8*cm_ucs2_to_utf8_buf (u16const*str);
/* */isizecm_utf8_decode (u8const*str, isizestr_len, Rune*codepoint);
/* */isizecm_utf8_codepoint_size (u8const*str, isizestr_len);
/* */isizecm_utf8_encode_rune (u8buf[4], Runer);

utils.h

#defineNULL#defineinline#definecm_restrict#definecm_inline#definecm_no_inline#definecm_thread_local#definecast(Type)
#definecm_size_of(x)
#definecm_count_of(x)
#definecm_offset_of(Type, element)
#definecm_align_of(Type)
#definecm_swap(Type, a, b)
#definecm_global#definecm_internal#definecm_local_persist#definecm_unused(x)
#definevprtcast(x)
#definevoidcast(x)
#defineCM_BIT(x)
#defineCM_MIN(a, b)
#defineCM_MAX(a, b)
#defineCM_MIN3(a, b, c)
#defineCM_MAX3(a, b, c)
#defineCM_CLAMP(x, lower, upper)
#defineCM_CLAMP01(x)
#defineCM_IS_BETWEEN(x, lower, upper)
#defineCM_ABS(x)
#defineCM_MASK_SET(var, set, mask)
#defineCM_PRINTF_ARGS(FMT)

About

c/c++ marcro and utility

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Latest commit

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

types.h

typedefu8;
typedefi8;
typedefu16;
typedefi16;
typedefu32;
typedefi32;
typedefu64;
typedefi64;
typedefusize; //typedef unsigned long long size_ttypedefisize; //typedef long long ptrdiff_ttypedefintptr;
typedefuintptr;
typedeff32;
typedeff64;
typedefRune;
typedefb8;
typedefb16;
typedefb32;
#defineCM_RUNE_INVALID#defineCM_RUNE_MAX #define CM_RUNE_BOM #defineCM_RUNE_EOF#defineU8_MIN#defineU8_MAX#defineI8_MIN#defineI8_MAX#defineU16_MIN#defineU16_MAX#defineI16_MIN#defineI16_MAX#defineU32_MIN#defineU32_MAX#defineI32_MIN#defineI32_MAX#defineU64_MIN#defineU64_MAX#defineI64_MIN#defineI64_MAX#defineUSIZE_MIX #define USIZE_MAX
#defineISIZE_MIX#defineISIZE_MAX#defineF32_MIN#defineF32_MAX#defineF64_MIN#defineF64_MAX

arch.h

/*  * Arch  */#defineCM_ARCH_64#defineCM_ARCH_32/*  * Endian  */#defineCM_ENDIAN_ORDER#defineCM_BIG_ENDIAN#defineCM_LITTLE_ENDIAN/* * OS */#defineCM_WINDOWS#defineCM_OS_WINDOWS#defineCM_SYS_WINDOWS#defineCM_OSX#defineCM_OS_OSX#defineCM_SYS_OSX#defineCM_UNIX#defineCM_OS_UNIX#defineCM_SYS_UNIX#defineCM_LINUX#defineCM_OS_LINUX#defineCM_SYS_LINUX#defineCM_FREEBSD#defineCM_OS_FREEBSD#defineCM_SYS_FREEBSD/* * Compiler */#defineCM_COMPILER_MSVC#defineCM_COMPILER_GCC#defineCM_COMPILER_CLANG/* * CPU */#defineCM_CPU_X86#defineCM_CPU_PPC#defineCM_CPU_ARM#defineCM_CPU_MIPS#defineCM_CACHE_LINE_SIZE

assert.h

#defineCM_STATIC_ASSERT(cond) #define CM_STATIC_ASSERT1(cond, line)
#defineCM_STATIC_ASSERT2(cond, line)
#defineCM_STATIC_ASSERT3(cond, msg)

affinity.h

  • Struct
/* * cmAffinity */typedefstructcmAffinity{
b32is_accurate;
isizecore_count;
isizethread_count;
usizecore_masks[CM_WIN32_MAX_THREADS];
} cmAffinity;
  • Function
/* */voidcm_affinity_init (cmAffinity*a);
/* */voidcm_affinity_destroy (cmAffinity*a);
/* */b32cm_affinity_set (cmAffinity*a, isizecore, isizethread);
/* */isizecm_affinity_thread_count_for_core (cmAffinity*a, isizecore);

atomics.h

  • Struct
/* * cmAtomic32 */typedefstructcmAtomic32 { i32volatilevalue; } cmAtomic32;
/* * cmAtomic64 */typedefstructcmAtomic64 {
i64volatilevalue; } cmAtomic64;
/* * cmAtomicPtr */typedefstructcmAtomicPtr { void*volatilevalue;
} cmAtomicPtr;
  • Function
/* * atomic32 */i32cm_atomic32_load (cmAtomic32constvolatile*a);
voidcm_atomic32_store (cmAtomic32volatile*a, i32value);
i32cm_atomic32_compare_exchange (cmAtomic32volatile*a, i32expected, i32desired);
i32cm_atomic32_exchanged (cmAtomic32volatile*a, i32desired);
i32cm_atomic32_fetch_add (cmAtomic32volatile*a, i32operand);
i32cm_atomic32_fetch_and (cmAtomic32volatile*a, i32operand);
i32cm_atomic32_fetch_or (cmAtomic32volatile*a, i32operand);
b32cm_atomic32_spin_lock (cmAtomic32volatile*a, isizetime_out);
voidcm_atomic32_spin_unlock (cmAtomic32volatile*a);
b32cm_atomic32_try_acquire_lock (cmAtomic32volatile*a);
/* * atomic64 */i64cm_atomic64_load (cmAtomic64constvolatile*a);
voidcm_atomic64_store (cmAtomic64volatile*a, i64value);
i64cm_atomic64_compare_exchange (cmAtomic64volatile*a, i64expected, i64desired);
i64cm_atomic64_exchanged (cmAtomic64volatile*a, i64desired);
i64cm_atomic64_fetch_add (cmAtomic64volatile*a, i64operand);
i64cm_atomic64_fetch_and (cmAtomic64volatile*a, i64operand);
i64cm_atomic64_fetch_or (cmAtomic64volatile*a, i64operand);
b32cm_atomic64_spin_lock (cmAtomic64volatile*a, isizetime_out);
voidcm_atomic64_spin_unlock (cmAtomic64volatile*a);
b32cm_atomic64_try_acquire_lock (cmAtomic64volatile*a);
/* * atomicptr */void*cm_atomic_ptr_load (cmAtomicPtrconstvolatile*a);
voidcm_atomic_ptr_store (cmAtomicPtrvolatile*a, void*value);
void*cm_atomic_ptr_compare_exchange (cmAtomicPtrvolatile*a, void*expected, void*desired);
void*cm_atomic_ptr_exchanged (cmAtomicPtrvolatile*a, void*desired);
void*cm_atomic_ptr_fetch_add (cmAtomicPtrvolatile*a, void*operand);
void*cm_atomic_ptr_fetch_and (cmAtomicPtrvolatile*a, void*operand);
void*cm_atomic_ptr_fetch_or (cmAtomicPtrvolatile*a, void*operand);
b32cm_atomic_ptr_spin_lock (cmAtomicPtrvolatile*a, isizetime_out);
voidcm_atomic_ptr_spin_unlock (cmAtomicPtrvolatile*a);
b32cm_atomic_ptr_try_acquire_lock (cmAtomicPtrvolatile*a);

buffer.h

  • Struct
/* * cmBufferHeader */typedefstructcmBufferHeader {
isizecount;
isizecapacity;
} cmBufferHeader;
  • Function
/* * ประกาศตัวแปร Ex. cmBuffer(i32) buffer; */cmBuffer(Type);
/* * จำนวน */isizecm_buffer_count (cmBufferHeader*bfh);
/* * ความจุ */isizecm_buffer_capacity (cmBufferHeader*bfh);
/* * ค่าเริ่มต้น */void*cm_buffer_init (x, allocator, cap);
/* * เลิกใช้งาน */voidcm_buffer_free (x, allocator);
/* * เพิ่มข้อมูล(1 รายการ) */voidcm_buffer_append (x, item);
/* * เพิ่มข้อมูล(มากกว่า 1 รายการ) */voidcm_buffer_appendv (x, items, item_count);
/* * นำข้อมูลออก */voidcm_buffer_pop (x);
/* * ล้างข้อมูล */cm_buffer_clear (x)

char.h

  • Function
/* * แปลงตัวอักษรเป็นพิมพ์เล็ก */charcm_char_to_lower (charc);
/* * แปลงตัวอักษรเป็นพิมพ์ใหญ่ */charcm_char_to_upper (charc);
/* * ตรวจสอบช่องว่าง */b32cm_char_is_space (charc);
/* * ตรวจสอบตัวเลข */b32cm_char_is_digit (charc);
/* * ตรวจสอบตัวเลขที่เป็นฐาน16 (hex) */b32cm_char_is_hex_digit (charc);
/* *  */b32cm_char_is_alpha (charc);
/* * ตรวจสอบว่าเป็นตัวเลขหรือตัวอักษร */b32cm_char_is_alphanumeric (charc);
/* * แปลงตัวอักษร */i32cm_digit_to_int (charc);
/* * แปลงตัวอักษรฐาน16(hex)เป็นตัวเลขจำนวนเต็ม */i32cm_hex_digit_to_int (charc);
/* * แปลงตัวอักษรเป็นพิมพ์เล็ก */voidcm_str_to_lower(char*str);
/* * แปลงตัวอักษรเป็นพิมพ์ใหญ่ */voidcm_str_to_upper(char*str);
/* * จำนวนข้อความ */isizecm_strlen (charconst*str);
/* *  */isizecm_strnlen(charconst*str, isizemax_len);
/* * เปรียบเทียบข้อความ */i32cm_strcmp (charconst*s1, charconst*s2);
/* *  */i32cm_strncmp(charconst*s1, charconst*s2, isizelen);
/* * ก๊อบปี้ข้อความ */char*cm_strcpy (char*dest, charconst*source);
/* *  */char*cm_strncpy(char*dest, charconst*source, isizelen);
/* *  */isizecm_strlcpy(char*dest, charconst*source, isizelen);
/* *  */char*cm_strrev (char*str);
/* *  */charconst*cm_strtok(char*output, charconst*src, charconst*delimit);
/* *  */b32cm_str_has_prefix(charconst*str, charconst*prefix);
/* *  */b32cm_str_has_suffix(charconst*str, charconst*suffix);
/* *  */charconst*cm_char_first_occurence(charconst*str, charc);
/* *  */charconst*cm_char_last_occurence (charconst*str, charc);
/* *  */voidcm_str_concat(char*dest, isizedest_len, charconst*src_a, isizesrc_a_len, charconst*src_b, isizesrc_b_len);
/* *  */u64cm_str_to_u64(charconst*str, char**end_ptr, i32base);
/* *  */i64cm_str_to_i64(charconst*str, char**end_ptr, i32base);
/* *  */f32cm_str_to_f32(charconst*str, char**end_ptr);
/* *  */f64cm_str_to_f64(charconst*str, char**end_ptr);
/* *  */voidcm_i64_to_str(i64value, char*string, i32base);
/* *  */voidcm_u64_to_str(u64value, char*string, i32base);

debug.h

#defineCM_DEBUG_TRAP()
#defineCM_ASSERT_MSG(cond, msg, ...)
#defineCM_ASSERT(cond)
#defineCM_ASSERT_NOT_NULL(ptr)
#defineCM_PANIC(msg, ...)
  • Function
//voidcm_assert_handler(charconst*prefix, charconst*condition, charconst*file, i32line, charconst*msg, ...);

defer.h

#defineCM_DEFER_1(x, y)
#defineCM_DEFER_2(x, y)
#defineCM_DEFER_3(x)
  • Function
/*ตัวอย่างcmMutex m;cm_mutex_init(&m);{	cm_mutex_lock(&m);	defer (cm_mutex_unlock(&m));	...}*/voiddefer(code);

dll.h

#defineCM_DLL_EXPORT#defineCM_DLL_IMPORT#defineCM_DEF#defineCM_SHARED_LIB_BUILD#defineCM_SHARED_LIB_USE#defineCM_C_API
  • Struct
typedefvoid*cmDllHandle;
typedefvoid (*cmDllProc)(void);
  • Function
/* * Ex. cmDllHandle handle = cm_dll_load("opengl32.dll"); */cmDllHandlecm_dll_load (charconst*filepath);
/* * Ex. cm_dll_unload(handle); */voidcm_dll_unload (cmDllHandledll);
/* * Ex. * cmDllHandle xinput_library = cm_dll_load("xinput9_1_0.dll"); * cmXInputGetStateProc *get_state = cast(cmXInputGetStateProc *)cm_dll_proc_address(xinput_library, "XInputGetState"); * cmXInputGetStateProc *set_state = cast(cmXInputSetStateProc *)cm_dll_proc_address(xinput_library, "XInputSetState"); */cmDllProccm_dll_proc_address (cmDllHandledll, charconst*proc_name);

dynarray.h

#defineCM_ARRAY_GROW_FORMULA(x)
#defineCM_ARRAY_HEADER(x)
  • Struct
/* * cmArrayHeader */typedefstructcmArrayHeader {
cmAllocatorallocator;
isizecount;
isizecapacity;
} cmArrayHeader;
  • Function
/* * ประกาศตัวแปร Ex. cmArray(i32) array; */cmArray(Type);
/* */cmAllocatorcm_array_allocator(x);
/* */isizecm_array_count(x);
/* */isizecm_array_capacity(x);
/* */voidcm_array_init_reserve(x, allocator_, cap);
/* */voidcm_array_init(x, allocator);
/* */voidcm_array_free(x);
/* */voidcm_array_set_capacity(x, capacity);
/* */void*cm__array_set_capacity(void*array, isizecapacity, isizeelement_size);
/* */voidcm_array_grow(x, min_capacity) ;
/* */voidcm_array_append(x, item);
/* */voidcm_array_appendv(x, items, item_count);
/* */voidcm_array_pop(x);
/* */voidcm_array_clear(x);
/* */voidcm_array_resize(x, new_count);
/* */voidcm_array_reserve(x, new_capacity);

extern.h

#defineCM_EXTERN#defineCM_BEGIN_EXTERN#defineCM_END_EXTERN

fences.h

  • Function
/* */voidcm_yield_thread(void);
/* */voidcm_mfence (void);
/* */voidcm_sfence (void);
/* */voidcm_lfence (void);

file.h

  • Struct
/* */typedefu32cmFileMode;
/* */typedefenumcmFileModeFlag {
cmFileMode_Read,
cmFileMode_Write,
cmFileMode_Append,
cmFileMode_Rw,
cmFileMode_Modes ,
} cmFileModeFlag;
/* */typedefenumcmSeekWhenceType {
cmSeekWhence_Begin,
cmSeekWhence_Current,
cmSeekWhence_End,
} cmSeekWhenceType;
/* */typedefenumcmFileError {
cmFileError_None,
cmFileError_Invalid,
cmFileError_InvalidFilename,
cmFileError_Exists,
cmFileError_NotExists,
cmFileError_Permission,
cmFileError_TruncationFailure,
} cmFileError;
/* */typedefunioncmFileDescriptor {
void*p;
intptri;
uintptru;
} cmFileDescriptor;
/* */typedefstructcmFileOperationscmFileOperations;
/* */typedefCM_FILE_OPEN_PROC(cmFileOpenProc);
/* */typedefCM_FILE_READ_AT_PROC(cmFileReadProc);
/* */typedefCM_FILE_WRITE_AT_PROC(cmFileWriteProc);
/* */typedefCM_FILE_SEEK_PROC(cmFileSeekProc);
/* */typedefCM_FILE_CLOSE_PROC(cmFileCloseProc)
/* */structcmFileOperations {
cmFileReadProc*read_at;
cmFileWriteProc*write_at;
cmFileSeekProc*seek;
cmFileCloseProc*close;
};
/* */externcmFileOperationsconstcmDefaultFileOperations;
/* */typedefu64cmFileTime;
/* */typedefstructcmFile {
cmFileOperationsops;
cmFileDescriptorfd;
charconst*filename;
cmFileTimelast_write_time;
// gbDirInfo * dir_info; // TODO(bill): Get directory info
} cmFile;
/* */typedefenumcmFileStandardType {
cmFileStandard_Input,
cmFileStandard_Output,
cmFileStandard_Error,
cmFileStandard_Count,
} cmFileStandardType;
/* */typedefstructcmFileContents {
cmAllocatorallocator;
void*data;
isizesize;
} cmFileContents;
/* */#defineCM_PATH_SEPARATOR
  • Function
/* */cmFile*constcm_file_get_standard (cmFileStandardTypestd);
/* */cmFileErrorcm_file_create (cmFile*file, charconst*filename);
/* */cmFileErrorcm_file_open_mode (cmFile*file, cmFileModemode, charconst*filename);
/* */cmFileErrorcm_file_new (cmFile*file, cmFileDescriptorfd, cmFileOperationsops, charconst*filename);
/* */b32cm_file_read_at_check (cmFile*file, void*buffer, isizesize, i64offset, isize*bytes_read);
/* */b32cm_file_write_at_check(cmFile*file, voidconst*buffer, isizesize, i64offset, isize*bytes_written);
/* */b32cm_file_read_at (cmFile*file, void*buffer, isizesize, i64offset);
/* */b32cm_file_write_at (cmFile*file, voidconst*buffer, isizesize, i64offset);
/* */i64cm_file_seek (cmFile*file, i64offset);
/* */i64cm_file_seek_to_end (cmFile*file);
/* */i64cm_file_skip (cmFile*file, i64bytes);
/* */i64cm_file_tell (cmFile*file);
/* */cmFileErrorcm_file_close (cmFile*file);
/* */b32cm_file_read (cmFile*file, void*buffer, isizesize);
/* */b32cm_file_write (cmFile*file, voidconst*buffer, isizesize);
/* */i64cm_file_size (cmFile*file);
/* */charconst*cm_file_name (cmFile*file);
/* */cmFileErrorcm_file_truncate (cmFile*file, i64size);
/* */b32cm_file_has_changed (cmFile*file);
/* */cmFileContentscm_file_read_contents(cmAllocatora, b32zero_terminate, charconst*filepath);
/* */voidcm_file_free_contents(cmFileContents*fc);
/* */b32cm_file_exists (charconst*filepath);
/* */cmFileTimecm_file_last_write_time(charconst*filepath);
/* */b32cm_file_copy (charconst*existing_filename, charconst*new_filename, b32fail_if_exists);
/* */b32cm_file_move (charconst*existing_filename, charconst*new_filename);
/* */b32cm_file_remove (charconst*filename);
/* */b32cm_path_is_absolute (charconst*path);
/* */b32cm_path_is_relative (charconst*path);
/* */b32cm_path_is_root (charconst*path);
/* */charconst*cm_path_base_name (charconst*path);
/* */charconst*cm_path_extension (charconst*path);
/* */char*cm_path_get_full_name(cmAllocatora, charconst*path);

hash.h

  • Function
/* */u32cm_adler32(voidconst*data, isizelen);
/* */u32cm_crc32(voidconst*data, isizelen);
/* */u64cm_crc64(voidconst*data, isizelen);
/* */u32cm_fnv32 (voidconst*data, isizelen);
/* */u64cm_fnv64 (voidconst*data, isizelen);
/* */u32cm_fnv32a(voidconst*data, isizelen);
/* */u64cm_fnv64a(voidconst*data, isizelen);
/* */u32cm_murmur32(voidconst*data, isizelen);
/* */u64cm_murmur64(voidconst*data, isizelen);
/* */u32cm_murmur32_seed(voidconst*data, isizelen, u32seed);
/* */u64cm_murmur64_seed(voidconst*data, isizelen, u64seed);

hashtable.h

#defineCM_TABLE(PREFIX, NAME, FUNC, VALUE)
#defineCM_TABLE_DECLARE(PREFIX, NAME, FUNC, VALUE)
#defineCM_TABLE_DEFINE(NAME, FUNC, VALUE)
  • Struct
/* * cmHashTableFindResult */typedefstructcmHashTableFindResult {
isizehash_index;
isizeentry_prev;
isizeentry_index;
} cmHashTableFindResult;

header.h

#define_CRT_SECURE_NO_WARNINGS#define_GNU_SOURCE#define_LARGEFILE64_SOURCE#defineWIN32_LEAN_AND_MEAN #define WIN32_MEAN_AND_LEAN #defineVC_EXTRALEAN#defineNOMINMAX

memory.h

#defineCM_DEFAULT_MEMORY_ALIGNMENT#defineCM_DEFAULT_ALLOCATOR_FLAGS
  • Struct
/* * cmVirtualMemory */typedefstructcmVirtualMemory {
void*data;
isizesize;
} cmVirtualMemory;
/* * cmVirtualMemory */typedefenumcmAllocationType {
cmAllocation_Alloc,
cmAllocation_Free,
cmAllocation_FreeAll,
cmAllocation_Resize,
} cmAllocationType;
/* * cmAllocator */typedefstructcmAllocator {
cmAllocatorProc*proc;
void*data;
} cmAllocator;
/* * cmAllocatorFlag */typedefenumcmAllocatorFlag {
cmAllocatorFlag_ClearToZero ,
} cmAllocatorFlag;
/* * cmArena */typedefstructcmArena {
cmAllocatorbacking;
void*physical_start;
isizetotal_size;
isizetotal_allocated;
isizetemp_count;
} cmArena;
  • Function
/* */b32cm_is_power_of_two (isizex);
/* */void*cm_align_forward (void*ptr, isizealignment);
/* */void*cm_pointer_add (void*ptr, isizebytes);
/* */void*cm_pointer_sub (void*ptr, isizebytes);
/* */voidconst*cm_pointer_add_const (voidconst*ptr, isizebytes);
/* */voidconst*cm_pointer_sub_const (voidconst*ptr, isizebytes);
/* */isizecm_pointer_diff (voidconst*begin, voidconst*end);
/* */voidcm_zero_size (void*ptr, isizesize);
/* */voidcm_zero_item (void*t)
/* */voidcm_zero_array (void*a, count)
/* */void*cm_memcopy (void*dest, voidconst*source, isizesize);
/* */void*cm_memmove (void*dest, voidconst*source, isizesize);
/* */void*cm_memset (void*data, u8byte_value, isizesize);
/* */i32cm_memcompare (voidconst*s1, voidconst*s2, isizesize);
/* */voidcm_memswap (void*i, void*j, isizesize);
/* */voidconst*cm_memchr (voidconst*data, u8byte_value, isizesize);
/* */voidconst*cm_memrchr (voidconst*data, u8byte_value, isizesize);
/* */cm_memcopy_array (dst, src, count);
/* */cm_memmove_array (dst, src, count) /* */cmVirtualMemorycm_virtual_memory (void*data, isizesize);
/* */cmVirtualMemorycm_vm_alloc (void*addr, isizesize);
/* */b32cm_vm_free (cmVirtualMemoryvm);
/* */cmVirtualMemorycm_vm_trim (cmVirtualMemoryvm, isizelead_size, isizesize);
/* */b32cm_vm_purge (cmVirtualMemoryvm);
/* */isizecm_virtual_memory_page_size (isize*alignment_out);
/* */void*cm_alloc_align (cmAllocatora, isizesize, isizealignment);
/* */void*cm_alloc (cmAllocatora, isizesize);
/* */voidcm_free (cmAllocatora, void*ptr);
/* */voidcm_free_all (cmAllocatora);
/* */void*cm_resize (cmAllocatora, void*ptr, isizeold_size, isizenew_size);
/* */void*cm_resize_align (cmAllocatora, void*ptr, isizeold_size, isizenew_size, isizealignment);
/* */void*cm_alloc_copy (cmAllocatora, voidconst*src, isizesize);
/* */void*cm_alloc_copy_align (cmAllocatora, voidconst*src, isizesize, isizealignment);
/* */char*cm_alloc_str (cmAllocatora, charconst*str);
/* */char*cm_alloc_str_len (cmAllocatora, charconst*str, isizelen);
/* */cm_alloc_item (allocator_, Type)
/* */cm_alloc_array (allocator_, Type, count)
/* */void*gb_default_resize_align (cmAllocatora, void*ptr, isizeold_size, isizenew_size, isizealignment);
/* */cmAllocatorcm_heap_allocator (void);
/* */cm_malloc(sz);
/* */cm_mfree(ptr);
/* */voidcm_arena_init_from_memory (cmArena*arena, void*start, isizesize);
/* */voidcm_arena_init_from_allocator (cmArena*arena, cmAllocatorbacking, isizesize);
/* */voidcm_arena_init_sub (cmArena*arena, cmArena*parent_arena, isizesize);
/* */voidcm_arena_free (cmArena*arena);
/* */isizecm_arena_alignment_of (cmArena*arena, isizealignment);
/* */isizecm_arena_size_remaining (cmArena*arena, isizealignment);
/* */voidcm_arena_check (cmArena*arena);
/* */cmAllocatorcm_arena_allocator (cmArena*arena);

math.h

#defineCM_MATH_INFINITYF#defineCM_MATH_NANF#defineCM_MATH_PZEROF#defineCM_MATH_NZEROF#defineCM_MATH_INFINITY#defineCM_MATH_NAN#defineCM_MATH_PZERO#defineCM_MATH_NZERO#defineCM_MATH_INFINITYL#defineCM_MATH_NANL#defineCM_MATH_PZEROL#defineCM_MATH_NZEROL#defineCM_SIZEOF_CHAR#defineCM_SIZEOF_BYTE#defineCM_SIZEOF_INT#defineCM_SIZEOF_INTP#defineCM_SIZEOF_UINTP#defineCM_SIZEOF_HALF#defineCM_SIZEOF_LONG#defineCM_SIZEOF_LONGLONG#defineCM_SIZEOF_DOUBLE#defineCM_SIZEOF_LONGDOUBLE#defineCM_SIZEOF_DATETIME#defineCM_SIZEOF_TIMEDELTA#defineCM_CHAR_BIT#defineCM_BYTE_FMT#defineCM_UBYTE_FMT#defineCM_SHORT_FMT#defineCM_USHORT_FMT#defineCM_INT_FMT#defineCM_UINT_FMT#defineCM_LONG_FMT#defineCM_ULONG_FMT#defineCM_HALF_FMT#defineCM_FLOAT_FMT#defineCM_DOUBLE_FMT#defineCM_LONGLONG_FMT#defineCM_ULONGLONG_FMT#defineCM_LONGLONG_SUFFIX(x)
#defineCM_ULONGLONG_SUFFIX(x)
#definecm_isnan(x)
#definecm_isfinite(x)
#definecm_isinf(x)
#defineCM_EXTRACT_WORDS(ix0,ix1,d)
#defineCM_GET_HIGH_WORD(i,d)
#defineCM_GET_LOW_WORD(i,d)
#defineCM_SET_HIGH_WORD(d,v)
#defineCM_SET_LOW_WORD(d,v)
#defineCM_INSERT_WORDS(d,ix0,ix1)
#defineCM_MATH_E#defineCM_MATH_LOG2E#defineCM_MATH_LOG10E#defineCM_MATH_LOGE2#defineCM_MATH_LOGE10#defineCM_MATH_PI#defineCM_MATH_PI_2 #define CM_MATH_PI_4
#defineCM_MATH_1_PI#defineCM_MATH_2_PI#defineCM_MATH_EULER#defineCM_MATH_SQRT2#defineCM_MATH_SQRT1_2#defineCM_MATH_Ef#defineCM_MATH_LOG2Ef#defineCM_MATH_LOG10Ef#defineCM_MATH_LOGE2f#defineCM_MATH_LOGE10f#defineCM_MATH_PIf#defineCM_MATH_PI_2f#defineCM_MATH_PI_4f#defineCM_MATH_1_PIf#defineCM_MATH_2_PIf#defineCM_MATH_EULERf#defineCM_MATH_SQRT2f#defineCM_MATH_SQRT1_2f#defineCM_MATH_El#defineCM_MATH_LOG2El#defineCM_MATH_LOG10El#defineCM_MATH_LOGE2l#defineCM_MATH_LOGE10l#defineCM_MATH_PIl#defineCM_MATH_PI_2l#defineCM_MATH_PI_4l#defineCM_MATH_1_PIl#defineCM_MATH_2_PIl#defineCM_MATH_EULERl#defineCM_MATH_SQRT2l#defineCM_MATH_SQRT1_2l#definecm_math_degrees#definecm_math_degreesf#definecm_math_degreesl#definecm_math_radians#definecm_math_radiansf#definecm_math_radiansl
  • Function
/* * Integer functions. *//* */u32cm_math_gcdu(u32a, u32b);
/* */u32cm_math_lcmu(u32a, u32b);
/* */ulcm_math_gcdul(ula, ulb);
/* */ulcm_math_lcmul(ula, ulb);
/* */ullcm_math_gcdull(ulla, ullb);
/* */ullcm_math_lcmull(ulla, ullb);
/* */u32cm_math_gcd(u32a, u32b);
/* */u32cm_math_lcm(u32a, u32b);
/* */ilcm_math_gcdl(ila, ilb);
/* */ilcm_math_lcml(ila, ilb);
/* */illcm_math_gcdll(illa, illb);
/* */illcm_math_lcmll(illa, illb);
/* */ubytecm_math_rshiftuhh(ubytea, ubyteb);
/* */ubytecm_math_lshiftuhh(ubytea, ubyteb);
/* */u16cm_math_rshiftuh(u16a, u16b);
/* */u16cm_math_lshiftuh(u16a, u16b);
/* */u32cm_math_rshiftu(u32a, u32b);
/* */u32cm_math_lshiftu(u32a, u32b);
/* */ulcm_math_rshiftul(ula, ulb);
/* */ulcm_math_lshiftul(ula, ulb);
/* */ullcm_math_rshiftull(ulla, ullb);
/* */ullcm_math_lshiftull(ulla, ullb);
/* */ibytecm_math_rshifthh(ibytea, ibyteb);
/* */ibytecm_math_lshifthh(ibytea, ibyteb);
/* */i16cm_math_rshifth(i16a, i16b);
/* */i16cm_math_lshifth(i16a, i16b);
/* */i32cm_math_rshift(i32a, i32b);
/* */i32cm_math_lshift(i32a, i32b);
/* */ilcm_math_rshiftl(ila, ilb);
/* */ilcm_math_lshiftl(ila, ilb);
/* */illcm_math_rshiftll(illa, illb);
/* */illcm_math_lshiftll(illa, illb);
/* * float C99 math functions *//* */f32cm_math_sinf(f32x);
/* */f32cm_math_cosf(f32x);
/* */f32cm_math_tanf(f32x);
/* */f32cm_math_sinhf(f32x);
/* */f32cm_math_coshf(f32x);
/* */f32cm_math_tanhf(f32x);
/* */f32cm_math_fabsf(f32x);
/* */f32cm_math_floorf(f32x);
/* */f32cm_math_ceilf(f32x);
/* */f32cm_math_rintf(f32x);
/* */f32cm_math_truncf(f32x);
/* */f32cm_math_sqrtf(f32x);
/* */f32cm_math_cbrtf(f32x);
/* */f32cm_math_log10f(f32x);
/* */f32cm_math_logf(f32x);
/* */f32cm_math_expf(f32x);
/* */f32cm_math_expm1f(f32x);
/* */f32cm_math_asinf(f32x);
/* */f32cm_math_acosf(f32x);
/* */f32cm_math_atanf(f32x);
/* */f32cm_math_asinhf(f32x);
/* */f32cm_math_acoshf(f32x);
/* */f32cm_math_atanhf(f32x);
/* */f32cm_math_log1pf(f32x);
/* */f32cm_math_exp2f(f32x);
/* */f32cm_math_log2f(f32x);
/* */f32cm_math_atan2f(f32x, f32y);
/* */f32cm_math_hypotf(f32x, f32y);
/* */f32cm_math_powf(f32x, f32y);
/* */f32cm_math_fmodf(f32x, f32y);
/* */f32cm_math_modff(f32x, f32*y);
/* */f32cm_math_frexpf(f32x, i32*y);
/* */f32cm_math_ldexpf(f32x, i32y);
/* */f32cm_math_copysignf(f32x, f32y);
/* */f32cm_math_nextafterf(f32x, f32y);
/* */f32cm_math_spacingf(f32x);
/* * long double C99 math functions *//* */fldcm_math_sinl(fldx);
/* */fldcm_math_cosl(fldx);
/* */fldcm_math_tanl(fldx);
/* */fldcm_math_sinhl(fldx);
/* */fldcm_math_coshl(fldx);
/* */fldcm_math_tanhl(fldx);
/* */fldcm_math_fabsl(fldx);
/* */fldcm_math_floorl(fldx);
/* */fldcm_math_ceill(fldx);
/* */fldcm_math_rintl(fldx);
/* */fldcm_math_truncl(fldx);
/* */fldcm_math_sqrtl(fldx);
/* */fldcm_math_cbrtl(fldx);
/* */fldcm_math_log10l(fldx);
/* */fldcm_math_logl(fldx);
/* */fldcm_math_expl(fldx);
/* */fldcm_math_expm1l(fldx);
/* */fldcm_math_asinl(fldx);
/* */fldcm_math_acosl(fldx);
/* */fldcm_math_atanl(fldx);
/* */fldcm_math_asinhl(fldx);
/* */fldcm_math_acoshl(fldx);
/* */fldcm_math_atanhl(fldx);
/* */fldcm_math_log1pl(fldx);
/* */fldcm_math_exp2l(fldx);
/* */fldcm_math_log2l(fldx);
/* */fldcm_math_atan2l(fldx, fldy);
/* */fldcm_math_hypotl(fldx, fldy);
/* */fldcm_math_powl(fldx, fldy);
/* */fldcm_math_fmodl(fldx, fldy);
/* */fldcm_math_modfl(fldx, fld*y);
/* */fldcm_math_frexpl(fldx, int*y);
/* */fldcm_math_ldexpl(fldx, inty);
/* */fldcm_math_copysignl(fldx, fldy);
/* */fldcm_math_nextafterl(fldx, fldy);
/* */fldcm_math_spacingl(fldx);
/* * Non standard functions *//* */f64cm_math_deg2rad(f64x);
/* */f64cm_math_rad2deg(f64x);
/* */f64cm_math_logaddexp(f64x, f64y);
/* */f64cm_math_logaddexp2(f64x, f64y);
/* */f64cm_math_divmod(f64x, f64y, f64*modulus);
/* */f64cm_math_heaviside(f64x, f64h0);
/* */f32cm_math_deg2radf(f32x);
/* */f32cm_math_rad2degf(f32x);
/* */f32cm_math_logaddexpf(f32x, f32y);
/* */f32cm_math_logaddexp2f(f32x, f32y);
/* */f32cm_math_divmodf(f32x, f32y, f32*modulus);
/* */f32cm_math_heavisidef(f32x, f32h0);
/* */fldcm_math_deg2radl(fldx);
/* */fldcm_math_rad2degl(fldx);
/* */fldcm_math_logaddexpl(fldx, fldy);
/* */fldcm_math_logaddexp2l(fldx, fldy);
/* */fldcm_math_divmodl(fldx, fldy, fld*modulus);
/* */fldcm_math_heavisidel(fldx, fldh0);
/* * Complex declarations *//* */inlinec64cm_math_cpack(f64x, f64y);
/* */inlinec32cm_math_cpackf(f32x, f32y);
/* */inlinecldcm_math_cpackl(fldx, fldy);
/* */inlinef64cm_math_creal(c64z);
/* */inlinef64cm_math_cimag(c64z);
/* */inlinef32cm_math_crealf(c32z);
/* */inlinef32cm_math_cimagf(c32z);
/* */inlinefldcm_math_creall(cldz);
/* */inlinefldcm_math_cimagl(cldz);
/* * Double precision complex functions *//* */f64cm_math_cabs(c64z);
/* */f64cm_math_carg(c64z);
/* */c64cm_math_cexp(c64z);
/* */c64cm_math_clog(c64z);
/* */c64cm_math_cpow(c64x, c64y);
/* */c64cm_math_csqrt(c64z);
/* */c64cm_math_ccos(c64z);
/* */c64cm_math_csin(c64z);
/* */c64cm_math_ctan(c64z);
/* */c64cm_math_ccosh(c64z);
/* */c64cm_math_csinh(c64z);
/* */c64cm_math_ctanh(c64z);
/* */c64cm_math_cacos(c64z);
/* */c64cm_math_casin(c64z);
/* */c64cm_math_catan(c64z);
/* */c64cm_math_cacosh(c64z);
/* */c64cm_math_casinh(c64z);
/* */c64cm_math_catanh(c64z);
/* * Single precision complex functions *//* */f32cm_math_cabsf(c32z);
/* */f32cm_math_cargf(c32z);
/* */c32cm_math_cexpf(c32z);
/* */c32cm_math_clogf(c32z);
/* */c32cm_math_cpowf(c32x, c32y);
/* */c32cm_math_csqrtf(c32z);
/* */c32cm_math_ccosf(c32z);
/* */c32cm_math_csinf(c32z);
/* */c32cm_math_ctanf(c32z);
/* */c32cm_math_ccoshf(c32z);
/* */c32cm_math_csinhf(c32z);
/* */c32cm_math_ctanhf(c32z);
/* */c32cm_math_cacosf(c32z);
/* */c32cm_math_casinf(c32z);
/* */c32cm_math_catanf(c32z);
/* */c32cm_math_cacoshf(c32z);
/* */c32cm_math_casinhf(c32z);
/* */c32cm_math_catanhf(c32z);
/* * Extended precision complex functions *//* */fldcm_math_cabsl(cldz);
/* */fldcm_math_cargl(cldz);
/* */cldcm_math_cexpl(cldz);
/* */cldcm_math_clogl(cldz);
/* */cldcm_math_cpowl(cldx, cldy);
/* */cldcm_math_csqrtl(cldz);
/* */cldcm_math_ccosl(cldz);
/* */cldcm_math_csinl(cldz);
/* */cldcm_math_ctanl(cldz);
/* */cldcm_math_ccoshl(cldz);
/* */cldcm_math_csinhl(cldz);
/* */cldcm_math_ctanhl(cldz);
/* */cldcm_math_cacosl(cldz);
/* */cldcm_math_casinl(cldz);
/* */cldcm_math_catanl(cldz);
/* */cldcm_math_cacoshl(cldz);
/* */cldcm_math_casinhl(cldz);
/* */cldcm_math_catanhl(cldz);

misc.h

  • Function
/* */voidcm_exit (u32code);
/* */voidcm_yield (void);
/* */voidcm_set_env (charconst*name, charconst*value);
/* */voidcm_unset_env (charconst*name);
/* */u16cm_endian_swap16 (u16i);
/* */u32cm_endian_swap32 (u32i);
/* */u64cm_endian_swap64 (u64i);
/* */isizecm_count_set_bits (u64mask);

mutex.h

  • Struct
/* * Windows */typedefstructcmMutex {
CRITICAL_SECTIONwin32_critical_section;
} cmMutex;
/* * Unix & Linux */typedefstructcmMutex {
pthread_mutex_tpthread_mutex;
pthread_mutexattr_tpthread_mutexattr;
} cmMutex;
  • Function
/* */voidcm_mutex_init (cmMutex*m);
/* */voidcm_mutex_destroy (cmMutex*m);
/* */voidcm_mutex_lock (cmMutex*m);
/* */b32cm_mutex_try_lock (cmMutex*m);
/* */voidcm_mutex_unlock (cmMutex*m);

print.h

  • Function
/* */isizecm_printf (charconst*fmt, ...) CM_PRINTF_ARGS(1);
/* */isizecm_printf_va (charconst*fmt, va_listva);
/* */isizecm_printf_err (charconst*fmt, ...) CM_PRINTF_ARGS(1);
/* */isizecm_printf_err_va (charconst*fmt, va_listva);
/* */isizecm_fprintf (cmFile*f, charconst*fmt, ...) CM_PRINTF_ARGS(2);
/* */isizecm_fprintf_va (cmFile*f, charconst*fmt, va_listva);
/* */char*cm_bprintf (charconst*fmt, ...) CM_PRINTF_ARGS(1);
/* */char*cm_bprintf_va (charconst*fmt, va_listva);
/* */isizecm_snprintf (char*str, isizen, charconst*fmt, ...) CM_PRINTF_ARGS(3);

random.h

  • Struct
/* */typedefstructcmRandom {
u32offsets[8];
u32value;
} cmRandom;
  • Function
/* */voidcm_random_init (cmRandom*r);
/* */u32cm_random_gen_u32 (cmRandom*r);
/* */u32cm_random_gen_u32_unique (cmRandom*r);
/* */u64cm_random_gen_u64 (cmRandom*r);
/* */isizecm_random_gen_isize (cmRandom*r);
/* */i64cm_random_range_i64 (cmRandom*r, i64lower_inc, i64higher_inc);
/* */isizecm_random_range_isize (cmRandom*r, isizelower_inc, isizehigher_inc);
/* */f64cm_random_range_f64 (cmRandom*r, f64lower_inc, f64higher_inc);

semaphore.h

  • Struct
/* * Window */typedefstructcmSemaphore { void*win32_handle;} cmSemaphore;
/* * OSX */typedefstructcmSemaphore { semaphore_tosx_handle; } cmSemaphore;
/* * Unix */typedefstructcmSemaphore { sem_tunix_handle; } cmSemaphore;
  • Function
/* */voidcm_semaphore_init (cmSemaphore*s);
/* */voidcm_semaphore_destroy (cmSemaphore*s);
/* */voidcm_semaphore_post (cmSemaphore*s, i32count);
/* */voidcm_semaphore_release (cmSemaphore*s);
/* */voidcm_semaphore_wait (cmSemaphore*s);

sortsearch.h

  • Function
/* */int (*cm_i16_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */int (*cm_i32_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */int (*cm_i64_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */int (*cm_isize_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */int (*cm_str_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */int (*cm_f32_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */int (*cm_f64_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */cm_sort_array(array, count, compare_proc) ;
/* */voidcm_sort(void*base, isizecount, isizesize, cmCompareProccompare_proc);
/* */cm_radix_sort(Type);
/* */voidcm_radix_sort_u8 (u8*items, u8*temp, isizecount);
/* */voidcm_radix_sort_u16 (u16*items, u16*temp, isizecount);
/* */voidcm_radix_sort_u32 (u32*items, u32*temp, isizecount);
/* */voidcm_radix_sort_u64 (u64*items, u64*temp, isizecount);
/* */cm_binary_search_array(array, count, key, compare_proc);
/* */isizecm_binary_search(voidconst*base, isizecount, isizesize, voidconst*key, cmCompareProccompare_proc);
/* */cm_shuffle_array(array, count);
/* */voidcm_shuffle(void*base, isizecount, isizesize);
/* */cm_reverse_array(array, count);
/* */voidcm_reverse(void*base, isizecount, isizesize);

string.h

  • Struct
/* */typedefchar*cmString;
/* */typedefstructcmStringHeader {
cmAllocatorallocator;
isizelength;
isizecapacity;
} cmStringHeader;
  • Function
/* */cmStringcm_string_make_reserve (cmAllocatora, isizecapacity);
/* */cmStringcm_string_make (cmAllocatora, charconst*str);
/* */cmStringcm_string_make_length (cmAllocatora, voidconst*str, isizenum_bytes);
/* */voidcm_string_free (cmStringstr);
/* */cmStringcm_string_duplicate (cmAllocatora, cmStringconststr);
/* */isizecm_string_length (cmStringconststr);
/* */isizecm_string_capacity (cmStringconststr);
/* */isizecm_string_available_space(cmStringconststr);
/* */voidcm_string_clear (cmStringstr);
/* */cmStringcm_string_append (cmStringstr, cmStringconstother);
/* */cmStringcm_string_append_length (cmStringstr, voidconst*other, isizenum_bytes);
/* */cmStringcm_string_appendc (cmStringstr, charconst*other);
/* */cmStringcm_string_append_rune (cmStringstr, Runer);
/* */cmStringcm_string_append_fmt (cmStringstr, charconst*fmt, ...);
/* */cmStringcm_string_set (cmStringstr, charconst*cstr);
/* */cmStringcm_string_make_space_for (cmStringstr, isizeadd_len);
/* */isizecm_string_allocation_size(cmStringconststr);
/* */b32cm_string_are_equal (cmStringconstlhs, cmStringconstrhs);
/* */cmStringcm_string_trim (cmStringstr, charconst*cut_set);
/* */cmStringcm_string_trim_space (cmStringstr);

thread.h

  • Struct
/* * Window */typedefstructcmThread {
void*win32_handle;
cmThreadProc*proc;
void*user_data;
isizeuser_index;
isizevolatilereturn_value;
cmSemaphoresemaphore;
isizestack_size;
b32volatileis_running;
} cmThread;
/* * Posix */typedefstructcmThread {
pthread_tposix_handle;
cmThreadProc*proc;
void*user_data;
isizeuser_index;
isizevolatilereturn_value;
cmSemaphoresemaphore;
isizestack_size;
b32volatileis_running;
} cmThread;
/* */typedefstructcmSync {
i32target; // Target Number of threadsi32current; // Threads to hiti32waiting; // Threads waitingcmMutexstart;
cmMutexmutex;
cmSemaphorerelease;
} cmSync;
  • Function
/* */voidcm_thread_init (cmThread*t);
/* */voidcm_thread_destroy (cmThread*t);
/* */voidcm_thread_start (cmThread*t, cmThreadProc*proc, void*data);
/* */voidcm_thread_start_with_stack (cmThread*t, cmThreadProc*proc, void*data, isizestack_size);
/* */voidcm_thread_join (cmThread*t);
/* */b32cm_thread_is_running (cmThreadconst*t);
/* */u32cm_thread_current_id (void);
/* */voidcm_thread_set_name (cmThread*t, charconst*name);
/* */voidcm_sync_init (cmSync*s);
/* */voidcm_sync_destroy (cmSync*s);
/* */voidcm_sync_set_target (cmSync*s, i32count);
/* */voidcm_sync_release (cmSync*s);
/* */i32cm_sync_reach (cmSync*s);
/* */voidcm_sync_reach_and_wait (cmSync*s);

time.h

  • Function
/* */u64cm_rdtsc (void);
/* */f64cm_time_now (void);
/* */u64cm_utc_time_now(void);
/* */voidcm_sleep_ms (u32ms);

utf8.h

  • Function
/* */isizecm_utf8_strlen (u8const*str);
/* */isizecm_utf8_strnlen(u8const*str, isizemax_len);
/* */u16*cm_utf8_to_ucs2 (u16*buffer, isizelen, u8const*str);
/* */u8*cm_ucs2_to_utf8 (u8*buffer, isizelen, u16const*str);
/* */u16*cm_utf8_to_ucs2_buf (u8const*str);
/* */u8*cm_ucs2_to_utf8_buf (u16const*str);
/* */isizecm_utf8_decode (u8const*str, isizestr_len, Rune*codepoint);
/* */isizecm_utf8_codepoint_size (u8const*str, isizestr_len);
/* */isizecm_utf8_encode_rune (u8buf[4], Runer);

utils.h

#defineNULL#defineinline#definecm_restrict#definecm_inline#definecm_no_inline#definecm_thread_local#definecast(Type)
#definecm_size_of(x)
#definecm_count_of(x)
#definecm_offset_of(Type, element)
#definecm_align_of(Type)
#definecm_swap(Type, a, b)
#definecm_global#definecm_internal#definecm_local_persist#definecm_unused(x)
#definevprtcast(x)
#definevoidcast(x)
#defineCM_BIT(x)
#defineCM_MIN(a, b)
#defineCM_MAX(a, b)
#defineCM_MIN3(a, b, c)
#defineCM_MAX3(a, b, c)
#defineCM_CLAMP(x, lower, upper)
#defineCM_CLAMP01(x)
#defineCM_IS_BETWEEN(x, lower, upper)
#defineCM_ABS(x)
#defineCM_MASK_SET(var, set, mask)
#defineCM_PRINTF_ARGS(FMT)

About

c/c++ marcro and utility

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

Latest commit

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

types.h

typedefu8;
typedefi8;
typedefu16;
typedefi16;
typedefu32;
typedefi32;
typedefu64;
typedefi64;
typedefusize; //typedef unsigned long long size_ttypedefisize; //typedef long long ptrdiff_ttypedefintptr;
typedefuintptr;
typedeff32;
typedeff64;
typedefRune;
typedefb8;
typedefb16;
typedefb32;
#defineCM_RUNE_INVALID#defineCM_RUNE_MAX #define CM_RUNE_BOM #defineCM_RUNE_EOF#defineU8_MIN#defineU8_MAX#defineI8_MIN#defineI8_MAX#defineU16_MIN#defineU16_MAX#defineI16_MIN#defineI16_MAX#defineU32_MIN#defineU32_MAX#defineI32_MIN#defineI32_MAX#defineU64_MIN#defineU64_MAX#defineI64_MIN#defineI64_MAX#defineUSIZE_MIX #define USIZE_MAX
#defineISIZE_MIX#defineISIZE_MAX#defineF32_MIN#defineF32_MAX#defineF64_MIN#defineF64_MAX

arch.h

/*  * Arch  */#defineCM_ARCH_64#defineCM_ARCH_32/*  * Endian  */#defineCM_ENDIAN_ORDER#defineCM_BIG_ENDIAN#defineCM_LITTLE_ENDIAN/* * OS */#defineCM_WINDOWS#defineCM_OS_WINDOWS#defineCM_SYS_WINDOWS#defineCM_OSX#defineCM_OS_OSX#defineCM_SYS_OSX#defineCM_UNIX#defineCM_OS_UNIX#defineCM_SYS_UNIX#defineCM_LINUX#defineCM_OS_LINUX#defineCM_SYS_LINUX#defineCM_FREEBSD#defineCM_OS_FREEBSD#defineCM_SYS_FREEBSD/* * Compiler */#defineCM_COMPILER_MSVC#defineCM_COMPILER_GCC#defineCM_COMPILER_CLANG/* * CPU */#defineCM_CPU_X86#defineCM_CPU_PPC#defineCM_CPU_ARM#defineCM_CPU_MIPS#defineCM_CACHE_LINE_SIZE

assert.h

#defineCM_STATIC_ASSERT(cond) #define CM_STATIC_ASSERT1(cond, line)
#defineCM_STATIC_ASSERT2(cond, line)
#defineCM_STATIC_ASSERT3(cond, msg)

affinity.h

  • Struct
/* * cmAffinity */typedefstructcmAffinity{
b32is_accurate;
isizecore_count;
isizethread_count;
usizecore_masks[CM_WIN32_MAX_THREADS];
} cmAffinity;
  • Function
/* */voidcm_affinity_init (cmAffinity*a);
/* */voidcm_affinity_destroy (cmAffinity*a);
/* */b32cm_affinity_set (cmAffinity*a, isizecore, isizethread);
/* */isizecm_affinity_thread_count_for_core (cmAffinity*a, isizecore);

atomics.h

  • Struct
/* * cmAtomic32 */typedefstructcmAtomic32 { i32volatilevalue; } cmAtomic32;
/* * cmAtomic64 */typedefstructcmAtomic64 {
i64volatilevalue; } cmAtomic64;
/* * cmAtomicPtr */typedefstructcmAtomicPtr { void*volatilevalue;
} cmAtomicPtr;
  • Function
/* * atomic32 */i32cm_atomic32_load (cmAtomic32constvolatile*a);
voidcm_atomic32_store (cmAtomic32volatile*a, i32value);
i32cm_atomic32_compare_exchange (cmAtomic32volatile*a, i32expected, i32desired);
i32cm_atomic32_exchanged (cmAtomic32volatile*a, i32desired);
i32cm_atomic32_fetch_add (cmAtomic32volatile*a, i32operand);
i32cm_atomic32_fetch_and (cmAtomic32volatile*a, i32operand);
i32cm_atomic32_fetch_or (cmAtomic32volatile*a, i32operand);
b32cm_atomic32_spin_lock (cmAtomic32volatile*a, isizetime_out);
voidcm_atomic32_spin_unlock (cmAtomic32volatile*a);
b32cm_atomic32_try_acquire_lock (cmAtomic32volatile*a);
/* * atomic64 */i64cm_atomic64_load (cmAtomic64constvolatile*a);
voidcm_atomic64_store (cmAtomic64volatile*a, i64value);
i64cm_atomic64_compare_exchange (cmAtomic64volatile*a, i64expected, i64desired);
i64cm_atomic64_exchanged (cmAtomic64volatile*a, i64desired);
i64cm_atomic64_fetch_add (cmAtomic64volatile*a, i64operand);
i64cm_atomic64_fetch_and (cmAtomic64volatile*a, i64operand);
i64cm_atomic64_fetch_or (cmAtomic64volatile*a, i64operand);
b32cm_atomic64_spin_lock (cmAtomic64volatile*a, isizetime_out);
voidcm_atomic64_spin_unlock (cmAtomic64volatile*a);
b32cm_atomic64_try_acquire_lock (cmAtomic64volatile*a);
/* * atomicptr */void*cm_atomic_ptr_load (cmAtomicPtrconstvolatile*a);
voidcm_atomic_ptr_store (cmAtomicPtrvolatile*a, void*value);
void*cm_atomic_ptr_compare_exchange (cmAtomicPtrvolatile*a, void*expected, void*desired);
void*cm_atomic_ptr_exchanged (cmAtomicPtrvolatile*a, void*desired);
void*cm_atomic_ptr_fetch_add (cmAtomicPtrvolatile*a, void*operand);
void*cm_atomic_ptr_fetch_and (cmAtomicPtrvolatile*a, void*operand);
void*cm_atomic_ptr_fetch_or (cmAtomicPtrvolatile*a, void*operand);
b32cm_atomic_ptr_spin_lock (cmAtomicPtrvolatile*a, isizetime_out);
voidcm_atomic_ptr_spin_unlock (cmAtomicPtrvolatile*a);
b32cm_atomic_ptr_try_acquire_lock (cmAtomicPtrvolatile*a);

buffer.h

  • Struct
/* * cmBufferHeader */typedefstructcmBufferHeader {
isizecount;
isizecapacity;
} cmBufferHeader;
  • Function
/* * ประกาศตัวแปร Ex. cmBuffer(i32) buffer; */cmBuffer(Type);
/* * จำนวน */isizecm_buffer_count (cmBufferHeader*bfh);
/* * ความจุ */isizecm_buffer_capacity (cmBufferHeader*bfh);
/* * ค่าเริ่มต้น */void*cm_buffer_init (x, allocator, cap);
/* * เลิกใช้งาน */voidcm_buffer_free (x, allocator);
/* * เพิ่มข้อมูล(1 รายการ) */voidcm_buffer_append (x, item);
/* * เพิ่มข้อมูล(มากกว่า 1 รายการ) */voidcm_buffer_appendv (x, items, item_count);
/* * นำข้อมูลออก */voidcm_buffer_pop (x);
/* * ล้างข้อมูล */cm_buffer_clear (x)

char.h

  • Function
/* * แปลงตัวอักษรเป็นพิมพ์เล็ก */charcm_char_to_lower (charc);
/* * แปลงตัวอักษรเป็นพิมพ์ใหญ่ */charcm_char_to_upper (charc);
/* * ตรวจสอบช่องว่าง */b32cm_char_is_space (charc);
/* * ตรวจสอบตัวเลข */b32cm_char_is_digit (charc);
/* * ตรวจสอบตัวเลขที่เป็นฐาน16 (hex) */b32cm_char_is_hex_digit (charc);
/* *  */b32cm_char_is_alpha (charc);
/* * ตรวจสอบว่าเป็นตัวเลขหรือตัวอักษร */b32cm_char_is_alphanumeric (charc);
/* * แปลงตัวอักษร */i32cm_digit_to_int (charc);
/* * แปลงตัวอักษรฐาน16(hex)เป็นตัวเลขจำนวนเต็ม */i32cm_hex_digit_to_int (charc);
/* * แปลงตัวอักษรเป็นพิมพ์เล็ก */voidcm_str_to_lower(char*str);
/* * แปลงตัวอักษรเป็นพิมพ์ใหญ่ */voidcm_str_to_upper(char*str);
/* * จำนวนข้อความ */isizecm_strlen (charconst*str);
/* *  */isizecm_strnlen(charconst*str, isizemax_len);
/* * เปรียบเทียบข้อความ */i32cm_strcmp (charconst*s1, charconst*s2);
/* *  */i32cm_strncmp(charconst*s1, charconst*s2, isizelen);
/* * ก๊อบปี้ข้อความ */char*cm_strcpy (char*dest, charconst*source);
/* *  */char*cm_strncpy(char*dest, charconst*source, isizelen);
/* *  */isizecm_strlcpy(char*dest, charconst*source, isizelen);
/* *  */char*cm_strrev (char*str);
/* *  */charconst*cm_strtok(char*output, charconst*src, charconst*delimit);
/* *  */b32cm_str_has_prefix(charconst*str, charconst*prefix);
/* *  */b32cm_str_has_suffix(charconst*str, charconst*suffix);
/* *  */charconst*cm_char_first_occurence(charconst*str, charc);
/* *  */charconst*cm_char_last_occurence (charconst*str, charc);
/* *  */voidcm_str_concat(char*dest, isizedest_len, charconst*src_a, isizesrc_a_len, charconst*src_b, isizesrc_b_len);
/* *  */u64cm_str_to_u64(charconst*str, char**end_ptr, i32base);
/* *  */i64cm_str_to_i64(charconst*str, char**end_ptr, i32base);
/* *  */f32cm_str_to_f32(charconst*str, char**end_ptr);
/* *  */f64cm_str_to_f64(charconst*str, char**end_ptr);
/* *  */voidcm_i64_to_str(i64value, char*string, i32base);
/* *  */voidcm_u64_to_str(u64value, char*string, i32base);

debug.h

#defineCM_DEBUG_TRAP()
#defineCM_ASSERT_MSG(cond, msg, ...)
#defineCM_ASSERT(cond)
#defineCM_ASSERT_NOT_NULL(ptr)
#defineCM_PANIC(msg, ...)
  • Function
//voidcm_assert_handler(charconst*prefix, charconst*condition, charconst*file, i32line, charconst*msg, ...);

defer.h

#defineCM_DEFER_1(x, y)
#defineCM_DEFER_2(x, y)
#defineCM_DEFER_3(x)
  • Function
/*ตัวอย่างcmMutex m;cm_mutex_init(&m);{	cm_mutex_lock(&m);	defer (cm_mutex_unlock(&m));	...}*/voiddefer(code);

dll.h

#defineCM_DLL_EXPORT#defineCM_DLL_IMPORT#defineCM_DEF#defineCM_SHARED_LIB_BUILD#defineCM_SHARED_LIB_USE#defineCM_C_API
  • Struct
typedefvoid*cmDllHandle;
typedefvoid (*cmDllProc)(void);
  • Function
/* * Ex. cmDllHandle handle = cm_dll_load("opengl32.dll"); */cmDllHandlecm_dll_load (charconst*filepath);
/* * Ex. cm_dll_unload(handle); */voidcm_dll_unload (cmDllHandledll);
/* * Ex. * cmDllHandle xinput_library = cm_dll_load("xinput9_1_0.dll"); * cmXInputGetStateProc *get_state = cast(cmXInputGetStateProc *)cm_dll_proc_address(xinput_library, "XInputGetState"); * cmXInputGetStateProc *set_state = cast(cmXInputSetStateProc *)cm_dll_proc_address(xinput_library, "XInputSetState"); */cmDllProccm_dll_proc_address (cmDllHandledll, charconst*proc_name);

dynarray.h

#defineCM_ARRAY_GROW_FORMULA(x)
#defineCM_ARRAY_HEADER(x)
  • Struct
/* * cmArrayHeader */typedefstructcmArrayHeader {
cmAllocatorallocator;
isizecount;
isizecapacity;
} cmArrayHeader;
  • Function
/* * ประกาศตัวแปร Ex. cmArray(i32) array; */cmArray(Type);
/* */cmAllocatorcm_array_allocator(x);
/* */isizecm_array_count(x);
/* */isizecm_array_capacity(x);
/* */voidcm_array_init_reserve(x, allocator_, cap);
/* */voidcm_array_init(x, allocator);
/* */voidcm_array_free(x);
/* */voidcm_array_set_capacity(x, capacity);
/* */void*cm__array_set_capacity(void*array, isizecapacity, isizeelement_size);
/* */voidcm_array_grow(x, min_capacity) ;
/* */voidcm_array_append(x, item);
/* */voidcm_array_appendv(x, items, item_count);
/* */voidcm_array_pop(x);
/* */voidcm_array_clear(x);
/* */voidcm_array_resize(x, new_count);
/* */voidcm_array_reserve(x, new_capacity);

extern.h

#defineCM_EXTERN#defineCM_BEGIN_EXTERN#defineCM_END_EXTERN

fences.h

  • Function
/* */voidcm_yield_thread(void);
/* */voidcm_mfence (void);
/* */voidcm_sfence (void);
/* */voidcm_lfence (void);

file.h

  • Struct
/* */typedefu32cmFileMode;
/* */typedefenumcmFileModeFlag {
cmFileMode_Read,
cmFileMode_Write,
cmFileMode_Append,
cmFileMode_Rw,
cmFileMode_Modes ,
} cmFileModeFlag;
/* */typedefenumcmSeekWhenceType {
cmSeekWhence_Begin,
cmSeekWhence_Current,
cmSeekWhence_End,
} cmSeekWhenceType;
/* */typedefenumcmFileError {
cmFileError_None,
cmFileError_Invalid,
cmFileError_InvalidFilename,
cmFileError_Exists,
cmFileError_NotExists,
cmFileError_Permission,
cmFileError_TruncationFailure,
} cmFileError;
/* */typedefunioncmFileDescriptor {
void*p;
intptri;
uintptru;
} cmFileDescriptor;
/* */typedefstructcmFileOperationscmFileOperations;
/* */typedefCM_FILE_OPEN_PROC(cmFileOpenProc);
/* */typedefCM_FILE_READ_AT_PROC(cmFileReadProc);
/* */typedefCM_FILE_WRITE_AT_PROC(cmFileWriteProc);
/* */typedefCM_FILE_SEEK_PROC(cmFileSeekProc);
/* */typedefCM_FILE_CLOSE_PROC(cmFileCloseProc)
/* */structcmFileOperations {
cmFileReadProc*read_at;
cmFileWriteProc*write_at;
cmFileSeekProc*seek;
cmFileCloseProc*close;
};
/* */externcmFileOperationsconstcmDefaultFileOperations;
/* */typedefu64cmFileTime;
/* */typedefstructcmFile {
cmFileOperationsops;
cmFileDescriptorfd;
charconst*filename;
cmFileTimelast_write_time;
// gbDirInfo * dir_info; // TODO(bill): Get directory info
} cmFile;
/* */typedefenumcmFileStandardType {
cmFileStandard_Input,
cmFileStandard_Output,
cmFileStandard_Error,
cmFileStandard_Count,
} cmFileStandardType;
/* */typedefstructcmFileContents {
cmAllocatorallocator;
void*data;
isizesize;
} cmFileContents;
/* */#defineCM_PATH_SEPARATOR
  • Function
/* */cmFile*constcm_file_get_standard (cmFileStandardTypestd);
/* */cmFileErrorcm_file_create (cmFile*file, charconst*filename);
/* */cmFileErrorcm_file_open_mode (cmFile*file, cmFileModemode, charconst*filename);
/* */cmFileErrorcm_file_new (cmFile*file, cmFileDescriptorfd, cmFileOperationsops, charconst*filename);
/* */b32cm_file_read_at_check (cmFile*file, void*buffer, isizesize, i64offset, isize*bytes_read);
/* */b32cm_file_write_at_check(cmFile*file, voidconst*buffer, isizesize, i64offset, isize*bytes_written);
/* */b32cm_file_read_at (cmFile*file, void*buffer, isizesize, i64offset);
/* */b32cm_file_write_at (cmFile*file, voidconst*buffer, isizesize, i64offset);
/* */i64cm_file_seek (cmFile*file, i64offset);
/* */i64cm_file_seek_to_end (cmFile*file);
/* */i64cm_file_skip (cmFile*file, i64bytes);
/* */i64cm_file_tell (cmFile*file);
/* */cmFileErrorcm_file_close (cmFile*file);
/* */b32cm_file_read (cmFile*file, void*buffer, isizesize);
/* */b32cm_file_write (cmFile*file, voidconst*buffer, isizesize);
/* */i64cm_file_size (cmFile*file);
/* */charconst*cm_file_name (cmFile*file);
/* */cmFileErrorcm_file_truncate (cmFile*file, i64size);
/* */b32cm_file_has_changed (cmFile*file);
/* */cmFileContentscm_file_read_contents(cmAllocatora, b32zero_terminate, charconst*filepath);
/* */voidcm_file_free_contents(cmFileContents*fc);
/* */b32cm_file_exists (charconst*filepath);
/* */cmFileTimecm_file_last_write_time(charconst*filepath);
/* */b32cm_file_copy (charconst*existing_filename, charconst*new_filename, b32fail_if_exists);
/* */b32cm_file_move (charconst*existing_filename, charconst*new_filename);
/* */b32cm_file_remove (charconst*filename);
/* */b32cm_path_is_absolute (charconst*path);
/* */b32cm_path_is_relative (charconst*path);
/* */b32cm_path_is_root (charconst*path);
/* */charconst*cm_path_base_name (charconst*path);
/* */charconst*cm_path_extension (charconst*path);
/* */char*cm_path_get_full_name(cmAllocatora, charconst*path);

hash.h

  • Function
/* */u32cm_adler32(voidconst*data, isizelen);
/* */u32cm_crc32(voidconst*data, isizelen);
/* */u64cm_crc64(voidconst*data, isizelen);
/* */u32cm_fnv32 (voidconst*data, isizelen);
/* */u64cm_fnv64 (voidconst*data, isizelen);
/* */u32cm_fnv32a(voidconst*data, isizelen);
/* */u64cm_fnv64a(voidconst*data, isizelen);
/* */u32cm_murmur32(voidconst*data, isizelen);
/* */u64cm_murmur64(voidconst*data, isizelen);
/* */u32cm_murmur32_seed(voidconst*data, isizelen, u32seed);
/* */u64cm_murmur64_seed(voidconst*data, isizelen, u64seed);

hashtable.h

#defineCM_TABLE(PREFIX, NAME, FUNC, VALUE)
#defineCM_TABLE_DECLARE(PREFIX, NAME, FUNC, VALUE)
#defineCM_TABLE_DEFINE(NAME, FUNC, VALUE)
  • Struct
/* * cmHashTableFindResult */typedefstructcmHashTableFindResult {
isizehash_index;
isizeentry_prev;
isizeentry_index;
} cmHashTableFindResult;

header.h

#define_CRT_SECURE_NO_WARNINGS#define_GNU_SOURCE#define_LARGEFILE64_SOURCE#defineWIN32_LEAN_AND_MEAN #define WIN32_MEAN_AND_LEAN #defineVC_EXTRALEAN#defineNOMINMAX

memory.h

#defineCM_DEFAULT_MEMORY_ALIGNMENT#defineCM_DEFAULT_ALLOCATOR_FLAGS
  • Struct
/* * cmVirtualMemory */typedefstructcmVirtualMemory {
void*data;
isizesize;
} cmVirtualMemory;
/* * cmVirtualMemory */typedefenumcmAllocationType {
cmAllocation_Alloc,
cmAllocation_Free,
cmAllocation_FreeAll,
cmAllocation_Resize,
} cmAllocationType;
/* * cmAllocator */typedefstructcmAllocator {
cmAllocatorProc*proc;
void*data;
} cmAllocator;
/* * cmAllocatorFlag */typedefenumcmAllocatorFlag {
cmAllocatorFlag_ClearToZero ,
} cmAllocatorFlag;
/* * cmArena */typedefstructcmArena {
cmAllocatorbacking;
void*physical_start;
isizetotal_size;
isizetotal_allocated;
isizetemp_count;
} cmArena;
  • Function
/* */b32cm_is_power_of_two (isizex);
/* */void*cm_align_forward (void*ptr, isizealignment);
/* */void*cm_pointer_add (void*ptr, isizebytes);
/* */void*cm_pointer_sub (void*ptr, isizebytes);
/* */voidconst*cm_pointer_add_const (voidconst*ptr, isizebytes);
/* */voidconst*cm_pointer_sub_const (voidconst*ptr, isizebytes);
/* */isizecm_pointer_diff (voidconst*begin, voidconst*end);
/* */voidcm_zero_size (void*ptr, isizesize);
/* */voidcm_zero_item (void*t)
/* */voidcm_zero_array (void*a, count)
/* */void*cm_memcopy (void*dest, voidconst*source, isizesize);
/* */void*cm_memmove (void*dest, voidconst*source, isizesize);
/* */void*cm_memset (void*data, u8byte_value, isizesize);
/* */i32cm_memcompare (voidconst*s1, voidconst*s2, isizesize);
/* */voidcm_memswap (void*i, void*j, isizesize);
/* */voidconst*cm_memchr (voidconst*data, u8byte_value, isizesize);
/* */voidconst*cm_memrchr (voidconst*data, u8byte_value, isizesize);
/* */cm_memcopy_array (dst, src, count);
/* */cm_memmove_array (dst, src, count) /* */cmVirtualMemorycm_virtual_memory (void*data, isizesize);
/* */cmVirtualMemorycm_vm_alloc (void*addr, isizesize);
/* */b32cm_vm_free (cmVirtualMemoryvm);
/* */cmVirtualMemorycm_vm_trim (cmVirtualMemoryvm, isizelead_size, isizesize);
/* */b32cm_vm_purge (cmVirtualMemoryvm);
/* */isizecm_virtual_memory_page_size (isize*alignment_out);
/* */void*cm_alloc_align (cmAllocatora, isizesize, isizealignment);
/* */void*cm_alloc (cmAllocatora, isizesize);
/* */voidcm_free (cmAllocatora, void*ptr);
/* */voidcm_free_all (cmAllocatora);
/* */void*cm_resize (cmAllocatora, void*ptr, isizeold_size, isizenew_size);
/* */void*cm_resize_align (cmAllocatora, void*ptr, isizeold_size, isizenew_size, isizealignment);
/* */void*cm_alloc_copy (cmAllocatora, voidconst*src, isizesize);
/* */void*cm_alloc_copy_align (cmAllocatora, voidconst*src, isizesize, isizealignment);
/* */char*cm_alloc_str (cmAllocatora, charconst*str);
/* */char*cm_alloc_str_len (cmAllocatora, charconst*str, isizelen);
/* */cm_alloc_item (allocator_, Type)
/* */cm_alloc_array (allocator_, Type, count)
/* */void*gb_default_resize_align (cmAllocatora, void*ptr, isizeold_size, isizenew_size, isizealignment);
/* */cmAllocatorcm_heap_allocator (void);
/* */cm_malloc(sz);
/* */cm_mfree(ptr);
/* */voidcm_arena_init_from_memory (cmArena*arena, void*start, isizesize);
/* */voidcm_arena_init_from_allocator (cmArena*arena, cmAllocatorbacking, isizesize);
/* */voidcm_arena_init_sub (cmArena*arena, cmArena*parent_arena, isizesize);
/* */voidcm_arena_free (cmArena*arena);
/* */isizecm_arena_alignment_of (cmArena*arena, isizealignment);
/* */isizecm_arena_size_remaining (cmArena*arena, isizealignment);
/* */voidcm_arena_check (cmArena*arena);
/* */cmAllocatorcm_arena_allocator (cmArena*arena);

math.h

#defineCM_MATH_INFINITYF#defineCM_MATH_NANF#defineCM_MATH_PZEROF#defineCM_MATH_NZEROF#defineCM_MATH_INFINITY#defineCM_MATH_NAN#defineCM_MATH_PZERO#defineCM_MATH_NZERO#defineCM_MATH_INFINITYL#defineCM_MATH_NANL#defineCM_MATH_PZEROL#defineCM_MATH_NZEROL#defineCM_SIZEOF_CHAR#defineCM_SIZEOF_BYTE#defineCM_SIZEOF_INT#defineCM_SIZEOF_INTP#defineCM_SIZEOF_UINTP#defineCM_SIZEOF_HALF#defineCM_SIZEOF_LONG#defineCM_SIZEOF_LONGLONG#defineCM_SIZEOF_DOUBLE#defineCM_SIZEOF_LONGDOUBLE#defineCM_SIZEOF_DATETIME#defineCM_SIZEOF_TIMEDELTA#defineCM_CHAR_BIT#defineCM_BYTE_FMT#defineCM_UBYTE_FMT#defineCM_SHORT_FMT#defineCM_USHORT_FMT#defineCM_INT_FMT#defineCM_UINT_FMT#defineCM_LONG_FMT#defineCM_ULONG_FMT#defineCM_HALF_FMT#defineCM_FLOAT_FMT#defineCM_DOUBLE_FMT#defineCM_LONGLONG_FMT#defineCM_ULONGLONG_FMT#defineCM_LONGLONG_SUFFIX(x)
#defineCM_ULONGLONG_SUFFIX(x)
#definecm_isnan(x)
#definecm_isfinite(x)
#definecm_isinf(x)
#defineCM_EXTRACT_WORDS(ix0,ix1,d)
#defineCM_GET_HIGH_WORD(i,d)
#defineCM_GET_LOW_WORD(i,d)
#defineCM_SET_HIGH_WORD(d,v)
#defineCM_SET_LOW_WORD(d,v)
#defineCM_INSERT_WORDS(d,ix0,ix1)
#defineCM_MATH_E#defineCM_MATH_LOG2E#defineCM_MATH_LOG10E#defineCM_MATH_LOGE2#defineCM_MATH_LOGE10#defineCM_MATH_PI#defineCM_MATH_PI_2 #define CM_MATH_PI_4
#defineCM_MATH_1_PI#defineCM_MATH_2_PI#defineCM_MATH_EULER#defineCM_MATH_SQRT2#defineCM_MATH_SQRT1_2#defineCM_MATH_Ef#defineCM_MATH_LOG2Ef#defineCM_MATH_LOG10Ef#defineCM_MATH_LOGE2f#defineCM_MATH_LOGE10f#defineCM_MATH_PIf#defineCM_MATH_PI_2f#defineCM_MATH_PI_4f#defineCM_MATH_1_PIf#defineCM_MATH_2_PIf#defineCM_MATH_EULERf#defineCM_MATH_SQRT2f#defineCM_MATH_SQRT1_2f#defineCM_MATH_El#defineCM_MATH_LOG2El#defineCM_MATH_LOG10El#defineCM_MATH_LOGE2l#defineCM_MATH_LOGE10l#defineCM_MATH_PIl#defineCM_MATH_PI_2l#defineCM_MATH_PI_4l#defineCM_MATH_1_PIl#defineCM_MATH_2_PIl#defineCM_MATH_EULERl#defineCM_MATH_SQRT2l#defineCM_MATH_SQRT1_2l#definecm_math_degrees#definecm_math_degreesf#definecm_math_degreesl#definecm_math_radians#definecm_math_radiansf#definecm_math_radiansl
  • Function
/* * Integer functions. *//* */u32cm_math_gcdu(u32a, u32b);
/* */u32cm_math_lcmu(u32a, u32b);
/* */ulcm_math_gcdul(ula, ulb);
/* */ulcm_math_lcmul(ula, ulb);
/* */ullcm_math_gcdull(ulla, ullb);
/* */ullcm_math_lcmull(ulla, ullb);
/* */u32cm_math_gcd(u32a, u32b);
/* */u32cm_math_lcm(u32a, u32b);
/* */ilcm_math_gcdl(ila, ilb);
/* */ilcm_math_lcml(ila, ilb);
/* */illcm_math_gcdll(illa, illb);
/* */illcm_math_lcmll(illa, illb);
/* */ubytecm_math_rshiftuhh(ubytea, ubyteb);
/* */ubytecm_math_lshiftuhh(ubytea, ubyteb);
/* */u16cm_math_rshiftuh(u16a, u16b);
/* */u16cm_math_lshiftuh(u16a, u16b);
/* */u32cm_math_rshiftu(u32a, u32b);
/* */u32cm_math_lshiftu(u32a, u32b);
/* */ulcm_math_rshiftul(ula, ulb);
/* */ulcm_math_lshiftul(ula, ulb);
/* */ullcm_math_rshiftull(ulla, ullb);
/* */ullcm_math_lshiftull(ulla, ullb);
/* */ibytecm_math_rshifthh(ibytea, ibyteb);
/* */ibytecm_math_lshifthh(ibytea, ibyteb);
/* */i16cm_math_rshifth(i16a, i16b);
/* */i16cm_math_lshifth(i16a, i16b);
/* */i32cm_math_rshift(i32a, i32b);
/* */i32cm_math_lshift(i32a, i32b);
/* */ilcm_math_rshiftl(ila, ilb);
/* */ilcm_math_lshiftl(ila, ilb);
/* */illcm_math_rshiftll(illa, illb);
/* */illcm_math_lshiftll(illa, illb);
/* * float C99 math functions *//* */f32cm_math_sinf(f32x);
/* */f32cm_math_cosf(f32x);
/* */f32cm_math_tanf(f32x);
/* */f32cm_math_sinhf(f32x);
/* */f32cm_math_coshf(f32x);
/* */f32cm_math_tanhf(f32x);
/* */f32cm_math_fabsf(f32x);
/* */f32cm_math_floorf(f32x);
/* */f32cm_math_ceilf(f32x);
/* */f32cm_math_rintf(f32x);
/* */f32cm_math_truncf(f32x);
/* */f32cm_math_sqrtf(f32x);
/* */f32cm_math_cbrtf(f32x);
/* */f32cm_math_log10f(f32x);
/* */f32cm_math_logf(f32x);
/* */f32cm_math_expf(f32x);
/* */f32cm_math_expm1f(f32x);
/* */f32cm_math_asinf(f32x);
/* */f32cm_math_acosf(f32x);
/* */f32cm_math_atanf(f32x);
/* */f32cm_math_asinhf(f32x);
/* */f32cm_math_acoshf(f32x);
/* */f32cm_math_atanhf(f32x);
/* */f32cm_math_log1pf(f32x);
/* */f32cm_math_exp2f(f32x);
/* */f32cm_math_log2f(f32x);
/* */f32cm_math_atan2f(f32x, f32y);
/* */f32cm_math_hypotf(f32x, f32y);
/* */f32cm_math_powf(f32x, f32y);
/* */f32cm_math_fmodf(f32x, f32y);
/* */f32cm_math_modff(f32x, f32*y);
/* */f32cm_math_frexpf(f32x, i32*y);
/* */f32cm_math_ldexpf(f32x, i32y);
/* */f32cm_math_copysignf(f32x, f32y);
/* */f32cm_math_nextafterf(f32x, f32y);
/* */f32cm_math_spacingf(f32x);
/* * long double C99 math functions *//* */fldcm_math_sinl(fldx);
/* */fldcm_math_cosl(fldx);
/* */fldcm_math_tanl(fldx);
/* */fldcm_math_sinhl(fldx);
/* */fldcm_math_coshl(fldx);
/* */fldcm_math_tanhl(fldx);
/* */fldcm_math_fabsl(fldx);
/* */fldcm_math_floorl(fldx);
/* */fldcm_math_ceill(fldx);
/* */fldcm_math_rintl(fldx);
/* */fldcm_math_truncl(fldx);
/* */fldcm_math_sqrtl(fldx);
/* */fldcm_math_cbrtl(fldx);
/* */fldcm_math_log10l(fldx);
/* */fldcm_math_logl(fldx);
/* */fldcm_math_expl(fldx);
/* */fldcm_math_expm1l(fldx);
/* */fldcm_math_asinl(fldx);
/* */fldcm_math_acosl(fldx);
/* */fldcm_math_atanl(fldx);
/* */fldcm_math_asinhl(fldx);
/* */fldcm_math_acoshl(fldx);
/* */fldcm_math_atanhl(fldx);
/* */fldcm_math_log1pl(fldx);
/* */fldcm_math_exp2l(fldx);
/* */fldcm_math_log2l(fldx);
/* */fldcm_math_atan2l(fldx, fldy);
/* */fldcm_math_hypotl(fldx, fldy);
/* */fldcm_math_powl(fldx, fldy);
/* */fldcm_math_fmodl(fldx, fldy);
/* */fldcm_math_modfl(fldx, fld*y);
/* */fldcm_math_frexpl(fldx, int*y);
/* */fldcm_math_ldexpl(fldx, inty);
/* */fldcm_math_copysignl(fldx, fldy);
/* */fldcm_math_nextafterl(fldx, fldy);
/* */fldcm_math_spacingl(fldx);
/* * Non standard functions *//* */f64cm_math_deg2rad(f64x);
/* */f64cm_math_rad2deg(f64x);
/* */f64cm_math_logaddexp(f64x, f64y);
/* */f64cm_math_logaddexp2(f64x, f64y);
/* */f64cm_math_divmod(f64x, f64y, f64*modulus);
/* */f64cm_math_heaviside(f64x, f64h0);
/* */f32cm_math_deg2radf(f32x);
/* */f32cm_math_rad2degf(f32x);
/* */f32cm_math_logaddexpf(f32x, f32y);
/* */f32cm_math_logaddexp2f(f32x, f32y);
/* */f32cm_math_divmodf(f32x, f32y, f32*modulus);
/* */f32cm_math_heavisidef(f32x, f32h0);
/* */fldcm_math_deg2radl(fldx);
/* */fldcm_math_rad2degl(fldx);
/* */fldcm_math_logaddexpl(fldx, fldy);
/* */fldcm_math_logaddexp2l(fldx, fldy);
/* */fldcm_math_divmodl(fldx, fldy, fld*modulus);
/* */fldcm_math_heavisidel(fldx, fldh0);
/* * Complex declarations *//* */inlinec64cm_math_cpack(f64x, f64y);
/* */inlinec32cm_math_cpackf(f32x, f32y);
/* */inlinecldcm_math_cpackl(fldx, fldy);
/* */inlinef64cm_math_creal(c64z);
/* */inlinef64cm_math_cimag(c64z);
/* */inlinef32cm_math_crealf(c32z);
/* */inlinef32cm_math_cimagf(c32z);
/* */inlinefldcm_math_creall(cldz);
/* */inlinefldcm_math_cimagl(cldz);
/* * Double precision complex functions *//* */f64cm_math_cabs(c64z);
/* */f64cm_math_carg(c64z);
/* */c64cm_math_cexp(c64z);
/* */c64cm_math_clog(c64z);
/* */c64cm_math_cpow(c64x, c64y);
/* */c64cm_math_csqrt(c64z);
/* */c64cm_math_ccos(c64z);
/* */c64cm_math_csin(c64z);
/* */c64cm_math_ctan(c64z);
/* */c64cm_math_ccosh(c64z);
/* */c64cm_math_csinh(c64z);
/* */c64cm_math_ctanh(c64z);
/* */c64cm_math_cacos(c64z);
/* */c64cm_math_casin(c64z);
/* */c64cm_math_catan(c64z);
/* */c64cm_math_cacosh(c64z);
/* */c64cm_math_casinh(c64z);
/* */c64cm_math_catanh(c64z);
/* * Single precision complex functions *//* */f32cm_math_cabsf(c32z);
/* */f32cm_math_cargf(c32z);
/* */c32cm_math_cexpf(c32z);
/* */c32cm_math_clogf(c32z);
/* */c32cm_math_cpowf(c32x, c32y);
/* */c32cm_math_csqrtf(c32z);
/* */c32cm_math_ccosf(c32z);
/* */c32cm_math_csinf(c32z);
/* */c32cm_math_ctanf(c32z);
/* */c32cm_math_ccoshf(c32z);
/* */c32cm_math_csinhf(c32z);
/* */c32cm_math_ctanhf(c32z);
/* */c32cm_math_cacosf(c32z);
/* */c32cm_math_casinf(c32z);
/* */c32cm_math_catanf(c32z);
/* */c32cm_math_cacoshf(c32z);
/* */c32cm_math_casinhf(c32z);
/* */c32cm_math_catanhf(c32z);
/* * Extended precision complex functions *//* */fldcm_math_cabsl(cldz);
/* */fldcm_math_cargl(cldz);
/* */cldcm_math_cexpl(cldz);
/* */cldcm_math_clogl(cldz);
/* */cldcm_math_cpowl(cldx, cldy);
/* */cldcm_math_csqrtl(cldz);
/* */cldcm_math_ccosl(cldz);
/* */cldcm_math_csinl(cldz);
/* */cldcm_math_ctanl(cldz);
/* */cldcm_math_ccoshl(cldz);
/* */cldcm_math_csinhl(cldz);
/* */cldcm_math_ctanhl(cldz);
/* */cldcm_math_cacosl(cldz);
/* */cldcm_math_casinl(cldz);
/* */cldcm_math_catanl(cldz);
/* */cldcm_math_cacoshl(cldz);
/* */cldcm_math_casinhl(cldz);
/* */cldcm_math_catanhl(cldz);

misc.h

  • Function
/* */voidcm_exit (u32code);
/* */voidcm_yield (void);
/* */voidcm_set_env (charconst*name, charconst*value);
/* */voidcm_unset_env (charconst*name);
/* */u16cm_endian_swap16 (u16i);
/* */u32cm_endian_swap32 (u32i);
/* */u64cm_endian_swap64 (u64i);
/* */isizecm_count_set_bits (u64mask);

mutex.h

  • Struct
/* * Windows */typedefstructcmMutex {
CRITICAL_SECTIONwin32_critical_section;
} cmMutex;
/* * Unix & Linux */typedefstructcmMutex {
pthread_mutex_tpthread_mutex;
pthread_mutexattr_tpthread_mutexattr;
} cmMutex;
  • Function
/* */voidcm_mutex_init (cmMutex*m);
/* */voidcm_mutex_destroy (cmMutex*m);
/* */voidcm_mutex_lock (cmMutex*m);
/* */b32cm_mutex_try_lock (cmMutex*m);
/* */voidcm_mutex_unlock (cmMutex*m);

print.h

  • Function
/* */isizecm_printf (charconst*fmt, ...) CM_PRINTF_ARGS(1);
/* */isizecm_printf_va (charconst*fmt, va_listva);
/* */isizecm_printf_err (charconst*fmt, ...) CM_PRINTF_ARGS(1);
/* */isizecm_printf_err_va (charconst*fmt, va_listva);
/* */isizecm_fprintf (cmFile*f, charconst*fmt, ...) CM_PRINTF_ARGS(2);
/* */isizecm_fprintf_va (cmFile*f, charconst*fmt, va_listva);
/* */char*cm_bprintf (charconst*fmt, ...) CM_PRINTF_ARGS(1);
/* */char*cm_bprintf_va (charconst*fmt, va_listva);
/* */isizecm_snprintf (char*str, isizen, charconst*fmt, ...) CM_PRINTF_ARGS(3);

random.h

  • Struct
/* */typedefstructcmRandom {
u32offsets[8];
u32value;
} cmRandom;
  • Function
/* */voidcm_random_init (cmRandom*r);
/* */u32cm_random_gen_u32 (cmRandom*r);
/* */u32cm_random_gen_u32_unique (cmRandom*r);
/* */u64cm_random_gen_u64 (cmRandom*r);
/* */isizecm_random_gen_isize (cmRandom*r);
/* */i64cm_random_range_i64 (cmRandom*r, i64lower_inc, i64higher_inc);
/* */isizecm_random_range_isize (cmRandom*r, isizelower_inc, isizehigher_inc);
/* */f64cm_random_range_f64 (cmRandom*r, f64lower_inc, f64higher_inc);

semaphore.h

  • Struct
/* * Window */typedefstructcmSemaphore { void*win32_handle;} cmSemaphore;
/* * OSX */typedefstructcmSemaphore { semaphore_tosx_handle; } cmSemaphore;
/* * Unix */typedefstructcmSemaphore { sem_tunix_handle; } cmSemaphore;
  • Function
/* */voidcm_semaphore_init (cmSemaphore*s);
/* */voidcm_semaphore_destroy (cmSemaphore*s);
/* */voidcm_semaphore_post (cmSemaphore*s, i32count);
/* */voidcm_semaphore_release (cmSemaphore*s);
/* */voidcm_semaphore_wait (cmSemaphore*s);

sortsearch.h

  • Function
/* */int (*cm_i16_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */int (*cm_i32_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */int (*cm_i64_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */int (*cm_isize_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */int (*cm_str_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */int (*cm_f32_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */int (*cm_f64_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */cm_sort_array(array, count, compare_proc) ;
/* */voidcm_sort(void*base, isizecount, isizesize, cmCompareProccompare_proc);
/* */cm_radix_sort(Type);
/* */voidcm_radix_sort_u8 (u8*items, u8*temp, isizecount);
/* */voidcm_radix_sort_u16 (u16*items, u16*temp, isizecount);
/* */voidcm_radix_sort_u32 (u32*items, u32*temp, isizecount);
/* */voidcm_radix_sort_u64 (u64*items, u64*temp, isizecount);
/* */cm_binary_search_array(array, count, key, compare_proc);
/* */isizecm_binary_search(voidconst*base, isizecount, isizesize, voidconst*key, cmCompareProccompare_proc);
/* */cm_shuffle_array(array, count);
/* */voidcm_shuffle(void*base, isizecount, isizesize);
/* */cm_reverse_array(array, count);
/* */voidcm_reverse(void*base, isizecount, isizesize);

string.h

  • Struct
/* */typedefchar*cmString;
/* */typedefstructcmStringHeader {
cmAllocatorallocator;
isizelength;
isizecapacity;
} cmStringHeader;
  • Function
/* */cmStringcm_string_make_reserve (cmAllocatora, isizecapacity);
/* */cmStringcm_string_make (cmAllocatora, charconst*str);
/* */cmStringcm_string_make_length (cmAllocatora, voidconst*str, isizenum_bytes);
/* */voidcm_string_free (cmStringstr);
/* */cmStringcm_string_duplicate (cmAllocatora, cmStringconststr);
/* */isizecm_string_length (cmStringconststr);
/* */isizecm_string_capacity (cmStringconststr);
/* */isizecm_string_available_space(cmStringconststr);
/* */voidcm_string_clear (cmStringstr);
/* */cmStringcm_string_append (cmStringstr, cmStringconstother);
/* */cmStringcm_string_append_length (cmStringstr, voidconst*other, isizenum_bytes);
/* */cmStringcm_string_appendc (cmStringstr, charconst*other);
/* */cmStringcm_string_append_rune (cmStringstr, Runer);
/* */cmStringcm_string_append_fmt (cmStringstr, charconst*fmt, ...);
/* */cmStringcm_string_set (cmStringstr, charconst*cstr);
/* */cmStringcm_string_make_space_for (cmStringstr, isizeadd_len);
/* */isizecm_string_allocation_size(cmStringconststr);
/* */b32cm_string_are_equal (cmStringconstlhs, cmStringconstrhs);
/* */cmStringcm_string_trim (cmStringstr, charconst*cut_set);
/* */cmStringcm_string_trim_space (cmStringstr);

thread.h

  • Struct
/* * Window */typedefstructcmThread {
void*win32_handle;
cmThreadProc*proc;
void*user_data;
isizeuser_index;
isizevolatilereturn_value;
cmSemaphoresemaphore;
isizestack_size;
b32volatileis_running;
} cmThread;
/* * Posix */typedefstructcmThread {
pthread_tposix_handle;
cmThreadProc*proc;
void*user_data;
isizeuser_index;
isizevolatilereturn_value;
cmSemaphoresemaphore;
isizestack_size;
b32volatileis_running;
} cmThread;
/* */typedefstructcmSync {
i32target; // Target Number of threadsi32current; // Threads to hiti32waiting; // Threads waitingcmMutexstart;
cmMutexmutex;
cmSemaphorerelease;
} cmSync;
  • Function
/* */voidcm_thread_init (cmThread*t);
/* */voidcm_thread_destroy (cmThread*t);
/* */voidcm_thread_start (cmThread*t, cmThreadProc*proc, void*data);
/* */voidcm_thread_start_with_stack (cmThread*t, cmThreadProc*proc, void*data, isizestack_size);
/* */voidcm_thread_join (cmThread*t);
/* */b32cm_thread_is_running (cmThreadconst*t);
/* */u32cm_thread_current_id (void);
/* */voidcm_thread_set_name (cmThread*t, charconst*name);
/* */voidcm_sync_init (cmSync*s);
/* */voidcm_sync_destroy (cmSync*s);
/* */voidcm_sync_set_target (cmSync*s, i32count);
/* */voidcm_sync_release (cmSync*s);
/* */i32cm_sync_reach (cmSync*s);
/* */voidcm_sync_reach_and_wait (cmSync*s);

time.h

  • Function
/* */u64cm_rdtsc (void);
/* */f64cm_time_now (void);
/* */u64cm_utc_time_now(void);
/* */voidcm_sleep_ms (u32ms);

utf8.h

  • Function
/* */isizecm_utf8_strlen (u8const*str);
/* */isizecm_utf8_strnlen(u8const*str, isizemax_len);
/* */u16*cm_utf8_to_ucs2 (u16*buffer, isizelen, u8const*str);
/* */u8*cm_ucs2_to_utf8 (u8*buffer, isizelen, u16const*str);
/* */u16*cm_utf8_to_ucs2_buf (u8const*str);
/* */u8*cm_ucs2_to_utf8_buf (u16const*str);
/* */isizecm_utf8_decode (u8const*str, isizestr_len, Rune*codepoint);
/* */isizecm_utf8_codepoint_size (u8const*str, isizestr_len);
/* */isizecm_utf8_encode_rune (u8buf[4], Runer);

utils.h

#defineNULL#defineinline#definecm_restrict#definecm_inline#definecm_no_inline#definecm_thread_local#definecast(Type)
#definecm_size_of(x)
#definecm_count_of(x)
#definecm_offset_of(Type, element)
#definecm_align_of(Type)
#definecm_swap(Type, a, b)
#definecm_global#definecm_internal#definecm_local_persist#definecm_unused(x)
#definevprtcast(x)
#definevoidcast(x)
#defineCM_BIT(x)
#defineCM_MIN(a, b)
#defineCM_MAX(a, b)
#defineCM_MIN3(a, b, c)
#defineCM_MAX3(a, b, c)
#defineCM_CLAMP(x, lower, upper)
#defineCM_CLAMP01(x)
#defineCM_IS_BETWEEN(x, lower, upper)
#defineCM_ABS(x)
#defineCM_MASK_SET(var, set, mask)
#defineCM_PRINTF_ARGS(FMT)

About

c/c++ marcro and utility

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Latest commit

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

types.h

typedefu8;
typedefi8;
typedefu16;
typedefi16;
typedefu32;
typedefi32;
typedefu64;
typedefi64;
typedefusize; //typedef unsigned long long size_ttypedefisize; //typedef long long ptrdiff_ttypedefintptr;
typedefuintptr;
typedeff32;
typedeff64;
typedefRune;
typedefb8;
typedefb16;
typedefb32;
#defineCM_RUNE_INVALID#defineCM_RUNE_MAX #define CM_RUNE_BOM #defineCM_RUNE_EOF#defineU8_MIN#defineU8_MAX#defineI8_MIN#defineI8_MAX#defineU16_MIN#defineU16_MAX#defineI16_MIN#defineI16_MAX#defineU32_MIN#defineU32_MAX#defineI32_MIN#defineI32_MAX#defineU64_MIN#defineU64_MAX#defineI64_MIN#defineI64_MAX#defineUSIZE_MIX #define USIZE_MAX
#defineISIZE_MIX#defineISIZE_MAX#defineF32_MIN#defineF32_MAX#defineF64_MIN#defineF64_MAX

arch.h

/*  * Arch  */#defineCM_ARCH_64#defineCM_ARCH_32/*  * Endian  */#defineCM_ENDIAN_ORDER#defineCM_BIG_ENDIAN#defineCM_LITTLE_ENDIAN/* * OS */#defineCM_WINDOWS#defineCM_OS_WINDOWS#defineCM_SYS_WINDOWS#defineCM_OSX#defineCM_OS_OSX#defineCM_SYS_OSX#defineCM_UNIX#defineCM_OS_UNIX#defineCM_SYS_UNIX#defineCM_LINUX#defineCM_OS_LINUX#defineCM_SYS_LINUX#defineCM_FREEBSD#defineCM_OS_FREEBSD#defineCM_SYS_FREEBSD/* * Compiler */#defineCM_COMPILER_MSVC#defineCM_COMPILER_GCC#defineCM_COMPILER_CLANG/* * CPU */#defineCM_CPU_X86#defineCM_CPU_PPC#defineCM_CPU_ARM#defineCM_CPU_MIPS#defineCM_CACHE_LINE_SIZE

assert.h

#defineCM_STATIC_ASSERT(cond) #define CM_STATIC_ASSERT1(cond, line)
#defineCM_STATIC_ASSERT2(cond, line)
#defineCM_STATIC_ASSERT3(cond, msg)

affinity.h

  • Struct
/* * cmAffinity */typedefstructcmAffinity{
b32is_accurate;
isizecore_count;
isizethread_count;
usizecore_masks[CM_WIN32_MAX_THREADS];
} cmAffinity;
  • Function
/* */voidcm_affinity_init (cmAffinity*a);
/* */voidcm_affinity_destroy (cmAffinity*a);
/* */b32cm_affinity_set (cmAffinity*a, isizecore, isizethread);
/* */isizecm_affinity_thread_count_for_core (cmAffinity*a, isizecore);

atomics.h

  • Struct
/* * cmAtomic32 */typedefstructcmAtomic32 { i32volatilevalue; } cmAtomic32;
/* * cmAtomic64 */typedefstructcmAtomic64 {
i64volatilevalue; } cmAtomic64;
/* * cmAtomicPtr */typedefstructcmAtomicPtr { void*volatilevalue;
} cmAtomicPtr;
  • Function
/* * atomic32 */i32cm_atomic32_load (cmAtomic32constvolatile*a);
voidcm_atomic32_store (cmAtomic32volatile*a, i32value);
i32cm_atomic32_compare_exchange (cmAtomic32volatile*a, i32expected, i32desired);
i32cm_atomic32_exchanged (cmAtomic32volatile*a, i32desired);
i32cm_atomic32_fetch_add (cmAtomic32volatile*a, i32operand);
i32cm_atomic32_fetch_and (cmAtomic32volatile*a, i32operand);
i32cm_atomic32_fetch_or (cmAtomic32volatile*a, i32operand);
b32cm_atomic32_spin_lock (cmAtomic32volatile*a, isizetime_out);
voidcm_atomic32_spin_unlock (cmAtomic32volatile*a);
b32cm_atomic32_try_acquire_lock (cmAtomic32volatile*a);
/* * atomic64 */i64cm_atomic64_load (cmAtomic64constvolatile*a);
voidcm_atomic64_store (cmAtomic64volatile*a, i64value);
i64cm_atomic64_compare_exchange (cmAtomic64volatile*a, i64expected, i64desired);
i64cm_atomic64_exchanged (cmAtomic64volatile*a, i64desired);
i64cm_atomic64_fetch_add (cmAtomic64volatile*a, i64operand);
i64cm_atomic64_fetch_and (cmAtomic64volatile*a, i64operand);
i64cm_atomic64_fetch_or (cmAtomic64volatile*a, i64operand);
b32cm_atomic64_spin_lock (cmAtomic64volatile*a, isizetime_out);
voidcm_atomic64_spin_unlock (cmAtomic64volatile*a);
b32cm_atomic64_try_acquire_lock (cmAtomic64volatile*a);
/* * atomicptr */void*cm_atomic_ptr_load (cmAtomicPtrconstvolatile*a);
voidcm_atomic_ptr_store (cmAtomicPtrvolatile*a, void*value);
void*cm_atomic_ptr_compare_exchange (cmAtomicPtrvolatile*a, void*expected, void*desired);
void*cm_atomic_ptr_exchanged (cmAtomicPtrvolatile*a, void*desired);
void*cm_atomic_ptr_fetch_add (cmAtomicPtrvolatile*a, void*operand);
void*cm_atomic_ptr_fetch_and (cmAtomicPtrvolatile*a, void*operand);
void*cm_atomic_ptr_fetch_or (cmAtomicPtrvolatile*a, void*operand);
b32cm_atomic_ptr_spin_lock (cmAtomicPtrvolatile*a, isizetime_out);
voidcm_atomic_ptr_spin_unlock (cmAtomicPtrvolatile*a);
b32cm_atomic_ptr_try_acquire_lock (cmAtomicPtrvolatile*a);

buffer.h

  • Struct
/* * cmBufferHeader */typedefstructcmBufferHeader {
isizecount;
isizecapacity;
} cmBufferHeader;
  • Function
/* * ประกาศตัวแปร Ex. cmBuffer(i32) buffer; */cmBuffer(Type);
/* * จำนวน */isizecm_buffer_count (cmBufferHeader*bfh);
/* * ความจุ */isizecm_buffer_capacity (cmBufferHeader*bfh);
/* * ค่าเริ่มต้น */void*cm_buffer_init (x, allocator, cap);
/* * เลิกใช้งาน */voidcm_buffer_free (x, allocator);
/* * เพิ่มข้อมูล(1 รายการ) */voidcm_buffer_append (x, item);
/* * เพิ่มข้อมูล(มากกว่า 1 รายการ) */voidcm_buffer_appendv (x, items, item_count);
/* * นำข้อมูลออก */voidcm_buffer_pop (x);
/* * ล้างข้อมูล */cm_buffer_clear (x)

char.h

  • Function
/* * แปลงตัวอักษรเป็นพิมพ์เล็ก */charcm_char_to_lower (charc);
/* * แปลงตัวอักษรเป็นพิมพ์ใหญ่ */charcm_char_to_upper (charc);
/* * ตรวจสอบช่องว่าง */b32cm_char_is_space (charc);
/* * ตรวจสอบตัวเลข */b32cm_char_is_digit (charc);
/* * ตรวจสอบตัวเลขที่เป็นฐาน16 (hex) */b32cm_char_is_hex_digit (charc);
/* *  */b32cm_char_is_alpha (charc);
/* * ตรวจสอบว่าเป็นตัวเลขหรือตัวอักษร */b32cm_char_is_alphanumeric (charc);
/* * แปลงตัวอักษร */i32cm_digit_to_int (charc);
/* * แปลงตัวอักษรฐาน16(hex)เป็นตัวเลขจำนวนเต็ม */i32cm_hex_digit_to_int (charc);
/* * แปลงตัวอักษรเป็นพิมพ์เล็ก */voidcm_str_to_lower(char*str);
/* * แปลงตัวอักษรเป็นพิมพ์ใหญ่ */voidcm_str_to_upper(char*str);
/* * จำนวนข้อความ */isizecm_strlen (charconst*str);
/* *  */isizecm_strnlen(charconst*str, isizemax_len);
/* * เปรียบเทียบข้อความ */i32cm_strcmp (charconst*s1, charconst*s2);
/* *  */i32cm_strncmp(charconst*s1, charconst*s2, isizelen);
/* * ก๊อบปี้ข้อความ */char*cm_strcpy (char*dest, charconst*source);
/* *  */char*cm_strncpy(char*dest, charconst*source, isizelen);
/* *  */isizecm_strlcpy(char*dest, charconst*source, isizelen);
/* *  */char*cm_strrev (char*str);
/* *  */charconst*cm_strtok(char*output, charconst*src, charconst*delimit);
/* *  */b32cm_str_has_prefix(charconst*str, charconst*prefix);
/* *  */b32cm_str_has_suffix(charconst*str, charconst*suffix);
/* *  */charconst*cm_char_first_occurence(charconst*str, charc);
/* *  */charconst*cm_char_last_occurence (charconst*str, charc);
/* *  */voidcm_str_concat(char*dest, isizedest_len, charconst*src_a, isizesrc_a_len, charconst*src_b, isizesrc_b_len);
/* *  */u64cm_str_to_u64(charconst*str, char**end_ptr, i32base);
/* *  */i64cm_str_to_i64(charconst*str, char**end_ptr, i32base);
/* *  */f32cm_str_to_f32(charconst*str, char**end_ptr);
/* *  */f64cm_str_to_f64(charconst*str, char**end_ptr);
/* *  */voidcm_i64_to_str(i64value, char*string, i32base);
/* *  */voidcm_u64_to_str(u64value, char*string, i32base);

debug.h

#defineCM_DEBUG_TRAP()
#defineCM_ASSERT_MSG(cond, msg, ...)
#defineCM_ASSERT(cond)
#defineCM_ASSERT_NOT_NULL(ptr)
#defineCM_PANIC(msg, ...)
  • Function
//voidcm_assert_handler(charconst*prefix, charconst*condition, charconst*file, i32line, charconst*msg, ...);

defer.h

#defineCM_DEFER_1(x, y)
#defineCM_DEFER_2(x, y)
#defineCM_DEFER_3(x)
  • Function
/*ตัวอย่างcmMutex m;cm_mutex_init(&m);{	cm_mutex_lock(&m);	defer (cm_mutex_unlock(&m));	...}*/voiddefer(code);

dll.h

#defineCM_DLL_EXPORT#defineCM_DLL_IMPORT#defineCM_DEF#defineCM_SHARED_LIB_BUILD#defineCM_SHARED_LIB_USE#defineCM_C_API
  • Struct
typedefvoid*cmDllHandle;
typedefvoid (*cmDllProc)(void);
  • Function
/* * Ex. cmDllHandle handle = cm_dll_load("opengl32.dll"); */cmDllHandlecm_dll_load (charconst*filepath);
/* * Ex. cm_dll_unload(handle); */voidcm_dll_unload (cmDllHandledll);
/* * Ex. * cmDllHandle xinput_library = cm_dll_load("xinput9_1_0.dll"); * cmXInputGetStateProc *get_state = cast(cmXInputGetStateProc *)cm_dll_proc_address(xinput_library, "XInputGetState"); * cmXInputGetStateProc *set_state = cast(cmXInputSetStateProc *)cm_dll_proc_address(xinput_library, "XInputSetState"); */cmDllProccm_dll_proc_address (cmDllHandledll, charconst*proc_name);

dynarray.h

#defineCM_ARRAY_GROW_FORMULA(x)
#defineCM_ARRAY_HEADER(x)
  • Struct
/* * cmArrayHeader */typedefstructcmArrayHeader {
cmAllocatorallocator;
isizecount;
isizecapacity;
} cmArrayHeader;
  • Function
/* * ประกาศตัวแปร Ex. cmArray(i32) array; */cmArray(Type);
/* */cmAllocatorcm_array_allocator(x);
/* */isizecm_array_count(x);
/* */isizecm_array_capacity(x);
/* */voidcm_array_init_reserve(x, allocator_, cap);
/* */voidcm_array_init(x, allocator);
/* */voidcm_array_free(x);
/* */voidcm_array_set_capacity(x, capacity);
/* */void*cm__array_set_capacity(void*array, isizecapacity, isizeelement_size);
/* */voidcm_array_grow(x, min_capacity) ;
/* */voidcm_array_append(x, item);
/* */voidcm_array_appendv(x, items, item_count);
/* */voidcm_array_pop(x);
/* */voidcm_array_clear(x);
/* */voidcm_array_resize(x, new_count);
/* */voidcm_array_reserve(x, new_capacity);

extern.h

#defineCM_EXTERN#defineCM_BEGIN_EXTERN#defineCM_END_EXTERN

fences.h

  • Function
/* */voidcm_yield_thread(void);
/* */voidcm_mfence (void);
/* */voidcm_sfence (void);
/* */voidcm_lfence (void);

file.h

  • Struct
/* */typedefu32cmFileMode;
/* */typedefenumcmFileModeFlag {
cmFileMode_Read,
cmFileMode_Write,
cmFileMode_Append,
cmFileMode_Rw,
cmFileMode_Modes ,
} cmFileModeFlag;
/* */typedefenumcmSeekWhenceType {
cmSeekWhence_Begin,
cmSeekWhence_Current,
cmSeekWhence_End,
} cmSeekWhenceType;
/* */typedefenumcmFileError {
cmFileError_None,
cmFileError_Invalid,
cmFileError_InvalidFilename,
cmFileError_Exists,
cmFileError_NotExists,
cmFileError_Permission,
cmFileError_TruncationFailure,
} cmFileError;
/* */typedefunioncmFileDescriptor {
void*p;
intptri;
uintptru;
} cmFileDescriptor;
/* */typedefstructcmFileOperationscmFileOperations;
/* */typedefCM_FILE_OPEN_PROC(cmFileOpenProc);
/* */typedefCM_FILE_READ_AT_PROC(cmFileReadProc);
/* */typedefCM_FILE_WRITE_AT_PROC(cmFileWriteProc);
/* */typedefCM_FILE_SEEK_PROC(cmFileSeekProc);
/* */typedefCM_FILE_CLOSE_PROC(cmFileCloseProc)
/* */structcmFileOperations {
cmFileReadProc*read_at;
cmFileWriteProc*write_at;
cmFileSeekProc*seek;
cmFileCloseProc*close;
};
/* */externcmFileOperationsconstcmDefaultFileOperations;
/* */typedefu64cmFileTime;
/* */typedefstructcmFile {
cmFileOperationsops;
cmFileDescriptorfd;
charconst*filename;
cmFileTimelast_write_time;
// gbDirInfo * dir_info; // TODO(bill): Get directory info
} cmFile;
/* */typedefenumcmFileStandardType {
cmFileStandard_Input,
cmFileStandard_Output,
cmFileStandard_Error,
cmFileStandard_Count,
} cmFileStandardType;
/* */typedefstructcmFileContents {
cmAllocatorallocator;
void*data;
isizesize;
} cmFileContents;
/* */#defineCM_PATH_SEPARATOR
  • Function
/* */cmFile*constcm_file_get_standard (cmFileStandardTypestd);
/* */cmFileErrorcm_file_create (cmFile*file, charconst*filename);
/* */cmFileErrorcm_file_open_mode (cmFile*file, cmFileModemode, charconst*filename);
/* */cmFileErrorcm_file_new (cmFile*file, cmFileDescriptorfd, cmFileOperationsops, charconst*filename);
/* */b32cm_file_read_at_check (cmFile*file, void*buffer, isizesize, i64offset, isize*bytes_read);
/* */b32cm_file_write_at_check(cmFile*file, voidconst*buffer, isizesize, i64offset, isize*bytes_written);
/* */b32cm_file_read_at (cmFile*file, void*buffer, isizesize, i64offset);
/* */b32cm_file_write_at (cmFile*file, voidconst*buffer, isizesize, i64offset);
/* */i64cm_file_seek (cmFile*file, i64offset);
/* */i64cm_file_seek_to_end (cmFile*file);
/* */i64cm_file_skip (cmFile*file, i64bytes);
/* */i64cm_file_tell (cmFile*file);
/* */cmFileErrorcm_file_close (cmFile*file);
/* */b32cm_file_read (cmFile*file, void*buffer, isizesize);
/* */b32cm_file_write (cmFile*file, voidconst*buffer, isizesize);
/* */i64cm_file_size (cmFile*file);
/* */charconst*cm_file_name (cmFile*file);
/* */cmFileErrorcm_file_truncate (cmFile*file, i64size);
/* */b32cm_file_has_changed (cmFile*file);
/* */cmFileContentscm_file_read_contents(cmAllocatora, b32zero_terminate, charconst*filepath);
/* */voidcm_file_free_contents(cmFileContents*fc);
/* */b32cm_file_exists (charconst*filepath);
/* */cmFileTimecm_file_last_write_time(charconst*filepath);
/* */b32cm_file_copy (charconst*existing_filename, charconst*new_filename, b32fail_if_exists);
/* */b32cm_file_move (charconst*existing_filename, charconst*new_filename);
/* */b32cm_file_remove (charconst*filename);
/* */b32cm_path_is_absolute (charconst*path);
/* */b32cm_path_is_relative (charconst*path);
/* */b32cm_path_is_root (charconst*path);
/* */charconst*cm_path_base_name (charconst*path);
/* */charconst*cm_path_extension (charconst*path);
/* */char*cm_path_get_full_name(cmAllocatora, charconst*path);

hash.h

  • Function
/* */u32cm_adler32(voidconst*data, isizelen);
/* */u32cm_crc32(voidconst*data, isizelen);
/* */u64cm_crc64(voidconst*data, isizelen);
/* */u32cm_fnv32 (voidconst*data, isizelen);
/* */u64cm_fnv64 (voidconst*data, isizelen);
/* */u32cm_fnv32a(voidconst*data, isizelen);
/* */u64cm_fnv64a(voidconst*data, isizelen);
/* */u32cm_murmur32(voidconst*data, isizelen);
/* */u64cm_murmur64(voidconst*data, isizelen);
/* */u32cm_murmur32_seed(voidconst*data, isizelen, u32seed);
/* */u64cm_murmur64_seed(voidconst*data, isizelen, u64seed);

hashtable.h

#defineCM_TABLE(PREFIX, NAME, FUNC, VALUE)
#defineCM_TABLE_DECLARE(PREFIX, NAME, FUNC, VALUE)
#defineCM_TABLE_DEFINE(NAME, FUNC, VALUE)
  • Struct
/* * cmHashTableFindResult */typedefstructcmHashTableFindResult {
isizehash_index;
isizeentry_prev;
isizeentry_index;
} cmHashTableFindResult;

header.h

#define_CRT_SECURE_NO_WARNINGS#define_GNU_SOURCE#define_LARGEFILE64_SOURCE#defineWIN32_LEAN_AND_MEAN #define WIN32_MEAN_AND_LEAN #defineVC_EXTRALEAN#defineNOMINMAX

memory.h

#defineCM_DEFAULT_MEMORY_ALIGNMENT#defineCM_DEFAULT_ALLOCATOR_FLAGS
  • Struct
/* * cmVirtualMemory */typedefstructcmVirtualMemory {
void*data;
isizesize;
} cmVirtualMemory;
/* * cmVirtualMemory */typedefenumcmAllocationType {
cmAllocation_Alloc,
cmAllocation_Free,
cmAllocation_FreeAll,
cmAllocation_Resize,
} cmAllocationType;
/* * cmAllocator */typedefstructcmAllocator {
cmAllocatorProc*proc;
void*data;
} cmAllocator;
/* * cmAllocatorFlag */typedefenumcmAllocatorFlag {
cmAllocatorFlag_ClearToZero ,
} cmAllocatorFlag;
/* * cmArena */typedefstructcmArena {
cmAllocatorbacking;
void*physical_start;
isizetotal_size;
isizetotal_allocated;
isizetemp_count;
} cmArena;
  • Function
/* */b32cm_is_power_of_two (isizex);
/* */void*cm_align_forward (void*ptr, isizealignment);
/* */void*cm_pointer_add (void*ptr, isizebytes);
/* */void*cm_pointer_sub (void*ptr, isizebytes);
/* */voidconst*cm_pointer_add_const (voidconst*ptr, isizebytes);
/* */voidconst*cm_pointer_sub_const (voidconst*ptr, isizebytes);
/* */isizecm_pointer_diff (voidconst*begin, voidconst*end);
/* */voidcm_zero_size (void*ptr, isizesize);
/* */voidcm_zero_item (void*t)
/* */voidcm_zero_array (void*a, count)
/* */void*cm_memcopy (void*dest, voidconst*source, isizesize);
/* */void*cm_memmove (void*dest, voidconst*source, isizesize);
/* */void*cm_memset (void*data, u8byte_value, isizesize);
/* */i32cm_memcompare (voidconst*s1, voidconst*s2, isizesize);
/* */voidcm_memswap (void*i, void*j, isizesize);
/* */voidconst*cm_memchr (voidconst*data, u8byte_value, isizesize);
/* */voidconst*cm_memrchr (voidconst*data, u8byte_value, isizesize);
/* */cm_memcopy_array (dst, src, count);
/* */cm_memmove_array (dst, src, count) /* */cmVirtualMemorycm_virtual_memory (void*data, isizesize);
/* */cmVirtualMemorycm_vm_alloc (void*addr, isizesize);
/* */b32cm_vm_free (cmVirtualMemoryvm);
/* */cmVirtualMemorycm_vm_trim (cmVirtualMemoryvm, isizelead_size, isizesize);
/* */b32cm_vm_purge (cmVirtualMemoryvm);
/* */isizecm_virtual_memory_page_size (isize*alignment_out);
/* */void*cm_alloc_align (cmAllocatora, isizesize, isizealignment);
/* */void*cm_alloc (cmAllocatora, isizesize);
/* */voidcm_free (cmAllocatora, void*ptr);
/* */voidcm_free_all (cmAllocatora);
/* */void*cm_resize (cmAllocatora, void*ptr, isizeold_size, isizenew_size);
/* */void*cm_resize_align (cmAllocatora, void*ptr, isizeold_size, isizenew_size, isizealignment);
/* */void*cm_alloc_copy (cmAllocatora, voidconst*src, isizesize);
/* */void*cm_alloc_copy_align (cmAllocatora, voidconst*src, isizesize, isizealignment);
/* */char*cm_alloc_str (cmAllocatora, charconst*str);
/* */char*cm_alloc_str_len (cmAllocatora, charconst*str, isizelen);
/* */cm_alloc_item (allocator_, Type)
/* */cm_alloc_array (allocator_, Type, count)
/* */void*gb_default_resize_align (cmAllocatora, void*ptr, isizeold_size, isizenew_size, isizealignment);
/* */cmAllocatorcm_heap_allocator (void);
/* */cm_malloc(sz);
/* */cm_mfree(ptr);
/* */voidcm_arena_init_from_memory (cmArena*arena, void*start, isizesize);
/* */voidcm_arena_init_from_allocator (cmArena*arena, cmAllocatorbacking, isizesize);
/* */voidcm_arena_init_sub (cmArena*arena, cmArena*parent_arena, isizesize);
/* */voidcm_arena_free (cmArena*arena);
/* */isizecm_arena_alignment_of (cmArena*arena, isizealignment);
/* */isizecm_arena_size_remaining (cmArena*arena, isizealignment);
/* */voidcm_arena_check (cmArena*arena);
/* */cmAllocatorcm_arena_allocator (cmArena*arena);

math.h

#defineCM_MATH_INFINITYF#defineCM_MATH_NANF#defineCM_MATH_PZEROF#defineCM_MATH_NZEROF#defineCM_MATH_INFINITY#defineCM_MATH_NAN#defineCM_MATH_PZERO#defineCM_MATH_NZERO#defineCM_MATH_INFINITYL#defineCM_MATH_NANL#defineCM_MATH_PZEROL#defineCM_MATH_NZEROL#defineCM_SIZEOF_CHAR#defineCM_SIZEOF_BYTE#defineCM_SIZEOF_INT#defineCM_SIZEOF_INTP#defineCM_SIZEOF_UINTP#defineCM_SIZEOF_HALF#defineCM_SIZEOF_LONG#defineCM_SIZEOF_LONGLONG#defineCM_SIZEOF_DOUBLE#defineCM_SIZEOF_LONGDOUBLE#defineCM_SIZEOF_DATETIME#defineCM_SIZEOF_TIMEDELTA#defineCM_CHAR_BIT#defineCM_BYTE_FMT#defineCM_UBYTE_FMT#defineCM_SHORT_FMT#defineCM_USHORT_FMT#defineCM_INT_FMT#defineCM_UINT_FMT#defineCM_LONG_FMT#defineCM_ULONG_FMT#defineCM_HALF_FMT#defineCM_FLOAT_FMT#defineCM_DOUBLE_FMT#defineCM_LONGLONG_FMT#defineCM_ULONGLONG_FMT#defineCM_LONGLONG_SUFFIX(x)
#defineCM_ULONGLONG_SUFFIX(x)
#definecm_isnan(x)
#definecm_isfinite(x)
#definecm_isinf(x)
#defineCM_EXTRACT_WORDS(ix0,ix1,d)
#defineCM_GET_HIGH_WORD(i,d)
#defineCM_GET_LOW_WORD(i,d)
#defineCM_SET_HIGH_WORD(d,v)
#defineCM_SET_LOW_WORD(d,v)
#defineCM_INSERT_WORDS(d,ix0,ix1)
#defineCM_MATH_E#defineCM_MATH_LOG2E#defineCM_MATH_LOG10E#defineCM_MATH_LOGE2#defineCM_MATH_LOGE10#defineCM_MATH_PI#defineCM_MATH_PI_2 #define CM_MATH_PI_4
#defineCM_MATH_1_PI#defineCM_MATH_2_PI#defineCM_MATH_EULER#defineCM_MATH_SQRT2#defineCM_MATH_SQRT1_2#defineCM_MATH_Ef#defineCM_MATH_LOG2Ef#defineCM_MATH_LOG10Ef#defineCM_MATH_LOGE2f#defineCM_MATH_LOGE10f#defineCM_MATH_PIf#defineCM_MATH_PI_2f#defineCM_MATH_PI_4f#defineCM_MATH_1_PIf#defineCM_MATH_2_PIf#defineCM_MATH_EULERf#defineCM_MATH_SQRT2f#defineCM_MATH_SQRT1_2f#defineCM_MATH_El#defineCM_MATH_LOG2El#defineCM_MATH_LOG10El#defineCM_MATH_LOGE2l#defineCM_MATH_LOGE10l#defineCM_MATH_PIl#defineCM_MATH_PI_2l#defineCM_MATH_PI_4l#defineCM_MATH_1_PIl#defineCM_MATH_2_PIl#defineCM_MATH_EULERl#defineCM_MATH_SQRT2l#defineCM_MATH_SQRT1_2l#definecm_math_degrees#definecm_math_degreesf#definecm_math_degreesl#definecm_math_radians#definecm_math_radiansf#definecm_math_radiansl
  • Function
/* * Integer functions. *//* */u32cm_math_gcdu(u32a, u32b);
/* */u32cm_math_lcmu(u32a, u32b);
/* */ulcm_math_gcdul(ula, ulb);
/* */ulcm_math_lcmul(ula, ulb);
/* */ullcm_math_gcdull(ulla, ullb);
/* */ullcm_math_lcmull(ulla, ullb);
/* */u32cm_math_gcd(u32a, u32b);
/* */u32cm_math_lcm(u32a, u32b);
/* */ilcm_math_gcdl(ila, ilb);
/* */ilcm_math_lcml(ila, ilb);
/* */illcm_math_gcdll(illa, illb);
/* */illcm_math_lcmll(illa, illb);
/* */ubytecm_math_rshiftuhh(ubytea, ubyteb);
/* */ubytecm_math_lshiftuhh(ubytea, ubyteb);
/* */u16cm_math_rshiftuh(u16a, u16b);
/* */u16cm_math_lshiftuh(u16a, u16b);
/* */u32cm_math_rshiftu(u32a, u32b);
/* */u32cm_math_lshiftu(u32a, u32b);
/* */ulcm_math_rshiftul(ula, ulb);
/* */ulcm_math_lshiftul(ula, ulb);
/* */ullcm_math_rshiftull(ulla, ullb);
/* */ullcm_math_lshiftull(ulla, ullb);
/* */ibytecm_math_rshifthh(ibytea, ibyteb);
/* */ibytecm_math_lshifthh(ibytea, ibyteb);
/* */i16cm_math_rshifth(i16a, i16b);
/* */i16cm_math_lshifth(i16a, i16b);
/* */i32cm_math_rshift(i32a, i32b);
/* */i32cm_math_lshift(i32a, i32b);
/* */ilcm_math_rshiftl(ila, ilb);
/* */ilcm_math_lshiftl(ila, ilb);
/* */illcm_math_rshiftll(illa, illb);
/* */illcm_math_lshiftll(illa, illb);
/* * float C99 math functions *//* */f32cm_math_sinf(f32x);
/* */f32cm_math_cosf(f32x);
/* */f32cm_math_tanf(f32x);
/* */f32cm_math_sinhf(f32x);
/* */f32cm_math_coshf(f32x);
/* */f32cm_math_tanhf(f32x);
/* */f32cm_math_fabsf(f32x);
/* */f32cm_math_floorf(f32x);
/* */f32cm_math_ceilf(f32x);
/* */f32cm_math_rintf(f32x);
/* */f32cm_math_truncf(f32x);
/* */f32cm_math_sqrtf(f32x);
/* */f32cm_math_cbrtf(f32x);
/* */f32cm_math_log10f(f32x);
/* */f32cm_math_logf(f32x);
/* */f32cm_math_expf(f32x);
/* */f32cm_math_expm1f(f32x);
/* */f32cm_math_asinf(f32x);
/* */f32cm_math_acosf(f32x);
/* */f32cm_math_atanf(f32x);
/* */f32cm_math_asinhf(f32x);
/* */f32cm_math_acoshf(f32x);
/* */f32cm_math_atanhf(f32x);
/* */f32cm_math_log1pf(f32x);
/* */f32cm_math_exp2f(f32x);
/* */f32cm_math_log2f(f32x);
/* */f32cm_math_atan2f(f32x, f32y);
/* */f32cm_math_hypotf(f32x, f32y);
/* */f32cm_math_powf(f32x, f32y);
/* */f32cm_math_fmodf(f32x, f32y);
/* */f32cm_math_modff(f32x, f32*y);
/* */f32cm_math_frexpf(f32x, i32*y);
/* */f32cm_math_ldexpf(f32x, i32y);
/* */f32cm_math_copysignf(f32x, f32y);
/* */f32cm_math_nextafterf(f32x, f32y);
/* */f32cm_math_spacingf(f32x);
/* * long double C99 math functions *//* */fldcm_math_sinl(fldx);
/* */fldcm_math_cosl(fldx);
/* */fldcm_math_tanl(fldx);
/* */fldcm_math_sinhl(fldx);
/* */fldcm_math_coshl(fldx);
/* */fldcm_math_tanhl(fldx);
/* */fldcm_math_fabsl(fldx);
/* */fldcm_math_floorl(fldx);
/* */fldcm_math_ceill(fldx);
/* */fldcm_math_rintl(fldx);
/* */fldcm_math_truncl(fldx);
/* */fldcm_math_sqrtl(fldx);
/* */fldcm_math_cbrtl(fldx);
/* */fldcm_math_log10l(fldx);
/* */fldcm_math_logl(fldx);
/* */fldcm_math_expl(fldx);
/* */fldcm_math_expm1l(fldx);
/* */fldcm_math_asinl(fldx);
/* */fldcm_math_acosl(fldx);
/* */fldcm_math_atanl(fldx);
/* */fldcm_math_asinhl(fldx);
/* */fldcm_math_acoshl(fldx);
/* */fldcm_math_atanhl(fldx);
/* */fldcm_math_log1pl(fldx);
/* */fldcm_math_exp2l(fldx);
/* */fldcm_math_log2l(fldx);
/* */fldcm_math_atan2l(fldx, fldy);
/* */fldcm_math_hypotl(fldx, fldy);
/* */fldcm_math_powl(fldx, fldy);
/* */fldcm_math_fmodl(fldx, fldy);
/* */fldcm_math_modfl(fldx, fld*y);
/* */fldcm_math_frexpl(fldx, int*y);
/* */fldcm_math_ldexpl(fldx, inty);
/* */fldcm_math_copysignl(fldx, fldy);
/* */fldcm_math_nextafterl(fldx, fldy);
/* */fldcm_math_spacingl(fldx);
/* * Non standard functions *//* */f64cm_math_deg2rad(f64x);
/* */f64cm_math_rad2deg(f64x);
/* */f64cm_math_logaddexp(f64x, f64y);
/* */f64cm_math_logaddexp2(f64x, f64y);
/* */f64cm_math_divmod(f64x, f64y, f64*modulus);
/* */f64cm_math_heaviside(f64x, f64h0);
/* */f32cm_math_deg2radf(f32x);
/* */f32cm_math_rad2degf(f32x);
/* */f32cm_math_logaddexpf(f32x, f32y);
/* */f32cm_math_logaddexp2f(f32x, f32y);
/* */f32cm_math_divmodf(f32x, f32y, f32*modulus);
/* */f32cm_math_heavisidef(f32x, f32h0);
/* */fldcm_math_deg2radl(fldx);
/* */fldcm_math_rad2degl(fldx);
/* */fldcm_math_logaddexpl(fldx, fldy);
/* */fldcm_math_logaddexp2l(fldx, fldy);
/* */fldcm_math_divmodl(fldx, fldy, fld*modulus);
/* */fldcm_math_heavisidel(fldx, fldh0);
/* * Complex declarations *//* */inlinec64cm_math_cpack(f64x, f64y);
/* */inlinec32cm_math_cpackf(f32x, f32y);
/* */inlinecldcm_math_cpackl(fldx, fldy);
/* */inlinef64cm_math_creal(c64z);
/* */inlinef64cm_math_cimag(c64z);
/* */inlinef32cm_math_crealf(c32z);
/* */inlinef32cm_math_cimagf(c32z);
/* */inlinefldcm_math_creall(cldz);
/* */inlinefldcm_math_cimagl(cldz);
/* * Double precision complex functions *//* */f64cm_math_cabs(c64z);
/* */f64cm_math_carg(c64z);
/* */c64cm_math_cexp(c64z);
/* */c64cm_math_clog(c64z);
/* */c64cm_math_cpow(c64x, c64y);
/* */c64cm_math_csqrt(c64z);
/* */c64cm_math_ccos(c64z);
/* */c64cm_math_csin(c64z);
/* */c64cm_math_ctan(c64z);
/* */c64cm_math_ccosh(c64z);
/* */c64cm_math_csinh(c64z);
/* */c64cm_math_ctanh(c64z);
/* */c64cm_math_cacos(c64z);
/* */c64cm_math_casin(c64z);
/* */c64cm_math_catan(c64z);
/* */c64cm_math_cacosh(c64z);
/* */c64cm_math_casinh(c64z);
/* */c64cm_math_catanh(c64z);
/* * Single precision complex functions *//* */f32cm_math_cabsf(c32z);
/* */f32cm_math_cargf(c32z);
/* */c32cm_math_cexpf(c32z);
/* */c32cm_math_clogf(c32z);
/* */c32cm_math_cpowf(c32x, c32y);
/* */c32cm_math_csqrtf(c32z);
/* */c32cm_math_ccosf(c32z);
/* */c32cm_math_csinf(c32z);
/* */c32cm_math_ctanf(c32z);
/* */c32cm_math_ccoshf(c32z);
/* */c32cm_math_csinhf(c32z);
/* */c32cm_math_ctanhf(c32z);
/* */c32cm_math_cacosf(c32z);
/* */c32cm_math_casinf(c32z);
/* */c32cm_math_catanf(c32z);
/* */c32cm_math_cacoshf(c32z);
/* */c32cm_math_casinhf(c32z);
/* */c32cm_math_catanhf(c32z);
/* * Extended precision complex functions *//* */fldcm_math_cabsl(cldz);
/* */fldcm_math_cargl(cldz);
/* */cldcm_math_cexpl(cldz);
/* */cldcm_math_clogl(cldz);
/* */cldcm_math_cpowl(cldx, cldy);
/* */cldcm_math_csqrtl(cldz);
/* */cldcm_math_ccosl(cldz);
/* */cldcm_math_csinl(cldz);
/* */cldcm_math_ctanl(cldz);
/* */cldcm_math_ccoshl(cldz);
/* */cldcm_math_csinhl(cldz);
/* */cldcm_math_ctanhl(cldz);
/* */cldcm_math_cacosl(cldz);
/* */cldcm_math_casinl(cldz);
/* */cldcm_math_catanl(cldz);
/* */cldcm_math_cacoshl(cldz);
/* */cldcm_math_casinhl(cldz);
/* */cldcm_math_catanhl(cldz);

misc.h

  • Function
/* */voidcm_exit (u32code);
/* */voidcm_yield (void);
/* */voidcm_set_env (charconst*name, charconst*value);
/* */voidcm_unset_env (charconst*name);
/* */u16cm_endian_swap16 (u16i);
/* */u32cm_endian_swap32 (u32i);
/* */u64cm_endian_swap64 (u64i);
/* */isizecm_count_set_bits (u64mask);

mutex.h

  • Struct
/* * Windows */typedefstructcmMutex {
CRITICAL_SECTIONwin32_critical_section;
} cmMutex;
/* * Unix & Linux */typedefstructcmMutex {
pthread_mutex_tpthread_mutex;
pthread_mutexattr_tpthread_mutexattr;
} cmMutex;
  • Function
/* */voidcm_mutex_init (cmMutex*m);
/* */voidcm_mutex_destroy (cmMutex*m);
/* */voidcm_mutex_lock (cmMutex*m);
/* */b32cm_mutex_try_lock (cmMutex*m);
/* */voidcm_mutex_unlock (cmMutex*m);

print.h

  • Function
/* */isizecm_printf (charconst*fmt, ...) CM_PRINTF_ARGS(1);
/* */isizecm_printf_va (charconst*fmt, va_listva);
/* */isizecm_printf_err (charconst*fmt, ...) CM_PRINTF_ARGS(1);
/* */isizecm_printf_err_va (charconst*fmt, va_listva);
/* */isizecm_fprintf (cmFile*f, charconst*fmt, ...) CM_PRINTF_ARGS(2);
/* */isizecm_fprintf_va (cmFile*f, charconst*fmt, va_listva);
/* */char*cm_bprintf (charconst*fmt, ...) CM_PRINTF_ARGS(1);
/* */char*cm_bprintf_va (charconst*fmt, va_listva);
/* */isizecm_snprintf (char*str, isizen, charconst*fmt, ...) CM_PRINTF_ARGS(3);

random.h

  • Struct
/* */typedefstructcmRandom {
u32offsets[8];
u32value;
} cmRandom;
  • Function
/* */voidcm_random_init (cmRandom*r);
/* */u32cm_random_gen_u32 (cmRandom*r);
/* */u32cm_random_gen_u32_unique (cmRandom*r);
/* */u64cm_random_gen_u64 (cmRandom*r);
/* */isizecm_random_gen_isize (cmRandom*r);
/* */i64cm_random_range_i64 (cmRandom*r, i64lower_inc, i64higher_inc);
/* */isizecm_random_range_isize (cmRandom*r, isizelower_inc, isizehigher_inc);
/* */f64cm_random_range_f64 (cmRandom*r, f64lower_inc, f64higher_inc);

semaphore.h

  • Struct
/* * Window */typedefstructcmSemaphore { void*win32_handle;} cmSemaphore;
/* * OSX */typedefstructcmSemaphore { semaphore_tosx_handle; } cmSemaphore;
/* * Unix */typedefstructcmSemaphore { sem_tunix_handle; } cmSemaphore;
  • Function
/* */voidcm_semaphore_init (cmSemaphore*s);
/* */voidcm_semaphore_destroy (cmSemaphore*s);
/* */voidcm_semaphore_post (cmSemaphore*s, i32count);
/* */voidcm_semaphore_release (cmSemaphore*s);
/* */voidcm_semaphore_wait (cmSemaphore*s);

sortsearch.h

  • Function
/* */int (*cm_i16_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */int (*cm_i32_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */int (*cm_i64_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */int (*cm_isize_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */int (*cm_str_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */int (*cm_f32_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */int (*cm_f64_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */cm_sort_array(array, count, compare_proc) ;
/* */voidcm_sort(void*base, isizecount, isizesize, cmCompareProccompare_proc);
/* */cm_radix_sort(Type);
/* */voidcm_radix_sort_u8 (u8*items, u8*temp, isizecount);
/* */voidcm_radix_sort_u16 (u16*items, u16*temp, isizecount);
/* */voidcm_radix_sort_u32 (u32*items, u32*temp, isizecount);
/* */voidcm_radix_sort_u64 (u64*items, u64*temp, isizecount);
/* */cm_binary_search_array(array, count, key, compare_proc);
/* */isizecm_binary_search(voidconst*base, isizecount, isizesize, voidconst*key, cmCompareProccompare_proc);
/* */cm_shuffle_array(array, count);
/* */voidcm_shuffle(void*base, isizecount, isizesize);
/* */cm_reverse_array(array, count);
/* */voidcm_reverse(void*base, isizecount, isizesize);

string.h

  • Struct
/* */typedefchar*cmString;
/* */typedefstructcmStringHeader {
cmAllocatorallocator;
isizelength;
isizecapacity;
} cmStringHeader;
  • Function
/* */cmStringcm_string_make_reserve (cmAllocatora, isizecapacity);
/* */cmStringcm_string_make (cmAllocatora, charconst*str);
/* */cmStringcm_string_make_length (cmAllocatora, voidconst*str, isizenum_bytes);
/* */voidcm_string_free (cmStringstr);
/* */cmStringcm_string_duplicate (cmAllocatora, cmStringconststr);
/* */isizecm_string_length (cmStringconststr);
/* */isizecm_string_capacity (cmStringconststr);
/* */isizecm_string_available_space(cmStringconststr);
/* */voidcm_string_clear (cmStringstr);
/* */cmStringcm_string_append (cmStringstr, cmStringconstother);
/* */cmStringcm_string_append_length (cmStringstr, voidconst*other, isizenum_bytes);
/* */cmStringcm_string_appendc (cmStringstr, charconst*other);
/* */cmStringcm_string_append_rune (cmStringstr, Runer);
/* */cmStringcm_string_append_fmt (cmStringstr, charconst*fmt, ...);
/* */cmStringcm_string_set (cmStringstr, charconst*cstr);
/* */cmStringcm_string_make_space_for (cmStringstr, isizeadd_len);
/* */isizecm_string_allocation_size(cmStringconststr);
/* */b32cm_string_are_equal (cmStringconstlhs, cmStringconstrhs);
/* */cmStringcm_string_trim (cmStringstr, charconst*cut_set);
/* */cmStringcm_string_trim_space (cmStringstr);

thread.h

  • Struct
/* * Window */typedefstructcmThread {
void*win32_handle;
cmThreadProc*proc;
void*user_data;
isizeuser_index;
isizevolatilereturn_value;
cmSemaphoresemaphore;
isizestack_size;
b32volatileis_running;
} cmThread;
/* * Posix */typedefstructcmThread {
pthread_tposix_handle;
cmThreadProc*proc;
void*user_data;
isizeuser_index;
isizevolatilereturn_value;
cmSemaphoresemaphore;
isizestack_size;
b32volatileis_running;
} cmThread;
/* */typedefstructcmSync {
i32target; // Target Number of threadsi32current; // Threads to hiti32waiting; // Threads waitingcmMutexstart;
cmMutexmutex;
cmSemaphorerelease;
} cmSync;
  • Function
/* */voidcm_thread_init (cmThread*t);
/* */voidcm_thread_destroy (cmThread*t);
/* */voidcm_thread_start (cmThread*t, cmThreadProc*proc, void*data);
/* */voidcm_thread_start_with_stack (cmThread*t, cmThreadProc*proc, void*data, isizestack_size);
/* */voidcm_thread_join (cmThread*t);
/* */b32cm_thread_is_running (cmThreadconst*t);
/* */u32cm_thread_current_id (void);
/* */voidcm_thread_set_name (cmThread*t, charconst*name);
/* */voidcm_sync_init (cmSync*s);
/* */voidcm_sync_destroy (cmSync*s);
/* */voidcm_sync_set_target (cmSync*s, i32count);
/* */voidcm_sync_release (cmSync*s);
/* */i32cm_sync_reach (cmSync*s);
/* */voidcm_sync_reach_and_wait (cmSync*s);

time.h

  • Function
/* */u64cm_rdtsc (void);
/* */f64cm_time_now (void);
/* */u64cm_utc_time_now(void);
/* */voidcm_sleep_ms (u32ms);

utf8.h

  • Function
/* */isizecm_utf8_strlen (u8const*str);
/* */isizecm_utf8_strnlen(u8const*str, isizemax_len);
/* */u16*cm_utf8_to_ucs2 (u16*buffer, isizelen, u8const*str);
/* */u8*cm_ucs2_to_utf8 (u8*buffer, isizelen, u16const*str);
/* */u16*cm_utf8_to_ucs2_buf (u8const*str);
/* */u8*cm_ucs2_to_utf8_buf (u16const*str);
/* */isizecm_utf8_decode (u8const*str, isizestr_len, Rune*codepoint);
/* */isizecm_utf8_codepoint_size (u8const*str, isizestr_len);
/* */isizecm_utf8_encode_rune (u8buf[4], Runer);

utils.h

#defineNULL#defineinline#definecm_restrict#definecm_inline#definecm_no_inline#definecm_thread_local#definecast(Type)
#definecm_size_of(x)
#definecm_count_of(x)
#definecm_offset_of(Type, element)
#definecm_align_of(Type)
#definecm_swap(Type, a, b)
#definecm_global#definecm_internal#definecm_local_persist#definecm_unused(x)
#definevprtcast(x)
#definevoidcast(x)
#defineCM_BIT(x)
#defineCM_MIN(a, b)
#defineCM_MAX(a, b)
#defineCM_MIN3(a, b, c)
#defineCM_MAX3(a, b, c)
#defineCM_CLAMP(x, lower, upper)
#defineCM_CLAMP01(x)
#defineCM_IS_BETWEEN(x, lower, upper)
#defineCM_ABS(x)
#defineCM_MASK_SET(var, set, mask)
#defineCM_PRINTF_ARGS(FMT)

About

c/c++ marcro and utility

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Latest commit

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

types.h

typedefu8;
typedefi8;
typedefu16;
typedefi16;
typedefu32;
typedefi32;
typedefu64;
typedefi64;
typedefusize; //typedef unsigned long long size_ttypedefisize; //typedef long long ptrdiff_ttypedefintptr;
typedefuintptr;
typedeff32;
typedeff64;
typedefRune;
typedefb8;
typedefb16;
typedefb32;
#defineCM_RUNE_INVALID#defineCM_RUNE_MAX #define CM_RUNE_BOM #defineCM_RUNE_EOF#defineU8_MIN#defineU8_MAX#defineI8_MIN#defineI8_MAX#defineU16_MIN#defineU16_MAX#defineI16_MIN#defineI16_MAX#defineU32_MIN#defineU32_MAX#defineI32_MIN#defineI32_MAX#defineU64_MIN#defineU64_MAX#defineI64_MIN#defineI64_MAX#defineUSIZE_MIX #define USIZE_MAX
#defineISIZE_MIX#defineISIZE_MAX#defineF32_MIN#defineF32_MAX#defineF64_MIN#defineF64_MAX

arch.h

/*  * Arch  */#defineCM_ARCH_64#defineCM_ARCH_32/*  * Endian  */#defineCM_ENDIAN_ORDER#defineCM_BIG_ENDIAN#defineCM_LITTLE_ENDIAN/* * OS */#defineCM_WINDOWS#defineCM_OS_WINDOWS#defineCM_SYS_WINDOWS#defineCM_OSX#defineCM_OS_OSX#defineCM_SYS_OSX#defineCM_UNIX#defineCM_OS_UNIX#defineCM_SYS_UNIX#defineCM_LINUX#defineCM_OS_LINUX#defineCM_SYS_LINUX#defineCM_FREEBSD#defineCM_OS_FREEBSD#defineCM_SYS_FREEBSD/* * Compiler */#defineCM_COMPILER_MSVC#defineCM_COMPILER_GCC#defineCM_COMPILER_CLANG/* * CPU */#defineCM_CPU_X86#defineCM_CPU_PPC#defineCM_CPU_ARM#defineCM_CPU_MIPS#defineCM_CACHE_LINE_SIZE

assert.h

#defineCM_STATIC_ASSERT(cond) #define CM_STATIC_ASSERT1(cond, line)
#defineCM_STATIC_ASSERT2(cond, line)
#defineCM_STATIC_ASSERT3(cond, msg)

affinity.h

  • Struct
/* * cmAffinity */typedefstructcmAffinity{
b32is_accurate;
isizecore_count;
isizethread_count;
usizecore_masks[CM_WIN32_MAX_THREADS];
} cmAffinity;
  • Function
/* */voidcm_affinity_init (cmAffinity*a);
/* */voidcm_affinity_destroy (cmAffinity*a);
/* */b32cm_affinity_set (cmAffinity*a, isizecore, isizethread);
/* */isizecm_affinity_thread_count_for_core (cmAffinity*a, isizecore);

atomics.h

  • Struct
/* * cmAtomic32 */typedefstructcmAtomic32 { i32volatilevalue; } cmAtomic32;
/* * cmAtomic64 */typedefstructcmAtomic64 {
i64volatilevalue; } cmAtomic64;
/* * cmAtomicPtr */typedefstructcmAtomicPtr { void*volatilevalue;
} cmAtomicPtr;
  • Function
/* * atomic32 */i32cm_atomic32_load (cmAtomic32constvolatile*a);
voidcm_atomic32_store (cmAtomic32volatile*a, i32value);
i32cm_atomic32_compare_exchange (cmAtomic32volatile*a, i32expected, i32desired);
i32cm_atomic32_exchanged (cmAtomic32volatile*a, i32desired);
i32cm_atomic32_fetch_add (cmAtomic32volatile*a, i32operand);
i32cm_atomic32_fetch_and (cmAtomic32volatile*a, i32operand);
i32cm_atomic32_fetch_or (cmAtomic32volatile*a, i32operand);
b32cm_atomic32_spin_lock (cmAtomic32volatile*a, isizetime_out);
voidcm_atomic32_spin_unlock (cmAtomic32volatile*a);
b32cm_atomic32_try_acquire_lock (cmAtomic32volatile*a);
/* * atomic64 */i64cm_atomic64_load (cmAtomic64constvolatile*a);
voidcm_atomic64_store (cmAtomic64volatile*a, i64value);
i64cm_atomic64_compare_exchange (cmAtomic64volatile*a, i64expected, i64desired);
i64cm_atomic64_exchanged (cmAtomic64volatile*a, i64desired);
i64cm_atomic64_fetch_add (cmAtomic64volatile*a, i64operand);
i64cm_atomic64_fetch_and (cmAtomic64volatile*a, i64operand);
i64cm_atomic64_fetch_or (cmAtomic64volatile*a, i64operand);
b32cm_atomic64_spin_lock (cmAtomic64volatile*a, isizetime_out);
voidcm_atomic64_spin_unlock (cmAtomic64volatile*a);
b32cm_atomic64_try_acquire_lock (cmAtomic64volatile*a);
/* * atomicptr */void*cm_atomic_ptr_load (cmAtomicPtrconstvolatile*a);
voidcm_atomic_ptr_store (cmAtomicPtrvolatile*a, void*value);
void*cm_atomic_ptr_compare_exchange (cmAtomicPtrvolatile*a, void*expected, void*desired);
void*cm_atomic_ptr_exchanged (cmAtomicPtrvolatile*a, void*desired);
void*cm_atomic_ptr_fetch_add (cmAtomicPtrvolatile*a, void*operand);
void*cm_atomic_ptr_fetch_and (cmAtomicPtrvolatile*a, void*operand);
void*cm_atomic_ptr_fetch_or (cmAtomicPtrvolatile*a, void*operand);
b32cm_atomic_ptr_spin_lock (cmAtomicPtrvolatile*a, isizetime_out);
voidcm_atomic_ptr_spin_unlock (cmAtomicPtrvolatile*a);
b32cm_atomic_ptr_try_acquire_lock (cmAtomicPtrvolatile*a);

buffer.h

  • Struct
/* * cmBufferHeader */typedefstructcmBufferHeader {
isizecount;
isizecapacity;
} cmBufferHeader;
  • Function
/* * ประกาศตัวแปร Ex. cmBuffer(i32) buffer; */cmBuffer(Type);
/* * จำนวน */isizecm_buffer_count (cmBufferHeader*bfh);
/* * ความจุ */isizecm_buffer_capacity (cmBufferHeader*bfh);
/* * ค่าเริ่มต้น */void*cm_buffer_init (x, allocator, cap);
/* * เลิกใช้งาน */voidcm_buffer_free (x, allocator);
/* * เพิ่มข้อมูล(1 รายการ) */voidcm_buffer_append (x, item);
/* * เพิ่มข้อมูล(มากกว่า 1 รายการ) */voidcm_buffer_appendv (x, items, item_count);
/* * นำข้อมูลออก */voidcm_buffer_pop (x);
/* * ล้างข้อมูล */cm_buffer_clear (x)

char.h

  • Function
/* * แปลงตัวอักษรเป็นพิมพ์เล็ก */charcm_char_to_lower (charc);
/* * แปลงตัวอักษรเป็นพิมพ์ใหญ่ */charcm_char_to_upper (charc);
/* * ตรวจสอบช่องว่าง */b32cm_char_is_space (charc);
/* * ตรวจสอบตัวเลข */b32cm_char_is_digit (charc);
/* * ตรวจสอบตัวเลขที่เป็นฐาน16 (hex) */b32cm_char_is_hex_digit (charc);
/* *  */b32cm_char_is_alpha (charc);
/* * ตรวจสอบว่าเป็นตัวเลขหรือตัวอักษร */b32cm_char_is_alphanumeric (charc);
/* * แปลงตัวอักษร */i32cm_digit_to_int (charc);
/* * แปลงตัวอักษรฐาน16(hex)เป็นตัวเลขจำนวนเต็ม */i32cm_hex_digit_to_int (charc);
/* * แปลงตัวอักษรเป็นพิมพ์เล็ก */voidcm_str_to_lower(char*str);
/* * แปลงตัวอักษรเป็นพิมพ์ใหญ่ */voidcm_str_to_upper(char*str);
/* * จำนวนข้อความ */isizecm_strlen (charconst*str);
/* *  */isizecm_strnlen(charconst*str, isizemax_len);
/* * เปรียบเทียบข้อความ */i32cm_strcmp (charconst*s1, charconst*s2);
/* *  */i32cm_strncmp(charconst*s1, charconst*s2, isizelen);
/* * ก๊อบปี้ข้อความ */char*cm_strcpy (char*dest, charconst*source);
/* *  */char*cm_strncpy(char*dest, charconst*source, isizelen);
/* *  */isizecm_strlcpy(char*dest, charconst*source, isizelen);
/* *  */char*cm_strrev (char*str);
/* *  */charconst*cm_strtok(char*output, charconst*src, charconst*delimit);
/* *  */b32cm_str_has_prefix(charconst*str, charconst*prefix);
/* *  */b32cm_str_has_suffix(charconst*str, charconst*suffix);
/* *  */charconst*cm_char_first_occurence(charconst*str, charc);
/* *  */charconst*cm_char_last_occurence (charconst*str, charc);
/* *  */voidcm_str_concat(char*dest, isizedest_len, charconst*src_a, isizesrc_a_len, charconst*src_b, isizesrc_b_len);
/* *  */u64cm_str_to_u64(charconst*str, char**end_ptr, i32base);
/* *  */i64cm_str_to_i64(charconst*str, char**end_ptr, i32base);
/* *  */f32cm_str_to_f32(charconst*str, char**end_ptr);
/* *  */f64cm_str_to_f64(charconst*str, char**end_ptr);
/* *  */voidcm_i64_to_str(i64value, char*string, i32base);
/* *  */voidcm_u64_to_str(u64value, char*string, i32base);

debug.h

#defineCM_DEBUG_TRAP()
#defineCM_ASSERT_MSG(cond, msg, ...)
#defineCM_ASSERT(cond)
#defineCM_ASSERT_NOT_NULL(ptr)
#defineCM_PANIC(msg, ...)
  • Function
//voidcm_assert_handler(charconst*prefix, charconst*condition, charconst*file, i32line, charconst*msg, ...);

defer.h

#defineCM_DEFER_1(x, y)
#defineCM_DEFER_2(x, y)
#defineCM_DEFER_3(x)
  • Function
/*ตัวอย่างcmMutex m;cm_mutex_init(&m);{	cm_mutex_lock(&m);	defer (cm_mutex_unlock(&m));	...}*/voiddefer(code);

dll.h

#defineCM_DLL_EXPORT#defineCM_DLL_IMPORT#defineCM_DEF#defineCM_SHARED_LIB_BUILD#defineCM_SHARED_LIB_USE#defineCM_C_API
  • Struct
typedefvoid*cmDllHandle;
typedefvoid (*cmDllProc)(void);
  • Function
/* * Ex. cmDllHandle handle = cm_dll_load("opengl32.dll"); */cmDllHandlecm_dll_load (charconst*filepath);
/* * Ex. cm_dll_unload(handle); */voidcm_dll_unload (cmDllHandledll);
/* * Ex. * cmDllHandle xinput_library = cm_dll_load("xinput9_1_0.dll"); * cmXInputGetStateProc *get_state = cast(cmXInputGetStateProc *)cm_dll_proc_address(xinput_library, "XInputGetState"); * cmXInputGetStateProc *set_state = cast(cmXInputSetStateProc *)cm_dll_proc_address(xinput_library, "XInputSetState"); */cmDllProccm_dll_proc_address (cmDllHandledll, charconst*proc_name);

dynarray.h

#defineCM_ARRAY_GROW_FORMULA(x)
#defineCM_ARRAY_HEADER(x)
  • Struct
/* * cmArrayHeader */typedefstructcmArrayHeader {
cmAllocatorallocator;
isizecount;
isizecapacity;
} cmArrayHeader;
  • Function
/* * ประกาศตัวแปร Ex. cmArray(i32) array; */cmArray(Type);
/* */cmAllocatorcm_array_allocator(x);
/* */isizecm_array_count(x);
/* */isizecm_array_capacity(x);
/* */voidcm_array_init_reserve(x, allocator_, cap);
/* */voidcm_array_init(x, allocator);
/* */voidcm_array_free(x);
/* */voidcm_array_set_capacity(x, capacity);
/* */void*cm__array_set_capacity(void*array, isizecapacity, isizeelement_size);
/* */voidcm_array_grow(x, min_capacity) ;
/* */voidcm_array_append(x, item);
/* */voidcm_array_appendv(x, items, item_count);
/* */voidcm_array_pop(x);
/* */voidcm_array_clear(x);
/* */voidcm_array_resize(x, new_count);
/* */voidcm_array_reserve(x, new_capacity);

extern.h

#defineCM_EXTERN#defineCM_BEGIN_EXTERN#defineCM_END_EXTERN

fences.h

  • Function
/* */voidcm_yield_thread(void);
/* */voidcm_mfence (void);
/* */voidcm_sfence (void);
/* */voidcm_lfence (void);

file.h

  • Struct
/* */typedefu32cmFileMode;
/* */typedefenumcmFileModeFlag {
cmFileMode_Read,
cmFileMode_Write,
cmFileMode_Append,
cmFileMode_Rw,
cmFileMode_Modes ,
} cmFileModeFlag;
/* */typedefenumcmSeekWhenceType {
cmSeekWhence_Begin,
cmSeekWhence_Current,
cmSeekWhence_End,
} cmSeekWhenceType;
/* */typedefenumcmFileError {
cmFileError_None,
cmFileError_Invalid,
cmFileError_InvalidFilename,
cmFileError_Exists,
cmFileError_NotExists,
cmFileError_Permission,
cmFileError_TruncationFailure,
} cmFileError;
/* */typedefunioncmFileDescriptor {
void*p;
intptri;
uintptru;
} cmFileDescriptor;
/* */typedefstructcmFileOperationscmFileOperations;
/* */typedefCM_FILE_OPEN_PROC(cmFileOpenProc);
/* */typedefCM_FILE_READ_AT_PROC(cmFileReadProc);
/* */typedefCM_FILE_WRITE_AT_PROC(cmFileWriteProc);
/* */typedefCM_FILE_SEEK_PROC(cmFileSeekProc);
/* */typedefCM_FILE_CLOSE_PROC(cmFileCloseProc)
/* */structcmFileOperations {
cmFileReadProc*read_at;
cmFileWriteProc*write_at;
cmFileSeekProc*seek;
cmFileCloseProc*close;
};
/* */externcmFileOperationsconstcmDefaultFileOperations;
/* */typedefu64cmFileTime;
/* */typedefstructcmFile {
cmFileOperationsops;
cmFileDescriptorfd;
charconst*filename;
cmFileTimelast_write_time;
// gbDirInfo * dir_info; // TODO(bill): Get directory info
} cmFile;
/* */typedefenumcmFileStandardType {
cmFileStandard_Input,
cmFileStandard_Output,
cmFileStandard_Error,
cmFileStandard_Count,
} cmFileStandardType;
/* */typedefstructcmFileContents {
cmAllocatorallocator;
void*data;
isizesize;
} cmFileContents;
/* */#defineCM_PATH_SEPARATOR
  • Function
/* */cmFile*constcm_file_get_standard (cmFileStandardTypestd);
/* */cmFileErrorcm_file_create (cmFile*file, charconst*filename);
/* */cmFileErrorcm_file_open_mode (cmFile*file, cmFileModemode, charconst*filename);
/* */cmFileErrorcm_file_new (cmFile*file, cmFileDescriptorfd, cmFileOperationsops, charconst*filename);
/* */b32cm_file_read_at_check (cmFile*file, void*buffer, isizesize, i64offset, isize*bytes_read);
/* */b32cm_file_write_at_check(cmFile*file, voidconst*buffer, isizesize, i64offset, isize*bytes_written);
/* */b32cm_file_read_at (cmFile*file, void*buffer, isizesize, i64offset);
/* */b32cm_file_write_at (cmFile*file, voidconst*buffer, isizesize, i64offset);
/* */i64cm_file_seek (cmFile*file, i64offset);
/* */i64cm_file_seek_to_end (cmFile*file);
/* */i64cm_file_skip (cmFile*file, i64bytes);
/* */i64cm_file_tell (cmFile*file);
/* */cmFileErrorcm_file_close (cmFile*file);
/* */b32cm_file_read (cmFile*file, void*buffer, isizesize);
/* */b32cm_file_write (cmFile*file, voidconst*buffer, isizesize);
/* */i64cm_file_size (cmFile*file);
/* */charconst*cm_file_name (cmFile*file);
/* */cmFileErrorcm_file_truncate (cmFile*file, i64size);
/* */b32cm_file_has_changed (cmFile*file);
/* */cmFileContentscm_file_read_contents(cmAllocatora, b32zero_terminate, charconst*filepath);
/* */voidcm_file_free_contents(cmFileContents*fc);
/* */b32cm_file_exists (charconst*filepath);
/* */cmFileTimecm_file_last_write_time(charconst*filepath);
/* */b32cm_file_copy (charconst*existing_filename, charconst*new_filename, b32fail_if_exists);
/* */b32cm_file_move (charconst*existing_filename, charconst*new_filename);
/* */b32cm_file_remove (charconst*filename);
/* */b32cm_path_is_absolute (charconst*path);
/* */b32cm_path_is_relative (charconst*path);
/* */b32cm_path_is_root (charconst*path);
/* */charconst*cm_path_base_name (charconst*path);
/* */charconst*cm_path_extension (charconst*path);
/* */char*cm_path_get_full_name(cmAllocatora, charconst*path);

hash.h

  • Function
/* */u32cm_adler32(voidconst*data, isizelen);
/* */u32cm_crc32(voidconst*data, isizelen);
/* */u64cm_crc64(voidconst*data, isizelen);
/* */u32cm_fnv32 (voidconst*data, isizelen);
/* */u64cm_fnv64 (voidconst*data, isizelen);
/* */u32cm_fnv32a(voidconst*data, isizelen);
/* */u64cm_fnv64a(voidconst*data, isizelen);
/* */u32cm_murmur32(voidconst*data, isizelen);
/* */u64cm_murmur64(voidconst*data, isizelen);
/* */u32cm_murmur32_seed(voidconst*data, isizelen, u32seed);
/* */u64cm_murmur64_seed(voidconst*data, isizelen, u64seed);

hashtable.h

#defineCM_TABLE(PREFIX, NAME, FUNC, VALUE)
#defineCM_TABLE_DECLARE(PREFIX, NAME, FUNC, VALUE)
#defineCM_TABLE_DEFINE(NAME, FUNC, VALUE)
  • Struct
/* * cmHashTableFindResult */typedefstructcmHashTableFindResult {
isizehash_index;
isizeentry_prev;
isizeentry_index;
} cmHashTableFindResult;

header.h

#define_CRT_SECURE_NO_WARNINGS#define_GNU_SOURCE#define_LARGEFILE64_SOURCE#defineWIN32_LEAN_AND_MEAN #define WIN32_MEAN_AND_LEAN #defineVC_EXTRALEAN#defineNOMINMAX

memory.h

#defineCM_DEFAULT_MEMORY_ALIGNMENT#defineCM_DEFAULT_ALLOCATOR_FLAGS
  • Struct
/* * cmVirtualMemory */typedefstructcmVirtualMemory {
void*data;
isizesize;
} cmVirtualMemory;
/* * cmVirtualMemory */typedefenumcmAllocationType {
cmAllocation_Alloc,
cmAllocation_Free,
cmAllocation_FreeAll,
cmAllocation_Resize,
} cmAllocationType;
/* * cmAllocator */typedefstructcmAllocator {
cmAllocatorProc*proc;
void*data;
} cmAllocator;
/* * cmAllocatorFlag */typedefenumcmAllocatorFlag {
cmAllocatorFlag_ClearToZero ,
} cmAllocatorFlag;
/* * cmArena */typedefstructcmArena {
cmAllocatorbacking;
void*physical_start;
isizetotal_size;
isizetotal_allocated;
isizetemp_count;
} cmArena;
  • Function
/* */b32cm_is_power_of_two (isizex);
/* */void*cm_align_forward (void*ptr, isizealignment);
/* */void*cm_pointer_add (void*ptr, isizebytes);
/* */void*cm_pointer_sub (void*ptr, isizebytes);
/* */voidconst*cm_pointer_add_const (voidconst*ptr, isizebytes);
/* */voidconst*cm_pointer_sub_const (voidconst*ptr, isizebytes);
/* */isizecm_pointer_diff (voidconst*begin, voidconst*end);
/* */voidcm_zero_size (void*ptr, isizesize);
/* */voidcm_zero_item (void*t)
/* */voidcm_zero_array (void*a, count)
/* */void*cm_memcopy (void*dest, voidconst*source, isizesize);
/* */void*cm_memmove (void*dest, voidconst*source, isizesize);
/* */void*cm_memset (void*data, u8byte_value, isizesize);
/* */i32cm_memcompare (voidconst*s1, voidconst*s2, isizesize);
/* */voidcm_memswap (void*i, void*j, isizesize);
/* */voidconst*cm_memchr (voidconst*data, u8byte_value, isizesize);
/* */voidconst*cm_memrchr (voidconst*data, u8byte_value, isizesize);
/* */cm_memcopy_array (dst, src, count);
/* */cm_memmove_array (dst, src, count) /* */cmVirtualMemorycm_virtual_memory (void*data, isizesize);
/* */cmVirtualMemorycm_vm_alloc (void*addr, isizesize);
/* */b32cm_vm_free (cmVirtualMemoryvm);
/* */cmVirtualMemorycm_vm_trim (cmVirtualMemoryvm, isizelead_size, isizesize);
/* */b32cm_vm_purge (cmVirtualMemoryvm);
/* */isizecm_virtual_memory_page_size (isize*alignment_out);
/* */void*cm_alloc_align (cmAllocatora, isizesize, isizealignment);
/* */void*cm_alloc (cmAllocatora, isizesize);
/* */voidcm_free (cmAllocatora, void*ptr);
/* */voidcm_free_all (cmAllocatora);
/* */void*cm_resize (cmAllocatora, void*ptr, isizeold_size, isizenew_size);
/* */void*cm_resize_align (cmAllocatora, void*ptr, isizeold_size, isizenew_size, isizealignment);
/* */void*cm_alloc_copy (cmAllocatora, voidconst*src, isizesize);
/* */void*cm_alloc_copy_align (cmAllocatora, voidconst*src, isizesize, isizealignment);
/* */char*cm_alloc_str (cmAllocatora, charconst*str);
/* */char*cm_alloc_str_len (cmAllocatora, charconst*str, isizelen);
/* */cm_alloc_item (allocator_, Type)
/* */cm_alloc_array (allocator_, Type, count)
/* */void*gb_default_resize_align (cmAllocatora, void*ptr, isizeold_size, isizenew_size, isizealignment);
/* */cmAllocatorcm_heap_allocator (void);
/* */cm_malloc(sz);
/* */cm_mfree(ptr);
/* */voidcm_arena_init_from_memory (cmArena*arena, void*start, isizesize);
/* */voidcm_arena_init_from_allocator (cmArena*arena, cmAllocatorbacking, isizesize);
/* */voidcm_arena_init_sub (cmArena*arena, cmArena*parent_arena, isizesize);
/* */voidcm_arena_free (cmArena*arena);
/* */isizecm_arena_alignment_of (cmArena*arena, isizealignment);
/* */isizecm_arena_size_remaining (cmArena*arena, isizealignment);
/* */voidcm_arena_check (cmArena*arena);
/* */cmAllocatorcm_arena_allocator (cmArena*arena);

math.h

#defineCM_MATH_INFINITYF#defineCM_MATH_NANF#defineCM_MATH_PZEROF#defineCM_MATH_NZEROF#defineCM_MATH_INFINITY#defineCM_MATH_NAN#defineCM_MATH_PZERO#defineCM_MATH_NZERO#defineCM_MATH_INFINITYL#defineCM_MATH_NANL#defineCM_MATH_PZEROL#defineCM_MATH_NZEROL#defineCM_SIZEOF_CHAR#defineCM_SIZEOF_BYTE#defineCM_SIZEOF_INT#defineCM_SIZEOF_INTP#defineCM_SIZEOF_UINTP#defineCM_SIZEOF_HALF#defineCM_SIZEOF_LONG#defineCM_SIZEOF_LONGLONG#defineCM_SIZEOF_DOUBLE#defineCM_SIZEOF_LONGDOUBLE#defineCM_SIZEOF_DATETIME#defineCM_SIZEOF_TIMEDELTA#defineCM_CHAR_BIT#defineCM_BYTE_FMT#defineCM_UBYTE_FMT#defineCM_SHORT_FMT#defineCM_USHORT_FMT#defineCM_INT_FMT#defineCM_UINT_FMT#defineCM_LONG_FMT#defineCM_ULONG_FMT#defineCM_HALF_FMT#defineCM_FLOAT_FMT#defineCM_DOUBLE_FMT#defineCM_LONGLONG_FMT#defineCM_ULONGLONG_FMT#defineCM_LONGLONG_SUFFIX(x)
#defineCM_ULONGLONG_SUFFIX(x)
#definecm_isnan(x)
#definecm_isfinite(x)
#definecm_isinf(x)
#defineCM_EXTRACT_WORDS(ix0,ix1,d)
#defineCM_GET_HIGH_WORD(i,d)
#defineCM_GET_LOW_WORD(i,d)
#defineCM_SET_HIGH_WORD(d,v)
#defineCM_SET_LOW_WORD(d,v)
#defineCM_INSERT_WORDS(d,ix0,ix1)
#defineCM_MATH_E#defineCM_MATH_LOG2E#defineCM_MATH_LOG10E#defineCM_MATH_LOGE2#defineCM_MATH_LOGE10#defineCM_MATH_PI#defineCM_MATH_PI_2 #define CM_MATH_PI_4
#defineCM_MATH_1_PI#defineCM_MATH_2_PI#defineCM_MATH_EULER#defineCM_MATH_SQRT2#defineCM_MATH_SQRT1_2#defineCM_MATH_Ef#defineCM_MATH_LOG2Ef#defineCM_MATH_LOG10Ef#defineCM_MATH_LOGE2f#defineCM_MATH_LOGE10f#defineCM_MATH_PIf#defineCM_MATH_PI_2f#defineCM_MATH_PI_4f#defineCM_MATH_1_PIf#defineCM_MATH_2_PIf#defineCM_MATH_EULERf#defineCM_MATH_SQRT2f#defineCM_MATH_SQRT1_2f#defineCM_MATH_El#defineCM_MATH_LOG2El#defineCM_MATH_LOG10El#defineCM_MATH_LOGE2l#defineCM_MATH_LOGE10l#defineCM_MATH_PIl#defineCM_MATH_PI_2l#defineCM_MATH_PI_4l#defineCM_MATH_1_PIl#defineCM_MATH_2_PIl#defineCM_MATH_EULERl#defineCM_MATH_SQRT2l#defineCM_MATH_SQRT1_2l#definecm_math_degrees#definecm_math_degreesf#definecm_math_degreesl#definecm_math_radians#definecm_math_radiansf#definecm_math_radiansl
  • Function
/* * Integer functions. *//* */u32cm_math_gcdu(u32a, u32b);
/* */u32cm_math_lcmu(u32a, u32b);
/* */ulcm_math_gcdul(ula, ulb);
/* */ulcm_math_lcmul(ula, ulb);
/* */ullcm_math_gcdull(ulla, ullb);
/* */ullcm_math_lcmull(ulla, ullb);
/* */u32cm_math_gcd(u32a, u32b);
/* */u32cm_math_lcm(u32a, u32b);
/* */ilcm_math_gcdl(ila, ilb);
/* */ilcm_math_lcml(ila, ilb);
/* */illcm_math_gcdll(illa, illb);
/* */illcm_math_lcmll(illa, illb);
/* */ubytecm_math_rshiftuhh(ubytea, ubyteb);
/* */ubytecm_math_lshiftuhh(ubytea, ubyteb);
/* */u16cm_math_rshiftuh(u16a, u16b);
/* */u16cm_math_lshiftuh(u16a, u16b);
/* */u32cm_math_rshiftu(u32a, u32b);
/* */u32cm_math_lshiftu(u32a, u32b);
/* */ulcm_math_rshiftul(ula, ulb);
/* */ulcm_math_lshiftul(ula, ulb);
/* */ullcm_math_rshiftull(ulla, ullb);
/* */ullcm_math_lshiftull(ulla, ullb);
/* */ibytecm_math_rshifthh(ibytea, ibyteb);
/* */ibytecm_math_lshifthh(ibytea, ibyteb);
/* */i16cm_math_rshifth(i16a, i16b);
/* */i16cm_math_lshifth(i16a, i16b);
/* */i32cm_math_rshift(i32a, i32b);
/* */i32cm_math_lshift(i32a, i32b);
/* */ilcm_math_rshiftl(ila, ilb);
/* */ilcm_math_lshiftl(ila, ilb);
/* */illcm_math_rshiftll(illa, illb);
/* */illcm_math_lshiftll(illa, illb);
/* * float C99 math functions *//* */f32cm_math_sinf(f32x);
/* */f32cm_math_cosf(f32x);
/* */f32cm_math_tanf(f32x);
/* */f32cm_math_sinhf(f32x);
/* */f32cm_math_coshf(f32x);
/* */f32cm_math_tanhf(f32x);
/* */f32cm_math_fabsf(f32x);
/* */f32cm_math_floorf(f32x);
/* */f32cm_math_ceilf(f32x);
/* */f32cm_math_rintf(f32x);
/* */f32cm_math_truncf(f32x);
/* */f32cm_math_sqrtf(f32x);
/* */f32cm_math_cbrtf(f32x);
/* */f32cm_math_log10f(f32x);
/* */f32cm_math_logf(f32x);
/* */f32cm_math_expf(f32x);
/* */f32cm_math_expm1f(f32x);
/* */f32cm_math_asinf(f32x);
/* */f32cm_math_acosf(f32x);
/* */f32cm_math_atanf(f32x);
/* */f32cm_math_asinhf(f32x);
/* */f32cm_math_acoshf(f32x);
/* */f32cm_math_atanhf(f32x);
/* */f32cm_math_log1pf(f32x);
/* */f32cm_math_exp2f(f32x);
/* */f32cm_math_log2f(f32x);
/* */f32cm_math_atan2f(f32x, f32y);
/* */f32cm_math_hypotf(f32x, f32y);
/* */f32cm_math_powf(f32x, f32y);
/* */f32cm_math_fmodf(f32x, f32y);
/* */f32cm_math_modff(f32x, f32*y);
/* */f32cm_math_frexpf(f32x, i32*y);
/* */f32cm_math_ldexpf(f32x, i32y);
/* */f32cm_math_copysignf(f32x, f32y);
/* */f32cm_math_nextafterf(f32x, f32y);
/* */f32cm_math_spacingf(f32x);
/* * long double C99 math functions *//* */fldcm_math_sinl(fldx);
/* */fldcm_math_cosl(fldx);
/* */fldcm_math_tanl(fldx);
/* */fldcm_math_sinhl(fldx);
/* */fldcm_math_coshl(fldx);
/* */fldcm_math_tanhl(fldx);
/* */fldcm_math_fabsl(fldx);
/* */fldcm_math_floorl(fldx);
/* */fldcm_math_ceill(fldx);
/* */fldcm_math_rintl(fldx);
/* */fldcm_math_truncl(fldx);
/* */fldcm_math_sqrtl(fldx);
/* */fldcm_math_cbrtl(fldx);
/* */fldcm_math_log10l(fldx);
/* */fldcm_math_logl(fldx);
/* */fldcm_math_expl(fldx);
/* */fldcm_math_expm1l(fldx);
/* */fldcm_math_asinl(fldx);
/* */fldcm_math_acosl(fldx);
/* */fldcm_math_atanl(fldx);
/* */fldcm_math_asinhl(fldx);
/* */fldcm_math_acoshl(fldx);
/* */fldcm_math_atanhl(fldx);
/* */fldcm_math_log1pl(fldx);
/* */fldcm_math_exp2l(fldx);
/* */fldcm_math_log2l(fldx);
/* */fldcm_math_atan2l(fldx, fldy);
/* */fldcm_math_hypotl(fldx, fldy);
/* */fldcm_math_powl(fldx, fldy);
/* */fldcm_math_fmodl(fldx, fldy);
/* */fldcm_math_modfl(fldx, fld*y);
/* */fldcm_math_frexpl(fldx, int*y);
/* */fldcm_math_ldexpl(fldx, inty);
/* */fldcm_math_copysignl(fldx, fldy);
/* */fldcm_math_nextafterl(fldx, fldy);
/* */fldcm_math_spacingl(fldx);
/* * Non standard functions *//* */f64cm_math_deg2rad(f64x);
/* */f64cm_math_rad2deg(f64x);
/* */f64cm_math_logaddexp(f64x, f64y);
/* */f64cm_math_logaddexp2(f64x, f64y);
/* */f64cm_math_divmod(f64x, f64y, f64*modulus);
/* */f64cm_math_heaviside(f64x, f64h0);
/* */f32cm_math_deg2radf(f32x);
/* */f32cm_math_rad2degf(f32x);
/* */f32cm_math_logaddexpf(f32x, f32y);
/* */f32cm_math_logaddexp2f(f32x, f32y);
/* */f32cm_math_divmodf(f32x, f32y, f32*modulus);
/* */f32cm_math_heavisidef(f32x, f32h0);
/* */fldcm_math_deg2radl(fldx);
/* */fldcm_math_rad2degl(fldx);
/* */fldcm_math_logaddexpl(fldx, fldy);
/* */fldcm_math_logaddexp2l(fldx, fldy);
/* */fldcm_math_divmodl(fldx, fldy, fld*modulus);
/* */fldcm_math_heavisidel(fldx, fldh0);
/* * Complex declarations *//* */inlinec64cm_math_cpack(f64x, f64y);
/* */inlinec32cm_math_cpackf(f32x, f32y);
/* */inlinecldcm_math_cpackl(fldx, fldy);
/* */inlinef64cm_math_creal(c64z);
/* */inlinef64cm_math_cimag(c64z);
/* */inlinef32cm_math_crealf(c32z);
/* */inlinef32cm_math_cimagf(c32z);
/* */inlinefldcm_math_creall(cldz);
/* */inlinefldcm_math_cimagl(cldz);
/* * Double precision complex functions *//* */f64cm_math_cabs(c64z);
/* */f64cm_math_carg(c64z);
/* */c64cm_math_cexp(c64z);
/* */c64cm_math_clog(c64z);
/* */c64cm_math_cpow(c64x, c64y);
/* */c64cm_math_csqrt(c64z);
/* */c64cm_math_ccos(c64z);
/* */c64cm_math_csin(c64z);
/* */c64cm_math_ctan(c64z);
/* */c64cm_math_ccosh(c64z);
/* */c64cm_math_csinh(c64z);
/* */c64cm_math_ctanh(c64z);
/* */c64cm_math_cacos(c64z);
/* */c64cm_math_casin(c64z);
/* */c64cm_math_catan(c64z);
/* */c64cm_math_cacosh(c64z);
/* */c64cm_math_casinh(c64z);
/* */c64cm_math_catanh(c64z);
/* * Single precision complex functions *//* */f32cm_math_cabsf(c32z);
/* */f32cm_math_cargf(c32z);
/* */c32cm_math_cexpf(c32z);
/* */c32cm_math_clogf(c32z);
/* */c32cm_math_cpowf(c32x, c32y);
/* */c32cm_math_csqrtf(c32z);
/* */c32cm_math_ccosf(c32z);
/* */c32cm_math_csinf(c32z);
/* */c32cm_math_ctanf(c32z);
/* */c32cm_math_ccoshf(c32z);
/* */c32cm_math_csinhf(c32z);
/* */c32cm_math_ctanhf(c32z);
/* */c32cm_math_cacosf(c32z);
/* */c32cm_math_casinf(c32z);
/* */c32cm_math_catanf(c32z);
/* */c32cm_math_cacoshf(c32z);
/* */c32cm_math_casinhf(c32z);
/* */c32cm_math_catanhf(c32z);
/* * Extended precision complex functions *//* */fldcm_math_cabsl(cldz);
/* */fldcm_math_cargl(cldz);
/* */cldcm_math_cexpl(cldz);
/* */cldcm_math_clogl(cldz);
/* */cldcm_math_cpowl(cldx, cldy);
/* */cldcm_math_csqrtl(cldz);
/* */cldcm_math_ccosl(cldz);
/* */cldcm_math_csinl(cldz);
/* */cldcm_math_ctanl(cldz);
/* */cldcm_math_ccoshl(cldz);
/* */cldcm_math_csinhl(cldz);
/* */cldcm_math_ctanhl(cldz);
/* */cldcm_math_cacosl(cldz);
/* */cldcm_math_casinl(cldz);
/* */cldcm_math_catanl(cldz);
/* */cldcm_math_cacoshl(cldz);
/* */cldcm_math_casinhl(cldz);
/* */cldcm_math_catanhl(cldz);

misc.h

  • Function
/* */voidcm_exit (u32code);
/* */voidcm_yield (void);
/* */voidcm_set_env (charconst*name, charconst*value);
/* */voidcm_unset_env (charconst*name);
/* */u16cm_endian_swap16 (u16i);
/* */u32cm_endian_swap32 (u32i);
/* */u64cm_endian_swap64 (u64i);
/* */isizecm_count_set_bits (u64mask);

mutex.h

  • Struct
/* * Windows */typedefstructcmMutex {
CRITICAL_SECTIONwin32_critical_section;
} cmMutex;
/* * Unix & Linux */typedefstructcmMutex {
pthread_mutex_tpthread_mutex;
pthread_mutexattr_tpthread_mutexattr;
} cmMutex;
  • Function
/* */voidcm_mutex_init (cmMutex*m);
/* */voidcm_mutex_destroy (cmMutex*m);
/* */voidcm_mutex_lock (cmMutex*m);
/* */b32cm_mutex_try_lock (cmMutex*m);
/* */voidcm_mutex_unlock (cmMutex*m);

print.h

  • Function
/* */isizecm_printf (charconst*fmt, ...) CM_PRINTF_ARGS(1);
/* */isizecm_printf_va (charconst*fmt, va_listva);
/* */isizecm_printf_err (charconst*fmt, ...) CM_PRINTF_ARGS(1);
/* */isizecm_printf_err_va (charconst*fmt, va_listva);
/* */isizecm_fprintf (cmFile*f, charconst*fmt, ...) CM_PRINTF_ARGS(2);
/* */isizecm_fprintf_va (cmFile*f, charconst*fmt, va_listva);
/* */char*cm_bprintf (charconst*fmt, ...) CM_PRINTF_ARGS(1);
/* */char*cm_bprintf_va (charconst*fmt, va_listva);
/* */isizecm_snprintf (char*str, isizen, charconst*fmt, ...) CM_PRINTF_ARGS(3);

random.h

  • Struct
/* */typedefstructcmRandom {
u32offsets[8];
u32value;
} cmRandom;
  • Function
/* */voidcm_random_init (cmRandom*r);
/* */u32cm_random_gen_u32 (cmRandom*r);
/* */u32cm_random_gen_u32_unique (cmRandom*r);
/* */u64cm_random_gen_u64 (cmRandom*r);
/* */isizecm_random_gen_isize (cmRandom*r);
/* */i64cm_random_range_i64 (cmRandom*r, i64lower_inc, i64higher_inc);
/* */isizecm_random_range_isize (cmRandom*r, isizelower_inc, isizehigher_inc);
/* */f64cm_random_range_f64 (cmRandom*r, f64lower_inc, f64higher_inc);

semaphore.h

  • Struct
/* * Window */typedefstructcmSemaphore { void*win32_handle;} cmSemaphore;
/* * OSX */typedefstructcmSemaphore { semaphore_tosx_handle; } cmSemaphore;
/* * Unix */typedefstructcmSemaphore { sem_tunix_handle; } cmSemaphore;
  • Function
/* */voidcm_semaphore_init (cmSemaphore*s);
/* */voidcm_semaphore_destroy (cmSemaphore*s);
/* */voidcm_semaphore_post (cmSemaphore*s, i32count);
/* */voidcm_semaphore_release (cmSemaphore*s);
/* */voidcm_semaphore_wait (cmSemaphore*s);

sortsearch.h

  • Function
/* */int (*cm_i16_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */int (*cm_i32_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */int (*cm_i64_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */int (*cm_isize_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */int (*cm_str_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */int (*cm_f32_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */int (*cm_f64_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */cm_sort_array(array, count, compare_proc) ;
/* */voidcm_sort(void*base, isizecount, isizesize, cmCompareProccompare_proc);
/* */cm_radix_sort(Type);
/* */voidcm_radix_sort_u8 (u8*items, u8*temp, isizecount);
/* */voidcm_radix_sort_u16 (u16*items, u16*temp, isizecount);
/* */voidcm_radix_sort_u32 (u32*items, u32*temp, isizecount);
/* */voidcm_radix_sort_u64 (u64*items, u64*temp, isizecount);
/* */cm_binary_search_array(array, count, key, compare_proc);
/* */isizecm_binary_search(voidconst*base, isizecount, isizesize, voidconst*key, cmCompareProccompare_proc);
/* */cm_shuffle_array(array, count);
/* */voidcm_shuffle(void*base, isizecount, isizesize);
/* */cm_reverse_array(array, count);
/* */voidcm_reverse(void*base, isizecount, isizesize);

string.h

  • Struct
/* */typedefchar*cmString;
/* */typedefstructcmStringHeader {
cmAllocatorallocator;
isizelength;
isizecapacity;
} cmStringHeader;
  • Function
/* */cmStringcm_string_make_reserve (cmAllocatora, isizecapacity);
/* */cmStringcm_string_make (cmAllocatora, charconst*str);
/* */cmStringcm_string_make_length (cmAllocatora, voidconst*str, isizenum_bytes);
/* */voidcm_string_free (cmStringstr);
/* */cmStringcm_string_duplicate (cmAllocatora, cmStringconststr);
/* */isizecm_string_length (cmStringconststr);
/* */isizecm_string_capacity (cmStringconststr);
/* */isizecm_string_available_space(cmStringconststr);
/* */voidcm_string_clear (cmStringstr);
/* */cmStringcm_string_append (cmStringstr, cmStringconstother);
/* */cmStringcm_string_append_length (cmStringstr, voidconst*other, isizenum_bytes);
/* */cmStringcm_string_appendc (cmStringstr, charconst*other);
/* */cmStringcm_string_append_rune (cmStringstr, Runer);
/* */cmStringcm_string_append_fmt (cmStringstr, charconst*fmt, ...);
/* */cmStringcm_string_set (cmStringstr, charconst*cstr);
/* */cmStringcm_string_make_space_for (cmStringstr, isizeadd_len);
/* */isizecm_string_allocation_size(cmStringconststr);
/* */b32cm_string_are_equal (cmStringconstlhs, cmStringconstrhs);
/* */cmStringcm_string_trim (cmStringstr, charconst*cut_set);
/* */cmStringcm_string_trim_space (cmStringstr);

thread.h

  • Struct
/* * Window */typedefstructcmThread {
void*win32_handle;
cmThreadProc*proc;
void*user_data;
isizeuser_index;
isizevolatilereturn_value;
cmSemaphoresemaphore;
isizestack_size;
b32volatileis_running;
} cmThread;
/* * Posix */typedefstructcmThread {
pthread_tposix_handle;
cmThreadProc*proc;
void*user_data;
isizeuser_index;
isizevolatilereturn_value;
cmSemaphoresemaphore;
isizestack_size;
b32volatileis_running;
} cmThread;
/* */typedefstructcmSync {
i32target; // Target Number of threadsi32current; // Threads to hiti32waiting; // Threads waitingcmMutexstart;
cmMutexmutex;
cmSemaphorerelease;
} cmSync;
  • Function
/* */voidcm_thread_init (cmThread*t);
/* */voidcm_thread_destroy (cmThread*t);
/* */voidcm_thread_start (cmThread*t, cmThreadProc*proc, void*data);
/* */voidcm_thread_start_with_stack (cmThread*t, cmThreadProc*proc, void*data, isizestack_size);
/* */voidcm_thread_join (cmThread*t);
/* */b32cm_thread_is_running (cmThreadconst*t);
/* */u32cm_thread_current_id (void);
/* */voidcm_thread_set_name (cmThread*t, charconst*name);
/* */voidcm_sync_init (cmSync*s);
/* */voidcm_sync_destroy (cmSync*s);
/* */voidcm_sync_set_target (cmSync*s, i32count);
/* */voidcm_sync_release (cmSync*s);
/* */i32cm_sync_reach (cmSync*s);
/* */voidcm_sync_reach_and_wait (cmSync*s);

time.h

  • Function
/* */u64cm_rdtsc (void);
/* */f64cm_time_now (void);
/* */u64cm_utc_time_now(void);
/* */voidcm_sleep_ms (u32ms);

utf8.h

  • Function
/* */isizecm_utf8_strlen (u8const*str);
/* */isizecm_utf8_strnlen(u8const*str, isizemax_len);
/* */u16*cm_utf8_to_ucs2 (u16*buffer, isizelen, u8const*str);
/* */u8*cm_ucs2_to_utf8 (u8*buffer, isizelen, u16const*str);
/* */u16*cm_utf8_to_ucs2_buf (u8const*str);
/* */u8*cm_ucs2_to_utf8_buf (u16const*str);
/* */isizecm_utf8_decode (u8const*str, isizestr_len, Rune*codepoint);
/* */isizecm_utf8_codepoint_size (u8const*str, isizestr_len);
/* */isizecm_utf8_encode_rune (u8buf[4], Runer);

utils.h

#defineNULL#defineinline#definecm_restrict#definecm_inline#definecm_no_inline#definecm_thread_local#definecast(Type)
#definecm_size_of(x)
#definecm_count_of(x)
#definecm_offset_of(Type, element)
#definecm_align_of(Type)
#definecm_swap(Type, a, b)
#definecm_global#definecm_internal#definecm_local_persist#definecm_unused(x)
#definevprtcast(x)
#definevoidcast(x)
#defineCM_BIT(x)
#defineCM_MIN(a, b)
#defineCM_MAX(a, b)
#defineCM_MIN3(a, b, c)
#defineCM_MAX3(a, b, c)
#defineCM_CLAMP(x, lower, upper)
#defineCM_CLAMP01(x)
#defineCM_IS_BETWEEN(x, lower, upper)
#defineCM_ABS(x)
#defineCM_MASK_SET(var, set, mask)
#defineCM_PRINTF_ARGS(FMT)

About

c/c++ marcro and utility

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Latest commit

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

types.h

typedefu8;
typedefi8;
typedefu16;
typedefi16;
typedefu32;
typedefi32;
typedefu64;
typedefi64;
typedefusize; //typedef unsigned long long size_ttypedefisize; //typedef long long ptrdiff_ttypedefintptr;
typedefuintptr;
typedeff32;
typedeff64;
typedefRune;
typedefb8;
typedefb16;
typedefb32;
#defineCM_RUNE_INVALID#defineCM_RUNE_MAX #define CM_RUNE_BOM #defineCM_RUNE_EOF#defineU8_MIN#defineU8_MAX#defineI8_MIN#defineI8_MAX#defineU16_MIN#defineU16_MAX#defineI16_MIN#defineI16_MAX#defineU32_MIN#defineU32_MAX#defineI32_MIN#defineI32_MAX#defineU64_MIN#defineU64_MAX#defineI64_MIN#defineI64_MAX#defineUSIZE_MIX #define USIZE_MAX
#defineISIZE_MIX#defineISIZE_MAX#defineF32_MIN#defineF32_MAX#defineF64_MIN#defineF64_MAX

arch.h

/*  * Arch  */#defineCM_ARCH_64#defineCM_ARCH_32/*  * Endian  */#defineCM_ENDIAN_ORDER#defineCM_BIG_ENDIAN#defineCM_LITTLE_ENDIAN/* * OS */#defineCM_WINDOWS#defineCM_OS_WINDOWS#defineCM_SYS_WINDOWS#defineCM_OSX#defineCM_OS_OSX#defineCM_SYS_OSX#defineCM_UNIX#defineCM_OS_UNIX#defineCM_SYS_UNIX#defineCM_LINUX#defineCM_OS_LINUX#defineCM_SYS_LINUX#defineCM_FREEBSD#defineCM_OS_FREEBSD#defineCM_SYS_FREEBSD/* * Compiler */#defineCM_COMPILER_MSVC#defineCM_COMPILER_GCC#defineCM_COMPILER_CLANG/* * CPU */#defineCM_CPU_X86#defineCM_CPU_PPC#defineCM_CPU_ARM#defineCM_CPU_MIPS#defineCM_CACHE_LINE_SIZE

assert.h

#defineCM_STATIC_ASSERT(cond) #define CM_STATIC_ASSERT1(cond, line)
#defineCM_STATIC_ASSERT2(cond, line)
#defineCM_STATIC_ASSERT3(cond, msg)

affinity.h

  • Struct
/* * cmAffinity */typedefstructcmAffinity{
b32is_accurate;
isizecore_count;
isizethread_count;
usizecore_masks[CM_WIN32_MAX_THREADS];
} cmAffinity;
  • Function
/* */voidcm_affinity_init (cmAffinity*a);
/* */voidcm_affinity_destroy (cmAffinity*a);
/* */b32cm_affinity_set (cmAffinity*a, isizecore, isizethread);
/* */isizecm_affinity_thread_count_for_core (cmAffinity*a, isizecore);

atomics.h

  • Struct
/* * cmAtomic32 */typedefstructcmAtomic32 { i32volatilevalue; } cmAtomic32;
/* * cmAtomic64 */typedefstructcmAtomic64 {
i64volatilevalue; } cmAtomic64;
/* * cmAtomicPtr */typedefstructcmAtomicPtr { void*volatilevalue;
} cmAtomicPtr;
  • Function
/* * atomic32 */i32cm_atomic32_load (cmAtomic32constvolatile*a);
voidcm_atomic32_store (cmAtomic32volatile*a, i32value);
i32cm_atomic32_compare_exchange (cmAtomic32volatile*a, i32expected, i32desired);
i32cm_atomic32_exchanged (cmAtomic32volatile*a, i32desired);
i32cm_atomic32_fetch_add (cmAtomic32volatile*a, i32operand);
i32cm_atomic32_fetch_and (cmAtomic32volatile*a, i32operand);
i32cm_atomic32_fetch_or (cmAtomic32volatile*a, i32operand);
b32cm_atomic32_spin_lock (cmAtomic32volatile*a, isizetime_out);
voidcm_atomic32_spin_unlock (cmAtomic32volatile*a);
b32cm_atomic32_try_acquire_lock (cmAtomic32volatile*a);
/* * atomic64 */i64cm_atomic64_load (cmAtomic64constvolatile*a);
voidcm_atomic64_store (cmAtomic64volatile*a, i64value);
i64cm_atomic64_compare_exchange (cmAtomic64volatile*a, i64expected, i64desired);
i64cm_atomic64_exchanged (cmAtomic64volatile*a, i64desired);
i64cm_atomic64_fetch_add (cmAtomic64volatile*a, i64operand);
i64cm_atomic64_fetch_and (cmAtomic64volatile*a, i64operand);
i64cm_atomic64_fetch_or (cmAtomic64volatile*a, i64operand);
b32cm_atomic64_spin_lock (cmAtomic64volatile*a, isizetime_out);
voidcm_atomic64_spin_unlock (cmAtomic64volatile*a);
b32cm_atomic64_try_acquire_lock (cmAtomic64volatile*a);
/* * atomicptr */void*cm_atomic_ptr_load (cmAtomicPtrconstvolatile*a);
voidcm_atomic_ptr_store (cmAtomicPtrvolatile*a, void*value);
void*cm_atomic_ptr_compare_exchange (cmAtomicPtrvolatile*a, void*expected, void*desired);
void*cm_atomic_ptr_exchanged (cmAtomicPtrvolatile*a, void*desired);
void*cm_atomic_ptr_fetch_add (cmAtomicPtrvolatile*a, void*operand);
void*cm_atomic_ptr_fetch_and (cmAtomicPtrvolatile*a, void*operand);
void*cm_atomic_ptr_fetch_or (cmAtomicPtrvolatile*a, void*operand);
b32cm_atomic_ptr_spin_lock (cmAtomicPtrvolatile*a, isizetime_out);
voidcm_atomic_ptr_spin_unlock (cmAtomicPtrvolatile*a);
b32cm_atomic_ptr_try_acquire_lock (cmAtomicPtrvolatile*a);

buffer.h

  • Struct
/* * cmBufferHeader */typedefstructcmBufferHeader {
isizecount;
isizecapacity;
} cmBufferHeader;
  • Function
/* * ประกาศตัวแปร Ex. cmBuffer(i32) buffer; */cmBuffer(Type);
/* * จำนวน */isizecm_buffer_count (cmBufferHeader*bfh);
/* * ความจุ */isizecm_buffer_capacity (cmBufferHeader*bfh);
/* * ค่าเริ่มต้น */void*cm_buffer_init (x, allocator, cap);
/* * เลิกใช้งาน */voidcm_buffer_free (x, allocator);
/* * เพิ่มข้อมูล(1 รายการ) */voidcm_buffer_append (x, item);
/* * เพิ่มข้อมูล(มากกว่า 1 รายการ) */voidcm_buffer_appendv (x, items, item_count);
/* * นำข้อมูลออก */voidcm_buffer_pop (x);
/* * ล้างข้อมูล */cm_buffer_clear (x)

char.h

  • Function
/* * แปลงตัวอักษรเป็นพิมพ์เล็ก */charcm_char_to_lower (charc);
/* * แปลงตัวอักษรเป็นพิมพ์ใหญ่ */charcm_char_to_upper (charc);
/* * ตรวจสอบช่องว่าง */b32cm_char_is_space (charc);
/* * ตรวจสอบตัวเลข */b32cm_char_is_digit (charc);
/* * ตรวจสอบตัวเลขที่เป็นฐาน16 (hex) */b32cm_char_is_hex_digit (charc);
/* *  */b32cm_char_is_alpha (charc);
/* * ตรวจสอบว่าเป็นตัวเลขหรือตัวอักษร */b32cm_char_is_alphanumeric (charc);
/* * แปลงตัวอักษร */i32cm_digit_to_int (charc);
/* * แปลงตัวอักษรฐาน16(hex)เป็นตัวเลขจำนวนเต็ม */i32cm_hex_digit_to_int (charc);
/* * แปลงตัวอักษรเป็นพิมพ์เล็ก */voidcm_str_to_lower(char*str);
/* * แปลงตัวอักษรเป็นพิมพ์ใหญ่ */voidcm_str_to_upper(char*str);
/* * จำนวนข้อความ */isizecm_strlen (charconst*str);
/* *  */isizecm_strnlen(charconst*str, isizemax_len);
/* * เปรียบเทียบข้อความ */i32cm_strcmp (charconst*s1, charconst*s2);
/* *  */i32cm_strncmp(charconst*s1, charconst*s2, isizelen);
/* * ก๊อบปี้ข้อความ */char*cm_strcpy (char*dest, charconst*source);
/* *  */char*cm_strncpy(char*dest, charconst*source, isizelen);
/* *  */isizecm_strlcpy(char*dest, charconst*source, isizelen);
/* *  */char*cm_strrev (char*str);
/* *  */charconst*cm_strtok(char*output, charconst*src, charconst*delimit);
/* *  */b32cm_str_has_prefix(charconst*str, charconst*prefix);
/* *  */b32cm_str_has_suffix(charconst*str, charconst*suffix);
/* *  */charconst*cm_char_first_occurence(charconst*str, charc);
/* *  */charconst*cm_char_last_occurence (charconst*str, charc);
/* *  */voidcm_str_concat(char*dest, isizedest_len, charconst*src_a, isizesrc_a_len, charconst*src_b, isizesrc_b_len);
/* *  */u64cm_str_to_u64(charconst*str, char**end_ptr, i32base);
/* *  */i64cm_str_to_i64(charconst*str, char**end_ptr, i32base);
/* *  */f32cm_str_to_f32(charconst*str, char**end_ptr);
/* *  */f64cm_str_to_f64(charconst*str, char**end_ptr);
/* *  */voidcm_i64_to_str(i64value, char*string, i32base);
/* *  */voidcm_u64_to_str(u64value, char*string, i32base);

debug.h

#defineCM_DEBUG_TRAP()
#defineCM_ASSERT_MSG(cond, msg, ...)
#defineCM_ASSERT(cond)
#defineCM_ASSERT_NOT_NULL(ptr)
#defineCM_PANIC(msg, ...)
  • Function
//voidcm_assert_handler(charconst*prefix, charconst*condition, charconst*file, i32line, charconst*msg, ...);

defer.h

#defineCM_DEFER_1(x, y)
#defineCM_DEFER_2(x, y)
#defineCM_DEFER_3(x)
  • Function
/*ตัวอย่างcmMutex m;cm_mutex_init(&m);{	cm_mutex_lock(&m);	defer (cm_mutex_unlock(&m));	...}*/voiddefer(code);

dll.h

#defineCM_DLL_EXPORT#defineCM_DLL_IMPORT#defineCM_DEF#defineCM_SHARED_LIB_BUILD#defineCM_SHARED_LIB_USE#defineCM_C_API
  • Struct
typedefvoid*cmDllHandle;
typedefvoid (*cmDllProc)(void);
  • Function
/* * Ex. cmDllHandle handle = cm_dll_load("opengl32.dll"); */cmDllHandlecm_dll_load (charconst*filepath);
/* * Ex. cm_dll_unload(handle); */voidcm_dll_unload (cmDllHandledll);
/* * Ex. * cmDllHandle xinput_library = cm_dll_load("xinput9_1_0.dll"); * cmXInputGetStateProc *get_state = cast(cmXInputGetStateProc *)cm_dll_proc_address(xinput_library, "XInputGetState"); * cmXInputGetStateProc *set_state = cast(cmXInputSetStateProc *)cm_dll_proc_address(xinput_library, "XInputSetState"); */cmDllProccm_dll_proc_address (cmDllHandledll, charconst*proc_name);

dynarray.h

#defineCM_ARRAY_GROW_FORMULA(x)
#defineCM_ARRAY_HEADER(x)
  • Struct
/* * cmArrayHeader */typedefstructcmArrayHeader {
cmAllocatorallocator;
isizecount;
isizecapacity;
} cmArrayHeader;
  • Function
/* * ประกาศตัวแปร Ex. cmArray(i32) array; */cmArray(Type);
/* */cmAllocatorcm_array_allocator(x);
/* */isizecm_array_count(x);
/* */isizecm_array_capacity(x);
/* */voidcm_array_init_reserve(x, allocator_, cap);
/* */voidcm_array_init(x, allocator);
/* */voidcm_array_free(x);
/* */voidcm_array_set_capacity(x, capacity);
/* */void*cm__array_set_capacity(void*array, isizecapacity, isizeelement_size);
/* */voidcm_array_grow(x, min_capacity) ;
/* */voidcm_array_append(x, item);
/* */voidcm_array_appendv(x, items, item_count);
/* */voidcm_array_pop(x);
/* */voidcm_array_clear(x);
/* */voidcm_array_resize(x, new_count);
/* */voidcm_array_reserve(x, new_capacity);

extern.h

#defineCM_EXTERN#defineCM_BEGIN_EXTERN#defineCM_END_EXTERN

fences.h

  • Function
/* */voidcm_yield_thread(void);
/* */voidcm_mfence (void);
/* */voidcm_sfence (void);
/* */voidcm_lfence (void);

file.h

  • Struct
/* */typedefu32cmFileMode;
/* */typedefenumcmFileModeFlag {
cmFileMode_Read,
cmFileMode_Write,
cmFileMode_Append,
cmFileMode_Rw,
cmFileMode_Modes ,
} cmFileModeFlag;
/* */typedefenumcmSeekWhenceType {
cmSeekWhence_Begin,
cmSeekWhence_Current,
cmSeekWhence_End,
} cmSeekWhenceType;
/* */typedefenumcmFileError {
cmFileError_None,
cmFileError_Invalid,
cmFileError_InvalidFilename,
cmFileError_Exists,
cmFileError_NotExists,
cmFileError_Permission,
cmFileError_TruncationFailure,
} cmFileError;
/* */typedefunioncmFileDescriptor {
void*p;
intptri;
uintptru;
} cmFileDescriptor;
/* */typedefstructcmFileOperationscmFileOperations;
/* */typedefCM_FILE_OPEN_PROC(cmFileOpenProc);
/* */typedefCM_FILE_READ_AT_PROC(cmFileReadProc);
/* */typedefCM_FILE_WRITE_AT_PROC(cmFileWriteProc);
/* */typedefCM_FILE_SEEK_PROC(cmFileSeekProc);
/* */typedefCM_FILE_CLOSE_PROC(cmFileCloseProc)
/* */structcmFileOperations {
cmFileReadProc*read_at;
cmFileWriteProc*write_at;
cmFileSeekProc*seek;
cmFileCloseProc*close;
};
/* */externcmFileOperationsconstcmDefaultFileOperations;
/* */typedefu64cmFileTime;
/* */typedefstructcmFile {
cmFileOperationsops;
cmFileDescriptorfd;
charconst*filename;
cmFileTimelast_write_time;
// gbDirInfo * dir_info; // TODO(bill): Get directory info
} cmFile;
/* */typedefenumcmFileStandardType {
cmFileStandard_Input,
cmFileStandard_Output,
cmFileStandard_Error,
cmFileStandard_Count,
} cmFileStandardType;
/* */typedefstructcmFileContents {
cmAllocatorallocator;
void*data;
isizesize;
} cmFileContents;
/* */#defineCM_PATH_SEPARATOR
  • Function
/* */cmFile*constcm_file_get_standard (cmFileStandardTypestd);
/* */cmFileErrorcm_file_create (cmFile*file, charconst*filename);
/* */cmFileErrorcm_file_open_mode (cmFile*file, cmFileModemode, charconst*filename);
/* */cmFileErrorcm_file_new (cmFile*file, cmFileDescriptorfd, cmFileOperationsops, charconst*filename);
/* */b32cm_file_read_at_check (cmFile*file, void*buffer, isizesize, i64offset, isize*bytes_read);
/* */b32cm_file_write_at_check(cmFile*file, voidconst*buffer, isizesize, i64offset, isize*bytes_written);
/* */b32cm_file_read_at (cmFile*file, void*buffer, isizesize, i64offset);
/* */b32cm_file_write_at (cmFile*file, voidconst*buffer, isizesize, i64offset);
/* */i64cm_file_seek (cmFile*file, i64offset);
/* */i64cm_file_seek_to_end (cmFile*file);
/* */i64cm_file_skip (cmFile*file, i64bytes);
/* */i64cm_file_tell (cmFile*file);
/* */cmFileErrorcm_file_close (cmFile*file);
/* */b32cm_file_read (cmFile*file, void*buffer, isizesize);
/* */b32cm_file_write (cmFile*file, voidconst*buffer, isizesize);
/* */i64cm_file_size (cmFile*file);
/* */charconst*cm_file_name (cmFile*file);
/* */cmFileErrorcm_file_truncate (cmFile*file, i64size);
/* */b32cm_file_has_changed (cmFile*file);
/* */cmFileContentscm_file_read_contents(cmAllocatora, b32zero_terminate, charconst*filepath);
/* */voidcm_file_free_contents(cmFileContents*fc);
/* */b32cm_file_exists (charconst*filepath);
/* */cmFileTimecm_file_last_write_time(charconst*filepath);
/* */b32cm_file_copy (charconst*existing_filename, charconst*new_filename, b32fail_if_exists);
/* */b32cm_file_move (charconst*existing_filename, charconst*new_filename);
/* */b32cm_file_remove (charconst*filename);
/* */b32cm_path_is_absolute (charconst*path);
/* */b32cm_path_is_relative (charconst*path);
/* */b32cm_path_is_root (charconst*path);
/* */charconst*cm_path_base_name (charconst*path);
/* */charconst*cm_path_extension (charconst*path);
/* */char*cm_path_get_full_name(cmAllocatora, charconst*path);

hash.h

  • Function
/* */u32cm_adler32(voidconst*data, isizelen);
/* */u32cm_crc32(voidconst*data, isizelen);
/* */u64cm_crc64(voidconst*data, isizelen);
/* */u32cm_fnv32 (voidconst*data, isizelen);
/* */u64cm_fnv64 (voidconst*data, isizelen);
/* */u32cm_fnv32a(voidconst*data, isizelen);
/* */u64cm_fnv64a(voidconst*data, isizelen);
/* */u32cm_murmur32(voidconst*data, isizelen);
/* */u64cm_murmur64(voidconst*data, isizelen);
/* */u32cm_murmur32_seed(voidconst*data, isizelen, u32seed);
/* */u64cm_murmur64_seed(voidconst*data, isizelen, u64seed);

hashtable.h

#defineCM_TABLE(PREFIX, NAME, FUNC, VALUE)
#defineCM_TABLE_DECLARE(PREFIX, NAME, FUNC, VALUE)
#defineCM_TABLE_DEFINE(NAME, FUNC, VALUE)
  • Struct
/* * cmHashTableFindResult */typedefstructcmHashTableFindResult {
isizehash_index;
isizeentry_prev;
isizeentry_index;
} cmHashTableFindResult;

header.h

#define_CRT_SECURE_NO_WARNINGS#define_GNU_SOURCE#define_LARGEFILE64_SOURCE#defineWIN32_LEAN_AND_MEAN #define WIN32_MEAN_AND_LEAN #defineVC_EXTRALEAN#defineNOMINMAX

memory.h

#defineCM_DEFAULT_MEMORY_ALIGNMENT#defineCM_DEFAULT_ALLOCATOR_FLAGS
  • Struct
/* * cmVirtualMemory */typedefstructcmVirtualMemory {
void*data;
isizesize;
} cmVirtualMemory;
/* * cmVirtualMemory */typedefenumcmAllocationType {
cmAllocation_Alloc,
cmAllocation_Free,
cmAllocation_FreeAll,
cmAllocation_Resize,
} cmAllocationType;
/* * cmAllocator */typedefstructcmAllocator {
cmAllocatorProc*proc;
void*data;
} cmAllocator;
/* * cmAllocatorFlag */typedefenumcmAllocatorFlag {
cmAllocatorFlag_ClearToZero ,
} cmAllocatorFlag;
/* * cmArena */typedefstructcmArena {
cmAllocatorbacking;
void*physical_start;
isizetotal_size;
isizetotal_allocated;
isizetemp_count;
} cmArena;
  • Function
/* */b32cm_is_power_of_two (isizex);
/* */void*cm_align_forward (void*ptr, isizealignment);
/* */void*cm_pointer_add (void*ptr, isizebytes);
/* */void*cm_pointer_sub (void*ptr, isizebytes);
/* */voidconst*cm_pointer_add_const (voidconst*ptr, isizebytes);
/* */voidconst*cm_pointer_sub_const (voidconst*ptr, isizebytes);
/* */isizecm_pointer_diff (voidconst*begin, voidconst*end);
/* */voidcm_zero_size (void*ptr, isizesize);
/* */voidcm_zero_item (void*t)
/* */voidcm_zero_array (void*a, count)
/* */void*cm_memcopy (void*dest, voidconst*source, isizesize);
/* */void*cm_memmove (void*dest, voidconst*source, isizesize);
/* */void*cm_memset (void*data, u8byte_value, isizesize);
/* */i32cm_memcompare (voidconst*s1, voidconst*s2, isizesize);
/* */voidcm_memswap (void*i, void*j, isizesize);
/* */voidconst*cm_memchr (voidconst*data, u8byte_value, isizesize);
/* */voidconst*cm_memrchr (voidconst*data, u8byte_value, isizesize);
/* */cm_memcopy_array (dst, src, count);
/* */cm_memmove_array (dst, src, count) /* */cmVirtualMemorycm_virtual_memory (void*data, isizesize);
/* */cmVirtualMemorycm_vm_alloc (void*addr, isizesize);
/* */b32cm_vm_free (cmVirtualMemoryvm);
/* */cmVirtualMemorycm_vm_trim (cmVirtualMemoryvm, isizelead_size, isizesize);
/* */b32cm_vm_purge (cmVirtualMemoryvm);
/* */isizecm_virtual_memory_page_size (isize*alignment_out);
/* */void*cm_alloc_align (cmAllocatora, isizesize, isizealignment);
/* */void*cm_alloc (cmAllocatora, isizesize);
/* */voidcm_free (cmAllocatora, void*ptr);
/* */voidcm_free_all (cmAllocatora);
/* */void*cm_resize (cmAllocatora, void*ptr, isizeold_size, isizenew_size);
/* */void*cm_resize_align (cmAllocatora, void*ptr, isizeold_size, isizenew_size, isizealignment);
/* */void*cm_alloc_copy (cmAllocatora, voidconst*src, isizesize);
/* */void*cm_alloc_copy_align (cmAllocatora, voidconst*src, isizesize, isizealignment);
/* */char*cm_alloc_str (cmAllocatora, charconst*str);
/* */char*cm_alloc_str_len (cmAllocatora, charconst*str, isizelen);
/* */cm_alloc_item (allocator_, Type)
/* */cm_alloc_array (allocator_, Type, count)
/* */void*gb_default_resize_align (cmAllocatora, void*ptr, isizeold_size, isizenew_size, isizealignment);
/* */cmAllocatorcm_heap_allocator (void);
/* */cm_malloc(sz);
/* */cm_mfree(ptr);
/* */voidcm_arena_init_from_memory (cmArena*arena, void*start, isizesize);
/* */voidcm_arena_init_from_allocator (cmArena*arena, cmAllocatorbacking, isizesize);
/* */voidcm_arena_init_sub (cmArena*arena, cmArena*parent_arena, isizesize);
/* */voidcm_arena_free (cmArena*arena);
/* */isizecm_arena_alignment_of (cmArena*arena, isizealignment);
/* */isizecm_arena_size_remaining (cmArena*arena, isizealignment);
/* */voidcm_arena_check (cmArena*arena);
/* */cmAllocatorcm_arena_allocator (cmArena*arena);

math.h

#defineCM_MATH_INFINITYF#defineCM_MATH_NANF#defineCM_MATH_PZEROF#defineCM_MATH_NZEROF#defineCM_MATH_INFINITY#defineCM_MATH_NAN#defineCM_MATH_PZERO#defineCM_MATH_NZERO#defineCM_MATH_INFINITYL#defineCM_MATH_NANL#defineCM_MATH_PZEROL#defineCM_MATH_NZEROL#defineCM_SIZEOF_CHAR#defineCM_SIZEOF_BYTE#defineCM_SIZEOF_INT#defineCM_SIZEOF_INTP#defineCM_SIZEOF_UINTP#defineCM_SIZEOF_HALF#defineCM_SIZEOF_LONG#defineCM_SIZEOF_LONGLONG#defineCM_SIZEOF_DOUBLE#defineCM_SIZEOF_LONGDOUBLE#defineCM_SIZEOF_DATETIME#defineCM_SIZEOF_TIMEDELTA#defineCM_CHAR_BIT#defineCM_BYTE_FMT#defineCM_UBYTE_FMT#defineCM_SHORT_FMT#defineCM_USHORT_FMT#defineCM_INT_FMT#defineCM_UINT_FMT#defineCM_LONG_FMT#defineCM_ULONG_FMT#defineCM_HALF_FMT#defineCM_FLOAT_FMT#defineCM_DOUBLE_FMT#defineCM_LONGLONG_FMT#defineCM_ULONGLONG_FMT#defineCM_LONGLONG_SUFFIX(x)
#defineCM_ULONGLONG_SUFFIX(x)
#definecm_isnan(x)
#definecm_isfinite(x)
#definecm_isinf(x)
#defineCM_EXTRACT_WORDS(ix0,ix1,d)
#defineCM_GET_HIGH_WORD(i,d)
#defineCM_GET_LOW_WORD(i,d)
#defineCM_SET_HIGH_WORD(d,v)
#defineCM_SET_LOW_WORD(d,v)
#defineCM_INSERT_WORDS(d,ix0,ix1)
#defineCM_MATH_E#defineCM_MATH_LOG2E#defineCM_MATH_LOG10E#defineCM_MATH_LOGE2#defineCM_MATH_LOGE10#defineCM_MATH_PI#defineCM_MATH_PI_2 #define CM_MATH_PI_4
#defineCM_MATH_1_PI#defineCM_MATH_2_PI#defineCM_MATH_EULER#defineCM_MATH_SQRT2#defineCM_MATH_SQRT1_2#defineCM_MATH_Ef#defineCM_MATH_LOG2Ef#defineCM_MATH_LOG10Ef#defineCM_MATH_LOGE2f#defineCM_MATH_LOGE10f#defineCM_MATH_PIf#defineCM_MATH_PI_2f#defineCM_MATH_PI_4f#defineCM_MATH_1_PIf#defineCM_MATH_2_PIf#defineCM_MATH_EULERf#defineCM_MATH_SQRT2f#defineCM_MATH_SQRT1_2f#defineCM_MATH_El#defineCM_MATH_LOG2El#defineCM_MATH_LOG10El#defineCM_MATH_LOGE2l#defineCM_MATH_LOGE10l#defineCM_MATH_PIl#defineCM_MATH_PI_2l#defineCM_MATH_PI_4l#defineCM_MATH_1_PIl#defineCM_MATH_2_PIl#defineCM_MATH_EULERl#defineCM_MATH_SQRT2l#defineCM_MATH_SQRT1_2l#definecm_math_degrees#definecm_math_degreesf#definecm_math_degreesl#definecm_math_radians#definecm_math_radiansf#definecm_math_radiansl
  • Function
/* * Integer functions. *//* */u32cm_math_gcdu(u32a, u32b);
/* */u32cm_math_lcmu(u32a, u32b);
/* */ulcm_math_gcdul(ula, ulb);
/* */ulcm_math_lcmul(ula, ulb);
/* */ullcm_math_gcdull(ulla, ullb);
/* */ullcm_math_lcmull(ulla, ullb);
/* */u32cm_math_gcd(u32a, u32b);
/* */u32cm_math_lcm(u32a, u32b);
/* */ilcm_math_gcdl(ila, ilb);
/* */ilcm_math_lcml(ila, ilb);
/* */illcm_math_gcdll(illa, illb);
/* */illcm_math_lcmll(illa, illb);
/* */ubytecm_math_rshiftuhh(ubytea, ubyteb);
/* */ubytecm_math_lshiftuhh(ubytea, ubyteb);
/* */u16cm_math_rshiftuh(u16a, u16b);
/* */u16cm_math_lshiftuh(u16a, u16b);
/* */u32cm_math_rshiftu(u32a, u32b);
/* */u32cm_math_lshiftu(u32a, u32b);
/* */ulcm_math_rshiftul(ula, ulb);
/* */ulcm_math_lshiftul(ula, ulb);
/* */ullcm_math_rshiftull(ulla, ullb);
/* */ullcm_math_lshiftull(ulla, ullb);
/* */ibytecm_math_rshifthh(ibytea, ibyteb);
/* */ibytecm_math_lshifthh(ibytea, ibyteb);
/* */i16cm_math_rshifth(i16a, i16b);
/* */i16cm_math_lshifth(i16a, i16b);
/* */i32cm_math_rshift(i32a, i32b);
/* */i32cm_math_lshift(i32a, i32b);
/* */ilcm_math_rshiftl(ila, ilb);
/* */ilcm_math_lshiftl(ila, ilb);
/* */illcm_math_rshiftll(illa, illb);
/* */illcm_math_lshiftll(illa, illb);
/* * float C99 math functions *//* */f32cm_math_sinf(f32x);
/* */f32cm_math_cosf(f32x);
/* */f32cm_math_tanf(f32x);
/* */f32cm_math_sinhf(f32x);
/* */f32cm_math_coshf(f32x);
/* */f32cm_math_tanhf(f32x);
/* */f32cm_math_fabsf(f32x);
/* */f32cm_math_floorf(f32x);
/* */f32cm_math_ceilf(f32x);
/* */f32cm_math_rintf(f32x);
/* */f32cm_math_truncf(f32x);
/* */f32cm_math_sqrtf(f32x);
/* */f32cm_math_cbrtf(f32x);
/* */f32cm_math_log10f(f32x);
/* */f32cm_math_logf(f32x);
/* */f32cm_math_expf(f32x);
/* */f32cm_math_expm1f(f32x);
/* */f32cm_math_asinf(f32x);
/* */f32cm_math_acosf(f32x);
/* */f32cm_math_atanf(f32x);
/* */f32cm_math_asinhf(f32x);
/* */f32cm_math_acoshf(f32x);
/* */f32cm_math_atanhf(f32x);
/* */f32cm_math_log1pf(f32x);
/* */f32cm_math_exp2f(f32x);
/* */f32cm_math_log2f(f32x);
/* */f32cm_math_atan2f(f32x, f32y);
/* */f32cm_math_hypotf(f32x, f32y);
/* */f32cm_math_powf(f32x, f32y);
/* */f32cm_math_fmodf(f32x, f32y);
/* */f32cm_math_modff(f32x, f32*y);
/* */f32cm_math_frexpf(f32x, i32*y);
/* */f32cm_math_ldexpf(f32x, i32y);
/* */f32cm_math_copysignf(f32x, f32y);
/* */f32cm_math_nextafterf(f32x, f32y);
/* */f32cm_math_spacingf(f32x);
/* * long double C99 math functions *//* */fldcm_math_sinl(fldx);
/* */fldcm_math_cosl(fldx);
/* */fldcm_math_tanl(fldx);
/* */fldcm_math_sinhl(fldx);
/* */fldcm_math_coshl(fldx);
/* */fldcm_math_tanhl(fldx);
/* */fldcm_math_fabsl(fldx);
/* */fldcm_math_floorl(fldx);
/* */fldcm_math_ceill(fldx);
/* */fldcm_math_rintl(fldx);
/* */fldcm_math_truncl(fldx);
/* */fldcm_math_sqrtl(fldx);
/* */fldcm_math_cbrtl(fldx);
/* */fldcm_math_log10l(fldx);
/* */fldcm_math_logl(fldx);
/* */fldcm_math_expl(fldx);
/* */fldcm_math_expm1l(fldx);
/* */fldcm_math_asinl(fldx);
/* */fldcm_math_acosl(fldx);
/* */fldcm_math_atanl(fldx);
/* */fldcm_math_asinhl(fldx);
/* */fldcm_math_acoshl(fldx);
/* */fldcm_math_atanhl(fldx);
/* */fldcm_math_log1pl(fldx);
/* */fldcm_math_exp2l(fldx);
/* */fldcm_math_log2l(fldx);
/* */fldcm_math_atan2l(fldx, fldy);
/* */fldcm_math_hypotl(fldx, fldy);
/* */fldcm_math_powl(fldx, fldy);
/* */fldcm_math_fmodl(fldx, fldy);
/* */fldcm_math_modfl(fldx, fld*y);
/* */fldcm_math_frexpl(fldx, int*y);
/* */fldcm_math_ldexpl(fldx, inty);
/* */fldcm_math_copysignl(fldx, fldy);
/* */fldcm_math_nextafterl(fldx, fldy);
/* */fldcm_math_spacingl(fldx);
/* * Non standard functions *//* */f64cm_math_deg2rad(f64x);
/* */f64cm_math_rad2deg(f64x);
/* */f64cm_math_logaddexp(f64x, f64y);
/* */f64cm_math_logaddexp2(f64x, f64y);
/* */f64cm_math_divmod(f64x, f64y, f64*modulus);
/* */f64cm_math_heaviside(f64x, f64h0);
/* */f32cm_math_deg2radf(f32x);
/* */f32cm_math_rad2degf(f32x);
/* */f32cm_math_logaddexpf(f32x, f32y);
/* */f32cm_math_logaddexp2f(f32x, f32y);
/* */f32cm_math_divmodf(f32x, f32y, f32*modulus);
/* */f32cm_math_heavisidef(f32x, f32h0);
/* */fldcm_math_deg2radl(fldx);
/* */fldcm_math_rad2degl(fldx);
/* */fldcm_math_logaddexpl(fldx, fldy);
/* */fldcm_math_logaddexp2l(fldx, fldy);
/* */fldcm_math_divmodl(fldx, fldy, fld*modulus);
/* */fldcm_math_heavisidel(fldx, fldh0);
/* * Complex declarations *//* */inlinec64cm_math_cpack(f64x, f64y);
/* */inlinec32cm_math_cpackf(f32x, f32y);
/* */inlinecldcm_math_cpackl(fldx, fldy);
/* */inlinef64cm_math_creal(c64z);
/* */inlinef64cm_math_cimag(c64z);
/* */inlinef32cm_math_crealf(c32z);
/* */inlinef32cm_math_cimagf(c32z);
/* */inlinefldcm_math_creall(cldz);
/* */inlinefldcm_math_cimagl(cldz);
/* * Double precision complex functions *//* */f64cm_math_cabs(c64z);
/* */f64cm_math_carg(c64z);
/* */c64cm_math_cexp(c64z);
/* */c64cm_math_clog(c64z);
/* */c64cm_math_cpow(c64x, c64y);
/* */c64cm_math_csqrt(c64z);
/* */c64cm_math_ccos(c64z);
/* */c64cm_math_csin(c64z);
/* */c64cm_math_ctan(c64z);
/* */c64cm_math_ccosh(c64z);
/* */c64cm_math_csinh(c64z);
/* */c64cm_math_ctanh(c64z);
/* */c64cm_math_cacos(c64z);
/* */c64cm_math_casin(c64z);
/* */c64cm_math_catan(c64z);
/* */c64cm_math_cacosh(c64z);
/* */c64cm_math_casinh(c64z);
/* */c64cm_math_catanh(c64z);
/* * Single precision complex functions *//* */f32cm_math_cabsf(c32z);
/* */f32cm_math_cargf(c32z);
/* */c32cm_math_cexpf(c32z);
/* */c32cm_math_clogf(c32z);
/* */c32cm_math_cpowf(c32x, c32y);
/* */c32cm_math_csqrtf(c32z);
/* */c32cm_math_ccosf(c32z);
/* */c32cm_math_csinf(c32z);
/* */c32cm_math_ctanf(c32z);
/* */c32cm_math_ccoshf(c32z);
/* */c32cm_math_csinhf(c32z);
/* */c32cm_math_ctanhf(c32z);
/* */c32cm_math_cacosf(c32z);
/* */c32cm_math_casinf(c32z);
/* */c32cm_math_catanf(c32z);
/* */c32cm_math_cacoshf(c32z);
/* */c32cm_math_casinhf(c32z);
/* */c32cm_math_catanhf(c32z);
/* * Extended precision complex functions *//* */fldcm_math_cabsl(cldz);
/* */fldcm_math_cargl(cldz);
/* */cldcm_math_cexpl(cldz);
/* */cldcm_math_clogl(cldz);
/* */cldcm_math_cpowl(cldx, cldy);
/* */cldcm_math_csqrtl(cldz);
/* */cldcm_math_ccosl(cldz);
/* */cldcm_math_csinl(cldz);
/* */cldcm_math_ctanl(cldz);
/* */cldcm_math_ccoshl(cldz);
/* */cldcm_math_csinhl(cldz);
/* */cldcm_math_ctanhl(cldz);
/* */cldcm_math_cacosl(cldz);
/* */cldcm_math_casinl(cldz);
/* */cldcm_math_catanl(cldz);
/* */cldcm_math_cacoshl(cldz);
/* */cldcm_math_casinhl(cldz);
/* */cldcm_math_catanhl(cldz);

misc.h

  • Function
/* */voidcm_exit (u32code);
/* */voidcm_yield (void);
/* */voidcm_set_env (charconst*name, charconst*value);
/* */voidcm_unset_env (charconst*name);
/* */u16cm_endian_swap16 (u16i);
/* */u32cm_endian_swap32 (u32i);
/* */u64cm_endian_swap64 (u64i);
/* */isizecm_count_set_bits (u64mask);

mutex.h

  • Struct
/* * Windows */typedefstructcmMutex {
CRITICAL_SECTIONwin32_critical_section;
} cmMutex;
/* * Unix & Linux */typedefstructcmMutex {
pthread_mutex_tpthread_mutex;
pthread_mutexattr_tpthread_mutexattr;
} cmMutex;
  • Function
/* */voidcm_mutex_init (cmMutex*m);
/* */voidcm_mutex_destroy (cmMutex*m);
/* */voidcm_mutex_lock (cmMutex*m);
/* */b32cm_mutex_try_lock (cmMutex*m);
/* */voidcm_mutex_unlock (cmMutex*m);

print.h

  • Function
/* */isizecm_printf (charconst*fmt, ...) CM_PRINTF_ARGS(1);
/* */isizecm_printf_va (charconst*fmt, va_listva);
/* */isizecm_printf_err (charconst*fmt, ...) CM_PRINTF_ARGS(1);
/* */isizecm_printf_err_va (charconst*fmt, va_listva);
/* */isizecm_fprintf (cmFile*f, charconst*fmt, ...) CM_PRINTF_ARGS(2);
/* */isizecm_fprintf_va (cmFile*f, charconst*fmt, va_listva);
/* */char*cm_bprintf (charconst*fmt, ...) CM_PRINTF_ARGS(1);
/* */char*cm_bprintf_va (charconst*fmt, va_listva);
/* */isizecm_snprintf (char*str, isizen, charconst*fmt, ...) CM_PRINTF_ARGS(3);

random.h

  • Struct
/* */typedefstructcmRandom {
u32offsets[8];
u32value;
} cmRandom;
  • Function
/* */voidcm_random_init (cmRandom*r);
/* */u32cm_random_gen_u32 (cmRandom*r);
/* */u32cm_random_gen_u32_unique (cmRandom*r);
/* */u64cm_random_gen_u64 (cmRandom*r);
/* */isizecm_random_gen_isize (cmRandom*r);
/* */i64cm_random_range_i64 (cmRandom*r, i64lower_inc, i64higher_inc);
/* */isizecm_random_range_isize (cmRandom*r, isizelower_inc, isizehigher_inc);
/* */f64cm_random_range_f64 (cmRandom*r, f64lower_inc, f64higher_inc);

semaphore.h

  • Struct
/* * Window */typedefstructcmSemaphore { void*win32_handle;} cmSemaphore;
/* * OSX */typedefstructcmSemaphore { semaphore_tosx_handle; } cmSemaphore;
/* * Unix */typedefstructcmSemaphore { sem_tunix_handle; } cmSemaphore;
  • Function
/* */voidcm_semaphore_init (cmSemaphore*s);
/* */voidcm_semaphore_destroy (cmSemaphore*s);
/* */voidcm_semaphore_post (cmSemaphore*s, i32count);
/* */voidcm_semaphore_release (cmSemaphore*s);
/* */voidcm_semaphore_wait (cmSemaphore*s);

sortsearch.h

  • Function
/* */int (*cm_i16_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */int (*cm_i32_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */int (*cm_i64_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */int (*cm_isize_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */int (*cm_str_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */int (*cm_f32_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */int (*cm_f64_cmp (isizeoffset))(voidconst*a, voidconst*b);
/* */cm_sort_array(array, count, compare_proc) ;
/* */voidcm_sort(void*base, isizecount, isizesize, cmCompareProccompare_proc);
/* */cm_radix_sort(Type);
/* */voidcm_radix_sort_u8 (u8*items, u8*temp, isizecount);
/* */voidcm_radix_sort_u16 (u16*items, u16*temp, isizecount);
/* */voidcm_radix_sort_u32 (u32*items, u32*temp, isizecount);
/* */voidcm_radix_sort_u64 (u64*items, u64*temp, isizecount);
/* */cm_binary_search_array(array, count, key, compare_proc);
/* */isizecm_binary_search(voidconst*base, isizecount, isizesize, voidconst*key, cmCompareProccompare_proc);
/* */cm_shuffle_array(array, count);
/* */voidcm_shuffle(void*base, isizecount, isizesize);
/* */cm_reverse_array(array, count);
/* */voidcm_reverse(void*base, isizecount, isizesize);

string.h

  • Struct
/* */typedefchar*cmString;
/* */typedefstructcmStringHeader {
cmAllocatorallocator;
isizelength;
isizecapacity;
} cmStringHeader;
  • Function
/* */cmStringcm_string_make_reserve (cmAllocatora, isizecapacity);
/* */cmStringcm_string_make (cmAllocatora, charconst*str);
/* */cmStringcm_string_make_length (cmAllocatora, voidconst*str, isizenum_bytes);
/* */voidcm_string_free (cmStringstr);
/* */cmStringcm_string_duplicate (cmAllocatora, cmStringconststr);
/* */isizecm_string_length (cmStringconststr);
/* */isizecm_string_capacity (cmStringconststr);
/* */isizecm_string_available_space(cmStringconststr);
/* */voidcm_string_clear (cmStringstr);
/* */cmStringcm_string_append (cmStringstr, cmStringconstother);
/* */cmStringcm_string_append_length (cmStringstr, voidconst*other, isizenum_bytes);
/* */cmStringcm_string_appendc (cmStringstr, charconst*other);
/* */cmStringcm_string_append_rune (cmStringstr, Runer);
/* */cmStringcm_string_append_fmt (cmStringstr, charconst*fmt, ...);
/* */cmStringcm_string_set (cmStringstr, charconst*cstr);
/* */cmStringcm_string_make_space_for (cmStringstr, isizeadd_len);
/* */isizecm_string_allocation_size(cmStringconststr);
/* */b32cm_string_are_equal (cmStringconstlhs, cmStringconstrhs);
/* */cmStringcm_string_trim (cmStringstr, charconst*cut_set);
/* */cmStringcm_string_trim_space (cmStringstr);

thread.h

  • Struct
/* * Window */typedefstructcmThread {
void*win32_handle;
cmThreadProc*proc;
void*user_data;
isizeuser_index;
isizevolatilereturn_value;
cmSemaphoresemaphore;
isizestack_size;
b32volatileis_running;
} cmThread;
/* * Posix */typedefstructcmThread {
pthread_tposix_handle;
cmThreadProc*proc;
void*user_data;
isizeuser_index;
isizevolatilereturn_value;
cmSemaphoresemaphore;
isizestack_size;
b32volatileis_running;
} cmThread;
/* */typedefstructcmSync {
i32target; // Target Number of threadsi32current; // Threads to hiti32waiting; // Threads waitingcmMutexstart;
cmMutexmutex;
cmSemaphorerelease;
} cmSync;
  • Function
/* */voidcm_thread_init (cmThread*t);
/* */voidcm_thread_destroy (cmThread*t);
/* */voidcm_thread_start (cmThread*t, cmThreadProc*proc, void*data);
/* */voidcm_thread_start_with_stack (cmThread*t, cmThreadProc*proc, void*data, isizestack_size);
/* */voidcm_thread_join (cmThread*t);
/* */b32cm_thread_is_running (cmThreadconst*t);
/* */u32cm_thread_current_id (void);
/* */voidcm_thread_set_name (cmThread*t, charconst*name);
/* */voidcm_sync_init (cmSync*s);
/* */voidcm_sync_destroy (cmSync*s);
/* */voidcm_sync_set_target (cmSync*s, i32count);
/* */voidcm_sync_release (cmSync*s);
/* */i32cm_sync_reach (cmSync*s);
/* */voidcm_sync_reach_and_wait (cmSync*s);

time.h

  • Function
/* */u64cm_rdtsc (void);
/* */f64cm_time_now (void);
/* */u64cm_utc_time_now(void);
/* */voidcm_sleep_ms (u32ms);

utf8.h

  • Function
/* */isizecm_utf8_strlen (u8const*str);
/* */isizecm_utf8_strnlen(u8const*str, isizemax_len);
/* */u16*cm_utf8_to_ucs2 (u16*buffer, isizelen, u8const*str);
/* */u8*cm_ucs2_to_utf8 (u8*buffer, isizelen, u16const*str);
/* */u16*cm_utf8_to_ucs2_buf (u8const*str);
/* */u8*cm_ucs2_to_utf8_buf (u16const*str);
/* */isizecm_utf8_decode (u8const*str, isizestr_len, Rune*codepoint);
/* */isizecm_utf8_codepoint_size (u8const*str, isizestr_len);
/* */isizecm_utf8_encode_rune (u8buf[4], Runer);

utils.h

#defineNULL#defineinline#definecm_restrict#definecm_inline#definecm_no_inline#definecm_thread_local#definecast(Type)
#definecm_size_of(x)
#definecm_count_of(x)
#definecm_offset_of(Type, element)
#definecm_align_of(Type)
#definecm_swap(Type, a, b)
#definecm_global#definecm_internal#definecm_local_persist#definecm_unused(x)
#definevprtcast(x)
#definevoidcast(x)
#defineCM_BIT(x)
#defineCM_MIN(a, b)
#defineCM_MAX(a, b)
#defineCM_MIN3(a, b, c)
#defineCM_MAX3(a, b, c)
#defineCM_CLAMP(x, lower, upper)
#defineCM_CLAMP01(x)
#defineCM_IS_BETWEEN(x, lower, upper)
#defineCM_ABS(x)
#defineCM_MASK_SET(var, set, mask)
#defineCM_PRINTF_ARGS(FMT)

About

c/c++ marcro and utility

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages