/**
 * PROJECT:         ExectOS
 * COPYRIGHT:       See COPYING.md in the top level directory
 * FILE:            sdk/xtdk/xtcompat.h
 * DESCRIPTION:     C/C++ compatibility macros
 * DEVELOPERS:      Aiken Harris <harraiken91@gmail.com>
 */

#ifndef __XTDK_XTCOMPAT_H
#define __XTDK_XTCOMPAT_H


/* C/C++ specific code */
#ifndef __XTOS_ASSEMBLER__

#ifdef __cplusplus
    /* C++ definitions */
    #define NULLPTR         nullptr
    #define VIRTUAL         virtual
    #define XTCLINK         extern "C"
    #define XTSYMBOL(Name)  __asm__(Name)

    /* C++ attributes */
    #define MUSTCHECK       [[nodiscard]]
    #define NORETURN        [[noreturn]]
    #define UNUSED          [[maybe_unused]]

    /* C++ boolean type */
    typedef bool BOOLEAN, *PBOOLEAN;
    #define TRUE true
    #define FALSE false

    /* C++ widechar type */
    typedef wchar_t wchar;
#else
    /* C definitions */
    #define NULLPTR         ((void *)0)
    #define VIRTUAL
    #define XTCLINK
    #define XTSYMBOL(Name)

    /* C attributes */
    #define MUSTCHECK       __attribute__((warn_unused_result))
    #define NORETURN        __attribute__((noreturn))
    #define UNUSED          __attribute__((unused))

    /* C boolean type */
    typedef enum _BOOLEAN
    {
        FALSE = 0,
        TRUE = 1
    } BOOLEAN, *PBOOLEAN;

    /* C widechar type */
    typedef unsigned short wchar;
#endif

#endif /* __XTOS_ASSEMBLER__ */
#endif /* __XTDK_XTCOMPAT_H */
