Permalink
Browse files

Linux support.

On 64 bit Linux this should - hopefully - get it building out of the box.
  • Loading branch information...
ltratt committed Dec 20, 2011
1 parent 11b7d76 commit 00e290ccbb11adaadbe720cf17f8fe1bd6d14b55
Showing with 98 additions and 16 deletions.
  1. +11 −11 configure
  2. +11 −4 vm/Config.py.in
  3. +5 −1 vm/Modules/Con_POSIX_File.py
  4. +71 −0 vm/platform/fgetln.c
View
@@ -19,15 +19,15 @@ while [ $# -ge 1 ]; do
esac
done
if [[ X$prefix == "X" ]]; then
if [ "X$prefix" = "X" ]; then
prefix="/usr/local/"
fi
echo -n "Checking for Python interpreter... "
which pypy-c 2> /dev/null > /dev/null
which pypy 2> /dev/null > /dev/null
if [ $? -eq 0 ]; then
PYTHON=`which pypy-c`
PYTHON=`which pypy`
elif [ $? -ne 0 ]; then
which python 2> /dev/null > /dev/null
if [ $? -eq 0 ]; then
@@ -40,22 +40,22 @@ fi
echo $PYTHON
echo -n "Checking for RPython translate.py... "
if [[ X$PYPY_SRC != "X" ]]; then
if [ "X$PYPY_SRC" != "X" ]; then
TRANSLATE_PY=$PYPY_SRC/pypy/translator/goal/translate.py
if [[ ! -f $TRANSLATE_PY ]]; then
if [ ! -f $TRANSLATE_PY ]; then
TRANSLATE_PY=""
fi
fi
if [[ X$TRANSLATE_PY == "X" ]]; then
if [ "X$TRANSLATE_PY" = "X" ]; then
echo "not found (try setting \$PYPY_SRC)."
exit 1
fi
echo $TRANSLATE_PY
operating_system=`uname -s`
machine_type=`uname -m`
if [[ $operating_system == "Darwin" && $machine_type == "i386" ]]; then
if [ "$operating_system" = "Darwin" -a "$machine_type" = "i386" ]; then
# On modern Darwin machine it now seems that it's easier to build 64 bit
# binaries than 32 bit. Why? I don't know.
machine_type=x86_64
@@ -92,12 +92,12 @@ echo -n "Checking for libpcre.a... "
libpcre_a=""
for dir in `pcre-config --libs | tr " " "\n" | grep "^-L" | sort -u | sed "s/^-L//"`; do
cnd=$dir/libpcre.a
if [[ -f $cnd ]]; then
if [ -f $cnd ]; then
libpcre_a=$cnd
break
fi
done
if [[ "X$libpcre_a" == "X" ]]; then
if [ "X$libpcre_a" = "X" ]; then
echo "not found."
exit 1
fi
@@ -122,12 +122,12 @@ echo -n "Checking for libxml2.a... "
libxml2_a=""
for dir in `xml2-config --libs | tr " " "\n" | grep "^-L" | sort -u | sed "s/^-L//"` ; do
cnd=$dir/libxml2.a
if [[ -f $cnd ]]; then
if [ -f $cnd ]; then
libxml2_a=$cnd
break
fi
done
if [[ "X$libpcre_a" == "X" ]]; then
if [ "X$libpcre_a" = "X" ]; then
echo "not found."
exit 1
fi
View
@@ -28,12 +28,19 @@ PLATFORM = "@PLATFORM@"
# Stuff needed for building the system.
LIBPCRE_INCLUDE_DIRS= "@LIBPCRE_INCLUDE_DIRS@".split(" ")
LIBPCRE_LIBRARY_DIRS= "@LIBPCRE_LINK_DIRS@".split(" ")
def _sanitise(dirs):
dirs = dirs.strip()
if not dirs:
return []
else:
return dirs.split(" ")
LIBPCRE_INCLUDE_DIRS = _sanitise("@LIBPCRE_INCLUDE_DIRS@")
LIBPCRE_LIBRARY_DIRS = _sanitise("@LIBPCRE_LINK_DIRS@")
LIBPCRE_LINK_FLAGS = "@LIBPCRE_LINK_FLAGS@"
LIBPCRE_A = "@LIBPCRE_A@"
LIBXML2_INCLUDE_DIRS= "@LIBXML2_INCLUDE_DIRS@".split(" ")
LIBXML2_LIBRARY_DIRS= "@LIBXML2_LINK_DIRS@".split(" ")
LIBXML2_INCLUDE_DIRS = _sanitise("@LIBXML2_INCLUDE_DIRS@")
LIBXML2_LIBRARY_DIRS = _sanitise("@LIBXML2_LINK_DIRS@")
LIBXML2_LINK_FLAGS = "@LIBXML2_LINK_FLAGS@"
LIBXML2_A = "@LIBXML2_A@"
@@ -29,8 +29,12 @@
separate_module_files = []
if not platform.has("fgetln", "#include <stdio.h>"):
separate_module_files.append("platform/fgetln.c")
eci = ExternalCompilationInfo(includes=["limits.h", "stdio.h", "stdlib.h", "string.h",
"unistd.h"])
"unistd.h"], separate_module_files=separate_module_files)
FILEP = rffi.COpaquePtr("FILE")
fclose = rffi.llexternal("fclose", [FILEP], rffi.INT, compilation_info=eci)
View
@@ -0,0 +1,71 @@
/* $OpenPackages: util.c,v 1.10 2001/07/22 01:00:52 harlan Exp $ */
/* $OpenBSD: util.c,v 1.16 2001/05/23 12:34:51 espie Exp $ */
/* $NetBSD: util.c,v 1.10 1996/12/31 17:56:04 christos Exp $ */
/* $TenDRA: contrib/make/util.c,v 1.5 2003/02/11 21:16:16 asmodai Exp $ */
/*
* Copyright (c) 2001 Marc Espie.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD
* PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/param.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
static void removeCR(char *s)
{
while (*s) {
if (*s == '\r' && s[1] == '\n') {
*s = '\n';
s[1] = 0;
break;
}
s++;
}
}
char *fgetln(FILE *stream, size_t *len)
{
static char *buffer = NULL;
static size_t buflen = 0;
if (buflen == 0) {
buflen = 512;
buffer = malloc(buflen+1);
}
if (fgets(buffer, buflen+1, stream) == NULL)
return NULL;
removeCR(buffer);
*len = strlen(buffer);
while (*len == buflen && buffer[*len-1] != '\n') {
buffer = realloc(buffer, 2*buflen + 1);
if (fgets(buffer + buflen, buflen + 1, stream) == NULL)
return NULL;
removeCR(buffer);
*len += strlen(buffer + buflen);
buflen *= 2;
}
return buffer;
}

0 comments on commit 00e290c

Please sign in to comment.