docs
Loading...
Searching...
No Matches
Defines.h
Go to the documentation of this file.
1///
2/// Copyright (C) 2026 Ultralight, Inc. All rights reserved.
3/// A license is required for commercial use. https://ultralig.ht
4///
5#pragma once
6
7// Needed for limit defines, like INTMAX_MAX, which is used by the std C++ library
8#ifndef __STDC_LIMIT_MACROS
9#define __STDC_LIMIT_MACROS
10#endif
11
12#include <cstdint>
13#include <cstddef>
14#include <limits.h>
15
16#ifdef SWIG
17#define UExport
18#else
19
20#include <Ultralight/Config.h>
21#include <Ultralight/Exports.h>
22
23// Require C++20 Support
24#if defined(_MSC_VER)
25# if _MSC_VER < 1930
26# error This project needs at least Visual Studio 2022 to build
27# elif defined(_MSVC_LANG) && _MSVC_LANG < 202002L
28# error This project must be compiled with /std:c++20 or later
29# endif
30#elif __cplusplus < 202002L
31# error This project can only be compiled with a compiler that supports C++20
32#endif
33
34#if INTPTR_MAX == INT32_MAX
35# define UL_ARCH_32_BIT
36#elif INTPTR_MAX == INT64_MAX
37# define UL_ARCH_64_BIT
38#else
39# error "Unknown CPU architecture: environment not 32 or 64-bit."
40#endif
41
42#if defined(__aarch64__)
43# define UL_ARCH_ARM64
44# if defined(__APPLE__)
45# define UL_ARCH_ARM64_APPLE_SILICON
46# endif
47#endif
48
49#if defined(__WIN32__) || defined(_WIN32)
50# define _thread_local __declspec(thread)
51# ifndef _NATIVE_WCHAR_T_DEFINED
52# define DISABLE_NATIVE_WCHAR_T
53# endif
54#else
55# define _thread_local __thread
56#endif
57
58#ifndef UL_COMPILER_GCC_LIKE
59# if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
60# define UL_COMPILER_GCC_LIKE
61# endif
62#endif
63
64#ifndef UL_ALWAYS_INLINE
65#if defined(UL_COMPILER_GCC_LIKE) && defined(NDEBUG)
66# define UL_ALWAYS_INLINE inline __attribute__((__always_inline__))
67# elif defined(_MSC_VER) && defined(NDEBUG)
68# define UL_ALWAYS_INLINE __forceinline
69# else
70# define UL_ALWAYS_INLINE inline
71# endif
72#endif
73
74#ifndef UL_UNLIKELY
75# if defined(UL_COMPILER_GCC_LIKE)
76# define UL_UNLIKELY(x) __builtin_expect(!!(x), 0)
77# else
78# define UL_UNLIKELY(x) (x)
79# endif
80#endif
81
82#ifndef UL_LIKELY
83# if defined(UL_COMPILER_GCC_LIKE)
84# define UL_LIKELY(x) __builtin_expect(!!(x), 1)
85# else
86# define UL_LIKELY(x) (x)
87# endif
88#endif
89
90#ifndef UL_ALIGN
91 #if defined(UL_COMPILER_GCC_LIKE)
92 #define UL_ALIGN(x) __attribute__((aligned(x)))
93 #elif defined(__cplusplus) && __cplusplus >= 201103L
94 #define UL_ALIGN(x) alignas(x)
95 #elif defined(_MSC_VER)
96 #define UL_ALIGN(x) __declspec(align(x))
97 #else
98 #define UL_ALIGN(x)
99 #endif
100#endif
101
102#endif // #ifdef SWIG
103
104#define ULTRALIGHT_VERSION "2.0.0"
105#define ULTRALIGHT_VERSION_MAJOR 2
106#define ULTRALIGHT_VERSION_MINOR 0
107#define ULTRALIGHT_VERSION_PATCH 0
108
109#define WEBKIT_VERSION "615.1.18.100.1"
110#define WEBKIT_VERSION_MAJOR 615
111#define WEBKIT_VERSION_MINOR 1
112#define WEBKIT_VERSION_TINY 18
113#define WEBKIT_VERSION_MICRO 100
114#define WEBKIT_VERSION_NANO 1
115
116///
117/// The platform token of ULTRALIGHT_USER_AGENT (the parenthesized part), chosen for the
118/// build's target OS. Apple builds report Intel on every architecture, as Safari does.
119///
120#if defined(_WIN32)
121# define ULTRALIGHT_USER_AGENT_PLATFORM "Windows NT 10.0; Win64; x64"
122#elif defined(__APPLE__)
123# define ULTRALIGHT_USER_AGENT_PLATFORM "Macintosh; Intel Mac OS X 10_15_7"
124#elif defined(__linux__) && defined(__aarch64__)
125# define ULTRALIGHT_USER_AGENT_PLATFORM "X11; Linux aarch64"
126#elif defined(__linux__)
127# define ULTRALIGHT_USER_AGENT_PLATFORM "X11; Linux x86_64"
128#else
129# define ULTRALIGHT_USER_AGENT_PLATFORM "Windows NT 10.0; Win64; x64"
130#endif
131
132#define ULTRALIGHT_USER_AGENT "Mozilla/5.0 (" ULTRALIGHT_USER_AGENT_PLATFORM ") " \
133 "AppleWebKit/" WEBKIT_VERSION " (KHTML, like Gecko) " \
134 "Ultralight/" ULTRALIGHT_VERSION " Version/16.4.1 " \
135 "Safari/" WEBKIT_VERSION
136
137#ifdef __cplusplus
138extern "C" {
139#endif
140
141///
142/// Full library version string (corresponds to ULTRALIGHT_VERSION)
143///
145
149
150///
151/// Full WebKit version string (corresponds to WEBKIT_VERSION)
152///
154
160
161#ifdef __cplusplus
162}
163#endif
#define UExport
Definition Exports.h:22
uint32_t UltralightVersionMinor()
uint32_t UltralightVersionPatch()
uint32_t WebKitVersionMinor()
uint32_t WebKitVersionNano()
uint32_t WebKitVersionMicro()
uint32_t WebKitVersionMajor()
uint32_t UltralightVersionMajor()
const char * WebKitVersionString()
Full WebKit version string (corresponds to WEBKIT_VERSION).
uint32_t WebKitVersionTiny()
const char * UltralightVersionString()
Full library version string (corresponds to ULTRALIGHT_VERSION).