This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- Load FFI | |
| local ffi = require("ffi") | |
| -- Define FFI functions & structures by OS | |
| local x11 | |
| if ffi.os == "Windows" then | |
| ffi.cdef([[ | |
| typedef int BOOL; | |
| typedef long LONG; | |
| typedef struct{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <windows.h> /* WinAPI */ | |
| /* Windows sleep in 100ns units */ | |
| BOOLEAN nanosleep(LONGLONG ns){ | |
| /* Declarations */ | |
| HANDLE timer; /* Timer handle */ | |
| LARGE_INTEGER li; /* Time defintion */ | |
| /* Create timer */ | |
| if(!(timer = CreateWaitableTimer(NULL, TRUE, NULL))) | |
| return FALSE; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "sapi.h" | |
| #include <stdio.h> | |
| // Program entry | |
| int main(){ | |
| // Initialize COM | |
| if(CoInitializeEx(NULL, COINIT_MULTITHREADED)) | |
| return 1; | |
| puts("COM initialized."); | |
| // Create SAPI voice |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- Load foreign functions interface | |
| local ffi = require("ffi") | |
| -- Load Ruby library & define function headers | |
| local ruby = ffi.load("msvcrt-ruby210") | |
| ffi.cdef([[ | |
| typedef uintptr_t RUBY_VALUE; | |
| enum{ | |
| RUBY_Qfalse = 0, | |
| RUBY_Qtrue = 2, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Load importer part of fiddle (ffi) library | |
| require 'fiddle/import' | |
| # Create module as body for an importer instance | |
| module MessageBox | |
| # Extend this module to an importer | |
| extend Fiddle::Importer | |
| # Load 'user32' dynamic library into this importer | |
| dlload 'user32' | |
| # Set C aliases to this importer for further understanding of function signatures |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- Load foreign-function-interface handle | |
| local ffi = require("ffi") | |
| -- Shortcut FFI C namespace | |
| local C = ffi.C | |
| -- Load Windows kernel32 DLL | |
| local kernel32 = ffi.load("kernel32") | |
| -- Add C definitions to FFI for usage descriptions of components | |
| ffi.cdef([[ | |
| // Redefinitions for WinAPI conventions | |
| typedef void VOID; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <ext/stdio_filebuf.h> // fstream (all sorts of IO stuff) + stdio_filebuf (=streambuf) | |
| #include <fcntl.h> // _O_RDONLY | |
| #include <iostream> // cout | |
| int main(){ | |
| __gnu_cxx::stdio_filebuf<char> wfile_buf(_wopen(L"D:\\...\\の.txt", _O_RDONLY), std::ios_base::in); | |
| std::istream wfile_stream(&wfile_buf); | |
| wfile_stream.seekg(0, std::ios_base::end); | |
| std::cout << wfile_stream.tellg(); | |
| return 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @echo off | |
| rem Set console appearance | |
| title Java environment (%cd%) | |
| color 0C | |
| rem Set console environment | |
| if "%~1"=="" ( | |
| set JAVA_BIN=C:\Program Files\Java\jdk1.8.0_45\bin | |
| ) else ( | |
| set JAVA_BIN=%~1 | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #pragma once | |
| #ifdef _MSC_VER | |
| #include <intrin.h> | |
| #define bit_SSE2 (1 << 26) | |
| #define bit_SSE3 (1 << 0) | |
| #define bit_AVX (1 << 28) | |
| #else | |
| #include <cpuid.h> | |
| #endif // _MSC_VER |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <emmintrin.h> // SSE2 | |
| static unsigned short x[8] = {0, 55, 2, 62003, 786, 5555, 123, 32111}; // Dividend | |
| __attribute__((noinline)) static void test_div_x86(unsigned i){ | |
| for(; i; --i) | |
| x[0] /= i, | |
| x[1] /= i, | |
| x[2] /= i, | |
| x[3] /= i, |