summaryrefslogtreecommitdiffhomepage
path: root/dev/LibC++/defines.h
blob: 85b3e5357a2161ea10b819c2c6ead69421498720 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/* -------------------------------------------

	Copyright (C) 2024-2025 Amlal EL Mahrouss, all rights reserved.

------------------------------------------- */

#ifndef __LIBCOMPILER_DEFINES_H__
#define __LIBCOMPILER_DEFINES_H__

extern "C"
{
#include <stdint.h>
#include <stddef.h>
}

#ifndef __GNUC__

typedef __SIZE_TYPE__ size_t;

#ifdef __LP64__
typedef long int ssize_t;
#else
typedef int ssize_t;
#endif // __LP64__

typedef void*		  ptr_type;
typedef __SIZE_TYPE__ size_type;

typedef size_t ptrdiff_t;
typedef size_t uintptr_t;
typedef void*  voidptr_t;
typedef void*  any_t;
typedef char*  caddr_t;

#ifndef NULL
#define NULL ((voidptr_t)0)
#endif // !null

#ifdef __GNUC__
#include <LibC++/alloca.h>
#elif defined(__LIBCOMPILER__)
#define __alloca(sz) __lc_alloca(sz)
#endif

#define __deref(ptr) (*(ptr))

#ifdef __cplusplus
#define __init_decl() \
	extern "C"        \
	{
#define __fini_decl() \
	}                 \
	;
#else
#define __init_decl()
#define __fini_decl()
#endif

#if __has_builtin(__builtin_alloca)
#define alloca(sz) __builtin_alloca(sz)
#ifdef __alloca
#undef __alloca
#endif
#define __alloca alloca
#else
#warning ! alloca not detected !
#endif

typedef long long		   off_t;
typedef unsigned long long uoff_t;

typedef union float_cast {
	struct
	{
		unsigned int mantissa : 23;
		unsigned int exponent : 8;
		unsigned int sign : 1;
	};

	float f;
} __attribute__((packed)) float_cast_t;

typedef union double_cast {
	struct
	{
		unsigned long long int mantissa : 52;
		unsigned int		   exponent : 11;
		unsigned int		   sign : 1;
	};

	double f;
} __attribute__((packed)) double_cast_t;

#endif // ifndef __GNUC__

#endif /* __LIBCOMPILER_DEFINES_H__ */