Skip to content

Instantly share code, notes, and snippets.

View vstakhov's full-sized avatar

Vsevolod Stakhov vstakhov

  • Cambridge, UK
  • 14:44 (UTC +01:00)
View GitHub Profile
@vstakhov
vstakhov / aio_syscalls.c
Created May 3, 2012 16:33
aio syscalls
#if defined(__i386__)
# define SYS_io_setup 245
# define SYS_io_destroy 246
# define SYS_io_getevents 247
# define SYS_io_submit 248
# define SYS_io_cancel 249
#elif defined(__x86_64__)
# define SYS_io_setup 206
# define SYS_io_destroy 207
# define SYS_io_getevents 208
@vstakhov
vstakhov / aio_struct.c
Created May 3, 2012 16:46
aio_getevents structure
struct io_event {
guint64 data; /* the data field from the iocb */
guint64 obj; /* what iocb this event came from */
gint64 res; /* result code for this event */
gint64 res2; /* secondary result */
};
@vstakhov
vstakhov / aio_submit.c
Created May 3, 2012 16:50
aio structure for io_submit
typedef enum io_iocb_cmd {
IO_CMD_PREAD = 0,
IO_CMD_PWRITE = 1,
IO_CMD_FSYNC = 2,
IO_CMD_FDSYNC = 3,
IO_CMD_POLL = 5,
IO_CMD_NOOP = 6,
} io_iocb_cmd_t;
@vstakhov
vstakhov / io_submit.c
Created May 3, 2012 16:54
io_submit sample
struct io_cbdata *cbdata;
struct iocb *iocb[1];
iocb[0] = alloca (sizeof (struct iocb));
memset (iocb[0], 0, sizeof (struct iocb));
iocb[0]->aio_fildes = fd;
iocb[0]->aio_lio_opcode = IO_CMD_PREAD;
iocb[0]->aio_reqprio = 0;
iocb[0]->aio_buf = (uint64_t)((uintptr_t)buf);
@vstakhov
vstakhov / ng_ipacct.diff
Last active December 21, 2015 00:49
ng_ipacct locking improvement
--- ng_ipacct/ng_ipacct.c.orig 2006-12-05 23:46:04.000000000 +0300
+++ ng_ipacct/ng_ipacct.c 2013-08-13 16:21:16.000000000 +0400
@@ -140,9 +140,6 @@
struct ipacct_hook {
hook_p hook;
node_p node;
-#if __FreeBSD_version >= 503000
- struct mtx h_mtx; /* protects hook data */
-#endif
struct ip_acct_hash *active; /* active database */
@vstakhov
vstakhov / ipfw2.diff
Last active December 21, 2015 17:29
settl patch for ipfw
Index: sbin/ipfw/ipfw2.c
===================================================================
--- sbin/ipfw/ipfw2.c (revision 254904)
+++ sbin/ipfw/ipfw2.c (working copy)
@@ -264,6 +264,7 @@
{ "reass", TOK_REASS },
{ "setfib", TOK_SETFIB },
{ "setdscp", TOK_SETDSCP },
+ { "setttl", TOK_SETTTL },
{ "call", TOK_CALL },
@vstakhov
vstakhov / rspamd_lua_ip.lua
Last active December 28, 2015 16:48
An example of how to use rspamd_lua_ip module
local print_octets = function(ip)
print('Normal order octets:')
for _,o in ipairs(ip:str_octets()) do
print(o)
end
print('Reversed order octets:')
for _,o in ipairs(ip:inversed_str_octets()) do
print(o)
end
print('Numeric octets:')
#!/bin/sh
[ -z "$CLASP_OPTS" ] && CLASP_OPTS="--opt-heu=1 --sat-prepro --restarts=L,128 --heuristic=VSIDS --opt-hierarch=1 --local-restarts --del-max=200000,250 --save-progress=0"
[ -z "$CLASP" ] && CLASP="clasp"
[ -z "$GRINGO_OPTS" ] && GRINGO_OPTS="/usr/local/share/aspcud/misc2012.lp"
[ -z "$GRINGO" ] && GRINGO="gringo"
[ -z "$CUDF2LP_OPTS" ] && CUDF2LP_OPTS=""
[ -z "$CUDF2LP" ] && CUDF2LP="cudf2lp"
@vstakhov
vstakhov / rspamd-0.7-roadmap.md
Last active January 4, 2016 14:49
Roadmap for rspamd 0.7
  • add http client and server code
  • implement http worker
  • implement http rspamc client
  • remove rspamc protocol support
  • migrate webui to http library
  • remove controller and move the rest of functions to webui
  • integrate webui code into rspamd
  • move maps code to http-client
  • move lua_http to http-client
  • replace jansson with ucl:
#include <stdio.h>
#include <limits.h>
int f(int x)
{
int y = x >> 31;
return (x ^ y) - y;
}