1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

bare: stdint.h

This commit is contained in:
Alexander Medvednikov 2019-11-16 11:10:38 +03:00
parent 56fee6835a
commit a545ccb740
3 changed files with 16 additions and 6 deletions

View File

@ -4,6 +4,7 @@ const (
c_headers = ' c_headers = '
//#include <inttypes.h> // int64_t etc
#include <stdio.h> // TODO remove all these includes, define all function signatures and types manually #include <stdio.h> // TODO remove all these includes, define all function signatures and types manually
#include <stdlib.h> #include <stdlib.h>
@ -20,9 +21,9 @@ c_headers = '
#error "The environment is not 32 or 64-bit." #error "The environment is not 32 or 64-bit."
#endif #endif
#if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ || defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN || defined(__BIG_ENDIAN__) || defined(__ARMEB__) || defined(__THUMBEB__) || defined(__AARCH64EB__) || defined(_MIBSEB) || defined(__MIBSEB) || defined(__MIBSEB__) #if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ || defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN || defined(__BIG_ENDIAN__) || defined(__ARMEB__) || defined(__THUMBEB__) || defined(__AARCH64EB__) || defined(_MIBSEB) || defined(__MIBSEB) || defined(__MIBSEB__)
#define TARGET_ORDER_IS_BIG #define TARGET_ORDER_IS_BIG
#elif defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ || defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN || defined(__LITTLE_ENDIAN__) || defined(__ARMEL__) || defined(__THUMBEL__) || defined(__AARCH64EL__) || defined(_MIPSEL) || defined(__MIPSEL) || defined(__MIPSEL__) || defined(_M_AMD64) || defined(_M_X64) || defined(_M_IX86) #elif defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ || defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN || defined(__LITTLE_ENDIAN__) || defined(__ARMEL__) || defined(__THUMBEL__) || defined(__AARCH64EL__) || defined(_MIPSEL) || defined(__MIPSEL) || defined(__MIPSEL__) || defined(_M_AMD64) || defined(_M_X64) || defined(_M_IX86)
#define TARGET_ORDER_IS_LITTLE #define TARGET_ORDER_IS_LITTLE
#else #else
#error "Unknown architecture endianness" #error "Unknown architecture endianness"
@ -168,9 +169,11 @@ var map_int = function() {}
c_builtin_types = ' c_builtin_types = '
//#include <inttypes.h> // int64_t etc
//#include <stdint.h> // int64_t etc
//================================== TYPEDEFS ================================*/ //================================== TYPEDEFS ================================*/
#include <inttypes.h> // int64_t etc
typedef int64_t i64; typedef int64_t i64;
typedef int16_t i16; typedef int16_t i16;
typedef int8_t i8; typedef int8_t i8;

View File

@ -234,7 +234,14 @@ pub fn (v mut V) compile() {
$if js { $if js {
cgen.genln(js_headers) cgen.genln(js_headers)
} $else { } $else {
if !v.pref.is_bare {
cgen.genln('#include <inttypes.h>') // int64_t etc
} else {
cgen.genln('#include <stdint.h>')
}
cgen.genln(c_builtin_types) cgen.genln(c_builtin_types)
if !v.pref.is_bare { if !v.pref.is_bare {
cgen.genln(c_headers) cgen.genln(c_headers)
} }

View File

@ -1,6 +1,6 @@
.intel_syntax noprefix .intel_syntax noprefix
.text .text
.globl _start, syscall5 .globl _start, main__syscall5
_start: _start:
xor rbp,rbp xor rbp,rbp
@ -16,7 +16,7 @@
ret /* should never be reached, but if the OS somehow fails ret /* should never be reached, but if the OS somehow fails
to kill us, it will cause a segmentation fault */ to kill us, it will cause a segmentation fault */
syscall5: main__syscall5:
mov rax,rdi mov rax,rdi
mov rdi,rsi mov rdi,rsi
mov rsi,rdx mov rsi,rdx
@ -26,7 +26,7 @@
syscall syscall
ret ret
syscall6: main__syscall6:
mov rax,rdi mov rax,rdi
mov rdi,rsi mov rdi,rsi
mov rsi,rdx mov rsi,rdx