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

Commit

Permalink
test: move container_of() macro into task.h
Browse files Browse the repository at this point in the history
  • Loading branch information
bnoordhuis committed Jan 18, 2012
1 parent fbbc085 commit 1161d31
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 14 deletions.
4 changes: 0 additions & 4 deletions test/benchmark-tcp-write-batch.c
Expand Up @@ -23,15 +23,11 @@
#include "task.h"

#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>

#define WRITE_REQ_DATA "Hello, world."
#define NUM_WRITE_REQS (1000 * 1000)

#define container_of(ptr, type, member) \
((type *) ((char *) (ptr) - offsetof(type, member)))

typedef struct {
uv_write_t req;
uv_buf_t buf;
Expand Down
4 changes: 0 additions & 4 deletions test/blackhole-server.c
Expand Up @@ -23,12 +23,8 @@
#include "task.h"

#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>

#define container_of(ptr, type, member) \
((type *) ((char *) (ptr) - offsetof(type, member)))

typedef struct {
uv_tcp_t handle;
uv_shutdown_t shutdown_req;
Expand Down
7 changes: 5 additions & 2 deletions test/task.h
Expand Up @@ -22,9 +22,9 @@
#ifndef TASK_H_
#define TASK_H_


#include <stdint.h>
#include <stdio.h>
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>

#define TEST_PORT 9123
Expand All @@ -40,6 +40,9 @@

#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))

#define container_of(ptr, type, member) \
((type *) ((char *) (ptr) - offsetof(type, member)))

typedef enum {
TCP = 0,
UDP,
Expand Down
4 changes: 0 additions & 4 deletions test/test-thread.c
Expand Up @@ -23,12 +23,8 @@
#include "task.h"

#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>

#define container_of(ptr, type, member) \
((type *) ((char *) (ptr) - offsetof(type, member)))

struct getaddrinfo_req {
uv_thread_t thread_id;
unsigned int counter;
Expand Down

0 comments on commit 1161d31

Please sign in to comment.