Skip to content

Instantly share code, notes, and snippets.

@chomy
Created April 26, 2014 11:27
Show Gist options
  • Select an option

  • Save chomy/11317642 to your computer and use it in GitHub Desktop.

Select an option

Save chomy/11317642 to your computer and use it in GitHub Desktop.
FFI test on CLISP
/*
gcc -fPIC -shared -o libnow.so now.c
*/
#include <time.h>
#include <stdio.h>
char* now()
{
time_t systime;
struct tm tmtime;
static char buff[64];
systime = time(NULL);
localtime_r(&systime, &tmtime);
strftime(buff, sizeof(buff), "%c", &tmtime);
return buff;
}
(use-package "FFI")
(ffi:open-foreign-library "libnow.so")
(ffi:def-call-out now (:LIBRARY "libnow.so") (:language :stdc) (:return-type ffi:c-string))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment