potion  0.2
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
internal.h File Reference

non-API internal parts More...

+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  PNBHeader
 .pnb binary dump header More...
 

Macros

#define PN_ALLOC(V, T)   (T *)potion_gc_alloc(P, V, sizeof(T))
 
#define PN_ALLOC_N(V, T, C)   (T *)potion_gc_alloc(P, V, sizeof(T)+C)
 
#define PN_CALLOC_N(V, T, C)   (T *)potion_gc_calloc(P, V, sizeof(T)+C)
 
#define PN_REALLOC(X, V, T, N)   (X)=(T *)potion_gc_realloc(P, V, (struct PNObject *)(X), sizeof(T) + N)
 
#define PN_DALLOC_N(T, N)   potion_data_alloc(P, sizeof(T)*N)
 
#define PN_STRDUP(S)   PN_STR(S)
 
#define PN_MEMZERO(X, T)   memset((X), 0, sizeof(T))
 
#define PN_MEMZERO_N(X, T, N)   memset((X), 0, sizeof(T)*(N))
 
#define PN_MEMCPY(X, Y, T)   memcpy((void *)(X), (void *)(Y), sizeof(T))
 
#define PN_MEMCPY_N(X, Y, T, N)   memcpy((void *)(X), (void *)(Y), sizeof(T)*(N))
 
#define PN_MEMMOVE_N(DST, SRC, T, N)   memmove((void *)(DST), (void *)(SRC), sizeof(T)*(N))
 
#define min(a, b)   ((a) <= (b) ? (a) : (b))
 
#define max(a, b)   ((a) >= (b) ? (a) : (b))
 
#define TYPE_BATCH_SIZE   4096
 
#define PN_FLEX_NEW(N, V, T, S)
 
#define PN_FLEX_NEEDS(X, N, V, T, S)
 
#define PN_ATOI(X, N, B)
 
#define PN_ALLOC_FUNC(size)   potion_mmap(size, 1)
 
#define PN_SAVED_REGS   3
 
#define POTION_ESP(p)   __asm__("mov %%esp, %0" : "=r" (*p))
 
#define POTION_EBP(p)   __asm__("mov %%ebp, %0" : "=r" (*p))
 
#define O_BINARY   0
 
#define GC_PROTECT(P)   P->mem->protect = (void *)P->mem->birth_cur
 

Typedefs

typedef unsigned char u8
 

Functions

size_t potion_cp_strlen_utf8 (const char *)
 wonderful utf-8 counting trickery by colin percival More...
 
void * potion_mmap (size_t, const char)
 
int potion_munmap (void *, size_t)
 
PN potion_vm_eq (Potion *, PN, PN)
 
PN potion_vm_neq (Potion *, PN, PN)
 

Detailed Description

non-API internal parts

(c) 2008 why the lucky stiff, the freelance professor

Definition in file internal.h.

Macro Definition Documentation

#define PN_ALLOC (   V,
 
)    (T *)potion_gc_alloc(P, V, sizeof(T))

Definition at line 12 of file internal.h.

#define PN_ALLOC_N (   V,
  T,
 
)    (T *)potion_gc_alloc(P, V, sizeof(T)+C)

Definition at line 13 of file internal.h.

#define PN_CALLOC_N (   V,
  T,
 
)    (T *)potion_gc_calloc(P, V, sizeof(T)+C)

Definition at line 14 of file internal.h.

#define PN_REALLOC (   X,
  V,
  T,
  N 
)    (X)=(T *)potion_gc_realloc(P, V, (struct PNObject *)(X), sizeof(T) + N)

Definition at line 15 of file internal.h.

#define PN_DALLOC_N (   T,
  N 
)    potion_data_alloc(P, sizeof(T)*N)

Definition at line 16 of file internal.h.

#define PN_STRDUP (   S)    PN_STR(S)

Definition at line 17 of file internal.h.

#define PN_MEMZERO (   X,
 
)    memset((X), 0, sizeof(T))

Definition at line 19 of file internal.h.

#define PN_MEMZERO_N (   X,
  T,
  N 
)    memset((X), 0, sizeof(T)*(N))

Definition at line 20 of file internal.h.

#define PN_MEMCPY (   X,
  Y,
 
)    memcpy((void *)(X), (void *)(Y), sizeof(T))

Definition at line 21 of file internal.h.

#define PN_MEMCPY_N (   X,
  Y,
  T,
  N 
)    memcpy((void *)(X), (void *)(Y), sizeof(T)*(N))

Definition at line 22 of file internal.h.

#define PN_MEMMOVE_N (   DST,
  SRC,
  T,
  N 
)    memmove((void *)(DST), (void *)(SRC), sizeof(T)*(N))

Definition at line 23 of file internal.h.

#define min (   a,
 
)    ((a) <= (b) ? (a) : (b))

Definition at line 26 of file internal.h.

#define max (   a,
 
)    ((a) >= (b) ? (a) : (b))

Definition at line 30 of file internal.h.

#define TYPE_BATCH_SIZE   4096

Definition at line 33 of file internal.h.

#define PN_FLEX_NEW (   N,
  V,
  T,
 
)
Value:
(N) = PN_ALLOC_N(V, T, (sizeof(*(N)->ptr) * S)); \
(N)->siz = sizeof(*(N)->ptr) * S; \
(N)->len = 0
#define PN_ALLOC_N(V, T, C)
Definition: internal.h:13
PN ptr
Definition: potion.h:307
#define N
Definition: mt19937ar.c:52
PN_SIZE siz
Definition: potion.h:306

Definition at line 35 of file internal.h.

#define PN_FLEX_NEEDS (   X,
  N,
  V,
  T,
 
)
Value:
({ \
PN_SIZE capa = (N)->siz / sizeof(*(N)->ptr); \
if (capa < (N)->len + X) { \
while (capa < (N)->len + X) \
capa += S; \
capa = sizeof(*(N)->ptr) * capa; \
PN_REALLOC(N, V, T, capa); \
(N)->siz = capa; \
} \
})
PN ptr
Definition: potion.h:307
#define PN_REALLOC(X, V, T, N)
Definition: internal.h:15
#define N
Definition: mt19937ar.c:52
unsigned int PN_SIZE
Definition: potion.h:79
PN_SIZE siz
Definition: potion.h:306

Definition at line 40 of file internal.h.

#define PN_ATOI (   X,
  N,
 
)
Value:
({ \
char *Ap = X; \
long Ai = 0; int Am = 1; \
size_t Al = N; \
if (*Ap == '-') { Am = -1; Ap++; Al--; } \
while (Al--) { \
if ((*Ap >= '0') && (*Ap <= '9')) \
Ai = (Ai * B) + (*Ap - '0'); \
else if ((*Ap >= 'A') && (*Ap <= 'F')) \
Ai = (Ai * B) + ((*Ap - 'A') + 10); \
else if ((*Ap >= 'a') && (*Ap <= 'f')) \
Ai = (Ai * B) + ((*Ap - 'a') + 10); \
else break; \
Ap++; \
} \
Ai * Am; \
})
#define N
Definition: mt19937ar.c:52

Definition at line 51 of file internal.h.

#define PN_ALLOC_FUNC (   size)    potion_mmap(size, 1)

Definition at line 88 of file internal.h.

#define PN_SAVED_REGS   3

Definition at line 108 of file internal.h.

#define POTION_ESP (   p)    __asm__("mov %%esp, %0" : "=r" (*p))

Definition at line 115 of file internal.h.

#define POTION_EBP (   p)    __asm__("mov %%ebp, %0" : "=r" (*p))

Definition at line 118 of file internal.h.

#define O_BINARY   0

Definition at line 128 of file internal.h.

#define GC_PROTECT (   P)    P->mem->protect = (void *)P->mem->birth_cur

Definition at line 137 of file internal.h.

Typedef Documentation

typedef unsigned char u8

Definition at line 8 of file internal.h.

Function Documentation

size_t potion_cp_strlen_utf8 ( const char *  _s)

wonderful utf-8 counting trickery by colin percival

http://www.daemonology.net/blog/2008-06-05-faster-utf8-strlen.html

Definition at line 17 of file contrib.c.

void* potion_mmap ( size_t  ,
const char   
)

Definition at line 89 of file contrib.c.

int potion_munmap ( void *  ,
size_t   
)

Definition at line 101 of file contrib.c.

PN potion_vm_eq ( Potion ,
PN  ,
PN   
)

Definition at line 416 of file vm.c.

PN potion_vm_neq ( Potion ,
PN  ,
PN   
)

Definition at line 427 of file vm.c.