Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions include/dbghelp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the mingw-w64 runtime package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
/*
* Unlike include/intrin.h in this same directory (an empty stub with zero
* dependencies), this is the real mingw-w64 header, and it is NOT
* include-order-independent: its dependency psdk_inc/_dbg_LOAD_IMAGE.h uses
* PSTR/PUCHAR/HANDLE/etc. without defining or including them itself - they
* must already come from <windows.h>. Including this header before
* <windows.h> fails to preprocess. This matches vc/v_win.c's actual order
* (<windows.h>, then <intrin.h>, then <dbghelp.h>), which this bundle's
* bootstrap depends on and has been verified to build; any other consumer
* must include <windows.h> first too.
*/
#ifndef _DBGHELP_
#define _DBGHELP_

#include <_mingw_unicode.h>

#ifdef _WIN64
#ifndef _IMAGEHLP64
#define _IMAGEHLP64
#endif
#endif

#include <psdk_inc/_dbg_LOAD_IMAGE.h>
#include <psdk_inc/_dbg_common.h>

#endif
36 changes: 36 additions & 0 deletions include/intrin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Minimal compatibility shim for MSVC's <intrin.h>.
*
* vlang's vc/v_win.c bootstrap snapshot is always generated with `-cc msvc`
* (see vlang/v's .github/workflows/gen_vc_ci.yml), which makes its cgen
* emit an unconditional `#include <intrin.h>` under `#ifdef _WIN32` (see
* vlang/v's vlib/v/gen/c/cleanc.v, the `g.ccompiler == 'msvc'` branch).
* This toolchain does not otherwise ship that header, so building
* vc/v_win.c directly with the bundled tcc fails before reaching any real
* code.
*
* This is an empty stub, not a ported real intrin.h, because this
* toolchain's own include/_mingw.h unconditionally does
* `#define __INTRIN_H_` (see its line ~146), which is the real
* mingw-w64 intrin.h's own header guard. Since <windows.h> (included
* immediately before this header in vc/v_win.c) pulls in _mingw.h first,
* a real ported intrin.h's body would already be skipped by its own
* guard in that include order - it would silently do nothing, while
* still being unable to preprocess standalone, since this bundle does
* not ship intrin.h's own dependencies (crtdefs.h,
* psdk_inc/intrin-impl.h). An empty stub is the honest version of the
* same no-op, without the missing-dependency failure in any other
* include order.
*
* No definitions are needed here regardless: every call site for the
* handful of MSVC intrinsics vlang's cgen can emit (_umul128, _udiv128,
* _addcarry_u64, _BitScanForward, _BitScanForward64) is wrapped in
* `#if defined(_MSC_VER)` at the C level, so under TCC those branches
* never compile in the first place - portable fallbacks run instead.
* include/winapi/winnt.h (pulled in by <windows.h>) already provides
* working `_BitScanForward`, `_BitScanForward64` and `__faststorefence`
* for this toolchain (see vlang-header-compat.patch).
*/
#ifndef TCC_INTRIN_H_SHIM
#define TCC_INTRIN_H_SHIM
#endif
8 changes: 8 additions & 0 deletions include/poppack.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the mingw-w64 runtime package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#if !(defined(lint) || defined(RC_INVOKED))
#pragma pack(pop)
#endif
52 changes: 52 additions & 0 deletions include/psdk_inc/_dbg_LOAD_IMAGE.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the mingw-w64 runtime package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#pragma once

#ifndef WINAPI
#if defined(_ARM_)
#define WINAPI
#else
#define WINAPI __stdcall
#endif
#endif

#define IMAGEAPI DECLSPEC_IMPORT WINAPI
#define DBHLP_DEPRECIATED __declspec(deprecated)

#define DBHLPAPI IMAGEAPI

#define IMAGE_SEPARATION (64*1024)

typedef struct _LOADED_IMAGE {
PSTR ModuleName;
HANDLE hFile;
PUCHAR MappedAddress;
#ifdef _IMAGEHLP64
PIMAGE_NT_HEADERS64 FileHeader;
#else
PIMAGE_NT_HEADERS32 FileHeader;
#endif
PIMAGE_SECTION_HEADER LastRvaSection;
ULONG NumberOfSections;
PIMAGE_SECTION_HEADER Sections;
ULONG Characteristics;
BOOLEAN fSystemImage;
BOOLEAN fDOSImage;
BOOLEAN fReadOnly;
UCHAR Version;
LIST_ENTRY Links;
ULONG SizeOfImage;
} LOADED_IMAGE,*PLOADED_IMAGE;

#define MAX_SYM_NAME 2000

typedef struct _MODLOAD_DATA {
DWORD ssize;
DWORD ssig;
PVOID data;
DWORD size;
DWORD flags;
} MODLOAD_DATA,*PMODLOAD_DATA;
Loading
Loading