os-k/src/kaleid/include/kaldefs.h

106 lines
2.9 KiB
C
Raw Normal View History

2019-01-01 13:09:57 +01:00
//----------------------------------------------------------------------------//
// GNU GPL OS/K //
// //
// Authors: spectral` //
// NeoX //
// //
// Desc: Kaleid general preprocessor constants //
//----------------------------------------------------------------------------//
#ifndef _KALDEFS_H
#define _KALDEFS_H
//------------------------------------------//
// Actual constants //
//------------------------------------------//
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#ifndef NULL
#define NULL ((void *)0)
#endif
#ifndef INITOK
#define INITOK ((unsigned int)0xCAFEBABE)
#endif
#ifndef DATA_SIZE_BLOCK
#define DATA_SIZE_BLOCK
# define BYTE_SIZE sizeof(char)
# define WORD_SIZE sizeof(short)
# define DWORD_SIZE sizeof(int)
# define QWORD_SIZE sizeof(long)
#endif
#ifndef DATA_ALIGN_BLOCK
#define DATA_ALIGN_BLOCK
# define BYTE_ALIGN alignof(char)
# define WORD_ALIGN alignof(short)
# define DWORD_ALIGN alignof(int)
# define QWORD_ALIGN alignof(long)
#endif
//------------------------------------------//
// Keywords and attributes //
//------------------------------------------//
#ifndef PACKED
#define PACKED __attribute__((packed))
#endif
#ifndef noreturn
#define noreturn __attribute__((noreturn))
#endif
#ifndef alignof
#define alignof _Alignof
#endif
#ifndef likely
#define likely(x) (__builtin_expect((x), 1))
#endif
#ifndef unlikely(x)
#define unlikely(x) (__builtin_expect((x), 0))
#endif
//------------------------------------------//
// API specific macros //
//------------------------------------------//
#ifndef KALAPI
# define KALAPI
#endif
//------------------------------------------//
// Values for APIRET //
//------------------------------------------//
#define STATUS_FAILED(x) ((x) < 0))
#define STATUS_SUCCESS(x) (!STATUS_FAILED(x))
#define SUCCESS (0) // everything went fine
#define FAILED (-1)
#define ERROR FAILED // something went wrong
#define NOT_PERMITTED (-2)
#define ACCESS_DENIED (-3)
#define BAD_ARGUMENT (-4) // invalid arguments
#define BAD_ARG_RANGE (-5) // arguments out of range
#define BAD_ARG_NULL (-6) // unexpected NULL argument
#define TRY_AGAIN (-7) // EAGAIN
//------------------------------------------//
// End of <kaldefs.h> //
//------------------------------------------//
#endif