mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-28 00:02:28 +00:00
I wanted a tiny scriptable meltdown proof way to run userspace programs and visualize how program execution impacts memory. It helps to explain how things like Actually Portable Executable works. It can show you how the GCC generated code is going about manipulating matrices and more. I didn't feel fully comfortable with Qemu and Bochs because I'm not smart enough to understand them. I wanted something like gVisor but with much stronger levels of assurances. I wanted a single binary that'll run, on all major operating systems with an embedded GPL barrier ZIP filesystem that is tiny enough to transpile to JavaScript and run in browsers too. https://justine.storage.googleapis.com/emulator625.mp4
34 lines
988 B
C
34 lines
988 B
C
#ifndef COSMOPOLITAN_LIBC_DNS_DNSQUESTION_H_
|
|
#define COSMOPOLITAN_LIBC_DNS_DNSQUESTION_H_
|
|
#ifndef __STRICT_ANSI__
|
|
#include "libc/dns/dns.h"
|
|
#include "libc/sysv/errfuns.h"
|
|
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
|
COSMOPOLITAN_C_START_
|
|
|
|
struct DnsQuestion {
|
|
const char *qname;
|
|
uint16_t qtype;
|
|
uint16_t qclass;
|
|
};
|
|
|
|
/**
|
|
* Serializes DNS question record to wire.
|
|
*
|
|
* @return number of bytes written
|
|
* @see pascalifydnsname()
|
|
*/
|
|
forceinline int serializednsquestion(uint8_t *buf, size_t size,
|
|
struct DnsQuestion dq) {
|
|
int wrote;
|
|
if ((wrote = pascalifydnsname(buf, size, dq.qname)) == -1) return -1;
|
|
if (wrote + 1 + 4 > size) return enospc();
|
|
buf[wrote + 1] = dq.qtype >> 010, buf[wrote + 2] = dq.qtype >> 000;
|
|
buf[wrote + 3] = dq.qclass >> 010, buf[wrote + 4] = dq.qclass >> 000;
|
|
return wrote + 5;
|
|
}
|
|
|
|
COSMOPOLITAN_C_END_
|
|
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
|
#endif /* !ANSI */
|
|
#endif /* COSMOPOLITAN_LIBC_DNS_DNSQUESTION_H_ */
|