Skip to content

Instantly share code, notes, and snippets.

@oriapp
Last active June 3, 2024 18:05
Show Gist options
  • Save oriapp/806f5177e218c04f12c4115b90e2fdda to your computer and use it in GitHub Desktop.
Save oriapp/806f5177e218c04f12c4115b90e2fdda to your computer and use it in GitHub Desktop.
Standard Definitions for RorthOS
#ifndef RORTH_STDDEF_H
#define RORTH_STDDEF_H
#ifndef NULL
#ifdef __cplusplus
#define NULL 0
#else
#define NULL ((void *)0)
#endif
#endif
// Define size_t as an unsigned integer type, considering architecture
#if defined(__x86_64__) || defined(_M_X64)
typedef unsigned long size_t;
#else
typedef unsigned int size_t;
#endif
// Define ptrdiff_t as a signed integer type for pointer differences, considering architecture
#if defined(__x86_64__) || defined(_M_X64)
typedef long ptrdiff_t;
#else
typedef int ptrdiff_t;
#endif
// Define wchar_t for wide characters, only if not defined by C++
#ifndef __cplusplus
typedef unsigned short wchar_t;
#endif
// Define max_align_t for the largest alignment requirements
typedef struct {
long long __max_align_ll __attribute__((__aligned__(__alignof__(long long))));
long double __max_align_ld __attribute__((__aligned__(__alignof__(long double))));
} max_align_t;
// Macro to compute the offset of a member in a structure
#define offsetof(type, member) ((size_t) &((type *)0)->member)
// Define a boolean type for systems without stdbool.h
#ifndef __bool_true_false_are_defined
#define bool _Bool
#define true 1
#define false 0
#define __bool_true_false_are_defined 1
#endif
#endif /* RORTH_STDDEF_H */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment