Skip to content

Instantly share code, notes, and snippets.

View Leandros's full-sized avatar
🦀
Available for Rust contracting

Arvid Gerstmann Leandros

🦀
Available for Rust contracting
View GitHub Profile
@Leandros
Leandros / windows.h
Created May 11, 2017 15:01
windows.h
#ifdef _MSC_VER
#pragma warning(push, 0)
#include <windows.h>
#pragma warning(pop)
#endif
@Leandros
Leandros / nobom.c
Created May 19, 2017 08:15
remove bom. usage: gcc -o nobom nobom.c && ./nobom path/to/file
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stddef.h>
static char bom[3] = { 0xEF, 0xBB, 0xBF };
#define error(msg) error__(msg, __LINE__)
static int
error__(char const *msg, int line)
@Leandros
Leandros / main.c
Created June 23, 2017 13:39
compile with clang: clang -x c -O3 main.c
#include <stdio.h>
#define 👉 ->
struct vec3 {
int x, y, z;
};
void print_vec(struct vec3 *v)
{
$ dumpbin -symbols main.obj
Microsoft (R) COFF/PE Dumper Version 14.00.24213.1
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file main.obj
File Type: COFF OBJECT
COFF SYMBOL TABLE
@Leandros
Leandros / coroutine
Last active August 24, 2017 18:59
coroutine
// -*- C++ -*-
//===----------------------------- coroutine -----------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
auto PtrLiteral = new (S.Context) CXXNullPtrLiteralExpr(
S.Context.NullPtrTy, NTTP->getLocation());
Expr *Value =
S.ImpCastExprToType(PtrLiteral, NullPtrType, CK_NullToPointer)
.get();
DeducedTemplateArgument NewDeduced(S.Context.getCanonicalTemplateName(Arg));
DeducedTemplateArgument Result = checkDeducedTemplateArguments(
S.Context,
@Leandros
Leandros / p4.py
Last active January 9, 2022 00:09
p4.py - p4 offline caching
#!/usr/bin/env python3
# p4.py - p4 offline caching
#
# Copyright (c) 2017 Arvid Gerstmann
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
@Leandros
Leandros / fix.sh
Last active January 17, 2018 11:41
Rewrite git author
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
VERSION=$(git --version | cut -b13- | sed -n 's/.*[0-9]*\.\([0-9]*\)\.[0-9]*.*/\1/p')
if [ "$VERSION" -lt 15 ]; then
echo "git version 2.15.0 or higher required"
echo "please upgrade your git: brew upgrade git"
exit 1
fi
#!/bin/bash
ROOT=output
CC=x86_64-linux-musl-g++
CFLAGS="
-nostdinc
-isystem $ROOT/x86_64-linux-musl/include/c++/7.2.0
-isystem $ROOT/x86_64-linux-musl/include/c++/7.2.0/x86_64-linux-musl
-isystem $ROOT/x86_64-linux-musl/include/c++/7.2.0/backward
-isystem $ROOT/x86_64-linux-musl/include/
@Leandros
Leandros / build.bat
Last active November 29, 2021 07:45
Compile LLVM
@echo off
del /s /q build/*
rmdir /s /q build
mkdir build
cd build
cmake .. -G"Visual Studio 16 2019" -A x64 -Thost=x64^
-DCMAKE_BUILD_TYPE:STRING="Release"^
-DCMAKE_INSTALL_PREFIX:STRING="output"^