parent
4161c5950b
commit
58a49b7ffb
|
@ -2,5 +2,6 @@
|
|||
#define __TIER0_ANSI_ERRNO_H__
|
||||
|
||||
#define E2BIG 7
|
||||
extern int errno;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -2,11 +2,38 @@
|
|||
#define __TIER0_ANSI_STDIO_H__
|
||||
|
||||
#include <stdarg.h>
|
||||
#include "Tier0/kstdlib.h"
|
||||
|
||||
//int printf(char *format, va_list args);
|
||||
#define BUFSIZ 1024
|
||||
#define FILE int
|
||||
int sprintf(char *str, const char *format, ...);
|
||||
int feof(FILE *stream);
|
||||
unsigned int fread(void *ptr, unsigned long long int size, unsigned long long int count, FILE *stream);
|
||||
int getc(FILE *stream);
|
||||
char *fgets(char *s, int size, FILE *stream);
|
||||
FILE *fopen(const char *path, const char *mode);
|
||||
FILE *freopen(const char *path, const char *mode, FILE *stream);
|
||||
int ferror(FILE *stream);
|
||||
int fclose(FILE *stream);
|
||||
int fprintf(FILE *stream, const char *format, ...);
|
||||
int fflush(FILE *stream);
|
||||
FILE *tmpfile(void);
|
||||
int fscanf(FILE *stream, const char *format, ...);
|
||||
int ungetc(int c, FILE *stream);
|
||||
int clearerr(FILE *stream);
|
||||
unsigned long long int fwrite(const void *ptr, unsigned long long int size, unsigned long long int nmemb, FILE *stream);
|
||||
int fseek(FILE *stream, long offset, int whence);
|
||||
int ftell(FILE *stream);
|
||||
int fputs(const char *s, FILE *stream);
|
||||
int printf(const char *format, ...);
|
||||
|
||||
#define EOF -1
|
||||
extern FILE *stdin;
|
||||
extern FILE *stdout;
|
||||
extern FILE *stderr;
|
||||
|
||||
#define SEEK_SET 0
|
||||
#define SEEK_CUR 1
|
||||
#define SEEK_END 2
|
||||
|
||||
#endif
|
||||
|
|
|
@ -2,8 +2,14 @@
|
|||
#define __TIER0_ANSI_STDLIB_H__
|
||||
|
||||
void *malloc(unsigned long long int size);
|
||||
void free(void *);
|
||||
void *realloc(void *ptr, unsigned long long int size);
|
||||
int abs(int X);
|
||||
void abort(void);
|
||||
long int strtol(const char *nptr, char **endptr, int base);
|
||||
void exit(int status);
|
||||
|
||||
#define EXIT_SUCCESS 0
|
||||
#define EXIT_FAILURE 1
|
||||
|
||||
#endif
|
||||
|
|
|
@ -7,31 +7,13 @@
|
|||
const char *strchr (const char *str, int character);
|
||||
inline int strcmp(const char *s1, const char *s2);
|
||||
char *strpbrk(const char *s1, const char *s2);
|
||||
char *strerror(int errnum);
|
||||
char *strstr(const char *haystack, const char *needle);
|
||||
unsigned long long int strspn(const char *s, const char *accept);
|
||||
void *memchr(const void *s, int c, unsigned long long int n);
|
||||
char *strcpy(char *dest, const char *src);
|
||||
|
||||
const char *strchr (const char *str, int character)
|
||||
{
|
||||
while (*str != 0)
|
||||
{
|
||||
if (*str == character)
|
||||
return str;
|
||||
str++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
inline int strcmp(const char *s1, const char *s2)
|
||||
{
|
||||
while((*s1 && *s2) && (*s1++ == *s2++));
|
||||
return *(--s1) - *(--s2);
|
||||
}
|
||||
|
||||
char *strpbrk(const char *s1, const char *s2)
|
||||
{
|
||||
while(*s1)
|
||||
if(strchr(s2, *s1++))
|
||||
return (char*)--s1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define strcoll(A, B) strcmp(A, B)
|
||||
#define strlen(A) kstrlen(A)
|
||||
#define memcpy(A, B, C) kmemcpy(A, B, C)
|
||||
#define memcmp(A, B, C) kmemcmp((const u8*)A, (const u8*)B, C)
|
||||
|
|
|
@ -32,8 +32,9 @@ LUA_A= liblua.a
|
|||
CORE_O= lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o \
|
||||
lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o \
|
||||
ltm.o lundump.o lvm.o lzio.o snprintf.o glue.o
|
||||
LIB_O= lauxlib.o lbaselib.o lbitlib.o lcorolib.o ldblib.o liolib.o \
|
||||
lmathlib.o loslib.o lstrlib.o ltablib.o loadlib.o linit.o
|
||||
# removed mathlib, oslib, iolib, loadlib ~q3k
|
||||
LIB_O= lauxlib.o lbaselib.o lbitlib.o lcorolib.o ldblib.o \
|
||||
lstrlib.o ltablib.o linit.o
|
||||
BASE_O= $(CORE_O) $(LIB_O) $(MYOBJS)
|
||||
|
||||
LUA_T= lua
|
||||
|
@ -98,7 +99,7 @@ bsd:
|
|||
$(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" SYSLIBS="-Wl,-E"
|
||||
|
||||
cucumber-kernel:
|
||||
$(MAKE) $(ALL) SYSCFLAGS="-DLUA_ANSI -I\"../../include/Lua/\" -I\"../../include/\""
|
||||
$(MAKE) $(ALL_O) SYSCFLAGS="-DLUA_ANSI -I\"../../include/Lua/\" -I\"../../include/\""
|
||||
|
||||
freebsd:
|
||||
$(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_LINUX" SYSLIBS="-Wl,-E -lreadline"
|
||||
|
|
|
@ -3,11 +3,20 @@
|
|||
#include <stdarg.h>
|
||||
|
||||
#include "setjmp.h"
|
||||
#include "stdio.h"
|
||||
#include "Tier0/panic.h"
|
||||
#include "Tier0/kstdio.h"
|
||||
|
||||
int errno;
|
||||
|
||||
// file descriptors for stdio...
|
||||
FILE _stdin = 0;
|
||||
FILE _stdout = 1;
|
||||
FILE _stderr = 2;
|
||||
FILE *stdin = &_stdin;
|
||||
FILE *stdout = &_stderr;
|
||||
FILE *stderr = &_stderr;
|
||||
|
||||
// math.h implementation
|
||||
//double floor(double X)
|
||||
//{
|
||||
|
@ -66,6 +75,7 @@ int abs(int X)
|
|||
void abort(void)
|
||||
{
|
||||
PANIC("abort() stub.");
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
// string.h implementation
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
|
||||
#include <signal.h>
|
||||
//#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -91,18 +91,18 @@ static const char *progname = LUA_PROGNAME;
|
|||
|
||||
|
||||
|
||||
static void lstop (lua_State *L, lua_Debug *ar) {
|
||||
(void)ar; /* unused arg. */
|
||||
lua_sethook(L, NULL, 0, 0);
|
||||
luaL_error(L, "interrupted!");
|
||||
}
|
||||
//static void lstop (lua_State *L, lua_Debug *ar) {
|
||||
// (void)ar; /* unused arg. */
|
||||
// lua_sethook(L, NULL, 0, 0);
|
||||
// luaL_error(L, "interrupted!");
|
||||
//}
|
||||
|
||||
|
||||
static void laction (int i) {
|
||||
signal(i, SIG_DFL); /* if another SIGINT happens before lstop,
|
||||
terminate process (default action) */
|
||||
lua_sethook(globalL, lstop, LUA_MASKCALL | LUA_MASKRET | LUA_MASKCOUNT, 1);
|
||||
}
|
||||
//static void laction (int i) {
|
||||
// signal(i, SIG_DFL); /* if another SIGINT happens before lstop,
|
||||
// terminate process (default action) */
|
||||
// lua_sethook(globalL, lstop, LUA_MASKCALL | LUA_MASKRET | LUA_MASKCOUNT, 1);
|
||||
//}
|
||||
|
||||
|
||||
static void print_usage (const char *badoption) {
|
||||
|
@ -175,9 +175,9 @@ static int docall (lua_State *L, int narg, int nres) {
|
|||
lua_pushcfunction(L, traceback); /* push traceback function */
|
||||
lua_insert(L, base); /* put it under chunk and args */
|
||||
globalL = L; /* to be available to 'laction' */
|
||||
signal(SIGINT, laction);
|
||||
//signal(SIGINT, laction);
|
||||
status = lua_pcall(L, narg, nres, base);
|
||||
signal(SIGINT, SIG_DFL);
|
||||
//signal(SIGINT, SIG_DFL);
|
||||
lua_remove(L, base); /* remove traceback function */
|
||||
return status;
|
||||
}
|
||||
|
@ -420,17 +420,18 @@ static int runargs (lua_State *L, char **argv, int n) {
|
|||
|
||||
|
||||
static int handle_luainit (lua_State *L) {
|
||||
const char *name = "=" LUA_INITVERSION;
|
||||
const char *init = getenv(name + 1);
|
||||
if (init == NULL) {
|
||||
name = "=" LUA_INIT;
|
||||
init = getenv(name + 1); /* try alternative name */
|
||||
}
|
||||
if (init == NULL) return LUA_OK;
|
||||
else if (init[0] == '@')
|
||||
return dofile(L, init+1);
|
||||
else
|
||||
return dostring(L, init, name);
|
||||
//const char *name = "=" LUA_INITVERSION;
|
||||
//const char *init = getenv(name + 1);
|
||||
//if (init == NULL) {
|
||||
// name = "=" LUA_INIT;
|
||||
// init = getenv(name + 1); /* try alternative name */
|
||||
//}
|
||||
//if (init == NULL) return LUA_OK;
|
||||
//else if (init[0] == '@')
|
||||
// return dofile(L, init+1);
|
||||
//else
|
||||
// return dostring(L, init, name);
|
||||
return LUA_OK;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue