// license:GPL-2.0+ // copyright-holders:Couriersud /* * palloc.c * */ #include "pconfig.h" #include "palloc.h" #include "pfmtlog.h" #include namespace plib { //============================================================ // Memory pool //============================================================ mempool::mempool(size_t min_alloc, size_t min_align) : m_min_alloc(min_alloc), m_min_align(min_align) { } mempool::~mempool() { for (auto & b : m_blocks) { if (b.m_num_alloc != 0) { fprintf(stderr, "Found block with %d dangling allocations\n", static_cast(b.m_num_alloc)); } ::operator delete(b.data); } m_blocks.clear(); } size_t mempool::new_block() { block b; b.data = static_cast(::operator new(m_min_alloc)); b.cur_ptr = b.data; b.m_free = m_min_alloc; b.m_num_alloc = 0; m_blocks.push_back(b); return m_blocks.size() - 1; } size_t mempool::mininfosize() { size_t sinfo = sizeof(mempool::info); #ifdef __APPLE__ size_t ma = 16; #else size_t ma = 8; #endif return ((std::max(m_min_align, sinfo) + ma - 1) / ma) * ma; } void *mempool::alloc(size_t size) { size_t rs = (size + mininfosize() + m_min_align - 1) & ~(m_min_align - 1); for (size_t bn=0; bn < m_blocks.size(); bn++) { auto &b = m_blocks[bn]; if (b.m_free > rs) { b.m_free -= rs; b.m_num_alloc++; auto i = reinterpret_cast(b.cur_ptr); i->m_block = bn; auto ret = reinterpret_cast(b.cur_ptr + mininfosize()); b.cur_ptr += rs; return ret; } } { size_t bn = new_block(); auto &b = m_blocks[bn]; b.m_num_alloc = 1; b.m_free = m_min_alloc - rs; auto i = reinterpret_cast(b.cur_ptr); i->m_block = bn; auto ret = reinterpret_cast(b.cur_ptr + mininfosize()); b.cur_ptr += rs; return ret; } } void mempool::free(void *ptr) { auto p = reinterpret_cast(ptr); auto i = reinterpret_cast(p - mininfosize()); block *b = &m_blocks[i->m_block]; if (b->m_num_alloc == 0) fprintf(stderr, "Argh .. double free\n"); else { //b->m_free = m_min_alloc; //b->cur_ptr = b->data; } b->m_num_alloc--; } } man/jedutil.1
blob: 4a0ce38e03fcec00efface6a775fed8013142c84 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
.\"  -*- nroff -*-
.\"
.\" jedutil.1
.\"
.\" Man page created from source and usage information
.\" Cesare Falco <c.falco@ubuntu.com>, February 2007
.\" 
.\" References
.\" http://aarongiles.com/?p=159
.\"
.TH JEDUTIL 1 2016-07-21 0.176 "MAME JEDEC file utilities"
.\"
.\" NAME chapter
.SH NAME
jedutil \- MAME JEDEC file utilities
.\"
.\" SYNOPSIS chapter
.SH SYNOPSIS
.B jedutil
.RI [ option ]
.\"
.\" DESCRIPTION chapter
.SH DESCRIPTION
Data for Programmable Logic Devices (PLDs) are usually stored in a format known
as JEDEC, basically a text file allowing insertion of further information by
programmers.
.PP
MAME uses a raw binary representation of the same data, in order to
achieve correct identification of PLD data through CRC and SHA1 algorithms
(i.e. with the \-romident option).
.PP
.B jedutil
provides an easy way to convert PLDs data between these two formats.
.\"
.\" OPTIONS chapter
.SH OPTIONS
.TP
.B \-convert \fIinputfile outputfile \fR[\fIfuses\fR]
Converts JEDEC data between file formats. Both .jed (JEDEC) and .pla
(Berkeley standard PLA) files can be converted to a .bin (binary) file,
while a binary file can be converted to a .jed file only.
.TP
.B \-view \fIinputfile device
Dump logic equations. \fIinputfile\fR can be either a JED or binary file.
.TP
.B \-viewlist
View list of supported devices.
.SH SEE ALSO
mame(6), mess(6)