From bee7112de02581b44240ea4d4e164e2e71ba86da Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Wed, 17 Aug 2011 17:51:30 +0200 Subject: [PATCH] unix: move container_of and SAVE_ERRNO to internal.h --- src/unix/internal.h | 13 +++++++++++++ src/unix/linux.c | 12 ------------ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/unix/internal.h b/src/unix/internal.h index 492efdad..42283ca2 100644 --- a/src/unix/internal.h +++ b/src/unix/internal.h @@ -25,6 +25,8 @@ #include "uv-common.h" #include "uv-eio.h" +#include /* offsetof */ + #if defined(__linux__) #include @@ -59,6 +61,17 @@ # define HAVE_FUTIMES #endif +#define container_of(ptr, type, member) \ + ((type *) ((char *) (ptr) - offsetof(type, member))) + +#define SAVE_ERRNO(block) \ + do { \ + int _saved_errno = errno; \ + do { block; } while (0); \ + errno = _saved_errno; \ + } \ + while (0); + /* flags */ enum { UV_CLOSING = 0x00000001, /* uv_close() called but not finished. */ diff --git a/src/unix/linux.c b/src/unix/linux.c index e0f72bb0..0b4ce64d 100644 --- a/src/unix/linux.c +++ b/src/unix/linux.c @@ -22,7 +22,6 @@ #include "internal.h" #include -#include #include #include #include @@ -35,17 +34,6 @@ #undef NANOSEC #define NANOSEC 1000000000 -#define container_of(ptr, type, member) \ - ((type *) ((char *) (ptr) - offsetof(type, member))) - -#define SAVE_ERRNO(block) \ - do { \ - int _saved_errno = errno; \ - do { block; } while (0); \ - errno = _saved_errno; \ - } \ - while (0); - /* Don't look aghast, this is exactly how glibc's basename() works. */ static char* basename_r(const char* path) {