Skip to content

Instantly share code, notes, and snippets.

View imasahiro's full-sized avatar

Masahiro Ide imasahiro

  • LINE Corporation
  • Tokyo Japan
View GitHub Profile
@imasahiro
imasahiro / mksc-macosx.diff
Created December 7, 2009 08:14
patch for mac-gcc
Index: include/mk.h
===================================================================
--- include/mk.h (revision 29)
+++ include/mk.h (working copy)
@@ -755,10 +755,19 @@
#ifdef _DEBUG
int mk_execute_expr( MK_VM_STRUCT *vm, MK_NODE_EXPR *pTarget, int hasParent );
#else
+static inline int mk_execute_expr( MK_VM_STRUCT *vm, MK_NODE_EXPR *pTarget, int hasParent )
+{
int main(int argc, char **argv)
{
struct list {
void *next;
} _op = {0}, *op = &_op;
asm volatile("jmp *%0;":: "r"(*(void const*)op->next));
return 0;
}
/*
* $ gcc-mp-4.4 jmp.c
@imasahiro
imasahiro / gist:770093
Created January 7, 2011 21:03
konha-mode.vim
" Vim syntax file
" Language: Konoha
" Maintainer: Masahiro Ide <[email protected]>
" URL: http://sourceforge.jp/projects/konoha/
" Last Change: 2009 July 09
" Quit when a syntax file was already loaded
if version < 600
syntax clear
elseif exists("b:current_syntax")
@imasahiro
imasahiro / gist:981138
Created May 19, 2011 16:09
SIMD memset
#ifdef __SSE__
#include <emmintrin.h>
static void __memset(void *ptr, int c, size_t len)
{
int i;
register char *p = (char *) ptr;
for (i = 0; i < len; i++) {
p[i] = c;
}
@imasahiro
imasahiro / gist:985546
Created May 22, 2011 14:58
ruby_gc oprofile
#
# ./miniruby ./ptest/ao-render.rb > ao.ppm
# ./miniruby ./ptest/bm_so_binary_trees.rb
# ./miniruby ./ptest/bm_so_nbody.rb
#
CPU: Core 2, speed 2003 MHz (estimated)
Counted CPU_CLK_UNHALTED events (Clock cycles when not halted) with a unit mask of 0x00 (Unhalted core cycles) count 10000
Counted LLC_MISSES events (L2 cache demand requests from this core that missed the L2) with a unit mask of 0x41 (No unit mask) count 10000
samples % samples % image name symbol name
8795893 39.1829 295 5.8590 miniruby vm_exec_core
@imasahiro
imasahiro / alloca.c
Last active September 29, 2015 04:37
llvm bug?
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char const* argv[])
{
while(1) {
void *a = alloca(1024);
fprintf(stderr, "%p\n", a);
}
return 0;
@imasahiro
imasahiro / build_error.txt
Created September 15, 2012 20:20
nanahan build error
[ 50%] Built target nanahan
[100%] Building CXX object CMakeFiles/test_map.dir/map/test_map.cc.o
In file included from /home/masa/src/nanahan/map/test_map.cc:1:
/home/masa/src/nanahan/map/map.hpp:35: warning: integer constant is too large for 'long' type
/home/masa/src/nanahan/map/map.hpp:35: warning: integer constant is too large for 'long' type
/home/masa/src/nanahan/map/map.hpp:36: warning: integer constant is too large for 'long' type
/home/masa/src/nanahan/map/map.hpp:36: warning: integer constant is too large for 'long' type
/home/masa/src/nanahan/map/map.hpp:37: warning: integer constant is too large for 'long' type
/home/masa/src/nanahan/map/map.hpp:37: warning: integer constant is too large for 'long' type
/home/masa/src/nanahan/map/map.hpp:38: warning: integer constant is too large for 'long' type
#include <stdio.h>
#include <stdint.h>
typedef uintptr_t VALUE;
struct RBasic {
VALUE flag;
const VALUE klass;
};
struct a {
ruby 2.2.0dev (2014-04-18 trunk 45574) [x86_64-darwin13]
benchmark/bm_vm1_swap.rb
original real 0m0.968s user 0m0.957s sys 0m0.009s
modified real 0m0.280s user 0m0.267s sys 0m0.011s
benchmark/bm_vm1_lvar_set.rb
original real 0m3.180s user 0m3.164s sys 0m0.011s
modified real 0m0.410s user 0m0.396s sys 0m0.012s
diff --git a/qrintf.h b/qrintf.h
index 6e6c7d8..35af13e 100644
--- a/qrintf.h
+++ b/qrintf.h
@@ -73,26 +73,37 @@ static inline qrintf_t _qrintf_s_len(qrintf_t ctx, const char *s, size_t l)
return ctx;
}
+static inline void _qprintf_reverse(char *start, char *end)
+{