Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

unix: move container_of and SAVE_ERRNO to internal.h

  • Loading branch information...
bnoordhuis committed Aug 17, 2011
1 parent 2a1c32a commit bee7112de02581b44240ea4d4e164e2e71ba86da
Showing with 13 additions and 12 deletions.
  1. +13 −0 src/unix/internal.h
  2. +0 −12 src/unix/linux.c
@@ -25,6 +25,8 @@
#include "uv-common.h"
#include "uv-eio.h"

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

#if defined(__linux__)

#include <linux/version.h>
@@ -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. */
@@ -22,7 +22,6 @@
#include "internal.h"

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

0 comments on commit bee7112

Please sign in to comment.
You can’t perform that action at this time.