New mason-based build system

This commit is contained in:
Konstantin Käfer
2014-10-22 15:13:35 +02:00
37 changed files with 311 additions and 519 deletions

View File

@@ -59,7 +59,7 @@ struct BucketAlloc
static int CreateBucket( struct BucketAlloc* ba )
{
size_t size;
unsigned int size;
Bucket* bucket;
void* freelist;
unsigned char* head;

View File

@@ -209,13 +209,13 @@ PQhandle pqHeapInsert( TESSalloc* alloc, PriorityQHeap *pq, PQkey keyNew )
// If the heap overflows, double its size.
pq->max <<= 1;
pq->nodes = (PQnode *)alloc->memrealloc( alloc->userData, pq->nodes,
(size_t)((pq->max + 1) * sizeof( pq->nodes[0] )));
(unsigned int)((pq->max + 1) * sizeof( pq->nodes[0] )));
if (pq->nodes == NULL) {
pq->nodes = saveNodes; // restore ptr to free upon return
return INV_HANDLE;
}
pq->handles = (PQhandleElem *)alloc->memrealloc( alloc->userData, pq->handles,
(size_t) ((pq->max + 1) * sizeof( pq->handles[0] )));
(unsigned int) ((pq->max + 1) * sizeof( pq->handles[0] )));
if (pq->handles == NULL) {
pq->handles = saveHandles; // restore ptr to free upon return
return INV_HANDLE;
@@ -351,7 +351,7 @@ int pqInit( TESSalloc* alloc, PriorityQ *pq )
(pq->size * sizeof(pq->order[0])) );
*/
pq->order = (PQkey **)alloc->memalloc( alloc->userData,
(size_t)((pq->size+1) * sizeof(pq->order[0])) );
(unsigned int)((pq->size+1) * sizeof(pq->order[0])) );
/* the previous line is a patch to compensate for the fact that IBM */
/* machines return a null on a malloc of zero bytes (unlike SGI), */
/* so we have to put in this defense to guard against a memory */
@@ -438,7 +438,7 @@ PQhandle pqInsert( TESSalloc* alloc, PriorityQ *pq, PQkey keyNew )
// If the heap overflows, double its size.
pq->max <<= 1;
pq->keys = (PQkey *)alloc->memrealloc( alloc->userData, pq->keys,
(size_t)(pq->max * sizeof( pq->keys[0] )));
(unsigned int)(pq->max * sizeof( pq->keys[0] )));
if (pq->keys == NULL) {
pq->keys = saveKey; // restore ptr to free upon return
return INV_HANDLE;

View File

@@ -428,6 +428,8 @@ static void VertexWeights( TESSvertex *isect, TESSvertex *org, TESSvertex *dst,
}
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
static void GetIntersectData( TESStesselator *tess, TESSvertex *isect,
TESSvertex *orgUp, TESSvertex *dstUp,
TESSvertex *orgLo, TESSvertex *dstLo )
@@ -444,6 +446,7 @@ static void GetIntersectData( TESStesselator *tess, TESSvertex *isect,
VertexWeights( isect, orgUp, dstUp, &weights[0] );
VertexWeights( isect, orgLo, dstLo, &weights[2] );
}
#pragma GCC diagnostic pop
static int CheckForRightSplice( TESStesselator *tess, ActiveRegion *regUp )
/*

View File

@@ -46,17 +46,6 @@
#define Dot(u,v) (u[0]*v[0] + u[1]*v[1] + u[2]*v[2])
static void Normalize( TESSreal v[3] )
{
TESSreal len = v[0]*v[0] + v[1]*v[1] + v[2]*v[2];
assert( len > 0 );
len = sqrtf( len );
v[0] /= len;
v[1] /= len;
v[2] /= len;
}
#define ABS(x) ((x) < 0 ? -(x) : (x))
static int LongAxis( TESSreal v[3] )
@@ -436,6 +425,8 @@ int tessMeshSetWindingNumber( TESSmesh *mesh, int value,
return 1;
}
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
void* heapAlloc( void* userData, unsigned int size )
{
return malloc( size );
@@ -450,6 +441,7 @@ void heapFree( void* userData, void* ptr )
{
free( ptr );
}
#pragma GCC diagnostic pop
static TESSalloc defaulAlloc =
{

View File

@@ -145,10 +145,6 @@ void Map::stop(stop_callback cb, void *data) {
async = false;
}
void Map::delete_async(uv_handle_t *handle) {
delete (uv_async_t *)handle;
}
void Map::run() {
#ifndef NDEBUG
if (!async) {
@@ -203,7 +199,11 @@ void Map::cleanup() {
}
}
#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10
void Map::cleanup(uv_async_t *async, int) {
#else
void Map::cleanup(uv_async_t *async) {
#endif
Map *map = static_cast<Map *>(async->data);
map->view.make_active();
@@ -221,7 +221,11 @@ void Map::setReachability(bool reachable) {
}
}
#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10
void Map::render(uv_async_t *async, int) {
#else
void Map::render(uv_async_t *async) {
#endif
Map *map = static_cast<Map *>(async->data);
assert(uv_thread_self() == map->map_thread);
@@ -241,7 +245,11 @@ void Map::render(uv_async_t *async) {
}
}
#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10
void Map::terminate(uv_async_t *async, int) {
#else
void Map::terminate(uv_async_t *async) {
#endif
// Closes all open handles on the loop. This means that the loop will automatically terminate.
Map *map = static_cast<Map *>(async->data);
assert(uv_thread_self() == map->map_thread);

View File

@@ -29,7 +29,11 @@ void FileRequestBaton::notify_error(uv_fs_t *req) {
if (ptr->request && req->result < 0 && !ptr->canceled && req->result != UV_ECANCELED) {
ptr->request->response = std::unique_ptr<Response>(new Response);
ptr->request->response->code = req->result == UV_ENOENT ? 404 : 500;
#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10
ptr->request->response->message = uv_strerror(uv_last_error(req->loop));
#else
ptr->request->response->message = uv_strerror(int(req->result));
#endif
ptr->request->notify();
}
}
@@ -63,7 +67,7 @@ void FileRequestBaton::file_stated(uv_fs_t *req) {
FileRequestBaton *ptr = (FileRequestBaton *)req->data;
assert(ptr->thread_id == uv_thread_self());
if (req->result < 0 || ptr->canceled || !ptr->request) {
if (req->result != 0 || ptr->canceled || !ptr->request) {
// Stating failed or was canceled. We already have an open file handle
// though, which we'll have to close.
notify_error(req);
@@ -71,13 +75,22 @@ void FileRequestBaton::file_stated(uv_fs_t *req) {
uv_fs_req_cleanup(req);
uv_fs_close(req->loop, req, ptr->fd, file_closed);
} else {
if (static_cast<const uv_stat_t *>(req->ptr)->st_size > std::numeric_limits<int>::max()) {
#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10
const uv_statbuf_t *stat = static_cast<const uv_statbuf_t *>(req->ptr);
#else
const uv_stat_t *stat = static_cast<const uv_stat_t *>(req->ptr);
#endif
if (stat->st_size > std::numeric_limits<int>::max()) {
// File is too large for us to open this way because uv_buf's only support unsigned
// ints as maximum size.
if (ptr->request) {
ptr->request->response = std::unique_ptr<Response>(new Response);
ptr->request->response->code = UV_EFBIG;
#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10
ptr->request->response->message = uv_strerror(uv_err_t {UV_EFBIG, 0});
#else
ptr->request->response->message = uv_strerror(UV_EFBIG);
#endif
ptr->request->notify();
}
@@ -85,11 +98,15 @@ void FileRequestBaton::file_stated(uv_fs_t *req) {
uv_fs_close(req->loop, req, ptr->fd, file_closed);
} else {
const unsigned int size =
(unsigned int)(static_cast<const uv_stat_t *>(req->ptr)->st_size);
(unsigned int)(stat->st_size);
ptr->body.resize(size);
ptr->buffer = uv_buf_init(const_cast<char *>(ptr->body.data()), size);
uv_fs_req_cleanup(req);
#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10
uv_fs_read(req->loop, req, ptr->fd, ptr->buffer.base, ptr->buffer.len, -1, file_read);
#else
uv_fs_read(req->loop, req, ptr->fd, &ptr->buffer, 1, 0, file_read);
#endif
}
}
}
@@ -117,8 +134,7 @@ void FileRequestBaton::file_read(uv_fs_t *req) {
}
void FileRequestBaton::file_closed(uv_fs_t *req) {
FileRequestBaton *ptr = (FileRequestBaton *)req->data;
assert(ptr->thread_id == uv_thread_self());
assert(((FileRequestBaton *)req->data)->thread_id == uv_thread_self());
if (req->result < 0) {
// Closing the file failed. But there isn't anything we can do.

View File

@@ -77,7 +77,11 @@ void HTTPRequest::startHTTPRequest(std::unique_ptr<Response> &&res) {
http_baton->response = std::move(res);
http_baton->async->data = new util::ptr<HTTPRequestBaton>(http_baton);
#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10
uv_async_init(loop, http_baton->async, [](uv_async_t *async, int) {
#else
uv_async_init(loop, http_baton->async, [](uv_async_t *async) {
#endif
util::ptr<HTTPRequestBaton> &http_baton = *(util::ptr<HTTPRequestBaton> *)async->data;
if (http_baton->request) {
@@ -193,7 +197,12 @@ void HTTPRequest::retryHTTPRequest(std::unique_ptr<Response> &&res, uint64_t tim
backoff_timer = new uv_timer_t();
uv_timer_init(loop, backoff_timer);
backoff_timer->data = new RetryBaton(this, std::move(res));
#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10
uv_timer_start(backoff_timer, [](uv_timer_t *timer, int) {
#else
uv_timer_start(backoff_timer, [](uv_timer_t *timer) {
#endif
std::unique_ptr<RetryBaton> pair { static_cast<RetryBaton *>(timer->data) };
pair->first->startHTTPRequest(std::move(pair->second));
pair->first->backoff_timer = nullptr;

View File

@@ -18,10 +18,10 @@ template <typename T>
T StopsFunction<T>::evaluate(float z) const {
bool smaller = false;
float smaller_z = 0.0f;
T smaller_val {};
T smaller_val = T();
bool larger = false;
float larger_z = 0.0f;
T larger_val {};
T larger_val = T();
for (uint32_t i = 0; i < values.size(); i++) {
float stop_z = values[i].first;

View File

@@ -18,7 +18,7 @@ std::string compress(const std::string &raw) {
}
deflate_stream.next_in = (Bytef *)raw.data();
deflate_stream.avail_in = raw.size();
deflate_stream.avail_in = uInt(raw.size());
std::string result;
char out[16384];
@@ -53,7 +53,7 @@ std::string decompress(const std::string &raw) {
}
inflate_stream.next_in = (Bytef *)raw.data();
inflate_stream.avail_in = raw.size();
inflate_stream.avail_in = uInt(raw.size());
std::string result;
char out[15384];

View File

@@ -208,7 +208,7 @@ int raw_equal(const char *first, const char *second)
int clamp_to_int(long slnum)
{
return slnum > INT_MAX ? INT_MAX : slnum < INT_MIN ? INT_MIN : slnum;
return slnum > INT_MAX ? INT_MAX : slnum < INT_MIN ? INT_MIN : (int)slnum;
}

View File

@@ -8,7 +8,15 @@ typedef struct {
void *queue[2];
} uv__messenger_item_t;
#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-parameter"
void uv__messenger_callback(uv_async_t *async, int status) {
#pragma clang diagnostic pop
#else
void uv__messenger_callback(uv_async_t *async) {
#endif
uv_messenger_t *msgr = (uv_messenger_t *)async->data;
uv__messenger_item_t *item;

View File

@@ -5,6 +5,11 @@
namespace uv {
std::string cwd() {
#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10
char dir[512];
uv_cwd(dir, 512);
return dir;
#else
size_t max = 0;
std::string dir;
do {
@@ -14,6 +19,7 @@ std::string cwd() {
} while (max == dir.size());
dir.resize(max - 1);
return dir;
#endif
}
void deleter::operator()(uv_async_t *async) {