[pypy-svn] r16802 - in pypy/release/0.7.x/pypy/translator/llvm: . module
rxe at codespeak.net
rxe at codespeak.net
Sat Aug 27 18:55:09 CEST 2005
Author: rxe
Date: Sat Aug 27 18:55:08 2005
New Revision: 16802
Modified:
pypy/release/0.7.x/pypy/translator/llvm/genllvm.py
pypy/release/0.7.x/pypy/translator/llvm/module/genexterns.c
pypy/release/0.7.x/pypy/translator/llvm/module/support.py
Log:
Mission accomplished! (ericvrp/rxe)
Reuse genc c code to do externs for llvm.
Modified: pypy/release/0.7.x/pypy/translator/llvm/genllvm.py
==============================================================================
--- pypy/release/0.7.x/pypy/translator/llvm/genllvm.py (original)
+++ pypy/release/0.7.x/pypy/translator/llvm/genllvm.py Sat Aug 27 18:55:08 2005
@@ -30,16 +30,16 @@
llcode_header = ll_functions = None
ll_func_names = [
- "%prepare_and_raise_IOError",
- "%prepare_and_raise_ValueError",
- "%prepare_and_raise_OverflowError",
- "%prepare_and_raise_ZeroDivisionError",
+ "%raisePyExc_IOError",
+ "%raisePyExc_ValueError",
+ "%raisePyExc_OverflowError",
+ "%raisePyExc_ZeroDivisionError",
"%RPyString_AsString",
"%RPyString_FromString",
"%RPyString_Size"]
def get_ll(ccode, function_names):
-
+
# goto codespeak and compile our c code
request = urllib.urlencode({'ccode':ccode})
llcode = urllib.urlopen('http://codespeak.net/pypy/llvm-gcc.cgi', request).read()
@@ -66,8 +66,8 @@
returntype, s = line.split(' ', 1)
funcname , s = s.split('(', 1)
funcnames[funcname] = True
- assert line.find("internal") == -1
- line = '%s %s %s' % ("", DEFAULT_CCONV, line,)
+ if line.find("internal") == -1:
+ line = '%s %s %s' % ("", DEFAULT_CCONV, line,)
ll_lines.append(line)
# patch calls to function that we just declared fastcc
@@ -96,7 +96,7 @@
class GenLLVM(object):
- def __init__(self, translator, debug=True):
+ def __init__(self, translator, debug=False):
# reset counters
LLVMNode.nodename_count = {}
@@ -161,12 +161,26 @@
if isinstance(lltype.typeOf(obj._obj), lltype.FuncType):
predeclarefn(c_name, self.db.repr_name(obj._obj))
+ include_files = []
# append local file
j = os.path.join
- p = j(j(os.path.dirname(__file__), "module"), "genexterns.c")
- ccode.append(open(p).read())
+ include_files.append(j(j(os.path.dirname(__file__), "module"), "genexterns.c"))
- get_ll("".join(ccode), function_names)
+ from pypy.translator.c import extfunc
+ for f in ["ll_os", "ll_math", "ll_time", "ll_strtod"]:
+ include_files.append(j(j(os.path.dirname(extfunc.__file__), "src"), f + ".h"))
+
+ for f in include_files:
+ ccode.append(open(f).read())
+
+ # for debugging
+ ccode = "".join(ccode)
+ filename = udir.join("ccode.c")
+ f = open(str(filename), "w")
+ f.write(ccode)
+ f.close()
+
+ get_ll(ccode, function_names)
def gen_llvm_source(self, func=None):
if self.debug: print 'gen_llvm_source begin) ' + time.ctime()
@@ -314,8 +328,10 @@
elif entryfunc_name == 'pypy_main_noargs': #XXX just to get on with bpnn & richards
extfuncnode.ExternalFuncNode.used_external_functions['%main_noargs'] = True
- for f in "prepare_and_raise_OverflowError prepare_and_raise_ValueError "\
- "prepare_and_raise_ZeroDivisionError prepare_and_raise_IOError "\
+
+
+ for f in "raisePyExc_IOError raisePyExc_ValueError "\
+ "raisePyExc_OverflowError raisePyExc_ZeroDivisionError "\
"prepare_ZeroDivisionError prepare_OverflowError prepare_ValueError "\
"RPyString_FromString RPyString_AsString RPyString_Size".split():
extfuncnode.ExternalFuncNode.used_external_functions["%" + f] = True
Modified: pypy/release/0.7.x/pypy/translator/llvm/module/genexterns.c
==============================================================================
--- pypy/release/0.7.x/pypy/translator/llvm/module/genexterns.c (original)
+++ pypy/release/0.7.x/pypy/translator/llvm/module/genexterns.c Sat Aug 27 18:55:08 2005
@@ -1,700 +1,29 @@
+// We hand craft these in module/support.ll
char *RPyString_AsString(RPyString*);
int RPyString_Size(RPyString*);
RPyString *RPyString_FromString(char *);
+void raisePyExc_IOError(char *);
+void raisePyExc_ValueError(char *);
+void raisePyExc_OverflowError(char *);
+void raisePyExc_ZeroDivisionError(char *);
+#define RPyRaiseSimpleException(exctype, errormsg) raise##exctype(errormsg)
+
// Generated by rpython - argggh have to feed in prototypes
RPyFREXP_RESULT *ll_frexp_result(double, int);
RPyMODF_RESULT *ll_modf_result(double, double);
RPySTAT_RESULT *ll_stat_result(int, int, int, int, int, int, int, int, int, int);
void RPYTHON_RAISE_OSERROR(int error);
-// We hand craft these in module/support.ll
-void prepare_and_raise_OverflowError(char *);
-void prepare_and_raise_ValueError(char *);
-void prepare_and_raise_IOError(char *);
-
#include <errno.h>
#include <locale.h>
#include <ctype.h>
#include <python2.3/Python.h>
-#define LL_MATH_SET_ERANGE_IF_MATH_ERROR Py_SET_ERANGE_IF_OVERFLOW
-
-int LL_math_is_error(double x) {
- if (errno == ERANGE) {
- if (!x)
- return 0;
- prepare_and_raise_OverflowError("math range error");
- } else {
- prepare_and_raise_ValueError("math domain error");
- }
- return 1;
-}
-
-#define LL_MATH_ERROR_RESET errno = 0
-
-#define LL_MATH_CHECK_ERROR(x, errret) do { \
- LL_MATH_SET_ERANGE_IF_MATH_ERROR(x); \
- if (errno && LL_math_is_error(x)) \
- return errret; \
-} while(0)
-
-
-double LL_math_pow(double x, double y) {
- double r;
- LL_MATH_ERROR_RESET;
- r = pow(x, y);
- LL_MATH_CHECK_ERROR(r, -1.0);
- return r;
-}
-
-double LL_math_atan2(double x, double y) {
- double r;
- LL_MATH_ERROR_RESET;
- r = atan2(x, y);
- LL_MATH_CHECK_ERROR(r, -1.0);
- return r;
-}
-
-double LL_math_fmod(double x, double y) {
- double r;
- LL_MATH_ERROR_RESET;
- r = fmod(x, y);
- LL_MATH_CHECK_ERROR(r, -1.0);
- return r;
-}
-
-double LL_math_ldexp(double x, long y) {
- double r;
- LL_MATH_ERROR_RESET;
- r = ldexp(x, (int) y);
- LL_MATH_CHECK_ERROR(r, -1.0);
- return r;
-}
-
-double LL_math_hypot(double x, double y) {
- double r;
- LL_MATH_ERROR_RESET;
- r = hypot(x, y);
- LL_MATH_CHECK_ERROR(r, -1.0);
- return r;
-}
-
-RPyMODF_RESULT* LL_math_modf(double x) {
- double intpart, fracpart;
- LL_MATH_ERROR_RESET;
- fracpart = modf(x, &intpart);
- LL_MATH_CHECK_ERROR(fracpart, NULL);
- return ll_modf_result(fracpart, intpart);
-}
-
-/* simple math function */
-
-double LL_math_acos(double x) {
- double r;
- LL_MATH_ERROR_RESET;
- r = acos(x);
- LL_MATH_CHECK_ERROR(r, -1.0);
- return r;
-}
-
-double LL_math_asin(double x) {
- double r;
- LL_MATH_ERROR_RESET;
- r = asin(x);
- LL_MATH_CHECK_ERROR(r, -1.0);
- return r;
-}
-
-double LL_math_atan(double x) {
- double r;
- LL_MATH_ERROR_RESET;
- r = atan(x);
- LL_MATH_CHECK_ERROR(r, -1.0);
- return r;
-}
-
-double LL_math_ceil(double x) {
- double r;
- LL_MATH_ERROR_RESET;
- r = ceil(x);
- LL_MATH_CHECK_ERROR(r, -1.0);
- return r;
-}
-
-double LL_math_cos(double x) {
- double r;
- LL_MATH_ERROR_RESET;
- r = cos(x);
- LL_MATH_CHECK_ERROR(r, -1.0);
- return r;
-}
-
-double LL_math_cosh(double x) {
- double r;
- LL_MATH_ERROR_RESET;
- r = cosh(x);
- LL_MATH_CHECK_ERROR(r, -1.0);
- return r;
-}
-
-double LL_math_exp(double x) {
- double r;
- LL_MATH_ERROR_RESET;
- r = exp(x);
- LL_MATH_CHECK_ERROR(r, -1.0);
- return r;
-}
-
-double LL_math_fabs(double x) {
- double r;
- LL_MATH_ERROR_RESET;
- r = fabs(x);
- LL_MATH_CHECK_ERROR(r, -1.0);
- return r;
-}
-
-double LL_math_floor(double x) {
- double r;
- LL_MATH_ERROR_RESET;
- r = floor(x);
- LL_MATH_CHECK_ERROR(r, -1.0);
- return r;
-}
-
-double LL_math_log(double x) {
- double r;
- LL_MATH_ERROR_RESET;
- r = log(x);
- LL_MATH_CHECK_ERROR(r, -1.0);
- return r;
-}
-
-double LL_math_log10(double x) {
- double r;
- LL_MATH_ERROR_RESET;
- r = log10(x);
- LL_MATH_CHECK_ERROR(r, -1.0);
- return r;
-}
-
-double LL_math_sin(double x) {
- double r;
- LL_MATH_ERROR_RESET;
- r = sin(x);
- LL_MATH_CHECK_ERROR(r, -1.0);
- return r;
-}
-
-double LL_math_sinh(double x) {
- double r;
- LL_MATH_ERROR_RESET;
- r = sinh(x);
- LL_MATH_CHECK_ERROR(r, -1.0);
- return r;
-}
-
-double LL_math_sqrt(double x) {
- double r;
- LL_MATH_ERROR_RESET;
- r = sqrt(x);
- LL_MATH_CHECK_ERROR(r, -1.0);
- return r;
-}
-
-double LL_math_tan(double x) {
- double r;
- LL_MATH_ERROR_RESET;
- r = tan(x);
- LL_MATH_CHECK_ERROR(r, -1.0);
- return r;
-}
-
-double LL_math_tanh(double x) {
- double r;
- LL_MATH_ERROR_RESET;
- r = tanh(x);
- LL_MATH_CHECK_ERROR(r, -1.0);
- return r;
-}
-
-RPyFREXP_RESULT* LL_math_frexp(double x) {
- int expo;
- double m;
- LL_MATH_ERROR_RESET;
- m= frexp(x, &expo);
- LL_MATH_CHECK_ERROR(m, NULL);
- return ll_frexp_result(m, expo);
-}
-
-/************************************************************/
- /*** C header subsection: time module ***/
-
-#include <time.h>
-#ifndef MS_WINDOWS
-# include <sys/time.h>
-#endif
-
-
-/****** clock() ******/
-
-#if defined(MS_WINDOWS) && !defined(MS_WIN64) && !defined(__BORLANDC__)
-/* Win32 has better clock replacement
- XXX Win64 does not yet, but might when the platform matures. */
-#include <windows.h>
-
-double LL_time_clock(void)
-{
- static LARGE_INTEGER ctrStart;
- static double divisor = 0.0;
- LARGE_INTEGER now;
- double diff;
-
- if (divisor == 0.0) {
- LARGE_INTEGER freq;
- QueryPerformanceCounter(&ctrStart);
- if (!QueryPerformanceFrequency(&freq) || freq.QuadPart == 0) {
- /* Unlikely to happen - this works on all intel
- machines at least! Revert to clock() */
- return clock();
- }
- divisor = (double)freq.QuadPart;
- }
- QueryPerformanceCounter(&now);
- diff = (double)(now.QuadPart - ctrStart.QuadPart);
- return diff / divisor;
-}
-
-#else /* if !MS_WINDOWS */
-
-#ifndef CLOCKS_PER_SEC
-#ifdef CLK_TCK
-#define CLOCKS_PER_SEC CLK_TCK
-#else
-#define CLOCKS_PER_SEC 1000000
-#endif
-#endif
-
-double LL_time_clock(void)
-{
- return ((double)clock()) / CLOCKS_PER_SEC;
-}
-#endif /* MS_WINDOWS */
-
-
-void LL_time_sleep(double secs)
-{
-#if defined(MS_WINDOWS)
- double millisecs = secs * 1000.0;
- unsigned long ul_millis;
-
- if (millisecs > (double)ULONG_MAX) {
- prepare_and_raise_OverflowError("sleep length is too large");
- }
- ul_millis = (unsigned long)millisecs;
- /* XXX copy CPython to make this interruptible again */
- /*if (ul_millis == 0)*/
- Sleep(ul_millis);
- /*else {
- DWORD rc;
- ResetEvent(hInterruptEvent);
- rc = WaitForSingleObject(hInterruptEvent, ul_millis);
- if (rc == WAIT_OBJECT_0) {
- * Yield to make sure real Python signal
- * handler called.
- *
- Sleep(1);
- RPyRaiseSimpleException(PyExc_IOError, "interrupted");
- return;
- }
- }*/
-#else
- struct timeval t;
- double frac;
- frac = fmod(secs, 1.0);
- secs = floor(secs);
- t.tv_sec = (long)secs;
- t.tv_usec = (long)(frac*1000000.0);
- if (select(0, (fd_set *)0, (fd_set *)0, (fd_set *)0, &t) != 0) {
-#ifdef EINTR
- if (errno != EINTR) {
-#else
- if (1) {
-#endif
- prepare_and_raise_IOError("select() failed");
- }
- }
-#endif
-}
-
-
-#ifdef HAVE_FTIME
-#include <sys/timeb.h>
-#if !defined(MS_WINDOWS) && !defined(PYOS_OS2)
-extern int ftime(struct timeb *);
-#endif /* MS_WINDOWS */
-#endif /* HAVE_FTIME */
-
-double LL_floattime(void)
-{
- /* There are three ways to get the time:
- (1) gettimeofday() -- resolution in microseconds
- (2) ftime() -- resolution in milliseconds
- (3) time() -- resolution in seconds
- In all cases the return value is a float in seconds.
- Since on some systems (e.g. SCO ODT 3.0) gettimeofday() may
- fail, so we fall back on ftime() or time().
- Note: clock resolution does not imply clock accuracy! */
-#ifdef HAVE_GETTIMEOFDAY
- {
- struct timeval t;
-#ifdef GETTIMEOFDAY_NO_TZ
- if (gettimeofday(&t) == 0)
- return (double)t.tv_sec + t.tv_usec*0.000001;
-#else /* !GETTIMEOFDAY_NO_TZ */
- if (gettimeofday(&t, (struct timezone *)NULL) == 0)
- return (double)t.tv_sec + t.tv_usec*0.000001;
-#endif /* !GETTIMEOFDAY_NO_TZ */
- }
-#endif /* !HAVE_GETTIMEOFDAY */
- {
-#if defined(HAVE_FTIME)
- struct timeb t;
- ftime(&t);
- return (double)t.time + (double)t.millitm * (double)0.001;
-#else /* !HAVE_FTIME */
- time_t secs;
- time(&secs);
- return (double)secs;
-#endif /* !HAVE_FTIME */
- }
-}
-
-double LL_time_time(void) /* xxx had support for better resolutions */
-{
- return LL_floattime();
-}
-
-
-double LL_strtod_parts_to_float(RPyString *sign,
- RPyString *beforept,
- RPyString *afterpt,
- RPyString *exponent)
-{
- char *fail_pos;
- struct lconv *locale_data;
- const char *decimal_point;
- int decimal_point_len;
- double x;
- char *last;
- int buf_size;
- char *s;
- char *expo = NULL;
-
- expo = RPyString_AsString(exponent);
-
- if (*expo == '\0') {
- expo = "0";
- }
-
- locale_data = localeconv();
- decimal_point = locale_data->decimal_point;
- decimal_point_len = strlen(decimal_point);
-
- buf_size = RPyString_Size(sign) +
- RPyString_Size(beforept) +
- decimal_point_len +
- RPyString_Size(afterpt) +
- 1 /* e */ +
- strlen(expo) +
- 1 /* asciiz */ ;
-
- s = malloc(buf_size);
-
- strcpy(s, RPyString_AsString(sign));
- strcat(s, RPyString_AsString(beforept));
- strcat(s, decimal_point);
- strcat(s, RPyString_AsString(afterpt));
- strcat(s, "e");
- strcat(s, expo);
-
- last = s + (buf_size-1);
- x = strtod(s, &fail_pos);
- errno = 0;
- if (fail_pos > last)
- fail_pos = last;
- if (fail_pos == s || *fail_pos != '\0' || fail_pos != last) {
- free(s);
- prepare_and_raise_ValueError("invalid float literal");
- return -1.0;
- }
- if (x == 0.0) { /* maybe a denormal value, ask for atof behavior */
- x = strtod(s, NULL);
- errno = 0;
- }
- free(s);
- return x;
-}
-
-
-RPyString *LL_strtod_formatd(RPyString *fmt, double x) {
- char buffer[120]; /* this should be enough, from PyString_Format code */
- int buflen = 120;
- int res;
-
- res = snprintf(buffer, buflen, RPyString_AsString(fmt), x);
- if (res <= 0 || res >= buflen) {
- strcpy(buffer, "??.?"); /* should not occur */
- } else {
- struct lconv *locale_data;
- const char *decimal_point;
- int decimal_point_len;
- char *p;
-
- locale_data = localeconv();
- decimal_point = locale_data->decimal_point;
- decimal_point_len = strlen(decimal_point);
-
- if (decimal_point[0] != '.' ||
- decimal_point[1] != 0)
- {
- p = buffer;
-
- if (*p == '+' || *p == '-')
- p++;
-
- while (isdigit((unsigned char)*p))
- p++;
-
- if (strncmp(p, decimal_point, decimal_point_len) == 0)
- {
- *p = '.';
- p++;
- if (decimal_point_len > 1) {
- int rest_len;
- rest_len = strlen(p + (decimal_point_len - 1));
- memmove(p, p + (decimal_point_len - 1),
- rest_len);
- p[rest_len] = 0;
- }
- }
- }
-
- }
-
- return RPyString_FromString(buffer);
-}
-
-/************************************************************/
- /*** C header subsection: os module ***/
-
-#if !(defined(MS_WIN64) || defined(MS_WINDOWS))
-# include <unistd.h>
-# include <sys/types.h>
-# include <sys/stat.h>
-#endif
-
-#include <errno.h>
-#include <fcntl.h>
-#ifndef PATH_MAX
- /* assume windows */
-# define PATH_MAX 254
-#endif
-
-/* The functions below are mapped to functions from pypy.rpython.module.*
- by the pypy.translator.c.extfunc.EXTERNALS dictionary.
- They should correspond to the functions with the suggested_primitive
- flag set, and NOT necessarily directly to the LL_os_*() functions.
- See for example LL_read_into(), which is called by LL_os_read().
- The latter would be messy to write here, but LL_read_into() is quite easy.
-*/
-
-
-/* just do what CPython is doing... */
-
-#if defined(MS_WIN64) || defined(MS_WINDOWS)
-# define STAT _stati64
-# define FSTAT _fstati64
-# define STRUCT_STAT struct _stati64
-#else
-# define STAT stat
-# define FSTAT fstat
-# define STRUCT_STAT struct stat
-#endif
-
-
-int LL_os_open(RPyString *filename, int flag, int mode)
-{
- /* XXX unicode_file_names */
- char buf[PATH_MAX];
- int fd, namelen = RPyString_Size(filename);
- if (namelen >= PATH_MAX) {
- RPYTHON_RAISE_OSERROR(ENAMETOOLONG);
- return -1;
- }
- else {
- memcpy(buf, RPyString_AsString(filename), namelen);
- buf[namelen] = 0;
- fd = open(buf, flag, mode);
- if (fd < 0)
- RPYTHON_RAISE_OSERROR(errno);
- return fd;
- }
-}
-
-long LL_read_into(int fd, RPyString *buffer)
-{
- long n = read(fd, RPyString_AsString(buffer), RPyString_Size(buffer));
- if (n < 0)
- RPYTHON_RAISE_OSERROR(errno);
- return n;
-}
-
-long LL_os_write(int fd, RPyString *buffer)
-{
- long n = write(fd, RPyString_AsString(buffer), RPyString_Size(buffer));
- if (n < 0)
- RPYTHON_RAISE_OSERROR(errno);
- return n;
-}
-
-void LL_os_close(int fd)
-{
- if (close(fd) < 0)
- RPYTHON_RAISE_OSERROR(errno);
-}
-
-int LL_os_dup(int fd)
-{
- fd = dup(fd);
- if (fd < 0)
- RPYTHON_RAISE_OSERROR(errno);
- return fd;
-}
-
-RPyString *LL_os_getcwd(void)
-{
- char buf[PATH_MAX];
- char *res;
- res = getcwd(buf, sizeof buf);
- if (res == NULL) {
- RPYTHON_RAISE_OSERROR(errno);
- return NULL;
- }
- return RPyString_FromString(buf);
-}
-
-RPySTAT_RESULT* _stat_construct_result_helper(STRUCT_STAT st) {
- long res0, res1, res2, res3, res4, res5, res6, res7, res8, res9;
- res0 = (long)st.st_mode;
- res1 = (long)st.st_ino; /*XXX HAVE_LARGEFILE_SUPPORT!*/
- res2 = (long)st.st_dev; /*XXX HAVE_LONG_LONG!*/
- res3 = (long)st.st_nlink;
- res4 = (long)st.st_uid;
- res5 = (long)st.st_gid;
- res6 = (long)st.st_size; /*XXX HAVE_LARGEFILE_SUPPORT!*/
- res7 = (long)st.st_atime; /*XXX ignoring quite a lot of things for time here */
- res8 = (long)st.st_mtime; /*XXX ignoring quite a lot of things for time here */
- res9 = (long)st.st_ctime; /*XXX ignoring quite a lot of things for time here */
- /*XXX ignoring BLOCK info here*/
-
- return ll_stat_result(res0, res1, res2, res3, res4, res5, res6, res7, res8, res9);
-}
-
-
-RPySTAT_RESULT* LL_os_stat(RPyString * fname) {
- STRUCT_STAT st;
- int error = STAT(RPyString_AsString(fname), &st);
- if (error != 0) {
- RPYTHON_RAISE_OSERROR(errno);
- return NULL;
- }
- return _stat_construct_result_helper(st);
-}
-
-RPySTAT_RESULT* LL_os_fstat(long fd) {
- STRUCT_STAT st;
- int error = FSTAT(fd, &st);
- if (error != 0) {
- RPYTHON_RAISE_OSERROR(errno);
- return NULL;
- }
- return _stat_construct_result_helper(st);
-}
-
-long LL_os_lseek(long fd, long pos, long how) {
-#if defined(MS_WIN64) || defined(MS_WINDOWS)
- PY_LONG_LONG res;
-#else
- off_t res;
-#endif
-#ifdef SEEK_SET
- /* Turn 0, 1, 2 into SEEK_{SET,CUR,END} */
- switch (how) {
- case 0: how = SEEK_SET; break;
- case 1: how = SEEK_CUR; break;
- case 2: how = SEEK_END; break;
- }
-#endif /* SEEK_END */
-#if defined(MS_WIN64) || defined(MS_WINDOWS)
- res = _lseeki64(fd, pos, how);
-#else
- res = lseek(fd, pos, how);
-#endif
- if (res < 0)
- RPYTHON_RAISE_OSERROR(errno);
- return res;
-}
-
-long LL_os_isatty(long fd) {
- return (int)isatty((int)fd);
-}
-
-#ifdef HAVE_FTRUNCATE
-void LL_os_ftruncate(long fd, long length) { /*XXX add longfile support */
- int res;
- res = ftruncate((int)fd, (off_t)length);
- if (res < 0) {
- RPYTHON_RAISE_OSERROR(errno);
- }
-}
-#endif
-
-RPyString *LL_os_strerror(int errnum) {
- char *res;
- res = strerror(errnum);
- return RPyString_FromString(res);
-}
-
-long LL_os_system(RPyString * fname) {
- return system(RPyString_AsString(fname));
-}
-
-void LL_os_unlink(RPyString * fname) {
- int error = unlink(RPyString_AsString(fname));
- if (error != 0) {
- RPYTHON_RAISE_OSERROR(errno);
- }
-}
-
-void LL_os_chdir(RPyString * path) {
- int error = chdir(RPyString_AsString(path));
- if (error != 0) {
- RPYTHON_RAISE_OSERROR(errno);
- }
-}
-
-void LL_os_mkdir(RPyString * path, int mode) {
- int error = mkdir(RPyString_AsString(path), mode);
- if (error != 0) {
- RPYTHON_RAISE_OSERROR(errno);
- }
-}
+// Do this manually from python :-(
+//#include "ll_os.h"
+//#include "ll_math.h"
+//#include "ll_time.h"
+//#include "ll_strtod.h"
-void LL_os_rmdir(RPyString * path) {
- int error = rmdir(RPyString_AsString(path));
- if (error != 0) {
- RPYTHON_RAISE_OSERROR(errno);
- }
-}
Modified: pypy/release/0.7.x/pypy/translator/llvm/module/support.py
==============================================================================
--- pypy/release/0.7.x/pypy/translator/llvm/module/support.py (original)
+++ pypy/release/0.7.x/pypy/translator/llvm/module/support.py Sat Aug 27 18:55:08 2005
@@ -88,10 +88,11 @@
}
""" % locals())
-#prepare exceptions
+
+#prepare and raise exceptions
for exc in "IOError ZeroDivisionError OverflowError ValueError".split(): #_ZER _OVF _VAL
- extfunctions["%%prepare_and_raise_%(exc)s" % locals()] = ((), """
-internal fastcc void %%prepare_and_raise_%(exc)s(sbyte* %%msg) {
+ extfunctions["%%raisePyExc_%(exc)s" % locals()] = ((), """
+internal fastcc void %%raisePyExc_%(exc)s(sbyte* %%msg) {
;XXX %%msg not used right now!
%%exception_value = call fastcc %%RPYTHON_EXCEPTION* %%pypy_instantiate_%(exc)s()
%%tmp = getelementptr %%RPYTHON_EXCEPTION* %%exception_value, int 0, uint 0
More information about the Pypy-commit
mailing list