unix: move container_of and SAVE_ERRNO to internal.h

This commit is contained in:
Ben Noordhuis 2011-08-17 17:51:30 +02:00
parent 2a1c32a60c
commit bee7112de0
2 changed files with 13 additions and 12 deletions

View File

@ -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. */

View File

@ -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) {