Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
unix: move container_of and SAVE_ERRNO to internal.h
  • Loading branch information
bnoordhuis committed Sep 21, 2011
1 parent 2a1c32a commit bee7112
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
13 changes: 13 additions & 0 deletions src/unix/internal.h
Expand Up @@ -25,6 +25,8 @@
#include "uv-common.h"
#include "uv-eio.h"

#include <stddef.h> /* offsetof */

#if defined(__linux__)

#include <linux/version.h>
Expand Down Expand Up @@ -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. */
Expand Down
12 changes: 0 additions & 12 deletions src/unix/linux.c
Expand Up @@ -22,7 +22,6 @@
#include "internal.h"

#include <stdint.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
Expand All @@ -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) {
Expand Down

0 comments on commit bee7112

Please sign in to comment.