| 1 | // libc.h: Replacement for native/libc.c
 | 
| 2 | 
 | 
| 3 | #ifndef LIBC_H
 | 
| 4 | #define LIBC_H
 | 
| 5 | 
 | 
| 6 | #include <stdlib.h>
 | 
| 7 | 
 | 
| 8 | #include "mycpp/runtime.h"
 | 
| 9 | 
 | 
| 10 | namespace libc {
 | 
| 11 | 
 | 
| 12 | // TODO: SHARE with pyext
 | 
| 13 | inline void print_time(double real, double user, double sys) {
 | 
| 14 |   fprintf(stderr, "real\t%.3f\n", real);
 | 
| 15 |   fprintf(stderr, "user\t%.3f\n", user);
 | 
| 16 |   fprintf(stderr, "sys\t%.3f\n", sys);
 | 
| 17 | }
 | 
| 18 | 
 | 
| 19 | BigStr* realpath(BigStr* path);
 | 
| 20 | 
 | 
| 21 | BigStr* gethostname();
 | 
| 22 | 
 | 
| 23 | int fnmatch(BigStr* pat, BigStr* str, int flags = 0);
 | 
| 24 | 
 | 
| 25 | List<BigStr*>* glob(BigStr* pat);
 | 
| 26 | 
 | 
| 27 | Tuple2<int, int>* regex_first_group_match(BigStr* pattern, BigStr* str,
 | 
| 28 |                                           int pos);
 | 
| 29 | 
 | 
| 30 | List<int>* regex_search(BigStr* pattern, int cflags, BigStr* str, int eflags,
 | 
| 31 |                         int pos = 0);
 | 
| 32 | 
 | 
| 33 | int wcswidth(BigStr* str);
 | 
| 34 | int get_terminal_width();
 | 
| 35 | 
 | 
| 36 | }  // namespace libc
 | 
| 37 | 
 | 
| 38 | #endif  // LIBC_H
 |