@ -1,6 +1,6 @@
#include "likely.h"
#include <stdlib.h>
#ifndef __MINGW32__
#ifndef _WIN32
#include <fcntl.h>
#include <sys/mman.h>
#include <unistd.h>
@ -13,7 +13,7 @@
#endif
static iarray_page* new_page(size_t pagesize) {
#ifdef __MINGW32__
#ifdef _WIN32
void* x=malloc(pagesize);
if (x==0) return 0;
#else
@ -49,7 +49,7 @@ void* iarray_allocate(iarray* ia,size_t pos) {
p=&(*p)->next;
}
if (newpage)
free(newpage);
munmap(newpage,ia->bytesperpage);
@ -1,14 +1,15 @@
#include "iarray.h"
static void freechain(iarray_page* p,size_t pagesize) {
while (p) {
iarray_page* n=p->next;
free(p);
munmap(p,pagesize);
@ -11,7 +11,13 @@ static unsigned int fmt_2digits(char* dest,int i) {
size_t fmt_httpdate(char* dest,time_t t) {
static const char days[] = "SunMonTueWedThuFriSat";
static const char months[] = "JanFebMarAprMayJunJulAugSepOctNovDec";
struct tm tmp;
struct tm* x=&tmp;
gmtime_s(&tmp,&t); // can't recover from when this fails
struct tm* x=gmtime(&t);
size_t i;
if (dest==0) return 29;
@ -9,7 +9,13 @@ static unsigned int fmt_2digits(char* dest,int i) {
size_t fmt_iso8601(char* dest,time_t t) {
if (dest==0) return sizeof("2014-05-27T19:22:16Z")-1;
@ -1,15 +1,15 @@
#include <sys/types.h>
#include <windows.h>
#include "open.h"
#include "mmap.h"
char* mmap_private(const char* filename,size_t * filesize) {
HANDLE fd,m;
char* map;
fd=CreateFile(filename,GENERIC_WRITE|GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,0,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);
extern const char* mmap_read(const char* filename,size_t * filesize) {
fd=CreateFile(filename,GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,0,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);
@ -2,18 +2,17 @@
#define _ATFILE_SOURCE
#include <sys/stat.h>
extern const char* mmap_readat(const char* filename,size_t * filesize,int dirfd) {
return 0;
int fd=openat(dirfd,filename,O_RDONLY);
extern char* mmap_shared(const char* filename,size_t * filesize) {
fd=CreateFile(filename,GENERIC_READ|GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,0,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);
int mmap_unmap(const char* mapped,size_t maplen) {
(void)maplen;
return UnmapViewOfFile(mapped)?0:-1;