Skip to content

Instantly share code, notes, and snippets.

@nhasbun
Created June 10, 2019 20:06
Show Gist options
  • Select an option

  • Save nhasbun/ae36faad9663a744ec9bbfee438e5627 to your computer and use it in GitHub Desktop.

Select an option

Save nhasbun/ae36faad9663a744ec9bbfee438e5627 to your computer and use it in GitHub Desktop.

Revisions

  1. nhasbun created this gist Jun 10, 2019.
    8 changes: 8 additions & 0 deletions useful_c_macros.h
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    #define BIT(x,n) (((x) >> (n)) & 1)
    #define INSERT_BITS(original, mask, value, num) (original & (~mask)) | (value << num)

    #ifdef __ASSEMBLY__
    #define CAST(type, value) value
    #else
    #define CAST(type, value) ((type)(value))
    #endif