Definen LLP64 data model for code completion

This change should not be interpreted as an intent to support MSVC which
appears to live on in VSCode IntelliSense for what's dead will never die
This commit is contained in:
Justine Tunney 2021-02-04 16:55:56 -08:00
parent 3384a5a48c
commit 74d48f7cb6
5 changed files with 114 additions and 7 deletions

1
.vscode/vscode.h vendored
View file

@ -1,5 +1,4 @@
#define __VSCODE_INTELLISENSE__ 1
#define __LP64__ /* TODO: this is a lazy kludge */
#include "libc/integral/normalize.inc"
#if 0

View file

@ -27,8 +27,21 @@
* optimizations.
*/
intptr_t(atomic_load)(void *p, size_t n) {
intptr_t x;
x = 0;
memcpy(&x, p, MAX(n, sizeof(x)));
intptr_t x = 0;
switch (n) {
case 1:
__builtin_memcpy(&x, p, 1);
return x;
case 2:
__builtin_memcpy(&x, p, 2);
return x;
case 4:
__builtin_memcpy(&x, p, 4);
return x;
case 8:
__builtin_memcpy(&x, p, 8);
return x;
default:
return 0;
}
}

View file

@ -27,6 +27,20 @@
* optimizations.
*/
intptr_t(atomic_store)(void *p, intptr_t x, size_t n) {
memcpy(p, &x, MAX(n, sizeof(x)));
switch (n) {
case 1:
__builtin_memcpy(p, &x, 1);
return x;
case 2:
__builtin_memcpy(p, &x, 2);
return x;
case 4:
__builtin_memcpy(p, &x, 4);
return x;
case 8:
__builtin_memcpy(p, &x, 8);
return x;
default:
return 0;
}
}

79
libc/integral/llp64.inc Normal file
View file

@ -0,0 +1,79 @@
#define __INT8_MAX__ 0x7f
#define __UINT8_MAX__ 0xff
#define __INT16_MAX__ 0x7fff
#define __UINT16_MAX__ 0xffff
#define __SHRT_MAX__ 0x7fff
#define __INT_MAX__ 0x7fffffff
#define __INT32_MAX__ 0x7fffffff
#define __UINT32_MAX__ 0xffffffffu
#define __INT64_MAX__ 0x7fffffffffffffffl
#define __UINT64_MAX__ 0xffffffffffffffffull
#define __SIZE_MAX__ 0xffffffffffffffffull
#define __INTPTR_MAX__ 0x7fffffffffffffffll
#define __UINTPTR_MAX__ 0xffffffffffffffffull
#define __WINT_MAX__ 0xffffffffu
#define __SIZEOF_SHORT__ 2
#define __SIZEOF_INT__ 4
#define __SIZEOF_LONG__ 4
#define __SIZEOF_LONG_LONG__ 8
#define __SIZEOF_POINTER__ 8
#define __SIZEOF_PTRDIFF_T__ 8
#define __SIZEOF_SIZE_T__ 4
#define __SIZEOF_WCHAR_T__ 4
#define __SIZEOF_WINT_T__ 4
#define __SIZEOF_FLOAT__ 4
#define __SIZEOF_FLOAT128__ 16
#define __SIZEOF_DOUBLE__ 8
#define __SIZEOF_FLOAT80__ 16
#define __SIZEOF_LONG_DOUBLE__ 16
#define __INT8_C(c) c
#define __UINT8_C(c) c
#define __INT16_C(c) c
#define __UINT16_C(c) c
#define __INT32_C(c) c
#define __UINT32_C(c) c##U
#define __INT64_C(c) c##LL
#define __UINT64_C(c) c##ULL
#if !(__ASSEMBLER__ + __LINKER__ + 0)
#define __INT8_TYPE__ signed char
#define __UINT8_TYPE__ unsigned char
#define __INT16_TYPE__ short int
#define __UINT16_TYPE__ short unsigned int
#define __INT32_TYPE__ int
#define __UINT32_TYPE__ unsigned int
#define __INT64_TYPE__ long long int
#define __UINT64_TYPE__ long long unsigned int
#define __INTPTR_TYPE__ long long int
#define __UINTPTR_TYPE__ long long unsigned int
#define __PTRDIFF_TYPE__ long long int
#define __SIZE_TYPE__ unsigned int
#define __WCHAR_TYPE__ int
#define __CHAR16_TYPE__ short unsigned int
#define __CHAR32_TYPE__ unsigned int
#define __WINT_TYPE__ unsigned int
#define __CHAR16_TYPE__ short unsigned int
#define __WCHAR_TYPE__ int
#define __CHAR32_TYPE__ unsigned int
#define __INT_LEAST8_TYPE__ __INT8_TYPE__
#define __UINT_LEAST8_TYPE__ __UINT8_TYPE__
#define __INT_LEAST16_TYPE__ __INT32_TYPE__
#define __UINT_LEAST16_TYPE__ __UINT16_TYPE__
#define __INT_LEAST32_TYPE__ __INT16_TYPE__
#define __UINT_LEAST32_TYPE__ __UINT32_TYPE__
#define __INT_LEAST64_TYPE__ __INT64_TYPE__
#define __UINT_LEAST64_TYPE__ __UINT64_TYPE__
#define __INT_FAST8_TYPE__ __INT8_TYPE__
#define __UINT_FAST8_TYPE__ __UINT8_TYPE__
#define __INT_FAST16_TYPE__ __INT32_TYPE__
#define __UINT_FAST16_TYPE__ __UINT32_TYPE__
#define __INT_FAST32_TYPE__ __INT32_TYPE__
#define __UINT_FAST32_TYPE__ __UINT32_TYPE__
#define __INT_FAST64_TYPE__ __INT64_TYPE__
#define __UINT_FAST64_TYPE__ __UINT64_TYPE__
#endif

View file

@ -80,6 +80,8 @@
#if defined(__LP64__) && !defined(__INT64_TYPE__)
#include "libc/integral/lp64.inc"
#elif defined(_MSC_VER) && !defined(__INT64_TYPE__)
#include "libc/integral/llp64.inc"
#endif
#if !(__ASSEMBLER__ + __LINKER__ + 0)