robotgo/base/os.h
2022-02-04 00:02:34 -08:00

56 lines
1.4 KiB
C

#pragma once
#ifndef OS_H
#define OS_H
#if !defined(IS_MACOSX) && defined(__APPLE__) && defined(__MACH__)
#define IS_MACOSX
#endif /* IS_MACOSX */
#if !defined(IS_WINDOWS) && (defined(WIN32) || defined(_WIN32) || \
defined(__WIN32__) || defined(__WINDOWS__) || defined(__CYGWIN__))
#define IS_WINDOWS
#endif /* IS_WINDOWS */
#if !defined(USE_X11) && !defined(NUSE_X11) && !defined(IS_MACOSX) && !defined(IS_WINDOWS)
#define USE_X11
#endif /* USE_X11 */
#if defined(IS_WINDOWS)
#define STRICT /* Require use of exact types. */
#define WIN32_LEAN_AND_MEAN 1 /* Speed up compilation. */
#include <windows.h>
#elif !defined(IS_MACOSX) && !defined(USE_X11)
#error "Sorry, this platform isn't supported yet!"
#endif
/* Interval to align by for large buffers (e.g. bitmaps). Must be a power of 2. */
#ifndef BYTE_ALIGN
#define BYTE_ALIGN 4 /* Bytes to align pixel buffers to. */
/* #include <stddef.h> */
/* #define BYTE_ALIGN (sizeof(size_t)) */
#endif /* BYTE_ALIGN */
#if BYTE_ALIGN == 0
/* No alignment needed. */
#define ADD_PADDING(width) (width)
#else
/* Aligns given width to padding. */
#define ADD_PADDING(width) (BYTE_ALIGN + (((width) - 1) & ~(BYTE_ALIGN - 1)))
#endif
#if defined(IS_WINDOWS)
#if defined (_WIN64)
#define RobotGo_64
#else
#define RobotGo_32
#endif
#else
#if defined (__x86_64__)
#define RobotGo_64
#else
#define RobotGo_32
#endif
#endif
#endif /* OS_H */