File: compat-cygwin.c

package info (click to toggle)
sparse 0.4.1-1
  • links: PTS, VCS
  • area: non-free
  • in suites: lenny
  • size: 1,268 kB
  • ctags: 2,691
  • sloc: ansic: 23,892; perl: 204; sh: 181; makefile: 174
file content (40 lines) | stat: -rw-r--r-- 733 bytes parent folder | download | duplicates (5)
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
/*	
 * Cygwin Compatibility functions	
 *	
 *	
 *  Licensed under the Open Software License version 1.1	
 */	
	
	
	
#include <sys/mman.h>	
#include <stdlib.h>	
#include <string.h>	
#include <sys/stat.h>

#include "lib.h"
#include "allocate.h"
#include "token.h"
	
void *blob_alloc(unsigned long size)	
{	
	void *ptr;	
	size = (size + 4095) & ~4095;	
	ptr = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);	
	if (ptr == MAP_FAILED)	
		ptr = NULL;	
	else	
		memset(ptr, 0, size);	
	return ptr;	
}	
	
void blob_free(void *addr, unsigned long size)	
{	
	size = (size + 4095) & ~4095;	
	munmap(addr, size);	
}	
	
long double string_to_ld(const char *nptr, char **endptr) 	
{	
	return strtod(nptr, endptr);	
}