--- /dev/null
+# 7.5 Errors <errno.h>
+
+cdef extern from "errno.h" nogil:
+
+ enum: EDOM
+ enum: EILSEQ
+ enum: ERANGE
+
+ int errno
+
--- /dev/null
+# 5.2.4.2.2 Characteristics of floating types <float.h>
+
+cdef extern from "float.h":
+
+ enum: FLT_RADIX
+
+ enum: FLT_MANT_DIG
+ enum: DBL_MANT_DIG
+ enum: LDBL_MANT_DIG
+
+ enum: DECIMAL_DIG
+
+ enum: FLT_DIG
+ enum: DBL_DIG
+ enum: LDBL_DIG
+
+ enum: FLT_MIN_EXP
+ enum: DBL_MIN_EXP
+ enum: LDBL_MIN_EXP
+
+ enum: FLT_MIN_10_EXP
+ enum: DBL_MIN_10_EXP
+ enum: LDBL_MIN_10_EXP
+
+ enum: FLT_MAX_EXP
+ enum: DBL_MAX_EXP
+ enum: LDBL_MAX_EXP
+
+ enum: FLT_MAX_10_EXP
+ enum: DBL_MAX_10_EXP
+ enum: LDBL_MAX_10_EXP
+
+ enum: FLT_MAX
+ enum: DBL_MAX
+ enum: LDBL_MAX
+
+ enum: FLT_EPSILON
+ enum: DBL_EPSILON
+ enum: LDBL_EPSILON
+
+ enum: FLT_MIN
+ enum: DBL_MIN
+ enum: LDBL_MIN
--- /dev/null
+# 5.2.4.2.1 Sizes of integer types <limits.h>
+
+cdef extern from "limits.h":
+
+ enum: CHAR_BIT
+ enum: MB_LEN_MAX
+
+ enum: CHAR_MIN
+ enum: CHAR_MAX
+
+ enum: SCHAR_MIN
+ enum: SCHAR_MAX
+ enum: UCHAR_MAX
+
+ enum: SHRT_MIN
+ enum: SHRT_MAX
+ enum: USHRT_MAX
+
+ enum: INT_MIN
+ enum: INT_MAX
+ enum: UINT_MAX
+
+ enum: LONG_MIN
+ enum: LONG_MAX
+ enum: ULONG_MAX
+
+ enum: LLONG_MIN
+ enum: LLONG_MAX
+ enum: ULLONG_MAX
--- /dev/null
+# 7.11 Localization <locale.h>
+
+cdef extern from *:
+ ctypedef char const_char "const char"
+
+cdef extern from "locale.h":
+
+ struct lconv:
+ char *decimal_point
+ char *thousands_sep
+ char *grouping
+ char *mon_decimal_point
+ char *mon_thousands_sep
+ char *mon_grouping
+ char *positive_sign
+ char *negative_sign
+ char *currency_symbol
+ char frac_digits
+ char p_cs_precedes
+ char n_cs_precedes
+ char p_sep_by_space
+ char n_sep_by_space
+ char p_sign_posn
+ char n_sign_posn
+ char *int_curr_symbol
+ char int_frac_digits
+ char int_p_cs_precedes
+ char int_n_cs_precedes
+ char int_p_sep_by_space
+ char int_n_sep_by_space
+ char int_p_sign_posn
+ char int_n_sign_posn
+
+ enum: LC_ALL
+ enum: LC_COLLATE
+ enum: LC_CTYPE
+ enum: LC_MONETARY
+ enum: LC_NUMERIC
+ enum: LC_TIME
+
+ # 7.11.1 Locale control
+ char *setlocale (int CATEGORY, const_char *LOCALE)
+
+ # 7.11.2 Numeric formatting convention inquiry
+ lconv *localeconv ()
--- /dev/null
+# 7.14 Signal handling <signal.h>
+
+ctypedef void (*sighandler_t)(int SIGNUM) nogil
+
+cdef extern from "signal.h" nogil:
+
+ ctypedef int sig_atomic_t
+
+ enum: SIGABRT
+ enum: SIGFPE
+ enum: SIGILL
+ enum: SIGINT
+ enum: SIGSEGV
+ enum: SIGTERM
+
+ sighandler_t SIG_DFL
+ sighandler_t SIG_IGN
+ sighandler_t SIG_ERR
+
+ sighandler_t signal (int SIGNUM, sighandler_t ACTION)
+ int raise_"raise" (int SIGNUM)
+
+
+cdef extern from "signal.h" nogil:
+
+ # Program Error
+ enum: SIGFPE
+ enum: SIGILL
+ enum: SIGSEGV
+ enum: SIGBUS
+ enum: SIGABRT
+ enum: SIGIOT
+ enum: SIGTRAP
+ enum: SIGEMT
+ enum: SIGSYS
+ # Termination
+ enum: SIGTERM
+ enum: SIGINT
+ enum: SIGQUIT
+ enum: SIGKILL
+ enum: SIGHUP
+ # Alarm
+ enum: SIGALRM
+ enum: SIGVTALRM
+ enum: SIGPROF
+ # Asynchronous I/O
+ enum: SIGIO
+ enum: SIGURG
+ enum: SIGPOLL
+ # Job Control
+ enum: SIGCHLD
+ enum: SIGCLD
+ enum: SIGCONT
+ enum: SIGSTOP
+ enum: SIGTSTP
+ enum: SIGTTIN
+ enum: SIGTTOU
+ # Operation Error
+ enum: SIGPIPE
+ enum: SIGLOST
+ enum: SIGXCPU
+ enum: SIGXFSZ
+ # Miscellaneous
+ enum: SIGUSR1
+ enum: SIGUSR2
+ enum: SIGWINCH
+ enum: SIGINFO
+
--- /dev/null
+# 7.17 Common definitions <stddef.h>
+
+cdef extern from "stddef.h":
+
+ ctypedef signed int ptrdiff_t
+
+ ctypedef unsigned int size_t
+
+ ctypedef int wchar_t
--- /dev/null
+# 7.18 Integer types <stdint.h>
+cdef extern from "stdint.h" nogil:
+
+ # 7.18.1 Integer types
+ # 7.18.1.1 Exact-width integer types
+ ctypedef signed int int8_t
+ ctypedef signed int int16_t
+ ctypedef signed int int32_t
+ ctypedef signed int int64_t
+ ctypedef unsigned int uint8_t
+ ctypedef unsigned int uint16_t
+ ctypedef unsigned int uint32_t
+ ctypedef unsigned int uint64_t
+ # 7.18.1.2 Minimum-width integer types
+ ctypedef signed int int_least8_t
+ ctypedef signed int int_least16_t
+ ctypedef signed int int_least32_t
+ ctypedef signed int int_least64_t
+ ctypedef unsigned int uint_least8_t
+ ctypedef unsigned int uint_least16_t
+ ctypedef unsigned int uint_least32_t
+ ctypedef unsigned int uint_least64_t
+ # 7.18.1.3 Fastest minimum-width integer types
+ ctypedef signed int int_fast8_t
+ ctypedef signed int int_fast16_t
+ ctypedef signed int int_fast32_t
+ ctypedef signed int int_fast64_t
+ ctypedef unsigned int uint_fast8_t
+ ctypedef unsigned int uint_fast16_t
+ ctypedef unsigned int uint_fast32_t
+ ctypedef unsigned int uint_fast64_t
+ # 7.18.1.4 Integer types capable of holding object pointers
+ ctypedef signed int intptr_t
+ ctypedef unsigned int uintptr_t
+ # 7.18.1.5 Greatest-width integer types
+ ctypedef signed int intmax_t
+ ctypedef unsigned int uintmax_t
+
+ # 7.18.2 Limits of specified-width integer types
+ # 7.18.2.1 Limits of exact-width integer types
+ enum: INT8_T_MIN
+ enum: INT16_T_MIN
+ enum: INT32_T_MIN
+ enum: INT64_T_MIN
+ enum: INT8_T_MAX
+ enum: INT16_T_MAX
+ enum: INT32_T_MAX
+ enum: INT64_T_MAX
+ enum: UINT8_T_MAX
+ enum: UINT16_T_MAX
+ enum: UINT32_T_MAX
+ enum: UINT64_T_MAX
+ #7.18.2.2 Limits of minimum-width integer types
+ enum: INT_LEAST8_T_MIN
+ enum: INT_LEAST16_T_MIN
+ enum: INT_LEAST32_T_MIN
+ enum: INT_LEAST64_T_MIN
+ enum: INT_LEAST8_T_MAX
+ enum: INT_LEAST16_T_MAX
+ enum: INT_LEAST32_T_MAX
+ enum: INT_LEAST64_T_MAX
+ enum: UINT_LEAST8_T_MAX
+ enum: UINT_LEAST16_T_MAX
+ enum: UINT_LEAST32_T_MAX
+ enum: UINT_LEAST64_T_MAX
+ #7.18.2.3 Limits of fastest minimum-width integer types
+ enum: INT_FAST8_T_MIN
+ enum: INT_FAST16_T_MIN
+ enum: INT_FAST32_T_MIN
+ enum: INT_FAST64_T_MIN
+ enum: INT_FAST8_T_MAX
+ enum: INT_FAST16_T_MAX
+ enum: INT_FAST32_T_MAX
+ enum: INT_FAST64_T_MAX
+ enum: UINT_FAST8_T_MAX
+ enum: UINT_FAST16_T_MAX
+ enum: UINT_FAST32_T_MAX
+ enum: UINT_FAST64_T_MAX
+ #7.18.2.4 Limits of integer types capable of holding object pointers
+ enum: INTPTR_MIN
+ enum: INTPTR_MAX
+ enum: UINTPTR_MAX
+ # 7.18.2.5 Limits of greatest-width integer types
+ enum: INTMAX_T_MAX
+ enum: INTMAX_T_MIN
+ enum: UINTMAX_T_MAX
+
+ # 7.18.3 Limits of other integer types
+ # ptrdiff_t
+ enum: PTRDIFF_MIN
+ enum: PTRDIFF_MAX
+ # sig_atomic_t
+ enum: SIG_ATOMIC_MIN
+ enum: SIG_ATOMIC_MAX
+ # size_t
+ enum: SIZE_MAX
+ # wchar_t
+ enum: WCHAR_MIN
+ enum: WCHAR_MAX
+ # wint_t
+ enum: WINT_MIN
+ enum: WINT_MAX
+# 7.19 Input/output <stdio.h>
+
+cdef extern from *:
+ ctypedef char const_char "const char"
+ ctypedef void const_void "const void"
+
cdef extern from "stdio.h" nogil:
+
ctypedef struct FILE
- int printf(char *format, ...)
- int fprintf(FILE *stream, char *format, ...)
- int sprintf(char *str, char *format, ...)
- FILE *fopen(char *path, char *mode)
- int fclose(FILE *strea)
+ cdef FILE *stdin
cdef FILE *stdout
- int scanf(char *format, ...)
+ cdef FILE *stderr
+
+ enum: FOPEN_MAX
+ enum: FILENAME_MAX
+ FILE *fopen (const_char *FILENAME, const_char *OPENTYPE)
+ FILE *freopen (const_char *FILENAME, const_char *OPENTYPE, FILE *STREAM)
+ int fclose (FILE *STREAM)
+ int remove (const_char *FILENAME)
+ int rename (const_char *OLDNAME, const_char *NEWNAME)
+ FILE *tmpfile ()
+
+ enum: _IOFBF
+ enum: _IOLBF
+ enum: _IONBF
+ int setvbuf (FILE *STREAM, char *BUF, int MODE, size_t SIZE)
+ enum: BUFSIZ
+ void setbuf (FILE *STREAM, char *BUF)
+
+ size_t fread (void *DATA, size_t SIZE, size_t COUNT, FILE *STREAM)
+ size_t fwrite (const_void *DATA, size_t SIZE, size_t COUNT, FILE *STREAM)
+ int fflush (FILE *STREAM)
+
+ enum: EOF
+ int feof (FILE *STREAM)
+ int ferror (FILE *STREAM)
+
+ enum: SEEK_SET
+ enum: SEEK_CUR
+ enum: SEEK_END
+ int fseek (FILE *STREAM, long int OFFSET, int WHENCE)
+ void rewind (FILE *STREAM)
+ long int ftell (FILE *STREAM)
+
+ ctypedef long long int fpos_t
+ ctypedef fpos_t const_fpos_t "const fpos_t"
+ int fgetpos (FILE *STREAM, fpos_t *POSITION)
+ int fsetpos (FILE *STREAM, const_fpos_t *POSITION)
+
+ int scanf (const_char *TEMPLATE, ...)
+ int sscanf (const_char *S, const_char *TEMPLATE, ...)
+ int fscanf (FILE *STREAM, const_char *TEMPLATE, ...)
+
+ int printf (const_char *TEMPLATE, ...)
+ int sprintf (char *S, const_char *TEMPLATE, ...)
+ int snprintf (char *S, size_t SIZE, const_char *TEMPLATE, ...)
+ int fprintf (FILE *STREAM, const_char *TEMPLATE, ...)
+
+ void perror (const_char *MESSAGE)
+
+ char *gets (char *S)
+ char *fgets (char *S, int COUNT, FILE *STREAM)
+
+ int puts (const_char *S)
+ int fputs (const_char *S, FILE *STREAM)
+# 7.20 General utilities <stdlib.h>
+
+cdef extern from *:
+ ctypedef char const_char "const char"
+ ctypedef void const_void "const void"
cdef extern from "stdlib.h" nogil:
- void free(void *ptr)
- void *malloc(size_t size)
- void *realloc(void *ptr, size_t size)
- size_t strlen(char *s)
- char *strcpy(char *dest, char *src)
+
+ # 7.20.1 Numeric conversion functions
+ int atoi (const_char *STRING)
+ long atol (const_char *STRING)
+ long long atoll (const_char *STRING)
+ double atof (const_char *STRING)
+ long strtol (const_char *STRING, char **TAILPTR, int BASE)
+ unsigned long int strtoul (const_char *STRING, char **TAILPTR, int BASE)
+ long long int strtoll (const_char *STRING, char **TAILPTR, int BASE)
+ unsigned long long int strtoull (const_char *STRING, char **TAILPTR, int BASE)
+ float strtof (const_char *STRING, char **TAILPTR)
+ double strtod (const_char *STRING, char **TAILPTR)
+ long double strtold (const_char *STRING, char **TAILPTR)
+
+ # 7.20.2 Pseudo-random sequence generation functions
+ enum: RAND_MAX
+ int rand ()
+ void srand (unsigned int SEED)
+
+ # 7.20.3 Memory management functions
+ void *calloc (size_t COUNT, size_t ELTSIZE)
+ void free (void *PTR)
+ void *malloc (size_t SIZE)
+ void *realloc (void *PTR, size_t NEWSIZE)
+
+ # 7.20.4 Communication with the environment
+ enum: EXIT_FAILURE
+ enum: EXIT_SUCCESS
+ void exit (int STATUS)
+ void _Exit (int STATUS)
+ int atexit (void (*FUNCTION) ())
+ void abort ()
+ char *getenv (const_char *NAME)
+ int system (const_char *COMMAND)
+
+ #7.20.5 Searching and sorting utilities
+ void *bsearch (const_void *KEY, const_void *ARRAY,
+ size_t COUNT, size_t SIZE,
+ int (*COMPARE)(const_void *, const_void *))
+ void qsort (void *ARRAY, size_t COUNT, size_t SIZE,
+ int (*COMPARE)(const_void *, const_void *))
+
+ # 7.20.6 Integer arithmetic functions
+ int abs (int NUMBER)
+ long int labs (long int NUMBER)
+ long long int llabs (long long int NUMBER)
+ ctypedef struct div_t:
+ int quot
+ int rem
+ div_t div (int NUMERATOR, int DENOMINATOR)
+ ctypedef struct ldiv_t:
+ long int quot
+ long int rem
+ ldiv_t ldiv (long int NUMERATOR, long int DENOMINATOR)
+ ctypedef struct lldiv_t:
+ long long int quot
+ long long int rem
+ lldiv_t lldiv (long long int NUMERATOR, long long int DENOMINATOR)
+
+
+ # 7.20.7 Multibyte/wide character conversion functions
+ # XXX TODO
+
+ # 7.20.8 Multibyte/wide string conversion functions
+ # XXX TODO
--- /dev/null
+# 7.21 String handling <string.h>
+
+cdef extern from *:
+ ctypedef char const_char "const char"
+ ctypedef void const_void "const void"
+
+cdef extern from "string.h" nogil:
+
+ void *memcpy (void *TO, const_void *FROM, size_t SIZE)
+ void *memmove (void *TO, const_void *FROM, size_t SIZE)
+ void *memset (void *BLOCK, int C, size_t SIZE)
+ int memcmp (const_void *A1, const_void *A2, size_t SIZE)
+ void *memchr (const_void *BLOCK, int C, size_t SIZE)
+
+ void *memchr (const_void *BLOCK, int C, size_t SIZE)
+ void *memrchr (const_void *BLOCK, int C, size_t SIZE)
+
+ size_t strlen (const_char *S)
+ char *strcpy (char *TO, const_char *FROM)
+ char *strncpy (char *TO, const_char *FROM, size_t SIZE)
+ char *strdup (const_char *S)
+ char *strndup (const_char *S, size_t SIZE)
+ char *strcat (char *TO, const_char *FROM)
+ char *strncat (char *TO, const_char *FROM, size_t SIZE)
+
+ int strcmp (const_char *S1, const_char *S2)
+ int strcasecmp (const_char *S1, const_char *S2)
+ int strncmp (const_char *S1, const_char *S2, size_t SIZE)
+ int strncasecmp (const_char *S1, const_char *S2, size_t N)
+
+ int strcoll (const_char *S1, const_char *S2)
+ size_t strxfrm (char *TO, const_char *FROM, size_t SIZE)
+
+
+ char *strchr (const_char *STRING, int C)
+ char *strrchr (const_char *STRING, int C)
+
+ char *strstr (const_char *HAYSTACK, const_char *NEEDLE)
+ char *strcasestr (const_char *HAYSTACK, const_char *NEEDLE)
+
+ size_t strcspn (const_char *STRING, const_char *STOPSET)
+ char * strpbrk (const_char *STRING, const_char *STOPSET)
+
+ char *strtok (char *NEWSTRING, const_char *DELIMITERS)
+ char *strsep (char **STRING_PTR, const_char *DELIMITER)
--- /dev/null
+from libc.errno cimport *
+from libc.float cimport *
+from libc.limits cimport *
+from libc.locale cimport *
+from libc.signal cimport *
+from libc.stddef cimport *
+from libc.stdint cimport *
+from libc.stdio cimport *
+from libc.stdlib cimport *
+from libc.string cimport *
--- /dev/null
+from libc.errno cimport *
+
+if errno == EDOM : pass
+if errno == EILSEQ : pass
+if errno == ERANGE : pass
+
+errno = 0
--- /dev/null
+from libc.signal cimport *
+
+cdef void sighdl(int signum) nogil:
+ pass
+
+cdef sighandler_t h
+
+h = signal(SIGABRT, sighdl)
+if h == SIG_ERR: pass
+h = signal(SIGABRT, SIG_IGN)
+if h == SIG_ERR: pass
+h = signal(SIGABRT, SIG_DFL)
+if h == SIG_ERR: pass
+
+h = signal(SIGABRT, SIG_IGN)
+cdef int e = raise_(SIGABRT)
+h = signal(SIGABRT, h)