***/
#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
+# define _GNU_SOURCE
#endif
#include <unistd.h>
#include "sd-readahead.h"
+#if (__GNUC__ >= 4)
+# ifdef SD_EXPORT_SYMBOLS
+/* Export symbols */
+# define _sd_export_ __attribute__ ((visibility("default")))
+# else
+/* Don't export the symbols */
+# define _sd_export_ __attribute__ ((visibility("hidden")))
+# endif
+#else
+# define _sd_export_
+#endif
+
static int touch(const char *path) {
#if !defined(DISABLE_SYSTEMD) && defined(__linux__)
mkdir("/run/systemd", 0755);
mkdir("/run/systemd/readahead", 0755);
- if ((fd = open(path, O_WRONLY|O_CREAT|O_CLOEXEC|O_NOCTTY, 0666)) < 0)
+ fd = open(path, O_WRONLY|O_CREAT|O_CLOEXEC|O_NOCTTY, 0666);
+ if (fd < 0)
return -errno;
for (;;) {
if (close(fd) >= 0)
break;
- if (errno != -EINTR)
+ if (errno != EINTR)
return -errno;
}
return 0;
}
-int sd_readahead(const char *action) {
+_sd_export_ int sd_readahead(const char *action) {
if (!action)
return -EINVAL;