Skip to content

Instantly share code, notes, and snippets.

@jonyesno
Created April 28, 2011 08:13
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonyesno/946001 to your computer and use it in GitHub Desktop.
Save jonyesno/946001 to your computer and use it in GitHub Desktop.
Patch to build ddar on BSD / OS X
--- scan.c.orig 2011-04-28 08:28:05.000000000 +0100
+++ scan.c 2011-04-28 09:01:10.000000000 +0100
@@ -38,6 +38,14 @@
#define likely(x) __builtin_expect(x, 1)
#define unlikely(x) __builtin_expect(x, 0)
+#ifndef __linux__
+#define TEMP_FAILURE_RETRY(expr) \
+ ({ long int _res; \
+ do _res = (long int) (expr); \
+ while (_res == -1L && errno == EINTR); \
+ _res; })
+#endif
+
struct scan_ctx {
/* The main read buffer itself */
unsigned char *buffer[3];
@@ -97,7 +105,9 @@
int bytes_read;
bytes_read = retry_read(scan, scan->io_destination, scan->buffer_size / 3);
+#ifdef __linux__
posix_fadvise(scan->fd, scan->source_offset, bytes_read, POSIX_FADV_DONTNEED);
+#endif
scan->source_offset += bytes_read;
scan->bytes_left += bytes_read;
}
@@ -147,7 +157,9 @@
longjmp(scan->jmp_env, 1);
}
+#ifdef __linux__
posix_fadvise(scan->fd, scan->source_offset, bytes_read, POSIX_FADV_DONTNEED);
+#endif
scan->source_offset += bytes_read;
scan->bytes_left += bytes_read;
}
--- setup.py.orig 2011-04-28 08:32:45.000000000 +0100
+++ setup.py 2011-04-28 08:33:31.000000000 +0100
@@ -12,7 +12,7 @@
ext_modules=[ Extension('synctus._dds', ['scan.c', 'rabin.c',
'synctus/ddsmodule.c'],
include_dirs=['.'],
- libraries=['rt']) ],
+ ) ],
install_requires=['protobuf'])
# vim: set ts=8 sts=4 sw=4 ai et :
--- Makefile.orig 2011-04-28 09:27:25.000000000 +0100
+++ Makefile 2011-04-28 09:27:31.000000000 +0100
@@ -1,4 +1,4 @@
-pydist: ddar.1 synctus/ddar_pb2.py
+pydist: synctus/ddar_pb2.py
sdist: pydist
python setup.py sdist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment