mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-14 15:09:09 +00:00
Make improvements
- Introduce portable sched_getcpu() api - Support GCC's __target_clones__ feature - Make fma() go faster on x86 in default mode - Remove some asan checks from core libraries - WinMain() now ensures $HOME and $USER are defined
This commit is contained in:
parent
d5225a693b
commit
2ab9e9f7fd
192 changed files with 2809 additions and 932 deletions
|
@ -1,18 +1,18 @@
|
|||
#include "libc/nt/codegen.h"
|
||||
.imp advapi32,__imp_SystemFunction036,SystemFunction036
|
||||
.imp BCryptPrimitives,__imp_ProcessPrng,ProcessPrng
|
||||
|
||||
.text.windows
|
||||
.ftrace1
|
||||
RtlGenRandom:
|
||||
ProcessPrng:
|
||||
.ftrace2
|
||||
#ifdef __x86_64__
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
mov __imp_SystemFunction036(%rip),%rax
|
||||
mov __imp_ProcessPrng(%rip),%rax
|
||||
jmp __sysv2nt
|
||||
#elif defined(__aarch64__)
|
||||
mov x0,#0
|
||||
ret
|
||||
#endif
|
||||
.endfn RtlGenRandom,globl
|
||||
.endfn ProcessPrng,globl
|
||||
.previous
|
|
@ -297,6 +297,24 @@ $(LIBC_NT_PSAPI_A).pkg: \
|
|||
|
||||
#───────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
LIBC_NT_ARTIFACTS += LIBC_NT_BCRYPTPRIMITIVES_A
|
||||
LIBC_NT_BCRYPTPRIMITIVES = $(LIBC_NT_BCRYPTPRIMITIVES_A_DEPS) $(LIBC_NT_BCRYPTPRIMITIVES_A)
|
||||
LIBC_NT_BCRYPTPRIMITIVES_A = o/$(MODE)/libc/nt/BCryptPrimitives.a
|
||||
LIBC_NT_BCRYPTPRIMITIVES_A_SRCS := $(wildcard libc/nt/BCryptPrimitives/*.S)
|
||||
LIBC_NT_BCRYPTPRIMITIVES_A_OBJS = $(LIBC_NT_BCRYPTPRIMITIVES_A_SRCS:%.S=o/$(MODE)/%.o)
|
||||
LIBC_NT_BCRYPTPRIMITIVES_A_CHECKS = $(LIBC_NT_BCRYPTPRIMITIVES_A).pkg
|
||||
LIBC_NT_BCRYPTPRIMITIVES_A_DIRECTDEPS = LIBC_NT_KERNEL32
|
||||
LIBC_NT_BCRYPTPRIMITIVES_A_DEPS := $(call uniq,$(foreach x,$(LIBC_NT_BCRYPTPRIMITIVES_A_DIRECTDEPS),$($(x))))
|
||||
$(LIBC_NT_BCRYPTPRIMITIVES_A): \
|
||||
libc/nt/BCryptPrimitives/ \
|
||||
$(LIBC_NT_BCRYPTPRIMITIVES_A).pkg \
|
||||
$(LIBC_NT_BCRYPTPRIMITIVES_A_OBJS)
|
||||
$(LIBC_NT_BCRYPTPRIMITIVES_A).pkg: \
|
||||
$(LIBC_NT_BCRYPTPRIMITIVES_A_OBJS) \
|
||||
$(foreach x,$(LIBC_NT_BCRYPTPRIMITIVES_A_DIRECTDEPS),$($(x)_A).pkg)
|
||||
|
||||
#───────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
# let aarch64 compile these
|
||||
o/$(MODE)/libc/nt/%.o: libc/nt/%.S
|
||||
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) $<
|
||||
|
|
|
@ -362,7 +362,6 @@ imp 'RegisterEventSource' RegisterEventSourceW advapi32 2
|
|||
imp 'ReportEvent' ReportEventW advapi32 9
|
||||
imp 'ReportEventA' ReportEventA advapi32 9
|
||||
imp 'RevertToSelf' RevertToSelf advapi32 0
|
||||
imp 'RtlGenRandom' SystemFunction036 advapi32 2
|
||||
imp 'TraceSetInformation' TraceSetInformation advapi32 # Windows 7+
|
||||
|
||||
# USER32.DLL
|
||||
|
@ -611,6 +610,11 @@ imp 'GetModuleBaseName' GetModuleBaseNameW psapi 4
|
|||
imp 'GetProcessImageFileName' GetProcessImageFileNameW psapi 3
|
||||
imp 'GetProcessMemoryInfo' GetProcessMemoryInfo psapi 3
|
||||
|
||||
# BCryptPrimitives.dll
|
||||
#
|
||||
# Name Actual DLL Arity
|
||||
imp 'ProcessPrng' ProcessPrng BCryptPrimitives 2
|
||||
|
||||
# API-MS-Win-Core-Synch-l1-2-0.dll (Windows 8+)
|
||||
#
|
||||
# Name Actual DLL Arity
|
||||
|
|
|
@ -36,11 +36,11 @@ bool32 TerminateProcess(int64_t hProcess, uint32_t uExitCode);
|
|||
void TerminateThisProcess(uint32_t dwWaitStatus) wontreturn;
|
||||
void ExitProcess(uint32_t uExitCode) wontreturn;
|
||||
uint32_t GetLastError(void) nosideeffect;
|
||||
bool32 CloseHandle(int64_t hObject) dontthrow nocallback;
|
||||
bool32 CloseHandle(int64_t hObject) dontthrow dontcallback;
|
||||
intptr_t GetStdHandle(uint32_t nStdHandle) nosideeffect;
|
||||
bool32 SetStdHandle(uint32_t nStdHandle, int64_t hHandle);
|
||||
bool32 SetDefaultDllDirectories(unsigned dirflags);
|
||||
bool32 RtlGenRandom(void *RandomBuffer, uint32_t RandomBufferLength);
|
||||
bool32 ProcessPrng(void *RandomBuffer, uint32_t RandomBufferLength);
|
||||
uint32_t GetModuleFileName(int64_t hModule, char16_t *lpFilename,
|
||||
uint32_t nSize);
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_NT_TEB_H_
|
||||
#define COSMOPOLITAN_LIBC_NT_TEB_H_
|
||||
#include "libc/intrin/segmentation.h"
|
||||
#include "libc/nt/struct/peb.h"
|
||||
#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
|
||||
|
||||
|
@ -8,19 +7,19 @@
|
|||
* These macros address directly into NT's TEB a.k.a. TIB
|
||||
* Any function that does this needs the `dontasan` keyword
|
||||
*/
|
||||
#define NtGetPeb() gs((struct NtPeb **)(0x60ULL))
|
||||
#define NtGetTeb() gs((void **)(0x30)) /* %gs:0 linear address */
|
||||
#define NtGetPid() gs((uint32_t *)(0x40)) /* GetCurrentProcessId() */
|
||||
#define NtGetTid() gs((uint32_t *)(0x48)) /* GetCurrentThreadId() */
|
||||
#define NtGetErr() gs((int *)(0x68))
|
||||
#define _NtGetSeh() gs((void **)(0x00))
|
||||
#define _NtGetStackHigh() gs((void **)(0x08))
|
||||
#define _NtGetStackLow() gs((void **)(0x10))
|
||||
#define _NtGetSubsystemTib() gs((void **)(0x18))
|
||||
#define _NtGetFib() gs((void **)(0x20))
|
||||
#define _NtGetEnv() gs((char16_t **)(0x38))
|
||||
#define _NtGetRpc() gs((void **)(0x50))
|
||||
#define _NtGetTls() gs((void **)(0x58)) /* cf. gs((long *)0x1480 + i0..64) */
|
||||
#define NtGetPeb() ((__seg_gs struct NtPeb *)0x60)
|
||||
#define NtGetTeb() ((void *)*(__seg_gs uintptr_t *)0x30)
|
||||
#define NtGetPid() (*(__seg_gs uint32_t *)0x40)
|
||||
#define NtGetTid() (*(__seg_gs uint32_t *)0x48)
|
||||
#define NtGetErr() (*(__seg_gs int *)0x68)
|
||||
#define _NtGetSeh() ((void *)*(__seg_gs uintptr_t *)0x00)
|
||||
#define _NtGetStackHigh() ((void *)*(__seg_gs uintptr_t *)0x08)
|
||||
#define _NtGetStackLow() ((void *)*(__seg_gs uintptr_t *)0x10)
|
||||
#define _NtGetSubsystemTib() ((void *)*(__seg_gs uintptr_t *)0x18)
|
||||
#define _NtGetFib() ((void *)*(__seg_gs uintptr_t *)0x20)
|
||||
#define _NtGetEnv() ((char16_t *)*(__seg_gs intptr_t *)0x38)
|
||||
#define _NtGetRpc() ((void *)*(__seg_gs uintptr_t *)0x50)
|
||||
#define _NtGetTls() ((void *)*(__seg_gs uintptr_t *)0x58)
|
||||
|
||||
#endif /* __GNUC__ && !__STRICT_ANSI__ */
|
||||
#endif /* COSMOPOLITAN_LIBC_NT_TEB_H_ */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue