mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-23 18:32:55 +00:00
check for posix_memalign(), pthread_attr_get_np() and madvise() during build
replace mmap() calls with QT_MMAP() so that mmap64() is called when supported by the host while at it and remove conditions that are assumed to always be true Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
1a73186189
commit
8d75d78a4f
13 changed files with 50 additions and 110 deletions
|
@ -362,6 +362,7 @@ katie_check_function(nl_langinfo "langinfo.h")
|
|||
katie_check_function(getaddrinfo "netdb.h")
|
||||
katie_check_function(clock_gettime "time.h")
|
||||
katie_check_function(vsnprintf "stdio.h")
|
||||
katie_check_function(posix_memalign "stdlib.h")
|
||||
# XSI/POSIX.1-2001
|
||||
katie_check_function(strerror_r "string.h")
|
||||
# SUSv2
|
||||
|
@ -372,6 +373,8 @@ katie_check_function(fcvt "stdlib.h")
|
|||
katie_check_function(ecvt "stdlib.h")
|
||||
# NetBSD 1.6 and FreeBSD 4.4
|
||||
katie_check_function(getprogname "stdlib.h")
|
||||
# FreeBSD 5.4
|
||||
katie_check_function(pthread_attr_get_np "pthread_np.h")
|
||||
# GNU
|
||||
katie_check_function(get_current_dir_name "unistd.h")
|
||||
katie_check_function(prctl "sys/prctl.h")
|
||||
|
@ -382,6 +385,7 @@ katie_check_function(fesetenv "fenv.h")
|
|||
katie_check_function(feclearexcept "fenv.h")
|
||||
katie_check_function(feenableexcept "fenv.h")
|
||||
# none
|
||||
katie_check_function(madvise "sys/mman.h")
|
||||
katie_check_function(getifaddrs "ifaddrs.h")
|
||||
katie_check_struct(sockaddr_ll sll_addr "netpacket/packet.h")
|
||||
katie_check_struct(sockaddr_dl sdl_index "net/if_dl.h")
|
||||
|
|
|
@ -33,17 +33,14 @@ namespace JSC {
|
|||
|
||||
RegisterFile::~RegisterFile()
|
||||
{
|
||||
#if HAVE(MMAP)
|
||||
munmap(reinterpret_cast<char*>(m_buffer), ((m_max - m_start) + m_maxGlobals) * sizeof(Register));
|
||||
#else
|
||||
fastFree(m_buffer);
|
||||
#endif
|
||||
::munmap(reinterpret_cast<char*>(m_buffer), ((m_max - m_start) + m_maxGlobals) * sizeof(Register));
|
||||
}
|
||||
|
||||
void RegisterFile::releaseExcessCapacity()
|
||||
{
|
||||
#if HAVE(MMAP) && HAVE(MADV_FREE)
|
||||
while (madvise(m_start, (m_max - m_start) * sizeof(Register), MADV_FREE) == -1 && errno == EAGAIN) { }
|
||||
// Hurd does not have MAD_FREE
|
||||
#if defined(QT_HAVE_MADVISE) && defined(MADV_FREE)
|
||||
while (::madvise(m_start, (m_max - m_start) * sizeof(Register), MADV_FREE) == -1 && errno == EAGAIN) { }
|
||||
#endif
|
||||
m_maxUsed = m_start;
|
||||
}
|
||||
|
|
|
@ -31,13 +31,13 @@
|
|||
|
||||
#include "Collector.h"
|
||||
#include "Register.h"
|
||||
#include <stdio.h>
|
||||
#include <wtf/Noncopyable.h>
|
||||
|
||||
#if HAVE(MMAP)
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <sys/mman.h>
|
||||
#endif
|
||||
|
||||
#include <qplatformdefs.h>
|
||||
|
||||
namespace JSC {
|
||||
|
||||
|
@ -167,23 +167,11 @@ namespace JSC {
|
|||
Q_ASSERT(isPageAligned(capacity));
|
||||
|
||||
size_t bufferLength = (capacity + maxGlobals) * sizeof(Register);
|
||||
#if HAVE(MMAP)
|
||||
m_buffer = reinterpret_cast<Register*>(mmap(0, bufferLength, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, -1, 0));
|
||||
m_buffer = reinterpret_cast<Register*>(QT_MMAP(0, bufferLength, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, -1, 0));
|
||||
if (m_buffer == MAP_FAILED) {
|
||||
fprintf(stderr, "Could not allocate register file: %d\n", errno);
|
||||
CRASH();
|
||||
}
|
||||
#else
|
||||
/*
|
||||
* If MMAP is not available - use fastMalloc instead.
|
||||
*
|
||||
* Please note that this is the fallback case, which is non-optimal.
|
||||
* If any possible, the platform should provide for a better memory
|
||||
* allocation mechanism that allows for "lazy commit" or dynamic
|
||||
* pre-allocation, similar to mmap, to avoid waste of memory.
|
||||
*/
|
||||
m_buffer = static_cast<Register*>(fastMalloc(bufferLength));
|
||||
#endif
|
||||
m_start = m_buffer + maxGlobals;
|
||||
m_end = m_start;
|
||||
m_maxUsed = m_end;
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
#if HAVE(PTHREAD_NP_H)
|
||||
#if defined(QT_HAVE_PTHREAD_ATTR_GET_NP)
|
||||
#include <pthread_np.h>
|
||||
#endif
|
||||
|
||||
|
@ -104,9 +104,9 @@ void Heap::destroy()
|
|||
|
||||
NEVER_INLINE CollectorBlock* Heap::allocateBlock()
|
||||
{
|
||||
#if HAVE(POSIX_MEMALIGN)
|
||||
#if defined(QT_HAVE_POSIX_MEMALIGN)
|
||||
void* address;
|
||||
posix_memalign(&address, BLOCK_SIZE, BLOCK_SIZE);
|
||||
::posix_memalign(&address, BLOCK_SIZE, BLOCK_SIZE);
|
||||
#else
|
||||
|
||||
static size_t pagesize = getpagesize();
|
||||
|
@ -115,7 +115,7 @@ NEVER_INLINE CollectorBlock* Heap::allocateBlock()
|
|||
if (BLOCK_SIZE > pagesize)
|
||||
extra = BLOCK_SIZE - pagesize;
|
||||
|
||||
void* mmapResult = mmap(NULL, BLOCK_SIZE + extra, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
|
||||
void* mmapResult = QT_MMAP(NULL, BLOCK_SIZE + extra, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
|
||||
uintptr_t address = reinterpret_cast<uintptr_t>(mmapResult);
|
||||
|
||||
size_t adjust = 0;
|
||||
|
@ -123,10 +123,10 @@ NEVER_INLINE CollectorBlock* Heap::allocateBlock()
|
|||
adjust = BLOCK_SIZE - (address & BLOCK_OFFSET_MASK);
|
||||
|
||||
if (adjust > 0)
|
||||
munmap(reinterpret_cast<char*>(address), adjust);
|
||||
::munmap(reinterpret_cast<char*>(address), adjust);
|
||||
|
||||
if (adjust < extra)
|
||||
munmap(reinterpret_cast<char*>(address + adjust + BLOCK_SIZE), extra - adjust);
|
||||
::munmap(reinterpret_cast<char*>(address + adjust + BLOCK_SIZE), extra - adjust);
|
||||
|
||||
address += adjust;
|
||||
#endif
|
||||
|
@ -179,10 +179,10 @@ NEVER_INLINE void Heap::freeBlock(size_t block)
|
|||
|
||||
NEVER_INLINE void Heap::freeBlockPtr(CollectorBlock* block)
|
||||
{
|
||||
#if HAVE(POSIX_MEMALIGN)
|
||||
free(block);
|
||||
#if defined(QT_HAVE_POSIX_MEMALIGN)
|
||||
::free(block);
|
||||
#else
|
||||
munmap(reinterpret_cast<char*>(block), BLOCK_SIZE);
|
||||
::munmap(reinterpret_cast<char*>(block), BLOCK_SIZE);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -350,7 +350,7 @@ static inline void* currentThreadStackBase()
|
|||
if (stackBase == 0 || thread != stackThread) {
|
||||
pthread_attr_t sattr;
|
||||
pthread_attr_init(&sattr);
|
||||
#if HAVE(PTHREAD_NP_H)
|
||||
#if defined(QT_HAVE_PTHREAD_ATTR_GET_NP)
|
||||
// e.g. on FreeBSD 5.4, neundorf@kde.org
|
||||
pthread_attr_get_np(thread, &sattr);
|
||||
#else
|
||||
|
|
|
@ -30,13 +30,11 @@
|
|||
#include "JSString.h"
|
||||
#include "ObjectPrototype.h"
|
||||
#include "PrototypeFunction.h"
|
||||
#include <math.h>
|
||||
#include <time.h>
|
||||
#include <wtf/DateMath.h>
|
||||
|
||||
#if HAVE(SYS_TIME_H)
|
||||
#include <math.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
using namespace WTF;
|
||||
|
||||
|
|
|
@ -22,30 +22,22 @@
|
|||
|
||||
#include "Platform.h"
|
||||
#include "DatePrototype.h"
|
||||
|
||||
#include "DateConversion.h"
|
||||
#include "Error.h"
|
||||
#include "JSString.h"
|
||||
#include "ObjectPrototype.h"
|
||||
#include "DateInstance.h"
|
||||
|
||||
#if HAVE(LANGINFO_H)
|
||||
#include <langinfo.h>
|
||||
#endif
|
||||
#include <wtf/Assertions.h>
|
||||
#include <wtf/DateMath.h>
|
||||
|
||||
#include <limits.h>
|
||||
#include <locale.h>
|
||||
#include <math.h>
|
||||
#include <time.h>
|
||||
#include <wtf/Assertions.h>
|
||||
#include <wtf/DateMath.h>
|
||||
|
||||
#if HAVE(SYS_PARAM_H)
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
|
||||
#if HAVE(SYS_TIME_H)
|
||||
#include <sys/time.h>
|
||||
|
||||
#if defined(QT_HAVE_NL_LANGINFO)
|
||||
#include <langinfo.h>
|
||||
#endif
|
||||
|
||||
using namespace WTF;
|
||||
|
@ -111,7 +103,7 @@ enum LocaleDateTimeFormat { LocaleDateAndTime, LocaleDate, LocaleTime };
|
|||
|
||||
static JSCell* formatLocaleDate(ExecState* exec, const GregorianDateTime& gdt, LocaleDateTimeFormat format)
|
||||
{
|
||||
#if HAVE(LANGINFO_H)
|
||||
#if defined(QT_HAVE_NL_LANGINFO)
|
||||
static const nl_item formats[] = { D_T_FMT, D_FMT, T_FMT };
|
||||
#else
|
||||
static const char* const formatStrings[] = { "%#c", "%#x", "%X" };
|
||||
|
@ -124,11 +116,11 @@ static JSCell* formatLocaleDate(ExecState* exec, const GregorianDateTime& gdt, L
|
|||
if (yearNeedsOffset)
|
||||
localTM.tm_year = equivalentYearForDST(year) - 1900;
|
||||
|
||||
#if HAVE(LANGINFO_H)
|
||||
#if defined(QT_HAVE_NL_LANGINFO)
|
||||
// We do not allow strftime to generate dates with 2-digits years,
|
||||
// both to avoid ambiguity, and a crash in strncpy, for years that
|
||||
// need offset.
|
||||
char* formatString = strdup(nl_langinfo(formats[format]));
|
||||
char* formatString = ::strdup(::nl_langinfo(formats[format]));
|
||||
char* yPos = strchr(formatString, 'y');
|
||||
if (yPos)
|
||||
*yPos = 'Y';
|
||||
|
@ -138,11 +130,11 @@ static JSCell* formatLocaleDate(ExecState* exec, const GregorianDateTime& gdt, L
|
|||
const int bufsize = 128;
|
||||
char timebuffer[bufsize];
|
||||
|
||||
#if HAVE(LANGINFO_H)
|
||||
size_t ret = strftime(timebuffer, bufsize, formatString, &localTM);
|
||||
free(formatString);
|
||||
#if defined(QT_HAVE_NL_LANGINFO)
|
||||
size_t ret = ::strftime(timebuffer, bufsize, formatString, &localTM);
|
||||
::free(formatString);
|
||||
#else
|
||||
size_t ret = strftime(timebuffer, bufsize, formatStrings[format], &localTM);
|
||||
size_t ret = ::strftime(timebuffer, bufsize, formatStrings[format], &localTM);
|
||||
#endif
|
||||
|
||||
if (ret == 0)
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
#include <unistd.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include <qplatformdefs.h>
|
||||
|
||||
namespace JSC {
|
||||
|
||||
size_t MarkStack::s_pageSize = 0;
|
||||
|
@ -42,16 +44,16 @@ void MarkStack::compact()
|
|||
|
||||
void MarkStack::initializePagesize()
|
||||
{
|
||||
MarkStack::s_pageSize = getpagesize();
|
||||
MarkStack::s_pageSize = ::getpagesize();
|
||||
}
|
||||
|
||||
void* MarkStack::allocateStack(size_t size)
|
||||
{
|
||||
return mmap(0, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
|
||||
return QT_MMAP(0, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
|
||||
}
|
||||
void MarkStack::releaseStack(void* addr, size_t size)
|
||||
{
|
||||
munmap(reinterpret_cast<char*>(addr), size);
|
||||
::munmap(reinterpret_cast<char*>(addr), size);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
13
src/3rdparty/javascriptcore/runtime/UString.cpp
vendored
13
src/3rdparty/javascriptcore/runtime/UString.cpp
vendored
|
@ -29,6 +29,11 @@
|
|||
#include "dtoa.h"
|
||||
#include "Identifier.h"
|
||||
#include "Operations.h"
|
||||
#include <wtf/ASCIICType.h>
|
||||
#include <wtf/Assertions.h>
|
||||
#include <wtf/Vector.h>
|
||||
#include <wtf/unicode/UTF8.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
#include <limits>
|
||||
|
@ -36,14 +41,6 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <wtf/ASCIICType.h>
|
||||
#include <wtf/Assertions.h>
|
||||
#include <wtf/Vector.h>
|
||||
#include <wtf/unicode/UTF8.h>
|
||||
|
||||
#if HAVE(STRINGS_H)
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#include <QTextCodec>
|
||||
|
||||
|
|
13
src/3rdparty/javascriptcore/wtf/DateMath.cpp
vendored
13
src/3rdparty/javascriptcore/wtf/DateMath.cpp
vendored
|
@ -81,15 +81,8 @@
|
|||
#include <limits>
|
||||
#include <stdint.h>
|
||||
#include <time.h>
|
||||
|
||||
|
||||
#if HAVE(ERRNO_H)
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
#if HAVE(SYS_TIME_H)
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#define NaN std::numeric_limits<double>::quiet_NaN()
|
||||
|
||||
|
@ -360,7 +353,7 @@ int equivalentYearForDST(int year)
|
|||
|
||||
static int32_t calculateUTCOffset()
|
||||
{
|
||||
time_t localTime = time(0);
|
||||
time_t localTime = ::time(0);
|
||||
tm localt;
|
||||
getLocalTime(&localTime, &localt);
|
||||
|
||||
|
@ -382,11 +375,11 @@ static int32_t calculateUTCOffset()
|
|||
#endif
|
||||
|
||||
#if HAVE(TIMEGM)
|
||||
time_t utcOffset = timegm(&localt) - mktime(&localt);
|
||||
time_t utcOffset = ::timegm(&localt) - ::mktime(&localt);
|
||||
#else
|
||||
// Using a canned date of 01/01/2009 on platforms with weaker date-handling foo.
|
||||
localt.tm_year = 109;
|
||||
time_t utcOffset = 1230768000 - mktime(&localt);
|
||||
time_t utcOffset = 1230768000 - ::mktime(&localt);
|
||||
#endif
|
||||
|
||||
return static_cast<int32_t>(utcOffset * 1000);
|
||||
|
|
17
src/3rdparty/javascriptcore/wtf/Platform.h
vendored
17
src/3rdparty/javascriptcore/wtf/Platform.h
vendored
|
@ -45,29 +45,12 @@ QT_USE_NAMESPACE
|
|||
|
||||
/* Operating environments */
|
||||
|
||||
#if defined(Q_OS_FREEBSD) || defined(Q_OS_OPENBSD)
|
||||
#define HAVE_PTHREAD_NP_H 1
|
||||
#endif
|
||||
|
||||
#if !defined(Q_OS_SOLARIS)
|
||||
#define HAVE_TM_GMTOFF 1
|
||||
#define HAVE_TM_ZONE 1
|
||||
#define HAVE_TIMEGM 1
|
||||
#endif
|
||||
|
||||
#if !defined(Q_OS_SOLARIS) && !defined(Q_OS_HURD)
|
||||
#define HAVE_MADV_FREE 1
|
||||
#endif
|
||||
|
||||
#define HAVE_ERRNO_H 1
|
||||
#define HAVE_SIGNAL_H 1
|
||||
#define HAVE_LANGINFO_H 1
|
||||
#define HAVE_STRINGS_H 1
|
||||
#define HAVE_SYS_PARAM_H 1
|
||||
#define HAVE_SYS_TIME_H 1
|
||||
#define HAVE_MMAP 1
|
||||
#define HAVE_POSIX_MEMALIGN 1
|
||||
|
||||
/* ENABLE macro defaults */
|
||||
|
||||
#define ENABLE_OPCODE_STATS 0
|
||||
|
|
12
src/3rdparty/javascriptcore/wtf/dtoa.cpp
vendored
12
src/3rdparty/javascriptcore/wtf/dtoa.cpp
vendored
|
@ -128,18 +128,12 @@
|
|||
* also does extra computations to set the underflow and overflow
|
||||
* flags when appropriate (i.e., when the result is tiny and
|
||||
* inexact or when it is a numeric value rounded to +-infinity).
|
||||
* #define NO_ERRNO if strtod should not assign errno = ERANGE when
|
||||
* the result overflows to +-Infinity or underflows to 0.
|
||||
*/
|
||||
|
||||
#include "Platform.h"
|
||||
#include "dtoa.h"
|
||||
|
||||
#if HAVE(ERRNO_H)
|
||||
#include <errno.h>
|
||||
#else
|
||||
#define NO_ERRNO
|
||||
#endif
|
||||
#include <cmath>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -1292,9 +1286,7 @@ ret0:
|
|||
if (e1 &= ~15) {
|
||||
if (e1 > DBL_MAX_10_EXP) {
|
||||
ovfl:
|
||||
#ifndef NO_ERRNO
|
||||
errno = ERANGE;
|
||||
#endif
|
||||
/* Can't trust HUGE_VAL */
|
||||
word0(&rv) = Exp_mask;
|
||||
word1(&rv) = 0;
|
||||
|
@ -1360,9 +1352,7 @@ ovfl:
|
|||
if (!dval(&rv)) {
|
||||
undfl:
|
||||
dval(&rv) = 0.;
|
||||
#ifndef NO_ERRNO
|
||||
errno = ERANGE;
|
||||
#endif
|
||||
goto ret;
|
||||
}
|
||||
#ifndef Avoid_Underflow
|
||||
|
@ -1686,11 +1676,9 @@ cont:
|
|||
word0(&rv0) = Exp_1 - 2 * P * Exp_msk1;
|
||||
word1(&rv0) = 0;
|
||||
dval(&rv) *= dval(&rv0);
|
||||
#ifndef NO_ERRNO
|
||||
/* try to avoid the bug of testing an 8087 register value */
|
||||
if (word0(&rv) == 0 && word1(&rv) == 0)
|
||||
errno = ERANGE;
|
||||
#endif
|
||||
}
|
||||
#endif /* Avoid_Underflow */
|
||||
#ifdef SET_INEXACT
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
|
||||
#include <sys/select.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
|
|
@ -62,8 +62,7 @@ QString qulltoa(qulonglong l, int base, const QChar zero)
|
|||
|
||||
l /= base;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
while (l != 0) {
|
||||
int c = l % base;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue