Skip to content

Instantly share code, notes, and snippets.

/*
* See if I can trigger the cache trashing issue.
*
* Use tcc to compile and run with:
* ./tcc -B. -DNOPS=0 -run cache-test-simple.c
*
* For performance metrics, try
* perf stat -d -d -d ./tcc -B. -DNOPS=0 -run cache-test-simple.c
*/
#include <stdio.h>
@run4flat
run4flat / rand-cblock.pl
Last active December 21, 2016 19:26
KISS RNG implementations using different Perl tcc wrappers
use strict;
use warnings;
use C::Blocks;
use C::Blocks::Types qw(uint);
my $N = $ARGV[0] || 100;
sub KISS_rand {
my uint $to_return = 0;
cblock {
static unsigned int x = 123456789,y = 362436000,
@run4flat
run4flat / keyword-scope.pl
Created December 13, 2016 14:33
Use C::Blocks to create a keyword hoook and investigate hints hash scoping at the ends of blocks.
use strict;
use warnings;
use C::Blocks;
use C::Blocks::PerlAPI;
# Write a little keyword hook that simply prints the keywords it encounters
clex {
int (*next_keyword_plugin)(pTHX_ char *, STRLEN, OP **);
int prev_count;
[directory]
caja-icon-view-keep-aligned=true
caja-icon-view-layout-timestamp=1447250394
caja-window-scroll-position=file:///home/dcmertens/Desktop/Georgios-meeting-notes
caja-icon-view-tighter-layout=false
[home]
caja-icon-position=64,22
icon-scale=1
caja-icon-position-timestamp=1447250394
memcpy func
memset func
div func
fabs func
gcvt func
tzset func
strerror func
Perl_pregcomp func
Perl_pregfree func
isalnum func
cc -D_REENTRANT -D_GNU_SOURCE -fwrapv -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/home/dcmertens/perl5/perlbrew/perls/perl-5.20.1/lib/5.20.1/x86_64-linux-thread-multi/CORE -Wl,-E -fstack-protector -L/usr/local/lib -L/home/dcmertens/perl5/perlbrew/perls/perl-5.20.1/lib/5.20.1/x86_64-linux-thread-multi/CORE -lperl -lnsl -ldl -lm -lcrypt -lutil -lpthread -lc func_test_402YB8e5.c -o func_test_9EF5Maod
/tmp/ccXxD47M.o: In function `S_croak_memory_wrap':
func_test_402YB8e5.c:(.text+0x5): undefined reference to `PL_memory_wrap'
func_test_402YB8e5.c:(.text+0x14): undefined reference to `Perl_croak_nocontext'
collect2: error: ld returned 1 exit status
# Here's what needs to happen:
# 1) Add a compiler switch to tcc that lets me specify the output filename for
# serialized extended symbol tables. DONE
# 2) Add a compiler switch to tcc that lets me specify the output filename for
# a list of global identifier names. DONE
# 3) Compile a text file with the headers below, saving the serialized extended
# symbol table and the list of global identifiers
# 4) Create an XS file with a BOOT section that loads the serialized table,
# adds the global identifiers, and pushes the extended symbol table onto the
# Perl exsymtab collection.
@run4flat
run4flat / ToTest.pm
Last active December 31, 2015 13:49
Most recent round of nvcc's interactions with SvNV and friends
package ToTest;
use 5.008_008;
use strict;
use warnings;
our $VERSION = '0.04';
require XSLoader;
XSLoader::load('ToTest', $VERSION);
@run4flat
run4flat / lib-ToTest.pm
Last active December 31, 2015 13:18
Weird XSness fails to fail
package ToTest;
use 5.008_008;
use strict;
use warnings;
our $VERSION = '0.01';
require XSLoader;
XSLoader::load('ToTest', $VERSION);
@run4flat
run4flat / Tests.i
Last active December 31, 2015 13:08
Output of weird SV stuff
This file has been truncated, but you can view the full file.
# 1 "lib/CUDA/Minimal/Tests.c"
# 1 "<command-line>"
# 1 "/usr/local/cuda/bin/..//include/cuda_runtime.h" 1
# 59 "/usr/local/cuda/bin/..//include/cuda_runtime.h"
# 1 "/usr/local/cuda/bin/..//include/host_config.h" 1
# 119 "/usr/local/cuda/bin/..//include/host_config.h"
# 1 "/usr/include/features.h" 1 3 4
# 323 "/usr/include/features.h" 3 4
# 1 "/usr/include/i386-linux-gnu/bits/predefs.h" 1 3 4
# 324 "/usr/include/features.h" 2 3 4