Browse Source

merged [380] from 1.2: make life easier for debugging

git-svn-id: svn://svn.lighttpd.net/xcache/trunk@381 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
3.0
Xuefer 15 years ago
parent
commit
5dd9e2439b
  1. 8
      mem.c
  2. 26
      mem.h
  3. 4
      mmap.c
  4. 10
      xc_malloc.c
  5. 21
      xc_shm.h

8
mem.c

@ -8,8 +8,8 @@
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#define XC_SHM_IMPL
#define XC_MEM_IMPL
#define XC_MEMBLOCK_IMPL _xc_mem_block_t
#define XC_MEM_IMPL _xc_mem_mem_t
#include "xc_shm.h"
#include "align.h"
#include "utils.h"
@ -30,7 +30,7 @@
#define PSUB(p1, p2) (CHAR_PTR(p1) - CHAR_PTR(p2))
/* {{{ mem */
struct _xc_block_t {
struct _xc_mem_block_t {
#ifdef ALLOC_DEBUG_BLOCK_CHECK
unsigned int magic;
#endif
@ -38,7 +38,7 @@ struct _xc_block_t {
xc_block_t *next; /* not used after alloc */
};
struct _xc_mem_t {
struct _xc_mem_mem_t {
const xc_mem_handlers_t *handlers;
xc_shm_t *shm;
xc_memsize_t size;

26
mem.h

@ -1,5 +1,18 @@
typedef struct _xc_mem_t xc_mem_t;
typedef struct _xc_block_t xc_block_t;
typedef struct _xc_mem_handlers_t xc_mem_handlers_t;
#ifndef XC_MEM_IMPL
struct _xc_mem_t {
const xc_mem_handlers_t *handlers;
xc_shm_t *shm;
};
# define XC_MEM_IMPL _xc_mem_t
#endif
#ifndef XC_MEMBLOCK_IMPL
# define XC_MEMBLOCK_IMPL _xc_block_t
#endif
typedef struct XC_MEM_IMPL xc_mem_t;
typedef struct XC_MEMBLOCK_IMPL xc_block_t;
typedef unsigned int xc_memsize_t;
/* shm::mem */
@ -37,7 +50,7 @@ typedef unsigned int xc_memsize_t;
, xc_##name##_destroy \
}
typedef struct {
struct _xc_mem_handlers_t {
XC_MEM_MALLOC((*malloc));
XC_MEM_FREE((*free));
XC_MEM_CALLOC((*calloc));
@ -53,14 +66,7 @@ typedef struct {
XC_MEM_INIT((*init));
XC_MEM_DESTROY((*destroy));
} xc_mem_handlers_t;
#ifndef XC_MEM_IMPL
struct _xc_mem_t {
const xc_mem_handlers_t *handlers;
xc_shm_t *shm;
};
#endif
int xc_mem_scheme_register(const char *name, const xc_mem_handlers_t *handlers);
const xc_mem_handlers_t *xc_mem_scheme_find(const char *name);

4
mmap.c

@ -29,7 +29,7 @@
#endif
#include "php.h"
#define XC_SHM_IMPL
#define XC_SHM_IMPL _xc_mmap_shm_t
#include "xc_shm.h"
#include "utils.h"
@ -38,7 +38,7 @@
#endif
/* {{{ xc_shm_t */
struct _xc_shm_t {
struct _xc_mmap_shm_t {
xc_shm_handlers_t *handlers;
void *ptr;
void *ptr_ro;

10
xc_malloc.c

@ -1,5 +1,5 @@
#define XC_SHM_IMPL
#define XC_MEM_IMPL
#define XC_SHM_IMPL _xc_malloc_shm_t
#define XC_MEM_IMPL _xc_malloc_mem_t
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@ -8,7 +8,7 @@
#include "align.h"
#include "utils.h"
struct _xc_mem_t {
struct _xc_malloc_mem_t {
const xc_mem_handlers_t *handlers;
xc_shm_t *shm;
xc_memsize_t size;
@ -106,8 +106,8 @@ static XC_MEM_DESTROY(xc_mem_malloc_destroy) /* {{{ */
}
/* }}} */
/* {{{ xc_shm_t */
struct _xc_shm_t {
/* {{{ _xc_malloc_shm_t */
struct _xc_malloc_shm_t {
xc_shm_handlers_t *handlers;
xc_shmsize_t size;
xc_shmsize_t memoffset;

21
xc_shm.h

@ -1,6 +1,15 @@
#ifndef XC_SHM_H
#define XC_SHM_H
typedef struct _xc_shm_t xc_shm_t;
typedef struct _xc_shm_handlers_t xc_shm_handlers_t;
#ifndef XC_SHM_IMPL
struct _xc_shm_t {
const xc_shm_handlers_t *handlers;
};
#define XC_SHM_IMPL _xc_shm_t
#endif
typedef struct XC_SHM_IMPL xc_shm_t;
typedef size_t xc_shmsize_t;
#include "mem.h"
@ -33,7 +42,7 @@ typedef size_t xc_shmsize_t;
, xc_##name##_memdestroy \
}
typedef struct {
struct _xc_shm_handlers_t {
const xc_mem_handlers_t *memhandlers;
XC_SHM_CAN_READONLY((*can_readonly));
XC_SHM_IS_READWRITE((*is_readwrite));
@ -45,14 +54,8 @@ typedef struct {
XC_SHM_MEMINIT((*meminit));
XC_SHM_MEMDESTROY((*memdestroy));
} xc_shm_handlers_t;
#ifndef XC_SHM_IMPL
struct _xc_shm_t {
const xc_shm_handlers_t *handlers;
};
#endif
typedef struct _xc_shm_scheme_t xc_shm_scheme_t;
void xc_shm_init_modules();

Loading…
Cancel
Save