Skip to content

Instantly share code, notes, and snippets.

@Zoxc
Zoxc / gist:5270635
Created March 29, 2013 12:51
OpenGL font rendering
#include <stdio.h>
#include <math.h>
#include <swl.h>
#include "gles.hpp"
#include <ft2build.h>
#include FT_FREETYPE_H
FT_Library library;
@Zoxc
Zoxc / gist:5566293
Last active December 17, 2015 06:29
Syntax for variable and field declarations
Trivial:
Type trailing with colon
global, other_global: int
yet_another_global: () -> string
func()
a, c: int
b := 4
Type trailing and var keyword
@Zoxc
Zoxc / gist:5765678
Last active December 18, 2015 09:59
Rendering on multiple threads with Wayland subsurfaces
mutex commit
atomic<int> render_complete_count
signal resizing_complete
apply_pending_state(surface) {
wl_surface_attach(surface, ...)
wl_surface_damage(surface, ...)
}
use "../core"
enum Token
None
Unknown
Id
struct Lexer
struct State
lexer *Lexer
@Zoxc
Zoxc / gist:2b50c3897e9cb1883d07
Last active August 29, 2015 14:04
Value type parameters
  • Start Date: 2014-07-20
  • RFC PR #: (leave this empty)
  • Rust Issue #: (leave this empty)

Summary

Values should be able to be passed as type parameters. The [T, ..n] fixed length array should be changed to use a value as a type parameter.

Motivation

@Zoxc
Zoxc / gist:2a69723a14704db3d50f
Last active August 29, 2015 14:04
Field offsets RFC
  • Start Date: 2014-07-21
  • RFC PR #: (leave this empty)
  • Rust Issue #: (leave this empty)

Summary

This adds the ability to refer to fields of types and use them later on with objects of that type. The FieldOffset<Obj, Field> type is added which refers to fields of type Field in the object Obj. The offsetof Type.field syntax is defined to construct instances of FieldOffset<Type, the type of field>.

@Zoxc
Zoxc / gist:44f0e0d3519fcfbcd35d
Last active August 29, 2015 14:04
Type macros
  • Start Date: 2014-07-22
  • RFC PR #: (leave this empty)
  • Rust Issue #: (leave this empty)

Summary

This adds the ability to have macros in type signatures.

Motivation

@Zoxc
Zoxc / nicer.ll
Created July 27, 2015 19:32
LLVM codegen
; ModuleID = 'nicer.ll'
target datalayout = "e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
define i8 @test({ i8*, i64 } %arg, i64 %arg1) unnamed_addr {
"the block":
%tmp = extractvalue { i8*, i64 } %arg, 1
%tmp2 = icmp ugt i64 %tmp, %arg1
br i1 %tmp2, label %exit, label %cond.i
; ModuleID = 'bugpoint-reduced-simplified.bc'
target datalayout = "e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
; Function Attrs: noreturn
declare void @fail()
declare void @llvm.experimental.patchpoint.void(i64, i32, i8*, i32, ...)
define void @test() {
All code is shared between processes. Processes can not read or write to the code segment.
The global code segment is 2 TB. It is split into 1MB blocks, giving 2M blocks in total.
A module is a executable or shared library.
Each process has an bitmap where each bit represents a block of code of the code segment.
With 1 bit per block means the size of the array is 256KB.
If a bit is 0, the process does not have access to the block in the code segment.